USB: kmemdup() cleanup in drivers/usb/
authorEric Sesterhenn <snakebyte@gmx.de>
Thu, 26 Oct 2006 19:06:24 +0000 (21:06 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 1 Dec 2006 22:23:27 +0000 (14:23 -0800)
replace open coded kmemdup() to save some screen space,
and allow inlining/not inlining to be triggered by gcc.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/atm/ueagle-atm.c
drivers/usb/misc/emi26.c
drivers/usb/misc/emi62.c
drivers/usb/serial/ezusb.c
drivers/usb/serial/ipw.c

index f6b9f7e1f716d5dd05c84b4bf836cfc57212adff..c137c041f7a43057d355b40654b31816a7092a50 100644 (file)
@@ -401,9 +401,8 @@ static int uea_send_modem_cmd(struct usb_device *usb,
        int ret = -ENOMEM;
        u8 *xfer_buff;
 
-       xfer_buff = kmalloc(size, GFP_KERNEL);
+       xfer_buff = kmemdup(buff, size, GFP_KERNEL);
        if (xfer_buff) {
-               memcpy(xfer_buff, buff, size);
                ret = usb_control_msg(usb,
                                      usb_sndctrlpipe(usb, 0),
                                      LOAD_INTERNAL,
@@ -595,14 +594,12 @@ static int uea_idma_write(struct uea_softc *sc, void *data, u32 size)
        u8 *xfer_buff;
        int bytes_read;
 
-       xfer_buff = kmalloc(size, GFP_KERNEL);
+       xfer_buff = kmemdup(data, size, GFP_KERNEL);
        if (!xfer_buff) {
                uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n");
                return ret;
        }
 
-       memcpy(xfer_buff, data, size);
-
        ret = usb_bulk_msg(sc->usb_dev,
                         usb_sndbulkpipe(sc->usb_dev, UEA_IDMA_PIPE),
                         xfer_buff, size, &bytes_read, BULK_TIMEOUT);
@@ -765,12 +762,11 @@ static int uea_request(struct uea_softc *sc,
        u8 *xfer_buff;
        int ret = -ENOMEM;
 
-       xfer_buff = kmalloc(size, GFP_KERNEL);
+       xfer_buff = kmemdup(data, size, GFP_KERNEL);
        if (!xfer_buff) {
                uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n");
                return ret;
        }
-       memcpy(xfer_buff, data, size);
 
        ret = usb_control_msg(sc->usb_dev, usb_sndctrlpipe(sc->usb_dev, 0),
                              UCDC_SEND_ENCAPSULATED_COMMAND,
index 1fd9cb85f4ca3aa9014e542d0a517d508dcad1e6..5c0a26cbd12884e212b319df3608121034ea8e01 100644 (file)
@@ -53,13 +53,12 @@ static void __exit emi26_exit (void);
 static int emi26_writememory (struct usb_device *dev, int address, unsigned char *data, int length, __u8 request)
 {
        int result;
-       unsigned char *buffer =  kmalloc (length, GFP_KERNEL);
+       unsigned char *buffer =  kmemdup(data, length, GFP_KERNEL);
 
        if (!buffer) {
                err("emi26: kmalloc(%d) failed.", length);
                return -ENOMEM;
        }
-       memcpy (buffer, data, length);
        /* Note: usb_control_msg returns negative value on error or length of the
         *               data that was written! */
        result = usb_control_msg (dev, usb_sndctrlpipe(dev, 0), request, 0x40, address, 0, buffer, length, 300);
index fe351371f274e11e6b576dcce1a671cd2b8ef0f8..23153eac0dfaf0b869991ed39af4698aa3089caa 100644 (file)
@@ -61,13 +61,12 @@ static void __exit emi62_exit (void);
 static int emi62_writememory (struct usb_device *dev, int address, unsigned char *data, int length, __u8 request)
 {
        int result;
-       unsigned char *buffer =  kmalloc (length, GFP_KERNEL);
+       unsigned char *buffer =  kmemdup(data, length, GFP_KERNEL);
 
        if (!buffer) {
                err("emi62: kmalloc(%d) failed.", length);
                return -ENOMEM;
        }
-       memcpy (buffer, data, length);
        /* Note: usb_control_msg returns negative value on error or length of the
         *               data that was written! */
        result = usb_control_msg (dev, usb_sndctrlpipe(dev, 0), request, 0x40, address, 0, buffer, length, 300);
index 5169c2d154abff4e3fd1dc5438a65980df1919a3..97ee718b1da2a29bf08ed4f30e88cff14bb3beb9 100644 (file)
@@ -31,12 +31,11 @@ int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *da
                return -ENODEV;
        }
 
-       transfer_buffer =  kmalloc (length, GFP_KERNEL);
+       transfer_buffer = kmemdup(data, length, GFP_KERNEL);
        if (!transfer_buffer) {
                dev_err(&serial->dev->dev, "%s - kmalloc(%d) failed.\n", __FUNCTION__, length);
                return -ENOMEM;
        }
-       memcpy (transfer_buffer, data, length);
        result = usb_control_msg (serial->dev, usb_sndctrlpipe(serial->dev, 0), bRequest, 0x40, address, 0, transfer_buffer, length, 3000);
        kfree (transfer_buffer);
        return result;
index 2a4bb66691ad4ae90cebe8b7b6201b0f4a82d404..d3b9a351cef8ae9f3ecbf585e27d225b1665fc43 100644 (file)
@@ -206,10 +206,9 @@ static int ipw_open(struct usb_serial_port *port, struct file *filp)
 
        dbg("%s", __FUNCTION__);
 
-       buf_flow_init = kmalloc(16, GFP_KERNEL);
+       buf_flow_init = kmemdup(buf_flow_static, 16, GFP_KERNEL);
        if (!buf_flow_init)
                return -ENOMEM;
-       memcpy(buf_flow_init, buf_flow_static, 16);
 
        if (port->tty)
                port->tty->low_latency = 1;