tree d83f2bbf989b838498d85cc05ad0a16b451211c1
parent 0256839619d9b1e933cafc83e7f0deaad4216465
author Nick Sillik <[EMAIL PROTECTED]> Wed, 17 Aug 2005 21:37:34 -0400
committer Greg Kroah-Hartman <[EMAIL PROTECTED]> Fri, 09 Sep 2005 06:30:33 -0700

[PATCH] USB Storage: code cleanups for onetouch.c

As sugested by Alan Stern here are a few code cleanups for onetouch.c:

-Check number of endpoints before directly referencing intf->endpoint[2]
-Use defined constants instead of magic numbers
-Revmove the non-ascii characters from copyright notice
-Make registration and deregistration messages more similar

Signed-off-by: Nick Sillik <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>

 drivers/usb/storage/onetouch.c |   29 +++++++++++++++++------------
 1 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c
--- a/drivers/usb/storage/onetouch.c
+++ b/drivers/usb/storage/onetouch.c
@@ -5,7 +5,7 @@
  *     Copyright (c) 2005 Nick Sillik <[EMAIL PROTECTED]>
  *
  * Initial work by:
- *     Copyright (c) 2003 Erik Thyrén <[EMAIL PROTECTED]>
+ *     Copyright (c) 2003 Erik Thyren <[EMAIL PROTECTED]>
  *
  * Based on usbmouse.c (Vojtech Pavlik) and xpad.c (Marko Friedemann)
  *
@@ -35,6 +35,8 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/usb.h>
+#include <linux/usb_ch9.h>
+#include <linux/usb_input.h>
 #include "usb.h"
 #include "onetouch.h"
 #include "debug.h"
@@ -116,10 +118,14 @@ int onetouch_connect_input(struct us_dat
 
        interface = ss->pusb_intf->cur_altsetting;
 
+       if (interface->desc.bNumEndpoints != 3)
+               return -ENODEV;
+
        endpoint = &interface->endpoint[2].desc;
-       if(!(endpoint->bEndpointAddress & 0x80))
+       if(!(endpoint->bEndpointAddress & USB_DIR_IN))
                return -ENODEV;
-       if((endpoint->bmAttributes & 3) != 3)
+       if((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
+                       != USB_ENDPOINT_XFER_INT)
                return -ENODEV;
 
        pipe = usb_rcvintpipe(udev, endpoint->bEndpointAddress);
@@ -128,7 +134,8 @@ int onetouch_connect_input(struct us_dat
        if (!(onetouch = kcalloc(1, sizeof(struct usb_onetouch), GFP_KERNEL)))
                return -ENOMEM;
 
-       onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN, SLAB_ATOMIC, 
&onetouch->data_dma);
+       onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN,
+                                         SLAB_ATOMIC, &onetouch->data_dma);
        if (!onetouch->data){
                kfree(onetouch);
                return -ENOMEM;
@@ -137,7 +144,8 @@ int onetouch_connect_input(struct us_dat
        onetouch->irq = usb_alloc_urb(0, GFP_KERNEL);
        if (!onetouch->irq){
                kfree(onetouch);
-               usb_buffer_free(udev, ONETOUCH_PKT_LEN, onetouch->data, 
onetouch->data_dma);
+               usb_buffer_free(udev, ONETOUCH_PKT_LEN,
+                               onetouch->data, onetouch->data_dma);
                return -ENODEV;
        }
 
@@ -152,16 +160,13 @@ int onetouch_connect_input(struct us_dat
        onetouch->dev.open = usb_onetouch_open;
        onetouch->dev.close = usb_onetouch_close;
 
-       usb_make_path(udev, path, 64);
+       usb_make_path(udev, path, sizeof(path));
        sprintf(onetouch->phys, "%s/input0", path);
 
        onetouch->dev.name = onetouch->name;
        onetouch->dev.phys = onetouch->phys;
 
-       onetouch->dev.id.bustype = BUS_USB;
-       onetouch->dev.id.vendor = le16_to_cpu(udev->descriptor.idVendor);
-       onetouch->dev.id.product = le16_to_cpu(udev->descriptor.idProduct);
-       onetouch->dev.id.version = le16_to_cpu(udev->descriptor.bcdDevice);
+       usb_to_input_id(udev, &onetouch->dev.id);
 
        onetouch->dev.dev = &udev->dev;
 
@@ -199,7 +204,7 @@ void onetouch_release_input(void *onetou
                usb_free_urb(onetouch->irq);
                usb_buffer_free(onetouch->udev, ONETOUCH_PKT_LEN,
                                onetouch->data, onetouch->data_dma);
-               printk(KERN_INFO "Maxtor Onetouch %04x:%04x Deregistered\n",
-                       onetouch->dev.id.vendor, onetouch->dev.id.product);
+               printk(KERN_INFO "usb-input: deregistering %s\n",
+                               onetouch->dev.name);
        }
 }
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to