diff options
author | Andrzej Pietrasiewicz <andrzej.p@samsung.com> | 2015-03-03 04:52:23 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2015-03-10 16:33:39 -0400 |
commit | f563d230903210acc2336af58e422216b68ded76 (patch) | |
tree | dbe10a4b868bf144d5565fc5c1c0f4cc6910b2c9 /include/linux/usb | |
parent | 143d53e10ecfeee7245341aa9c50515b5680ffd4 (diff) |
usb: gadget: composite: add req_match method to usb_function
Non-standard requests can encode the actual interface number in a
non-standard way. For example composite_setup() assumes
that it is w_index && 0xFF, but the printer function encodes the interface
number in a context-dependet way (either w_index or w_index >> 8).
This can lead to such requests being directed to wrong functions.
This patch adds req_match() method to usb_function. Its purpose is to
verify that a given request can be handled by a given function.
If any function within a configuration provides the method and it returns
true, then it is assumed that the right function is found.
If a function uses req_match(), it should try as hard as possible to
determine if the request is meant for it.
If no functions in a configuration provide req_match or none of them
returns true, then fall back to the usual approach.
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'include/linux/usb')
-rw-r--r-- | include/linux/usb/composite.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index 3d87defcc527..2511469a9904 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h | |||
@@ -148,6 +148,7 @@ struct usb_os_desc_table { | |||
148 | * @disable: (REQUIRED) Indicates the function should be disabled. Reasons | 148 | * @disable: (REQUIRED) Indicates the function should be disabled. Reasons |
149 | * include host resetting or reconfiguring the gadget, and disconnection. | 149 | * include host resetting or reconfiguring the gadget, and disconnection. |
150 | * @setup: Used for interface-specific control requests. | 150 | * @setup: Used for interface-specific control requests. |
151 | * @req_match: Tests if a given class request can be handled by this function. | ||
151 | * @suspend: Notifies functions when the host stops sending USB traffic. | 152 | * @suspend: Notifies functions when the host stops sending USB traffic. |
152 | * @resume: Notifies functions when the host restarts USB traffic. | 153 | * @resume: Notifies functions when the host restarts USB traffic. |
153 | * @get_status: Returns function status as a reply to | 154 | * @get_status: Returns function status as a reply to |
@@ -213,6 +214,8 @@ struct usb_function { | |||
213 | void (*disable)(struct usb_function *); | 214 | void (*disable)(struct usb_function *); |
214 | int (*setup)(struct usb_function *, | 215 | int (*setup)(struct usb_function *, |
215 | const struct usb_ctrlrequest *); | 216 | const struct usb_ctrlrequest *); |
217 | bool (*req_match)(struct usb_function *, | ||
218 | const struct usb_ctrlrequest *); | ||
216 | void (*suspend)(struct usb_function *); | 219 | void (*suspend)(struct usb_function *); |
217 | void (*resume)(struct usb_function *); | 220 | void (*resume)(struct usb_function *); |
218 | 221 | ||