• Andrzej Pietrasiewicz's avatar
    usb: gadget: composite: add req_match method to usb_function · f563d230
    Andrzej Pietrasiewicz authored
    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: default avatarAndrzej Pietrasiewicz <andrzej.p@samsung.com>
    Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
    f563d230
composite.c 60.1 KB