]> oss.titaniummirror.com Git - cp210x.git/blobdiff - src/cp210x.c
Fix warnings generated by sparse tool.
[cp210x.git] / src / cp210x.c
index a8851ddc2aeb7a627c6b5a672bdb1fa17f6165f3..e89ed3cccd2b507227ca3a036cebcc9c3c2901a8 100644 (file)
  * thanks to Karl Hiramoto karl@hiramoto.org. RTSCTS hardware flow
  * control thanks to Munir Nassar nassarmu@real-time.com
  *
- * Silicon Labs RJM: updated to 0.11 for 2.6.15 and later kernels
- *
- * vxxPKGVERxx by R. Steve McKown, Titanium Mirror, Inc., rsmckown@gmail.com.
- * Added port configuration, usb descriptor and gpio management.
- *
- * Outstanding Issues:
- *  Buffers are not flushed when the port is opened.
- *  Multiple calls to write() may fail with "Resource temporarily unavailable"
- *
  */
 
 #include <linux/kernel.h>
@@ -58,7 +49,7 @@ static int cp210x_ioctl(struct usb_serial_port *, struct file *,
 
 static int debug;
 
-static struct usb_device_id id_table [] = {
+static const struct usb_device_id id_table[] = {
        { USB_DEVICE(0x0471, 0x066A) }, /* AKTAKOM ACE-1001 cable */
        { USB_DEVICE(0x0489, 0xE000) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */
        { USB_DEVICE(0x0745, 0x1000) }, /* CipherLab USB CCD Barcode Scanner 1000 */
@@ -94,11 +85,12 @@ static struct usb_device_id id_table [] = {
        { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */
        { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */
        { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */
+       { USB_DEVICE(0x10C4, 0x81E8) }, /* Zephyr Bioharness */
        { USB_DEVICE(0x10C4, 0x81F2) }, /* C1007 HF band RFID controller */
        { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */
        { USB_DEVICE(0x10C4, 0x822B) }, /* Modem EDGE(GSM) Comander 2 */
        { USB_DEVICE(0x10C4, 0x826B) }, /* Cygnal Integrated Products, Inc., Fasttrax GPS demostration module */
-       { USB_DEVICE(0x10c4, 0x8293) }, /* Telegesys ETRX2USB */
+       { USB_DEVICE(0x10C4, 0x8293) }, /* Telegesys ETRX2USB */
        { USB_DEVICE(0x10C4, 0x82F9) }, /* Procyon AVS */
        { USB_DEVICE(0x10C4, 0x8341) }, /* Siemens MC35PU GPRS Modem */
        { USB_DEVICE(0x10C4, 0x8382) }, /* Cygnal Integrated Products, Inc. */
@@ -118,6 +110,7 @@ static struct usb_device_id id_table [] = {
        { USB_DEVICE(0x166A, 0x0303) }, /* Clipsal 5500PCU C-Bus USB interface */
        { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */
        { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
+       { USB_DEVICE(0x413C, 0x9500) }, /* DW700 GPS USB interface */
        { } /* Terminating Entry */
 };
 
@@ -286,11 +279,13 @@ static size_t copy_buf_from_user(char *kbuf, unsigned long ubuf, size_t klen)
        cp210x_buffer_t t;
 
        if (!kbuf || !ubuf || !klen ||
-                       copy_from_user(&t, (cp210x_buffer_t *)ubuf, sizeof(t)))
+                       copy_from_user(&t, (cp210x_buffer_t __user *)ubuf,
+                       sizeof(t)))
                return 0;
        if (t.len < klen)
                klen = t.len;
-       if (!t.buf || !t.len || copy_from_user(kbuf, t.buf, klen))
+       if (!t.buf || !t.len ||
+                       copy_from_user(kbuf, (char __user *)t.buf, klen))
                return 0;
        return klen;
 }
@@ -339,7 +334,7 @@ static int cp210x_reset(struct usb_serial_port *port)
         * connections are torn down.  We also ignore the error return, since
         * the part resets and doesn't send one...
         */
-       cp210x_ctlmsg(port, 0xff, 0x40, 0x0008, 0x00, 0, 0);
+       cp210x_ctlmsg(port, 0xff, 0x40, 0x0008, 0x00, NULL, 0);
 #else
        usb_reset_device(port->serial->dev);
 #endif
@@ -373,7 +368,7 @@ static inline int cp210x_setu16(struct usb_serial_port *port, int cmd,
                unsigned int value)
 {
        return cp210x_ctlmsg(port, 0xff, 0x40, 0x3700 | (cmd & 0xff),
-                       value, 0, 0);
+                       value, NULL, 0);
 }
 
 /* Populates usbstr with: (len) + (0x03) + unicode(str).  Each char in str
@@ -431,7 +426,7 @@ static int cp210x_gpioset(struct usb_serial_port *port, u8 gpio)
        dbg("%s - port %d, gpio = 0x%.2x", __FUNCTION__, port->number, gpio);
 
        return cp210x_ctlmsg(port, 0xff, 0x40, 0x37e1,
-                       ((uint16_t)gpio << 8) | GPIO_MASK, 0, 0);
+                       ((uint16_t)gpio << 8) | GPIO_MASK, NULL, 0);
 }
 
 /* Set select gpio bits */
@@ -460,7 +455,7 @@ static int cp210x_gpiosetb(struct usb_serial_port *port, u8 set, u8 clear)
        dbg("%s - port %d, gpiob = 0x%.4x", __FUNCTION__, port->number, gpio);
 
        /* FIXME: how about REQTYPE_HOST_TO_DEVICE instead of 0x40? */
-       return cp210x_ctlmsg(port, 0xff, 0x40, 0x37e1, gpio, 0, 0);
+       return cp210x_ctlmsg(port, 0xff, 0x40, 0x37e1, gpio, NULL, 0);
 }
 
 static int cp210x_gpioget(struct usb_serial_port *port, u8 *gpio)
@@ -635,11 +630,6 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request,
                return -EPROTO;
        }
 
-       /* Single data value */
-       result = usb_control_msg(serial->dev,
-                       usb_sndctrlpipe(serial->dev, 0),
-                       request, REQTYPE_HOST_TO_DEVICE, data[0],
-                       0, NULL, 0, 300);
        return 0;
 }
 
@@ -724,24 +714,23 @@ static int cp210x_ioctl(struct usb_serial_port *port, struct file *file,
        dbg("%s (%d) cmd = 0x%04x", __FUNCTION__, port->number, cmd);
 
        switch (cmd) {
-               
+
        case TIOCMGET:
        {
                int result = cp210x_tiocmget(port, file);
-               if (copy_to_user(&arg, &result, sizeof(int)))
-                       return -EFAULT; 
+               if (copy_to_user((int __user *)&arg, &result, sizeof(int)))
+                       return -EFAULT;
                return 0;
        }
        break;
 
        case TIOCMSET:
        case TIOCMBIS:
-
        case TIOCMBIC:
        {
                int val = 0;
 
-               if (copy_from_user(&val, &arg, sizeof(int)))
+               if (copy_from_user(&val, (int __user *)&arg, sizeof(int)))
                        return -EFAULT;
 
                /* this looks wrong: TIOCMSET isn't going to work right */
@@ -755,8 +744,8 @@ static int cp210x_ioctl(struct usb_serial_port *port, struct file *file,
        case IOCTL_GPIOGET:
        if (cp210x_get_partnum(port) == CP210x_CP2103_VERSION) {
                u8 gpio = 0;
-               if (!cp210x_gpioget(port, &gpio) && !copy_to_user((u8*)arg,
-                                       &gpio, sizeof(gpio)))
+               if (!cp210x_gpioget(port, &gpio) && !copy_to_user(
+                                       (u8 __user *)arg, &gpio, sizeof(gpio)))
                        return 0;
        }
        return -EFAULT;
@@ -786,8 +775,8 @@ static int cp210x_ioctl(struct usb_serial_port *port, struct file *file,
        {
                cp210x_port_config_t config;
                if (!cp210x_portconfget(port, &config) && !copy_to_user(
-                                       (cp210x_port_config_t*)arg, &config,
-                                       sizeof(config)))
+                                       (cp210x_port_config_t __user *)arg,
+                                       &config, sizeof(config)))
                        return 0;
        }
        return -EFAULT;
@@ -796,7 +785,7 @@ static int cp210x_ioctl(struct usb_serial_port *port, struct file *file,
        case IOCTL_PORTCONFSET:
        {
        cp210x_port_config_t config;
-       if (!copy_from_user(&config, (cp210x_port_config_t*)arg,
+       if (!copy_from_user(&config, (cp210x_port_config_t __user *)arg,
                        sizeof(config)) &&
                        !cp210x_portconfset(port, &config))
                return 0;
@@ -807,7 +796,7 @@ static int cp210x_ioctl(struct usb_serial_port *port, struct file *file,
        case IOCTL_SETVID:
        {
                unsigned int vid;
-               if (!copy_from_user(&vid, (unsigned int *)arg,
+               if (!copy_from_user(&vid, (unsigned int __user *)arg,
                                sizeof(unsigned int)) &&
                                !cp210x_setu16(port, 0x01, vid))
                        return 0;
@@ -818,7 +807,7 @@ static int cp210x_ioctl(struct usb_serial_port *port, struct file *file,
        case IOCTL_SETPID:
        {
                unsigned int pid;
-               if (!copy_from_user(&pid, (unsigned int *)arg,
+               if (!copy_from_user(&pid, (unsigned int __user *)arg,
                                sizeof(unsigned int)) &&
                                !cp210x_setu16(port, 0x02, pid))
                        return 0;
@@ -870,7 +859,7 @@ static int cp210x_ioctl(struct usb_serial_port *port, struct file *file,
        case IOCTL_SETDEVVER:
        {
                unsigned int ver;
-               if (!copy_from_user(&ver, (unsigned int *)arg,
+               if (!copy_from_user(&ver, (unsigned int __user *)arg,
                                sizeof(unsigned int)) &&
                                !cp210x_setu16(port, 0x07, ver))
                        return 0;