public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: linux-usb-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] More USB fixes for 2.5.68
Date: Thu, 24 Apr 2003 16:47:32 -0700	[thread overview]
Message-ID: <1051228052721@kroah.com> (raw)
In-Reply-To: <1051228052617@kroah.com>

ChangeSet 1.1165.2.8, 2003/04/23 17:35:11-07:00, greg@kroah.com

[PATCH] USB: cdc-acm: add support for new tty tiocmget and tiocmset functions.


 drivers/usb/class/cdc-acm.c |   60 ++++++++++++++++++++++++--------------------
 1 files changed, 33 insertions(+), 27 deletions(-)


diff -Nru a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
--- a/drivers/usb/class/cdc-acm.c	Thu Apr 24 16:24:52 2003
+++ b/drivers/usb/class/cdc-acm.c	Thu Apr 24 16:24:52 2003
@@ -432,43 +432,47 @@
 		dbg("send break failed");
 }
 
-static int acm_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
+static int acm_tty_tiocmget(struct tty_struct *tty, struct file *file)
 {
 	struct acm *acm = tty->driver_data;
-	unsigned int mask, newctrl;
 
-	if (!ACM_READY(acm)) return -EINVAL;
+	if (!ACM_READY(acm))
+		return -EINVAL;
 
-	switch (cmd) {
+	return (acm->ctrlout & ACM_CTRL_DTR ? TIOCM_DTR : 0) |
+	       (acm->ctrlout & ACM_CTRL_RTS ? TIOCM_RTS : 0) |
+	       (acm->ctrlin  & ACM_CTRL_DSR ? TIOCM_DSR : 0) |
+	       (acm->ctrlin  & ACM_CTRL_RI  ? TIOCM_RI  : 0) |
+	       (acm->ctrlin  & ACM_CTRL_DCD ? TIOCM_CD  : 0) |
+	       TIOCM_CTS;
+}
 
-		case TIOCMGET:
+static int acm_tty_tiocmset(struct tty_struct *tty, struct file *file,
+			    unsigned int set, unsigned int clear)
+{
+	struct acm *acm = tty->driver_data;
+	unsigned int newctrl;
 
-			return put_user((acm->ctrlout & ACM_CTRL_DTR ? TIOCM_DTR : 0) |
-				(acm->ctrlout & ACM_CTRL_RTS ? TIOCM_RTS : 0) |
-				(acm->ctrlin  & ACM_CTRL_DSR ? TIOCM_DSR : 0) |
-				(acm->ctrlin  & ACM_CTRL_RI  ? TIOCM_RI  : 0) |
-				(acm->ctrlin  & ACM_CTRL_DCD ? TIOCM_CD  : 0) |
-				 TIOCM_CTS, (unsigned long *) arg);
+	if (!ACM_READY(acm))
+		return -EINVAL;
 
-		case TIOCMSET:
-		case TIOCMBIS:
-		case TIOCMBIC:
+	newctrl = acm->ctrlout;
+	set = (set & TIOCM_DTR ? ACM_CTRL_DTR : 0) | (set & TIOCM_RTS ? ACM_CTRL_RTS : 0);
+	clear = (clear & TIOCM_DTR ? ACM_CTRL_DTR : 0) | (clear & TIOCM_RTS ? ACM_CTRL_RTS : 0);
 
-			if (get_user(mask, (unsigned long *) arg))
-				return -EFAULT;
+	newctrl = (newctrl & ~clear) | set;
 
-			newctrl = acm->ctrlout;
-			mask = (mask & TIOCM_DTR ? ACM_CTRL_DTR : 0) | (mask & TIOCM_RTS ? ACM_CTRL_RTS : 0);
+	if (acm->ctrlout == newctrl)
+		return 0;
+	return acm_set_control(acm, acm->ctrlout = newctrl);
+}
 
-			switch (cmd) {
-				case TIOCMSET: newctrl  =  mask; break;
-				case TIOCMBIS: newctrl |=  mask; break;
-				case TIOCMBIC: newctrl &= ~mask; break;
-			}
+static int acm_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg)
+{
+	struct acm *acm = tty->driver_data;
 
-			if (acm->ctrlout == newctrl) return 0;
-			return acm_set_control(acm, acm->ctrlout = newctrl);
-	}
+	if (!ACM_READY(acm))
+		return -EINVAL;
 
 	return -ENOIOCTLCMD;
 }
@@ -750,7 +754,9 @@
 	.unthrottle =		acm_tty_unthrottle,
 	.chars_in_buffer =	acm_tty_chars_in_buffer,
 	.break_ctl =		acm_tty_break_ctl,
-	.set_termios =		acm_tty_set_termios
+	.set_termios =		acm_tty_set_termios,
+	.tiocmget =		acm_tty_tiocmget,
+	.tiocmset =		acm_tty_tiocmset,
 };
 
 /*


  reply	other threads:[~2003-04-25  0:22 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-24 23:46 [BK PATCH] USB changes for 2.5.68 Greg KH
2003-04-24 23:47 ` [PATCH] More USB fixes " Greg KH
2003-04-24 23:47   ` Greg KH
2003-04-24 23:47     ` Greg KH
2003-04-24 23:47       ` Greg KH
2003-04-24 23:47         ` Greg KH
2003-04-24 23:47           ` Greg KH
2003-04-24 23:47             ` Greg KH
2003-04-24 23:47               ` Greg KH [this message]
2003-04-24 23:47                 ` Greg KH
2003-04-24 23:47                   ` Greg KH
2003-04-24 23:47                     ` Greg KH
2003-04-24 23:47                       ` Greg KH
2003-04-24 23:47                         ` Greg KH
2003-04-24 23:47                           ` Greg KH
2003-04-24 23:47                             ` Greg KH
2003-04-24 23:47                               ` Greg KH
2003-04-24 23:47                                 ` Greg KH
2003-04-24 23:47                                   ` Greg KH
2003-04-24 23:47                                     ` Greg KH
2003-04-24 23:47                                       ` Greg KH
2003-04-25  4:14 ` [BK PATCH] USB changes " Greg KH

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=1051228052721@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb-devel@lists.sourceforge.net \
    /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