]> oss.titaniummirror.com Git - cp210x.git/commitdiff
Style cleanups
authorR. Steve McKown <rsmckown@gmail.com>
Mon, 17 May 2010 21:27:27 +0000 (15:27 -0600)
committerR. Steve McKown <rsmckown@gmail.com>
Thu, 20 May 2010 01:21:17 +0000 (19:21 -0600)
src/cp210x.c
src/cp210x.c.karmic
src/cp210x.h

index 1ec4b8eaa403d9c581e0474dde5d695933744e62..d1fbf26753346a7a4a7351dab590fdac21c3fb07 100644 (file)
@@ -248,10 +248,11 @@ static int make_usb_string(char *usbstr, size_t usblen, char *src,
  * is the size of the buffer at kbuf.
  * Returns the number of bytes used in kbuf.
  */
-static size_t cp210x_usbstr_from_user(char *kbuf, unsigned long ubuf, size_t klen)
+static size_t cp210x_usbstr_from_user(char *kbuf, unsigned long ubuf,
+               size_t klen)
 {
        struct cp210x_buffer t;
-       charstr;
+       char *str;
        size_t slen;
 
        if (!kbuf || !ubuf || !klen)
@@ -293,7 +294,8 @@ static int cp210x_ctlmsg(struct usb_serial_port *port, u8 request,
        u8 *tbuf;
        int ret;
 
-       if (!(tbuf = kmalloc(size, GFP_KERNEL)))
+       tbuf = kmalloc(size, GFP_KERNEL);
+       if (!tbuf)
                return -ENOMEM;
        if (requestype & 0x80) {
                ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request,
@@ -308,8 +310,9 @@ static int cp210x_ctlmsg(struct usb_serial_port *port, u8 request,
        }
        kfree(tbuf);
        if (ret < 0 && ret != -EPIPE) {
-               dev_printk(KERN_DEBUG, &dev->dev, "cp210x: control failed cmd rqt %u "
-                               "rq %u len %u ret %d\n", requestype, request, size, ret);
+               dev_printk(KERN_DEBUG, &dev->dev,
+                       "cp210x: ctl failed cmd rqt %u rq %u len %u ret %d\n",
+                       requestype, request, size, ret);
        }
        return ret;
 }
@@ -319,10 +322,10 @@ static int cp210x_reset(struct usb_serial_port *port)
        dbg("%s", __FUNCTION__);
 
 #if 1
-       /* Is this better than usb_device_reset?  It may be.  Once a client issues
-        * the reset ioctl, it must disconnect and reconnect, since the USB
-        * connections are torn down.  We also ignore the error return, since
-        * the part resets and doesn't send one...
+       /* Is this better than usb_device_reset?  It may be.  Once a client
+        * issues the reset ioctl, it must disconnect and reconnect, since the
+        * USB 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, NULL, 0);
 #else
@@ -437,7 +440,7 @@ static int cp210x_portconfset(struct usb_serial_port *port,
 
        memcpy(&lconfig, config, sizeof(lconfig));
 
-       /* Words from cp2103 are MSB */
+       /* Words from cp210x are MSB */
        lconfig.reset.mode = cpu_to_be16(config->reset.mode);
        lconfig.reset.latch = cpu_to_be16(config->reset.latch);
        lconfig.suspend.mode = cpu_to_be16(config->suspend.mode);
@@ -470,7 +473,7 @@ static int cp210x_portconfget(struct usb_serial_port *port,
        ret = cp210x_ctlmsg(port, 0xff, 0xc0, 0x370c, 0, config,
                        sizeof(struct cp210x_port_config));
        if (ret == sizeof(struct cp210x_port_config)) {
-               /* Words from cp2103 are MSB */
+               /* Words from cp210x are MSB */
                config->reset.mode = be16_to_cpu(config->reset.mode);
                config->reset.lowPower = be16_to_cpu(config->reset.lowPower);
                config->reset.latch = be16_to_cpu(config->reset.latch);
@@ -690,8 +693,8 @@ static int cp210x_ioctl(struct usb_serial_port *port, struct file *file,
                        return -EFAULT;
 
                /* this looks wrong: TIOCMSET isn't going to work right */
-               if (cp210x_tiocmset(port, file, cmd==TIOCMBIC ? 0 : val,
-                                       cmd==TIOCMBIC ? val : 0))
+               if (cp210x_tiocmset(port, file, (cmd == TIOCMBIC) ? 0 : val,
+                                       (cmd == TIOCMBIC) ? val : 0))
                        return -EFAULT;
                return 0;
        }
@@ -718,8 +721,8 @@ static int cp210x_ioctl(struct usb_serial_port *port, struct file *file,
        case CP210x_IOCTL_GPIOBIS:
        if (cp210x_get_partnum(port) == CP210x_PART_CP2103 &&
                        !cp210x_gpiosetb(port,
-                               (cmd==CP210x_IOCTL_GPIOBIC) ?  0 : arg,
-                               (cmd==CP210x_IOCTL_GPIOBIC) ? arg : 0))
+                               (cmd == CP210x_IOCTL_GPIOBIC) ?  0 : arg,
+                               (cmd == CP210x_IOCTL_GPIOBIC) ? arg : 0))
                return 0;
        return -EFAULT;
        break;
index 707665782103b02ad8597c86c77c839a45b32e91..267ff4c8b50401b97d1ecc9592ccfc636ebe2d9c 100644 (file)
@@ -269,10 +269,11 @@ static int make_usb_string(char *usbstr, size_t usblen, char *src,
  * is the size of the buffer at kbuf.
  * Returns the number of bytes used in kbuf.
  */
-static size_t cp210x_usbstr_from_user(char *kbuf, unsigned long ubuf, size_t klen)
+static size_t cp210x_usbstr_from_user(char *kbuf, unsigned long ubuf,
+               size_t klen)
 {
        struct cp210x_buffer t;
-       charstr;
+       char *str;
        size_t slen;
 
        if (!kbuf || !ubuf || !klen)
@@ -314,7 +315,8 @@ static int cp210x_ctlmsg(struct usb_serial_port *port, u8 request,
        u8 *tbuf;
        int ret;
 
-       if (!(tbuf = kmalloc(size, GFP_KERNEL)))
+       tbuf = kmalloc(size, GFP_KERNEL);
+       if (!tbuf)
                return -ENOMEM;
        if (requestype & 0x80) {
                ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request,
@@ -329,8 +331,9 @@ static int cp210x_ctlmsg(struct usb_serial_port *port, u8 request,
        }
        kfree(tbuf);
        if (ret < 0 && ret != -EPIPE) {
-               dev_printk(KERN_DEBUG, &dev->dev, "cp210x: control failed cmd rqt %u "
-                               "rq %u len %u ret %d\n", requestype, request, size, ret);
+               dev_printk(KERN_DEBUG, &dev->dev,
+                       "cp210x: ctl failed cmd rqt %u rq %u len %u ret %d\n",
+                       requestype, request, size, ret);
        }
        return ret;
 }
@@ -340,10 +343,10 @@ static int cp210x_reset(struct usb_serial_port *port)
        dbg("%s", __func__);
 
 #if 1
-       /* Is this better than usb_device_reset?  It may be.  Once a client issues
-        * the reset ioctl, it must disconnect and reconnect, since the USB
-        * connections are torn down.  We also ignore the error return, since
-        * the part resets and doesn't send one...
+       /* Is this better than usb_device_reset?  It may be.  Once a client
+        * issues the reset ioctl, it must disconnect and reconnect, since the
+        * USB 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, NULL, 0);
 #else
@@ -458,7 +461,7 @@ static int cp210x_portconfset(struct usb_serial_port *port,
 
        memcpy(&lconfig, config, sizeof(lconfig));
 
-       /* Words from cp2103 are MSB */
+       /* Words from cp210x are MSB */
        lconfig.reset.mode = cpu_to_be16(config->reset.mode);
        lconfig.reset.latch = cpu_to_be16(config->reset.latch);
        lconfig.suspend.mode = cpu_to_be16(config->suspend.mode);
@@ -491,7 +494,7 @@ static int cp210x_portconfget(struct usb_serial_port *port,
        ret = cp210x_ctlmsg(port, 0xff, 0xc0, 0x370c, 0, config,
                        sizeof(struct cp210x_port_config));
        if (ret == sizeof(struct cp210x_port_config)) {
-               /* Words from cp2103 are MSB */
+               /* Words from cp210x are MSB */
                config->reset.mode = be16_to_cpu(config->reset.mode);
                config->reset.lowPower = be16_to_cpu(config->reset.lowPower);
                config->reset.latch = be16_to_cpu(config->reset.latch);
@@ -757,8 +760,8 @@ static int cp210x_ioctl(struct tty_struct *tty, struct file *file,
                        return -EFAULT;
 
                /* this looks wrong: TIOCMSET isn't going to work right */
-               if (cp210x_tiocmset(tty, file, cmd==TIOCMBIC ? 0 : val,
-                                       cmd==TIOCMBIC ? val : 0))
+               if (cp210x_tiocmset(tty, file, (cmd == TIOCMBIC) ? 0 : val,
+                                       (cmd == TIOCMBIC) ? val : 0))
                        return -EFAULT;
                return 0;
        }
@@ -785,8 +788,8 @@ static int cp210x_ioctl(struct tty_struct *tty, struct file *file,
        case CP210x_IOCTL_GPIOBIS:
        if (cp210x_get_partnum(port) == CP210x_PART_CP2103 &&
                        !cp210x_gpiosetb(port,
-                               (cmd==CP210x_IOCTL_GPIOBIC) ?  0 : arg,
-                               (cmd==CP210x_IOCTL_GPIOBIC) ? arg : 0))
+                               (cmd == CP210x_IOCTL_GPIOBIC) ?  0 : arg,
+                               (cmd == CP210x_IOCTL_GPIOBIC) ? arg : 0))
                return 0;
        return -EFAULT;
        break;
index ab4eddb7581e79726adeba3579d8b3ee76bce8c0..14a13f422da4291f7585774d9acf8ac815907b0c 100644 (file)
@@ -7,7 +7,7 @@
  *     modify it under the terms of the GNU General Public License version
  *     2 as published by the Free Software Foundation.
  *
- * Definitions usable by both the cp210x kernel module and userspace.
+ * Header file shared by both the cp210x kernel module and userspace.
  *
  */
 
 #if defined(__KERNEL__)
 #include <linux/sockios.h>
 #else
-#include <asm/types.h>
+#include <linux/types.h>
 #include <sys/ioctl.h>
 #endif
 
 /* CP2103 GPIO ioctls */
-#define CP210x_IOCTL_GPIOGET           (SIOCDEVPRIVATE + 0)    /* Get gpio bits */
-#define CP210x_IOCTL_GPIOSET           (SIOCDEVPRIVATE + 1)    /* Set gpio bits */
-#define CP210x_IOCTL_GPIOBIC           (SIOCDEVPRIVATE + 2)    /* Clear specific gpio bit(s) */
-#define CP210x_IOCTL_GPIOBIS           (SIOCDEVPRIVATE + 3)    /* Set specific gpio bit(s) */
+#define CP210x_IOCTL_GPIOGET           (SIOCDEVPRIVATE + 0)
+#define CP210x_IOCTL_GPIOSET           (SIOCDEVPRIVATE + 1)
+#define CP210x_IOCTL_GPIOBIC           (SIOCDEVPRIVATE + 2)
+#define CP210x_IOCTL_GPIOBIS           (SIOCDEVPRIVATE + 3)
 
 /* CP210x ioctls principally used during initial device configuration */
-#define CP210x_IOCTL_DEVICERESET       (SIOCDEVPRIVATE + 4)    /* Reset the cp210x */
-#define CP210x_IOCTL_PORTCONFGET       (SIOCDEVPRIVATE + 5)    /* Get port configuration */
-#define CP210x_IOCTL_PORTCONFSET       (SIOCDEVPRIVATE + 6)    /* Set port configuration */
-#define CP210x_IOCTL_SETVID            (SIOCDEVPRIVATE + 7)    /* Set vendor id */
-#define CP210x_IOCTL_SETPID            (SIOCDEVPRIVATE + 8)    /* Set product id */
-#define CP210x_IOCTL_SETMFG            (SIOCDEVPRIVATE + 9)    /* Set manufacturer string */
-#define CP210x_IOCTL_SETPRODUCT        (SIOCDEVPRIVATE + 10)   /* Set product string */
-#define CP210x_IOCTL_SETSERIAL         (SIOCDEVPRIVATE + 11)   /* Set serial number string */
-#define CP210x_IOCTL_SETDEVVER         (SIOCDEVPRIVATE + 12)   /* Set device version id */
+#define CP210x_IOCTL_DEVICERESET       (SIOCDEVPRIVATE + 4)
+#define CP210x_IOCTL_PORTCONFGET       (SIOCDEVPRIVATE + 5)
+#define CP210x_IOCTL_PORTCONFSET       (SIOCDEVPRIVATE + 6)
+#define CP210x_IOCTL_SETVID            (SIOCDEVPRIVATE + 7)
+#define CP210x_IOCTL_SETPID            (SIOCDEVPRIVATE + 8)
+#define CP210x_IOCTL_SETMFG            (SIOCDEVPRIVATE + 9)
+#define CP210x_IOCTL_SETPRODUCT                (SIOCDEVPRIVATE + 10)
+#define CP210x_IOCTL_SETSERIAL         (SIOCDEVPRIVATE + 11)
+#define CP210x_IOCTL_SETDEVVER         (SIOCDEVPRIVATE + 12)
 
 /* CP2103 GPIO bit positions */
 #define GPIO_0                 0x01
 #define CP210x_ENH_nTXLED              0x01
 #endif /* __KERNEL__ */
 
-/* Used to pass variable sized buffers between user and kernel space (ioctls) */
+/* Used to pass variable size buffers between user and kernel space (ioctls) */
 struct cp210x_buffer {
        __u8 *buf;
        __s32 len;