Am Montag, 1. Juni 2009 20:49:37 schrieb Elina Pasheva: > Subject: [PATCH 1/2] USB: serial: sierra driver adding suspend/resume > From: Elina Pasheva <epasheva@xxxxxxxxxxxxxxxxxx> > > The following is summary of changes we have made to sierra.c driver in > [PATCH 1/2] sierra driver adding suspend/resume: > - Adding sierra_suspend(), sierra_resume() functions and support. > - Moved sierra_device structure at the bottom > - Added entries for suspend and resume interfaces to sierra_device > structure. Signed-off-by: Elina Pasheva <epasheva@xxxxxxxxxxxxxxxxxx> > --- > > drivers/usb/serial/sierra.c | 57 +++++++++++++++++++++++++++++----- > 1 file changed, 49 insertions(+), 8 deletions(-) > > --- a/drivers/usb/serial/sierra.c 2009-05-22 15:28:25.000000000 -0700 > +++ a/drivers/usb/serial/sierra.c 2009-05-22 15:56:11.000000000 -0700 > @@ -44,6 +44,7 @@ > > static int debug; > static int nmea; > +static int suspend_support; > > /* Used in interface blacklisting */ > struct sierra_iface_info { > @@ -245,14 +246,7 @@ static struct usb_device_id id_table [] > }; > MODULE_DEVICE_TABLE(usb, id_table); > > -static struct usb_driver sierra_driver = { > - .name = "sierra", > - .probe = usb_serial_probe, > - .disconnect = usb_serial_disconnect, > - .id_table = id_table, > - .no_dynamic_id = 1, > -}; > - > +/* per port private data */ > struct sierra_port_private { > spinlock_t lock; /* lock the structure */ > int outstanding_urbs; /* number of out urbs in flight */ > @@ -840,6 +834,48 @@ static void sierra_shutdown(struct usb_s > } > } > > +int sierra_suspend(struct usb_serial *serial, pm_message_t message) > +{ > + int i; > + > + dev_dbg(&serial->dev->dev, "%s\n", __func__); > + > + /* The dummy interface doesn't prevent suspended state */ > + if (serial->num_ports == 0) > + return 0; > + > + if (!suspend_support) > + return -EOPNOTSUPP; This means that the whole system cannot be suspended. Is this really needed? > + > + for (i = 0; i < serial->num_ports ; i++) > + sierra_stop_rx_urbs(serial->port[i]); This is insufficient. You must also handle the tx urbs. Either waiting for them to finish or kill them. > + return 0; > +} > + > +int sierra_resume(struct usb_serial *serial) > +{ > + int i; > + > + dev_dbg(&serial->dev->dev, "%s\n", __func__); > + > + for (i = 0; i < serial->num_ports ; i++) > + sierra_submit_rx_urbs(serial->port[i], GFP_KERNEL); You must use GFP_NOIO > + > + return 0; > +} > + > +static struct usb_driver sierra_driver = { > + .name = "sierra", > + .probe = usb_serial_probe, > + .disconnect = usb_serial_disconnect, > + .suspend = usb_serial_suspend, > + .resume = usb_serial_resume, > + .id_table = id_table, > + > + .no_dynamic_id = 1, > + .supports_autosuspend = 1, > +}; > + > static struct usb_serial_driver sierra_device = { > .driver = { > .owner = THIS_MODULE, > @@ -861,6 +897,8 @@ static struct usb_serial_driver sierra_d > .attach = sierra_startup, > .shutdown = sierra_shutdown, > .read_int_callback = sierra_instat_callback, > + .suspend = sierra_suspend, > + .resume = sierra_resume, > }; > > /* Functions used by new usb-serial code. */ > @@ -906,3 +944,6 @@ MODULE_PARM_DESC(nmea, "NMEA streaming") > > module_param(debug, bool, S_IRUGO | S_IWUSR); > MODULE_PARM_DESC(debug, "Debug messages"); > + > +module_param(suspend_support, bool, S_IRUGO | S_IWUSR); > +MODULE_PARM_DESC(suspend_support, "Selective Suspend support"); This comment is misleading. Regards Oliver -- 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