usb: gadget: composite: Test get_alt() presence instead of set_alt()
authorKrzysztof Opasiak <k.opasiak@samsung.com>
Tue, 20 Dec 2016 18:52:16 +0000 (19:52 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Jun 2017 22:46:50 +0000 (00:46 +0200)
commit7e3f800640d31cdaf12397ab30c6ba8e954f149e
tree120642e48937c18940422df4c6bdf80aa1d68e91
parentecf33babd51448a7390dff6adb17cbf8e196383c
usb: gadget: composite: Test get_alt() presence instead of set_alt()

commit 7e4da3fcf7c9fe042f2f7cb7bf23861a899b4a8f upstream.

By convention (according to doc) if function does not provide
get_alt() callback composite framework should assume that it has only
altsetting 0 and should respond with error if host tries to set
other one.

After commit dd4dff8b035f ("USB: composite: Fix bug: should test
set_alt function pointer before use it")
we started checking set_alt() callback instead of get_alt().
This check is useless as we check if set_alt() is set inside
usb_add_function() and fail if it's NULL.

Let's fix this check and move comment about why we check the get
method instead of set a little bit closer to prevent future false
fixes.

Fixes: dd4dff8b035f ("USB: composite: Fix bug: should test set_alt function pointer before use it")
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
drivers/usb/gadget/composite.c