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:33 -0700 [thread overview]
Message-ID: <1051228053892@kroah.com> (raw)
In-Reply-To: <10512280533216@kroah.com>
ChangeSet 1.1165.2.12, 2003/04/23 17:38:41-07:00, greg@kroah.com
[PATCH] USB: ftdi_sio: add support for new tty tiocmget and tiocmset functions.
drivers/usb/serial/ftdi_sio.c | 193 ++++++++++++++++++------------------------
1 files changed, 87 insertions(+), 106 deletions(-)
diff -Nru a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
--- a/drivers/usb/serial/ftdi_sio.c Thu Apr 24 16:23:00 2003
+++ b/drivers/usb/serial/ftdi_sio.c Thu Apr 24 16:23:00 2003
@@ -175,6 +175,8 @@
static void ftdi_sio_write_bulk_callback (struct urb *urb, struct pt_regs *regs);
static void ftdi_sio_read_bulk_callback (struct urb *urb, struct pt_regs *regs);
static void ftdi_sio_set_termios (struct usb_serial_port *port, struct termios * old);
+static int ftdi_sio_tiocmget (struct usb_serial_port *port, struct file *file);
+static int ftdi_sio_tiocmset (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear);
static int ftdi_sio_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
static void ftdi_sio_break_ctl (struct usb_serial_port *port, int break_state );
@@ -198,6 +200,8 @@
.ioctl = ftdi_sio_ioctl,
.set_termios = ftdi_sio_set_termios,
.break_ctl = ftdi_sio_break_ctl,
+ .tiocmget = ftdi_sio_tiocmget,
+ .tiocmset = ftdi_sio_tiocmset,
.attach = ftdi_sio_startup,
.shutdown = ftdi_sio_shutdown,
};
@@ -219,6 +223,8 @@
.ioctl = ftdi_sio_ioctl,
.set_termios = ftdi_sio_set_termios,
.break_ctl = ftdi_sio_break_ctl,
+ .tiocmget = ftdi_sio_tiocmget,
+ .tiocmset = ftdi_sio_tiocmset,
.attach = ftdi_8U232AM_startup,
.shutdown = ftdi_sio_shutdown,
};
@@ -823,125 +829,100 @@
return;
} /* ftdi_sio_set_termios */
-static int ftdi_sio_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
+static int ftdi_sio_tiocmget (struct usb_serial_port *port, struct file *file)
{
struct usb_serial *serial = port->serial;
struct ftdi_private *priv = usb_get_serial_port_data(port);
- __u16 urb_value=0; /* Will hold the new flags */
- char buf[2];
- int ret, mask;
+ char *buf = NULL;
+ int ret = -EINVAL;
+ int size;
- dbg("%s cmd 0x%04x", __FUNCTION__, cmd);
+ dbg("%s", __FUNCTION__);
- /* Based on code from acm.c and others */
- switch (cmd) {
+ buf = kmalloc(2, GFP_KERNEL);
+ if (!buf)
+ goto exit;
- case TIOCMGET:
- dbg("%s TIOCMGET", __FUNCTION__);
- if (priv->ftdi_type == sio){
- /* Request the status from the device */
- if ((ret = usb_control_msg(serial->dev,
- usb_rcvctrlpipe(serial->dev, 0),
- FTDI_SIO_GET_MODEM_STATUS_REQUEST,
- FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
- 0, 0,
- buf, 1, WDR_TIMEOUT)) < 0 ) {
- err("%s Could not get modem status of device - err: %d", __FUNCTION__,
- ret);
- return(ret);
- }
- } else {
- /* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same
- format as the data returned from the in point */
- if ((ret = usb_control_msg(serial->dev,
- usb_rcvctrlpipe(serial->dev, 0),
- FTDI_SIO_GET_MODEM_STATUS_REQUEST,
- FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
- 0, 0,
- buf, 2, WDR_TIMEOUT)) < 0 ) {
- err("%s Could not get modem status of device - err: %d", __FUNCTION__,
- ret);
- return(ret);
- }
- }
+ if (priv->ftdi_type == sio) {
+ size = 1;
+ } else {
+ /* the 8U232AM returns a two byte value (the sio is a 1 byte value) - in the same
+ format as the data returned from the in point */
+ size = 2;
+ }
+ ret = usb_control_msg(serial->dev,
+ usb_rcvctrlpipe(serial->dev, 0),
+ FTDI_SIO_GET_MODEM_STATUS_REQUEST,
+ FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE,
+ 0, 0, buf, size, WDR_TIMEOUT);
+ if (ret < 0) {
+ err("%s Could not get modem status of device - err: %d",
+ __FUNCTION__, ret);
+ goto exit;
+ }
+
+ ret = (buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) |
+ (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) |
+ (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) |
+ (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0);
+
+exit:
+ kfree(buf);
+ return ret;
+}
- return put_user((buf[0] & FTDI_SIO_DSR_MASK ? TIOCM_DSR : 0) |
- (buf[0] & FTDI_SIO_CTS_MASK ? TIOCM_CTS : 0) |
- (buf[0] & FTDI_SIO_RI_MASK ? TIOCM_RI : 0) |
- (buf[0] & FTDI_SIO_RLSD_MASK ? TIOCM_CD : 0),
- (unsigned long *) arg);
- break;
-
- case TIOCMSET: /* Turns on and off the lines as specified by the mask */
- dbg("%s TIOCMSET", __FUNCTION__);
- if (get_user(mask, (unsigned long *) arg))
- return -EFAULT;
- urb_value = ((mask & TIOCM_DTR) ? HIGH : LOW);
- if (set_dtr(serial->dev, usb_sndctrlpipe(serial->dev, 0),urb_value) < 0){
- err("Error from DTR set urb (TIOCMSET)");
- }
- urb_value = ((mask & TIOCM_RTS) ? HIGH : LOW);
- if (set_rts(serial->dev, usb_sndctrlpipe(serial->dev, 0),urb_value) < 0){
- err("Error from RTS set urb (TIOCMSET)");
- }
- break;
-
- case TIOCMBIS: /* turns on (Sets) the lines as specified by the mask */
- dbg("%s TIOCMBIS", __FUNCTION__);
- if (get_user(mask, (unsigned long *) arg))
- return -EFAULT;
- if (mask & TIOCM_DTR){
- if ((ret = set_dtr(serial->dev,
- usb_sndctrlpipe(serial->dev, 0),
- HIGH)) < 0) {
- err("Urb to set DTR failed");
- return(ret);
- }
- }
- if (mask & TIOCM_RTS) {
- if ((ret = set_rts(serial->dev,
- usb_sndctrlpipe(serial->dev, 0),
- HIGH)) < 0){
- err("Urb to set RTS failed");
- return(ret);
- }
- }
- break;
+static int ftdi_sio_tiocmset (struct usb_serial_port *port, struct file *file,
+ unsigned int set, unsigned int clear)
+{
+ struct usb_serial *serial = port->serial;
+ int ret = 0;
+
+ dbg("%s", __FUNCTION__);
- case TIOCMBIC: /* turns off (Clears) the lines as specified by the mask */
- dbg("%s TIOCMBIC", __FUNCTION__);
- if (get_user(mask, (unsigned long *) arg))
- return -EFAULT;
- if (mask & TIOCM_DTR){
- if ((ret = set_dtr(serial->dev,
- usb_sndctrlpipe(serial->dev, 0),
- LOW)) < 0){
- err("Urb to unset DTR failed");
- return(ret);
- }
- }
- if (mask & TIOCM_RTS) {
- if ((ret = set_rts(serial->dev,
- usb_sndctrlpipe(serial->dev, 0),
- LOW)) < 0){
- err("Urb to unset RTS failed");
- return(ret);
- }
+ if (set & TIOCM_RTS)
+ if ((ret = set_rts(serial->dev,
+ usb_sndctrlpipe(serial->dev, 0),
+ HIGH)) < 0) {
+ err("Urb to set RTS failed");
+ goto exit;
+ }
+
+ if (set & TIOCM_DTR)
+ if ((ret = set_dtr(serial->dev,
+ usb_sndctrlpipe(serial->dev, 0),
+ HIGH)) < 0) {
+ err("Urb to set DTR failed");
+ goto exit;
+ }
+
+ if (clear & TIOCM_RTS)
+ if ((ret = set_rts(serial->dev,
+ usb_sndctrlpipe(serial->dev, 0),
+ LOW)) < 0) {
+ err("Urb to unset RTS failed");
+ goto exit;
+ }
+
+ if (clear & TIOCM_DTR)
+ if ((ret = set_dtr(serial->dev,
+ usb_sndctrlpipe(serial->dev, 0),
+ LOW)) < 0) {
+ err("Urb to unset DTR failed");
+ goto exit;
}
- break;
- /*
- * I had originally implemented TCSET{A,S}{,F,W} and
- * TCGET{A,S} here separately, however when testing I
- * found that the higher layers actually do the termios
- * conversions themselves and pass the call onto
- * ftdi_sio_set_termios.
- *
- */
+exit:
+ return ret;
+}
+static int ftdi_sio_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
+{
+ dbg("%s cmd 0x%04x", __FUNCTION__, cmd);
+
+ switch (cmd) {
default:
/* This is not an error - turns out the higher layers will do
- * some ioctls itself (see comment above)
+ * some ioctls itself
*/
dbg("%s arg not supported - it was 0x%04x", __FUNCTION__,cmd);
return(-ENOIOCTLCMD);
next prev parent 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
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-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=1051228053892@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.