mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] implement TIOCGSERIAL in sn_serial.c
@ 2004-05-19 15:09 Jesse Barnes
  2004-05-19 15:31 ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Jesse Barnes @ 2004-05-19 15:09 UTC (permalink / raw)
  To: akpm, linux-kernel; +Cc: pfg, Erik Jacobson

[-- Attachment #1: Type: text/plain, Size: 249 bytes --]

The sn2 console driver behaves something like a serial port, but was missing 
some of the ioctls that userland apps expected.  This patch implements the 
TIOCGSERIAL ioctl, which allows applications to identify the console as a 
serial port.

Jesse

[-- Attachment #2: sn-serial-ioctl-3.patch --]
[-- Type: text/x-diff, Size: 2505 bytes --]

--- linux-2.6.6.orig/drivers/char/sn_serial.c	2004-05-09 22:33:21.000000000 -0400
+++ linux-2.6.6/drivers/char/sn_serial.c	2004-05-19 10:59:20.000000000 -0400
@@ -21,6 +21,7 @@
 #include <linux/sysrq.h>
 #include <linux/circ_buf.h>
 #include <linux/serial_reg.h>
+#include <linux/serial_core.h>
 #include <asm/uaccess.h>
 #include <asm/sn/sgi.h>
 #include <asm/sn/sn_sal.h>
@@ -38,7 +39,7 @@ static unsigned long sysrq_requested;
 #define SN_SAL_MINOR 64
 
 /* number of characters left in xmit buffer before we ask for more */
-#define WAKEUP_CHARS 128
+#define SN_WAKEUP_CHARS 128
 
 /* number of characters we can transmit to the SAL console at a time */
 #define SN_SAL_MAX_CHARS 120
@@ -411,7 +412,7 @@ sn_poll_transmit_chars(void)
 	 * that we could stand for the upper layer to send us some
 	 * more, ask for it. */
 	if (sn_sal_tty)
-		if (CIRC_CNT(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE) < WAKEUP_CHARS)
+		if (CIRC_CNT(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE) < SN_WAKEUP_CHARS)
 			sn_sal_sched_event(SN_SAL_EVENT_WRITE_WAKEUP);
 }
 
@@ -466,7 +467,7 @@ sn_intr_transmit_chars(void)
 	 * that we could stand for the upper layer to send us some
 	 * more, ask for it. */
 	if (sn_sal_tty)
-		if (CIRC_CNT(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE) < WAKEUP_CHARS)
+		if (CIRC_CNT(xmit.cb_head, xmit.cb_tail, SN_SAL_BUFFER_SIZE) < SN_WAKEUP_CHARS)
 			sn_sal_sched_event(SN_SAL_EVENT_WRITE_WAKEUP);
 }
 
@@ -784,6 +785,29 @@ sn_sal_read_proc(char *page, char **star
 	return count < begin+len-off ? count : begin+len-off;
 }
 
+/*
+ * sn_sal_ioctl - we only support a very limited TIOCGSERIAL
+ */
+static int
+sn_sal_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd,
+	     unsigned long arg)
+{
+	struct serial_struct tmp_serial;
+	struct serial_struct *force_cast_serial;
+
+	force_cast_serial = (struct serial_struct *)arg;
+
+	memset(&tmp_serial, 0, sizeof(tmp_serial));
+	tmp_serial.irq = sn_sal_irq;
+	tmp_serial.xmit_fifo_size = SN_SAL_UART_FIFO_DEPTH;
+
+	if (cmd == TIOCGSERIAL) {
+		if (copy_to_user(force_cast_serial, &tmp_serial, sizeof(*force_cast_serial)))
+			return -EFAULT;
+		return 0;
+	}
+	return -ENOIOCTLCMD;
+}
 
 static struct tty_operations sn_sal_driver_ops = {
 	.open		 = sn_sal_open,
@@ -796,6 +820,7 @@ static struct tty_operations sn_sal_driv
 	.hangup		 = sn_sal_hangup,
 	.wait_until_sent = sn_sal_wait_until_sent,
 	.read_proc	 = sn_sal_read_proc,
+	.ioctl		 = sn_sal_ioctl,
 };
 static struct tty_driver *sn_sal_driver;
 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] implement TIOCGSERIAL in sn_serial.c
  2004-05-19 15:09 [PATCH] implement TIOCGSERIAL in sn_serial.c Jesse Barnes
@ 2004-05-19 15:31 ` Christoph Hellwig
  2004-05-19 15:38   ` Jesse Barnes
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2004-05-19 15:31 UTC (permalink / raw)
  To: Jesse Barnes; +Cc: akpm, linux-kernel, pfg, Erik Jacobson

On Wed, May 19, 2004 at 11:09:51AM -0400, Jesse Barnes wrote:
> The sn2 console driver behaves something like a serial port, but was missing 
> some of the ioctls that userland apps expected.  This patch implements the 
> TIOCGSERIAL ioctl, which allows applications to identify the console as a 
> serial port.

And whats the point for this one?  TIOCGSERIAL is just some messy internals
of the old serial.c driver (and serial_core now) that's exposed for the
sake of setserial.  Given that the sn console is quite different I don't
see the point to emulate all the mess of a real serial driver - and if you
want to do so use the serial_core framework.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] implement TIOCGSERIAL in sn_serial.c
  2004-05-19 15:31 ` Christoph Hellwig
@ 2004-05-19 15:38   ` Jesse Barnes
  2004-05-19 15:41     ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Jesse Barnes @ 2004-05-19 15:38 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: akpm, linux-kernel, pfg, Erik Jacobson

