Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: composite: add bind_deactivated flag to usb_function

This patch introduces 'bind_deactivated' flag in struct usb_function.
Functions which don't want to be activated automatically after bind should
set this flag, and when they start to be ready to work they should call
usb_function_activate().

When USB function sets 'bind_deactivated' flag, initial deactivation
counter is incremented automatically, so there is no need to call
usb_function_deactivate() in function bind.

Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>

authored by

Robert Baldyga and committed by
Felipe Balbi
d5bb9b81 5601250b

+8
+6
drivers/usb/gadget/composite.c
··· 209 209 function->config = config; 210 210 list_add_tail(&function->list, &config->functions); 211 211 212 + if (function->bind_deactivated) { 213 + value = usb_function_deactivate(function); 214 + if (value) 215 + goto done; 216 + } 217 + 212 218 /* REVISIT *require* function->bind? */ 213 219 if (function->bind) { 214 220 value = function->bind(config, function);
+2
include/linux/usb/composite.h
··· 228 228 struct list_head list; 229 229 DECLARE_BITMAP(endpoints, 32); 230 230 const struct usb_function_instance *fi; 231 + 232 + unsigned int bind_deactivated:1; 231 233 }; 232 234 233 235 int usb_add_function(struct usb_configuration *, struct usb_function *);