From: Jesse Barnes <jbarnes@engr.sgi.com>
To: akpm@osdl.org, linux-kernel@vger.kernel.org
Cc: pfg@sgi.com, Erik Jacobson <erikj@sgi.com>
Subject: [PATCH] implement TIOCGSERIAL in sn_serial.c
Date: Wed, 19 May 2004 11:09:51 -0400 [thread overview]
Message-ID: <200405191109.51751.jbarnes@engr.sgi.com> (raw)
[-- 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;
next reply other threads:[~2004-05-19 15:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-19 15:09 Jesse Barnes [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200405191109.51751.jbarnes@engr.sgi.com \
--to=jbarnes@engr.sgi.com \
--cc=akpm@osdl.org \
--cc=erikj@sgi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pfg@sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®