On Mon, Nov 04 2013, Andrzej Pietrasiewicz wrote: > If there are setup requests not directed to an endpont or an interface, > current config's setup() has been attempted so far. > This patch, in case the above fails, adds code which tries the setup() of > configuration's function if there is only one function in the configuration. > > This behavior is required to provide equivalent of gadget zero with configfs. > > The gadget zero has a "config driver" for sourcesink, but all it does is > delegating the request to the function proper. So when the equivalent gadget > is set up with configfs it needs to handle requests directed to > "config driver", but with configfs it is not possible to specify > "config drivers". > > Signed-off-by: Andrzej Pietrasiewicz <[email protected]> > Signed-off-by: Kyungmin Park <[email protected]> > --- > drivers/usb/gadget/composite.c | 17 ++++++++++++++++- > 1 files changed, 16 insertions(+), 1 deletions(-) > > diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c > index d4f0f33..287c63d 100644 > --- a/drivers/usb/gadget/composite.c > +++ b/drivers/usb/gadget/composite.c > @@ -1451,8 +1451,23 @@ unknown: > struct usb_configuration *c; > > c = cdev->config; > - if (c && c->setup) > + if (!c) > + goto done; > + > + /* try current config's setup */ > + if (c->setup) { > value = c->setup(c, ctrl); > + goto done; > + } > + > + /* try the only function in the current config */ > + if (!&c->functions || &c->functions == c->functions.next > + || &c->functions.next != &c->functions.prev)
!&c->functions always yields true, and the rest can be replaced with
a single function call:
if (!list_is_singular(&c->functions))
goto done;
> + goto done;
> + f = list_entry(cdev->config->functions.next,
> + struct usb_function, list);
f = list_first_entry(&c->functions,
struct usb_function, list);
> + if (f && f->setup)
> + value = f->setup(f, ctrl);
f always yields true, so this can be replaced by simple:
if (f->setup)
value = f->setup(f, ctrl);
> }
>
> goto done;
> --
> 1.7.0.4
>
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +--<[email protected]>--<xmpp:[email protected]>--ooO--(_)--Ooo--
signature.asc
Description: PGP signature
