Commit 7931e1c6 authored by Matthew Dharm's avatar Matthew Dharm Committed by Greg Kroah-Hartman

[PATCH] USB Storage: make OneTouch PM-aware

The OneTouch subdriver submits its own interrupt URB for notifications
about button presses.  Consequently it needs to know about suspend and
resume events, so it can cancel or restart the URB.

This patch (as593) adds a hook to struct us_data, to be used for
notifying subdrivers about Power Management events, and it implements
the hook in the OneTouch driver.
Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarNick Sillik <n.sillik@temple.edu>
Signed-off-by: default avatarMatthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent b9b09422
...@@ -52,6 +52,7 @@ struct usb_onetouch { ...@@ -52,6 +52,7 @@ struct usb_onetouch {
struct urb *irq; /* urb for interrupt in report */ struct urb *irq; /* urb for interrupt in report */
unsigned char *data; /* input data */ unsigned char *data; /* input data */
dma_addr_t data_dma; dma_addr_t data_dma;
unsigned int is_open:1;
}; };
static void usb_onetouch_irq(struct urb *urb, struct pt_regs *regs) static void usb_onetouch_irq(struct urb *urb, struct pt_regs *regs)
...@@ -89,6 +90,7 @@ static int usb_onetouch_open(struct input_dev *dev) ...@@ -89,6 +90,7 @@ static int usb_onetouch_open(struct input_dev *dev)
{ {
struct usb_onetouch *onetouch = dev->private; struct usb_onetouch *onetouch = dev->private;
onetouch->is_open = 1;
onetouch->irq->dev = onetouch->udev; onetouch->irq->dev = onetouch->udev;
if (usb_submit_urb(onetouch->irq, GFP_KERNEL)) { if (usb_submit_urb(onetouch->irq, GFP_KERNEL)) {
err("usb_submit_urb failed"); err("usb_submit_urb failed");
...@@ -103,8 +105,30 @@ static void usb_onetouch_close(struct input_dev *dev) ...@@ -103,8 +105,30 @@ static void usb_onetouch_close(struct input_dev *dev)
struct usb_onetouch *onetouch = dev->private; struct usb_onetouch *onetouch = dev->private;
usb_kill_urb(onetouch->irq); usb_kill_urb(onetouch->irq);
onetouch->is_open = 0;
} }
#ifdef CONFIG_PM
static void usb_onetouch_pm_hook(struct us_data *us, int action)
{
struct usb_onetouch *onetouch = (struct usb_onetouch *) us->extra;
if (onetouch->is_open) {
switch (action) {
case US_SUSPEND:
usb_kill_urb(onetouch->irq);
break;
case US_RESUME:
if (usb_submit_urb(onetouch->irq, GFP_KERNEL) != 0)
err("usb_submit_urb failed");
break;
default:
break;
}
}
}
#endif /* CONFIG_PM */
int onetouch_connect_input(struct us_data *ss) int onetouch_connect_input(struct us_data *ss)
{ {
struct usb_device *udev = ss->pusb_dev; struct usb_device *udev = ss->pusb_dev;
...@@ -185,6 +209,9 @@ int onetouch_connect_input(struct us_data *ss) ...@@ -185,6 +209,9 @@ int onetouch_connect_input(struct us_data *ss)
ss->extra_destructor = onetouch_release_input; ss->extra_destructor = onetouch_release_input;
ss->extra = onetouch; ss->extra = onetouch;
#ifdef CONFIG_PM
ss->suspend_resume_hook = usb_onetouch_pm_hook;
#endif
input_register_device(onetouch->dev); input_register_device(onetouch->dev);
......
...@@ -188,6 +188,8 @@ static int storage_suspend(struct usb_interface *iface, pm_message_t message) ...@@ -188,6 +188,8 @@ static int storage_suspend(struct usb_interface *iface, pm_message_t message)
down(&us->dev_semaphore); down(&us->dev_semaphore);
US_DEBUGP("%s\n", __FUNCTION__); US_DEBUGP("%s\n", __FUNCTION__);
if (us->suspend_resume_hook)
(us->suspend_resume_hook)(us, US_SUSPEND);
iface->dev.power.power_state.event = message.event; iface->dev.power.power_state.event = message.event;
/* When runtime PM is working, we'll set a flag to indicate /* When runtime PM is working, we'll set a flag to indicate
...@@ -204,6 +206,8 @@ static int storage_resume(struct usb_interface *iface) ...@@ -204,6 +206,8 @@ static int storage_resume(struct usb_interface *iface)
down(&us->dev_semaphore); down(&us->dev_semaphore);
US_DEBUGP("%s\n", __FUNCTION__); US_DEBUGP("%s\n", __FUNCTION__);
if (us->suspend_resume_hook)
(us->suspend_resume_hook)(us, US_RESUME);
iface->dev.power.power_state.event = PM_EVENT_ON; iface->dev.power.power_state.event = PM_EVENT_ON;
up(&us->dev_semaphore); up(&us->dev_semaphore);
......
...@@ -94,6 +94,10 @@ typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data*); ...@@ -94,6 +94,10 @@ typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data*);
typedef int (*trans_reset)(struct us_data*); typedef int (*trans_reset)(struct us_data*);
typedef void (*proto_cmnd)(struct scsi_cmnd*, struct us_data*); typedef void (*proto_cmnd)(struct scsi_cmnd*, struct us_data*);
typedef void (*extra_data_destructor)(void *); /* extra data destructor */ typedef void (*extra_data_destructor)(void *); /* extra data destructor */
typedef void (*pm_hook)(struct us_data *, int); /* power management hook */
#define US_SUSPEND 0
#define US_RESUME 1
/* we allocate one of these for every device that we remember */ /* we allocate one of these for every device that we remember */
struct us_data { struct us_data {
...@@ -149,6 +153,9 @@ struct us_data { ...@@ -149,6 +153,9 @@ struct us_data {
/* subdriver information */ /* subdriver information */
void *extra; /* Any extra data */ void *extra; /* Any extra data */
extra_data_destructor extra_destructor;/* extra data destructor */ extra_data_destructor extra_destructor;/* extra data destructor */
#ifdef CONFIG_PM
pm_hook suspend_resume_hook;
#endif
}; };
/* Convert between us_data and the corresponding Scsi_Host */ /* Convert between us_data and the corresponding Scsi_Host */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment