Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ba734f349d5ba02a736e2d574584c56cd21bad14
Commit:     ba734f349d5ba02a736e2d574584c56cd21bad14
Parent:     9ce6cf25538de8036793a7e517674ede86e41f00
Author:     Peter Korsgaard <[EMAIL PROTECTED]>
AuthorDate: Thu Nov 15 11:10:12 2007 +0100
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Mon Jan 28 15:04:01 2008 -0800

    dm9601: Consolidate common parts of dm_write_*_async
    
    dm_write_async and dm_write_reg_async are almost identical.
    Move common functionality to dm_write_async_helper (saves ~256b).
    
    Signed-off-by: Peter Korsgaard <[EMAIL PROTECTED]>
    Signed-off-by: Jeff Garzik <[EMAIL PROTECTED]>
---
 drivers/net/usb/dm9601.c |   53 +++++++++++----------------------------------
 1 files changed, 13 insertions(+), 40 deletions(-)

diff --git a/drivers/net/usb/dm9601.c b/drivers/net/usb/dm9601.c
index 1ffdd10..633a511 100644
--- a/drivers/net/usb/dm9601.c
+++ b/drivers/net/usb/dm9601.c
@@ -101,17 +101,16 @@ static void dm_write_async_callback(struct urb *urb)
        usb_free_urb(urb);
 }
 
-static void dm_write_async(struct usbnet *dev, u8 reg, u16 length, void *data)
+static void dm_write_async_helper(struct usbnet *dev, u8 reg, u8 value,
+                                 u16 length, void *data)
 {
        struct usb_ctrlrequest *req;
        struct urb *urb;
        int status;
 
-       devdbg(dev, "dm_write_async() reg=0x%02x length=%d", reg, length);
-
        urb = usb_alloc_urb(0, GFP_ATOMIC);
        if (!urb) {
-               deverr(dev, "Error allocating URB in dm_write_async!");
+               deverr(dev, "Error allocating URB in dm_write_async_helper!");
                return;
        }
 
@@ -123,8 +122,8 @@ static void dm_write_async(struct usbnet *dev, u8 reg, u16 
length, void *data)
        }
 
        req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
-       req->bRequest = DM_WRITE_REGS;
-       req->wValue = 0;
+       req->bRequest = length ? DM_WRITE_REGS : DM_WRITE_REG;
+       req->wValue = cpu_to_le16(value);
        req->wIndex = cpu_to_le16(reg);
        req->wLength = cpu_to_le16(length);
 
@@ -142,45 +141,19 @@ static void dm_write_async(struct usbnet *dev, u8 reg, 
u16 length, void *data)
        }
 }
 
-static void dm_write_reg_async(struct usbnet *dev, u8 reg, u8 value)
+static void dm_write_async(struct usbnet *dev, u8 reg, u16 length, void *data)
 {
-       struct usb_ctrlrequest *req;
-       struct urb *urb;
-       int status;
+       devdbg(dev, "dm_write_async() reg=0x%02x length=%d", reg, length);
 
+       dm_write_async_helper(dev, reg, 0, length, data);
+}
+
+static void dm_write_reg_async(struct usbnet *dev, u8 reg, u8 value)
+{
        devdbg(dev, "dm_write_reg_async() reg=0x%02x value=0x%02x",
               reg, value);
 
-       urb = usb_alloc_urb(0, GFP_ATOMIC);
-       if (!urb) {
-               deverr(dev, "Error allocating URB in dm_write_async!");
-               return;
-       }
-
-       req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC);
-       if (!req) {
-               deverr(dev, "Failed to allocate memory for control request");
-               usb_free_urb(urb);
-               return;
-       }
-
-       req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
-       req->bRequest = DM_WRITE_REG;
-       req->wValue = cpu_to_le16(value);
-       req->wIndex = cpu_to_le16(reg);
-       req->wLength = 0;
-
-       usb_fill_control_urb(urb, dev->udev,
-                            usb_sndctrlpipe(dev->udev, 0),
-                            (void *)req, NULL, 0, dm_write_async_callback, 
req);
-
-       status = usb_submit_urb(urb, GFP_ATOMIC);
-       if (status < 0) {
-               deverr(dev, "Error submitting the control message: status=%d",
-                      status);
-               kfree(req);
-               usb_free_urb(urb);
-       }
+       dm_write_async_helper(dev, reg, value, 0, NULL);
 }
 
 static int dm_read_shared_word(struct usbnet *dev, int phy, u8 reg, u16 *value)
-
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