On Wednesday, May 19, 2004 11:31 am, Christoph Hellwig wrote:
> On Wed, May 19, 2004 at 11:09:51AM -0400, Jesse Barnes wrote:
> > The sn2 console driver behaves something like a serial port, but was
> > missing some of the ioctls that userland apps expected.  This patch
> > implements the TIOCGSERIAL ioctl, which allows applications to identify
> > the console as a serial port.
>
> And whats the point for this one?  TIOCGSERIAL is just some messy internals
> of the old serial.c driver (and serial_core now) that's exposed for the
> sake of setserial.  Given that the sn console is quite different I don't
> see the point to emulate all the mess of a real serial driver - and if you
> want to do so use the serial_core framework.

Pat is working on that and should have a patch ready to post soon (is that 
right Pat?).  In the meantime, we need this little bit.

Jesse

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] implement TIOCGSERIAL in sn_serial.c
  2004-05-19 15:38   ` Jesse Barnes
@ 2004-05-19 15:41     ` Christoph Hellwig
  2004-05-19 15:50       ` Jesse Barnes
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2004-05-19 15:41 UTC (permalink / raw)
  To: Jesse Barnes; +Cc: akpm, linux-kernel, pfg, Erik Jacobson

> Pat is working on that and should have a patch ready to post soon (is that 
> right Pat?).  In the meantime, we need this little bit.

Huh?  We need this little bit isn't exactly a patch desciption that gets
your patch included.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] implement TIOCGSERIAL in sn_serial.c
  2004-05-19 15:41     ` Christoph Hellwig
@ 2004-05-19 15:50       ` Jesse Barnes
  2004-05-19 15:56         ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Jesse Barnes @ 2004-05-19 15:50 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: akpm, linux-kernel, pfg, Erik Jacobson

On Wednesday, May 19, 2004 11:41 am, Christoph Hellwig wrote:
> > Pat is working on that and should have a patch ready to post soon (is
> > that right Pat?).  In the meantime, we need this little bit.
>
> Huh?  We need this little bit isn't exactly a patch desciption that gets
> your patch included.

Umm... I described the patch in the last mail.  I don't know when Pat will 
have the conversion to the serial core interface done, but I have a need for 
this ioctl now.  If you want to wait for the full blown version, then so be 
it, I just hope it comes soon.

Jesse

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] implement TIOCGSERIAL in sn_serial.c
  2004-05-19 15:50       ` Jesse Barnes
@ 2004-05-19 15:56         ` Christoph Hellwig
  2004-05-19 16:17           ` Jesse Barnes
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2004-05-19 15:56 UTC (permalink / raw)
  To: Jesse Barnes; +Cc: akpm, linux-kernel, pfg, Erik Jacobson

> Umm... I described the patch in the last mail.  I don't know when Pat will 
> have the conversion to the serial core interface done, but I have a need for 
> this ioctl now.  If you want to wait for the full blown version, then so be 
> it, I just hope it comes soon.

And the point of an ioctl copying two values that are compltely irrelevant
for userspace with your driver are? [please fill in here]


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] implement TIOCGSERIAL in sn_serial.c
  2004-05-19 15:56         ` Christoph Hellwig
@ 2004-05-19 16:17           ` Jesse Barnes
  2004-05-19 16:34             ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Jesse Barnes @ 2004-05-19 16:17 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: akpm, linux-kernel, pfg, Erik Jacobson

On Wednesday, May 19, 2004 11:56 am, Christoph Hellwig wrote:
> > Umm... I described the patch in the last mail.  I don't know when Pat
> > will have the conversion to the serial core interface done, but I have a
> > need for this ioctl now.  If you want to wait for the full blown version,
> > then so be it, I just hope it comes soon.
>
> And the point of an ioctl copying two values that are compltely irrelevant
> for userspace with your driver are? [please fill in here]

What, you think userland isn't interested in the FIFO depth?  Or are you 
suggesting that we fill in all the values?  Pat?

Jesse

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] implement TIOCGSERIAL in sn_serial.c
  2004-05-19 16:17           ` Jesse Barnes
@ 2004-05-19 16:34             ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2004-05-19 16:34 UTC (permalink / raw)
  To: Jesse Barnes; +Cc: akpm, linux-kernel, pfg, Erik Jacobson

On Wed, May 19, 2004 at 12:17:13PM -0400, Jesse Barnes wrote:
> > And the point of an ioctl copying two values that are compltely irrelevant
> > for userspace with your driver are? [please fill in here]
> 
> What, you think userland isn't interested in the FIFO depth?  Or are you 
> suggesting that we fill in all the values?  Pat?

I want to say this awfully smells like a quickhack.  And your secrecy on
why you need this doesn't help either.  So what userspace needs to know
your fifo depth?


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-05-19 16:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-19 15:09 [PATCH] implement TIOCGSERIAL in sn_serial.c Jesse Barnes
2004-05-19 15:31 ` Christoph Hellwig
2004-05-19 15:38   ` Jesse Barnes
2004-05-19 15:41     ` Christoph Hellwig
2004-05-19 15:50       ` Jesse Barnes
2004-05-19 15:56         ` Christoph Hellwig
2004-05-19 16:17           ` Jesse Barnes
2004-05-19 16:34             ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®