Subject: [PATCH 2/3] 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 2/3] sierra driver adding suspend/resume: - Adding sierra_suspend(), sierra_resume() functions and support. - Added comment line for private data structure - Moved sierra_device structure at the bottom and added entries for suspend and resume interfaces. Signed-off-by: Elina Pasheva <epasheva@xxxxxxxxxxxxxxxxxx> --- drivers/usb/serial/sierra.c | 56 +++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 7 deletions(-) --- a/drivers/usb/serial/sierra.c 2009-05-06 17:12:28.000000000 -0700 +++ b/drivers/usb/serial/sierra.c 2009-05-06 17:16:25.000000000 -0700 @@ -44,6 +44,7 @@ static int debug; static int nmea; +static int suspend_support; /* list of interface numbers - used for constructing interface blacklists */ struct list { @@ -243,13 +244,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 */ @@ -839,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; + + for (i = 0; i < serial->num_ports ; i++) + sierra_stop_rx_urbs(serial->port[i]); + 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); + + 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, @@ -860,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. */ @@ -905,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"); -- 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