Subject: [PATCH 007/008] [RESUBMIT2] USB: serial: modifications in sierra_startup() and sierra_shutdown() functions From: Elina Pasheva <epasheva@xxxxxxxxxxxxxxxxxx> The following is summary of changes we have made to sierra.c driver in [PATCH 007/008] from the series dealing with improving urb handling: - Modified sierra_startup() so that allocation of urbs happens whenever an interface is activated (urb allocation is moved to sierra_open()). - Modified sierra_shutdown() so that urbs are freed whenever an interface is de-activated (urb freeing moved to sierra_close() as shown in previous patch from the series) - Removed unecessary data structure from sierra_port_private_data Signed-off-by: Elina Pasheva <epasheva@xxxxxxxxxxxxxxxxxx> --- drivers/usb/serial/sierra.c | 40 +--------------------------------- 1 file changed, 2 insertions(+), 38 deletions(-) --- a/drivers/usb/serial/sierra.c 2009-05-22 14:39:14.000000000 -0700 +++ b/drivers/usb/serial/sierra.c 2009-05-22 14:46:22.000000000 -0700 @@ -259,7 +259,6 @@ struct sierra_port_private { /* Input endpoints and buffers for this port */ struct urb *in_urbs[N_IN_URB]; - char *in_buffer[N_IN_URB]; /* Settings for the port */ int rts_state; /* Handshaking pins (outputs) */ @@ -792,9 +791,7 @@ static int sierra_startup(struct usb_ser { struct usb_serial_port *port; struct sierra_port_private *portdata; - struct urb *urb; int i; - int j; dev_dbg(&serial->dev->dev, "%s\n", __func__); @@ -815,35 +812,8 @@ static int sierra_startup(struct usb_ser __func__, i); return -ENOMEM; } - spin_lock_init(&portdata->lock); - for (j = 0; j < N_IN_URB; j++) { - portdata->in_buffer[j] = kmalloc(IN_BUFLEN, GFP_KERNEL); - if (!portdata->in_buffer[j]) { - for (--j; j >= 0; j--) - kfree(portdata->in_buffer[j]); - kfree(portdata); - return -ENOMEM; - } - } - + /* Set the port private data pointer */ usb_set_serial_port_data(port, portdata); - - /* initialize the in urbs */ - for (j = 0; j < N_IN_URB; ++j) { - urb = usb_alloc_urb(0, GFP_KERNEL); - if (urb == NULL) { - dev_dbg(&port->dev, "%s: alloc for in " - "port failed.\n", __func__); - continue; - } - /* Fill URB using supplied data. */ - usb_fill_bulk_urb(urb, serial->dev, - usb_rcvbulkpipe(serial->dev, - port->bulk_in_endpointAddress), - portdata->in_buffer[j], IN_BUFLEN, - sierra_indat_callback, port); - portdata->in_urbs[j] = urb; - } } return 0; @@ -851,7 +821,7 @@ static int sierra_startup(struct usb_ser static void sierra_shutdown(struct usb_serial *serial) { - int i, j; + int i; struct usb_serial_port *port; struct sierra_port_private *portdata; @@ -864,12 +834,6 @@ static void sierra_shutdown(struct usb_s portdata = usb_get_serial_port_data(port); if (!portdata) continue; - - for (j = 0; j < N_IN_URB; j++) { - usb_kill_urb(portdata->in_urbs[j]); - usb_free_urb(portdata->in_urbs[j]); - kfree(portdata->in_buffer[j]); - } kfree(portdata); usb_set_serial_port_data(port, NULL); } -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html