o CodingStyle fixes
o Removes trailing spaces
o Do not make not needed initialiation of automatic variables
o Use usb_endpoint_* functions
o If we get an error in the write URB callback print an error message instead
  of a debug one

 (Pretty unrelated changes, but spliting this up doesn't pay off as our main
changes are just CodingStyle fixes).

Signed-off-by: Luiz Fernando N. Capitulino <[EMAIL PROTECTED]>
---
 drivers/usb/usb-skeleton.c |   52 +++++++++++++++++++--------------------------
 1 file changed, 23 insertions(+), 29 deletions(-)

--- linux-2.6.orig/drivers/usb/usb-skeleton.c
+++ linux-2.6/drivers/usb/usb-skeleton.c
@@ -1,5 +1,5 @@
 /*
- * USB Skeleton driver - 2.0
+ * USB Skeleton driver - 2.1
  *
  * Copyright (C) 2001-2004 Greg Kroah-Hartman ([EMAIL PROTECTED])
  *
@@ -7,7 +7,7 @@
  *     modify it under the terms of the GNU General Public License as
  *     published by the Free Software Foundation, version 2.
  *
- * This driver is based on the 2.6.3 version of drivers/usb/usb-skeleton.c 
+ * This driver is based on the 2.6.3 version of drivers/usb/usb-skeleton.c
  * but has been rewritten to be easy to read and use, as no locks are now
  * needed anymore.
  *
@@ -32,14 +32,14 @@ static struct usb_device_id skel_table [
        { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) },
        { }                                     /* Terminating entry */
 };
-MODULE_DEVICE_TABLE (usb, skel_table);
+MODULE_DEVICE_TABLE(usb, skel_table);
 
 
 /* Get a minor range for your devices from the usb maintainer */
 #define USB_SKEL_MINOR_BASE    192
 
 /* our private defines. if this grows any larger, use your own .h file */
-#define MAX_TRANSFER           ( PAGE_SIZE - 512 )
+#define MAX_TRANSFER           (PAGE_SIZE - 512)
 #define WRITES_IN_FLIGHT       8
 
 /* Structure to hold all of our device specific stuff */
@@ -58,12 +58,12 @@ struct usb_skel {
 static struct usb_driver skel_driver;
 
 static void skel_delete(struct kref *kref)
-{      
+{
        struct usb_skel *dev = to_skel_dev(kref);
 
        usb_put_dev(dev->udev);
-       kfree (dev->bulk_in_buffer);
-       kfree (dev);
+       kfree(dev->bulk_in_buffer);
+       kfree(dev);
 }
 
 static int skel_open(struct inode *inode, struct file *file)
@@ -104,7 +104,7 @@ static int skel_release(struct inode *in
        struct usb_skel *dev;
 
        dev = (struct usb_skel *)file->private_data;
-       if (dev == NULL)
+       if (!dev)
                return -ENODEV;
 
        /* decrement the count on our device */
@@ -115,11 +115,11 @@ static int skel_release(struct inode *in
 static ssize_t skel_read(struct file *file, char *buffer, size_t count, loff_t 
*ppos)
 {
        struct usb_skel *dev;
-       int retval = 0;
+       int retval;
        int bytes_read;
 
        dev = (struct usb_skel *)file->private_data;
-       
+
        /* do a blocking bulk read to get data from the device */
        retval = usb_bulk_msg(dev->udev,
                              usb_rcvbulkpipe(dev->udev, 
dev->bulk_in_endpointAddr),
@@ -145,16 +145,16 @@ static void skel_write_bulk_callback(str
        dev = (struct usb_skel *)urb->context;
 
        /* sync/async unlink faults aren't errors */
-       if (urb->status && 
-           !(urb->status == -ENOENT || 
+       if (urb->status &&
+           !(urb->status == -ENOENT ||
              urb->status == -ECONNRESET ||
              urb->status == -ESHUTDOWN)) {
-               dbg("%s - nonzero write bulk status received: %d",
+               err("%s - nonzero write bulk status received: %d",
                    __FUNCTION__, urb->status);
        }
 
        /* free up our allocated buffer */
-       usb_buffer_free(urb->dev, urb->transfer_buffer_length, 
+       usb_buffer_free(urb->dev, urb->transfer_buffer_length,
                        urb->transfer_buffer, urb->transfer_dma);
        up(&dev->limit_sem);
 }
@@ -162,8 +162,8 @@ static void skel_write_bulk_callback(str
 static ssize_t skel_write(struct file *file, const char *user_buffer, size_t 
count, loff_t *ppos)
 {
        struct usb_skel *dev;
-       int retval = 0;
-       struct urb *urb = NULL;
+       int retval;
+       struct urb *urb;
        char *buf = NULL;
        size_t writesize = min(count, (size_t)MAX_TRANSFER);
 
@@ -231,7 +231,7 @@ static const struct file_operations skel
        .release =      skel_release,
 };
 
-/* 
+/*
  * usb class driver info in order to get a minor number from the usb core,
  * and to have the device registered with the driver core
  */
@@ -243,7 +243,7 @@ static struct usb_class_driver skel_clas
 
 static int skel_probe(struct usb_interface *interface, const struct 
usb_device_id *id)
 {
-       struct usb_skel *dev = NULL;
+       struct usb_skel *dev;
        struct usb_host_interface *iface_desc;
        struct usb_endpoint_descriptor *endpoint;
        size_t buffer_size;
@@ -252,7 +252,7 @@ static int skel_probe(struct usb_interfa
 
        /* allocate memory for our device state and initialize it */
        dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-       if (dev == NULL) {
+       if (!dev) {
                err("Out of memory");
                goto error;
        }
@@ -269,10 +269,7 @@ static int skel_probe(struct usb_interfa
                endpoint = &iface_desc->endpoint[i].desc;
 
                if (!dev->bulk_in_endpointAddr &&
-                   ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
-                                       == USB_DIR_IN) &&
-                   ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
-                                       == USB_ENDPOINT_XFER_BULK)) {
+                   usb_endpoint_is_bulk_in(endpoint)) {
                        /* we found a bulk in endpoint */
                        buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
                        dev->bulk_in_size = buffer_size;
@@ -285,10 +282,7 @@ static int skel_probe(struct usb_interfa
                }
 
                if (!dev->bulk_out_endpointAddr &&
-                   ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
-                                       == USB_DIR_OUT) &&
-                   ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
-                                       == USB_ENDPOINT_XFER_BULK)) {
+                   usb_endpoint_is_bulk_out(endpoint)) {
                        /* we found a bulk out endpoint */
                        dev->bulk_out_endpointAddr = endpoint->bEndpointAddress;
                }
@@ -367,7 +361,7 @@ static void __exit usb_skel_exit(void)
        usb_deregister(&skel_driver);
 }
 
-module_init (usb_skel_init);
-module_exit (usb_skel_exit);
+module_init(usb_skel_init);
+module_exit(usb_skel_exit);
 
 MODULE_LICENSE("GPL");

-- 
Luiz Fernando N. Capitulino

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to