]> code.ossystems Code Review - openembedded-core.git/blob
3f49a4d6365fade7e0bdfaaa21109235e7713dfc
[openembedded-core.git] /
1 From 7eef82d231578140c6000d04846a48bdaf341a65 Mon Sep 17 00:00:00 2001
2 From: David Brownell <dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
3 Date: Tue, 24 Mar 2009 17:23:19 -0700
4 Subject: [PATCH] USB: gadget: composite device-level suspend/resume hooks
5
6 Address one open question in the composite gadget framework:
7 Yes, we should have device-level suspend/resume callbacks
8 in addition to the function-level ones.  We have at least one
9 scenario (with gadget zero in OTG test mode) that's awkward
10 to handle without it.
11
12 Signed-off-by: David Brownell <dbrownell-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
13 Cc: Felipe Balbi <felipe.balbi-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
14 Signed-off-by: Greg Kroah-Hartman <gregkh-l3A5Bk7waGM@public.gmane.org>
15 ---
16  drivers/usb/gadget/composite.c |    8 ++++++--
17  include/linux/usb/composite.h  |    8 ++++++++
18  2 files changed, 14 insertions(+), 2 deletions(-)
19
20 diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
21 index 40f1da7..59e8523 100644
22 --- a/drivers/usb/gadget/composite.c
23 +++ b/drivers/usb/gadget/composite.c
24 @@ -1014,7 +1014,7 @@ composite_suspend(struct usb_gadget *gadget)
25         struct usb_composite_dev        *cdev = get_gadget_data(gadget);
26         struct usb_function             *f;
27  
28 -       /* REVISIT:  should we have config and device level
29 +       /* REVISIT:  should we have config level
30          * suspend/resume callbacks?
31          */
32         DBG(cdev, "suspend\n");
33 @@ -1024,6 +1024,8 @@ composite_suspend(struct usb_gadget *gadget)
34                                 f->suspend(f);
35                 }
36         }
37 +       if (composite->suspend)
38 +               composite->suspend(cdev);
39  }
40  
41  static void
42 @@ -1032,10 +1034,12 @@ composite_resume(struct usb_gadget *gadget)
43         struct usb_composite_dev        *cdev = get_gadget_data(gadget);
44         struct usb_function             *f;
45  
46 -       /* REVISIT:  should we have config and device level
47 +       /* REVISIT:  should we have config level
48          * suspend/resume callbacks?
49          */
50         DBG(cdev, "resume\n");
51 +       if (composite->resume)
52 +               composite->resume(cdev);
53         if (cdev->config) {
54                 list_for_each_entry(f, &cdev->config->functions, list) {
55                         if (f->resume)
56 diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
57 index 935c380..acd7b0f 100644
58 --- a/include/linux/usb/composite.h
59 +++ b/include/linux/usb/composite.h
60 @@ -244,6 +244,10 @@ int usb_add_config(struct usb_composite_dev *,
61   *     value; it should return zero on successful initialization.
62   * @unbind: Reverses @bind(); called as a side effect of unregistering
63   *     this driver.
64 + * @suspend: Notifies when the host stops sending USB traffic,
65 + *     after function notifications
66 + * @resume: Notifies configuration when the host restarts USB traffic,
67 + *     before function notifications
68   *
69   * Devices default to reporting self powered operation.  Devices which rely
70   * on bus powered operation should report this in their @bind() method.
71 @@ -268,6 +272,10 @@ struct usb_composite_driver {
72  
73         int                     (*bind)(struct usb_composite_dev *);
74         int                     (*unbind)(struct usb_composite_dev *);
75 +
76 +       /* global suspend hooks */
77 +       void                    (*suspend)(struct usb_composite_dev *);
78 +       void                    (*resume)(struct usb_composite_dev *);
79  };
80  
81  extern int usb_composite_register(struct usb_composite_driver *);
82 -- 
83 1.6.0.4
84