lkml.org 
[lkml]   [2015]   [Nov]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 14/23] usb: gadget: composite: introduce clear_alt() operation
    Date
    Introduce clear_alt() callback, which is called when prevoiusly set
    altsetting is cleared. This can take place in two situations:
    - when another altsetting is selected,
    - during function disable.

    Thanks to symetry to set_alt(), clear_alt() simplifies managing of
    resources allocated in set_alt(). It also takes over the function of
    disable() opetarion, so it can be removed after converting all USB
    functions to new API.

    Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
    ---
    drivers/usb/gadget/composite.c | 12 ++++++++----
    include/linux/usb/composite.h | 4 ++++
    2 files changed, 12 insertions(+), 4 deletions(-)

    diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
    index 439beca..5ce95d2 100644
    --- a/drivers/usb/gadget/composite.c
    +++ b/drivers/usb/gadget/composite.c
    @@ -982,6 +982,9 @@ static void disable_interface(struct usb_function *f, unsigned i)
    for (e = 0; e < alt->eps_num; ++e)
    usb_ep_disable(alt->eps[e]->ep);

    + if (f->clear_alt)
    + f->clear_alt(f, i, intf->cur_altset);
    +
    intf->cur_altset = -1;
    }

    @@ -993,12 +996,13 @@ static void disable_function(struct usb_function *f)
    {
    int i;

    - if (usb_function_is_new_api(f))
    + if (usb_function_is_new_api(f)) {
    for (i = 0; i < f->descs->intfs_num; ++i)
    disable_interface(f, i);
    -
    - if (f->disable)
    - f->disable(f);
    + } else {
    + if (f->disable)
    + f->disable(f);
    + }

    bitmap_zero(f->endpoints, 32);
    }
    diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
    index 7cef8c0..3838eb6 100644
    --- a/include/linux/usb/composite.h
    +++ b/include/linux/usb/composite.h
    @@ -301,6 +301,8 @@ struct usb_os_desc_table {
    * initialize usb_ep.driver data at this time (when it is used).
    * Note that setting an interface to its current altsetting resets
    * interface state, and that all interfaces have a disabled state.
    + * @clear_alt: (REQUIRED) Clears altsetting, frees all ep requiests and other
    + * resources allocated by set_alt.
    * @get_alt: Returns the active altsetting. If this is not provided,
    * then only altsetting zero is supported.
    * @disable: (REQUIRED) Indicates the function should be disabled. Reasons
    @@ -373,6 +375,8 @@ struct usb_function {
    /* runtime state management */
    int (*set_alt)(struct usb_function *,
    unsigned interface, unsigned alt);
    + void (*clear_alt)(struct usb_function *,
    + unsigned interface, unsigned alt);
    int (*get_alt)(struct usb_function *,
    unsigned interface);
    void (*disable)(struct usb_function *);
    --
    1.9.1


    \
     
     \ /
      Last update: 2015-11-03 14:01    [W:2.779 / U:0.032 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site