Skip to content

Commit

Permalink
USB: gadget: composite device-level suspend/resume hooks
Browse files Browse the repository at this point in the history
Address one open question in the composite gadget framework:
Yes, we should have device-level suspend/resume callbacks
in addition to the function-level ones.  We have at least one
scenario (with gadget zero in OTG test mode) that's awkward
to handle without it.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: Felipe Balbi <felipe.balbi@nokia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
David Brownell authored and Greg Kroah-Hartman committed Mar 24, 2009
1 parent e1e609b commit 8942939
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/usb/gadget/composite.c
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ composite_suspend(struct usb_gadget *gadget)
struct usb_composite_dev *cdev = get_gadget_data(gadget);
struct usb_function *f;

/* REVISIT: should we have config and device level
/* REVISIT: should we have config level
* suspend/resume callbacks?
*/
DBG(cdev, "suspend\n");
Expand All @@ -1024,6 +1024,8 @@ composite_suspend(struct usb_gadget *gadget)
f->suspend(f);
}
}
if (composite->suspend)
composite->suspend(cdev);
}

static void
Expand All @@ -1032,10 +1034,12 @@ composite_resume(struct usb_gadget *gadget)
struct usb_composite_dev *cdev = get_gadget_data(gadget);
struct usb_function *f;

/* REVISIT: should we have config and device level
/* REVISIT: should we have config level
* suspend/resume callbacks?
*/
DBG(cdev, "resume\n");
if (composite->resume)
composite->resume(cdev);
if (cdev->config) {
list_for_each_entry(f, &cdev->config->functions, list) {
if (f->resume)
Expand Down
8 changes: 8 additions & 0 deletions include/linux/usb/composite.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ int usb_add_config(struct usb_composite_dev *,
* value; it should return zero on successful initialization.
* @unbind: Reverses @bind(); called as a side effect of unregistering
* this driver.
* @suspend: Notifies when the host stops sending USB traffic,
* after function notifications
* @resume: Notifies configuration when the host restarts USB traffic,
* before function notifications
*
* Devices default to reporting self powered operation. Devices which rely
* on bus powered operation should report this in their @bind() method.
Expand All @@ -268,6 +272,10 @@ struct usb_composite_driver {

int (*bind)(struct usb_composite_dev *);
int (*unbind)(struct usb_composite_dev *);

/* global suspend hooks */
void (*suspend)(struct usb_composite_dev *);
void (*resume)(struct usb_composite_dev *);
};

extern int usb_composite_register(struct usb_composite_driver *);
Expand Down

0 comments on commit 8942939

Please sign in to comment.