From: sander van ginkel <sander@van-ginkel.eu>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ptmx: adding handshake support
Date: Sun, 13 Apr 2008 17:42:03 +0200 [thread overview]
Message-ID: <480229CB.2080108@van-ginkel.eu> (raw)
In-Reply-To: <20080330131652.7073589c@core>
I've created a new patch, build against linux-2.6.25-rc8.
Signed-off-by: Sander van Ginkel <sander@van-ginkel.eu>
===================================================================
diff -pru linux-2.6.25-rc8.orig/drivers/char/pty.c
linux-2.6.25-rc8/drivers/char/pty.c
--- linux-2.6.25-rc8.orig/drivers/char/pty.c 2008-04-01
21:44:26.000000000 +0200
+++ linux-2.6.25-rc8/drivers/char/pty.c 2008-04-13 16:40:03.000000000
+0200
@@ -7,6 +7,8 @@
* -- C. Scott Ananian <cananian@alumni.princeton.edu>, 14-Jan-1998
* Added TTY_DO_WRITE_WAKEUP to enable n_tty to send POLL_OUT to
* waiting writers -- Sapan Bhatia <sapan@corewars.org>
+ * Added support for MCR/MSR, used for serial over ethernet
+ * -- Sander van Ginkel <sander@van-ginkel.eu>
*
*
*/
@@ -196,6 +198,7 @@ static void pty_flush_buffer(struct tty_
static int pty_open(struct tty_struct *tty, struct file * filp)
{
+ unsigned int *mcrmsr;
int retval = -ENODEV;
if (!tty || !tty->link)
@@ -212,11 +215,56 @@ static int pty_open(struct tty_struct *t
clear_bit(TTY_OTHER_CLOSED, &tty->link->flags);
set_bit(TTY_THROTTLED, &tty->flags);
set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
+
+ /* initialize the pointer in case something fails */
+
+ tty->driver_data = NULL;
+ tty->link->driver_data = NULL;
+
+ /* first time accessing this device, let's create it */
+
+ mcrmsr = kmalloc(sizeof(*mcrmsr), GFP_KERNEL);
+
+ if (mcrmsr != NULL) {
+
+ /* save our data within the tty structure */
+
+ *mcrmsr=0;
+
+ tty->driver_data = mcrmsr;
+ tty->link->driver_data = mcrmsr;
+ }
+ else
+ {
+ goto out;
+ }
+
retval = 0;
+
out:
return retval;
}
+static int pty_tiocmget(struct tty_struct *tty, struct file *file)
+{
+ unsigned int *mcrmsr;
+
+ mcrmsr = tty->driver_data;
+
+ return *mcrmsr;
+}
+
+static int pty_tiocmset(struct tty_struct *tty, struct file
*file,unsigned int set, unsigned int clear)
+{
+ unsigned int *mcrmsr;
+
+ mcrmsr = tty->driver_data;
+ *mcrmsr=set;
+ tty->driver_data=mcrmsr;
+
+ return 0;
+}
+
static void pty_set_termios(struct tty_struct *tty, struct ktermios
*old_termios)
{
tty->termios->c_cflag &= ~(CSIZE | PARENB);
@@ -232,6 +280,8 @@ static const struct tty_operations pty_o
.chars_in_buffer = pty_chars_in_buffer,
.unthrottle = pty_unthrottle,
.set_termios = pty_set_termios,
+ .tiocmget = pty_tiocmget,
+ .tiocmset = pty_tiocmset,
};
/* Traditional BSD devices */
@@ -364,11 +414,27 @@ static struct ctl_table pty_root_table[]
static int pty_unix98_ioctl(struct tty_struct *tty, struct file *file,
unsigned int cmd, unsigned long arg)
{
+ unsigned int value;
+ unsigned int *mcrmsr;
+
+ mcrmsr=tty->driver_data;
+
switch (cmd) {
case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */
return pty_set_lock(tty, (int __user *)arg);
case TIOCGPTN: /* Get PT Number */
return put_user(tty->index, (unsigned int __user *)arg);
+
+ case VMCRMSR: /* Set all of the handshake line, even the normally
read only */
+ {
+ if (copy_from_user(&value,(unsigned int *)arg,sizeof(unsigned
int)))
+ return -EFAULT;
+
+ *mcrmsr=value;
+ tty->driver_data=mcrmsr;
+
+ return 0;
+ }
}
return -ENOIOCTLCMD;
next prev parent reply other threads:[~2008-04-13 13:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-11 20:28 [PATCH] ptmx: adding handshake support sander van ginkel
2008-03-30 12:09 ` postmaster
2008-03-30 12:16 ` Alan Cox
2008-03-30 12:48 ` sander van ginkel
2008-04-13 15:42 ` sander van ginkel [this message]
2008-04-13 22:35 ` Alan Cox
2008-04-14 20:39 ` sander van ginkel
2008-04-14 20:02 ` Randy Dunlap
2008-04-29 18:01 ` Alan Cox
-- strict thread matches above, loose matches on Subject: below --
2008-03-11 21:19 sander van ginkel
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=480229CB.2080108@van-ginkel.eu \
--to=sander@van-ginkel.eu \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
/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