switch (func->function_group) {
case USB_FUNCTION_GROUP_SIMPLE:
+ case USB_FUNCTION_GROUP_WITH_POST_SERVICE:
ret = usbg_lookup_function_type(func->name);
res = ret >= 0;
break;
switch (usb_func->function_group) {
case USB_FUNCTION_GROUP_SIMPLE:
+ case USB_FUNCTION_GROUP_WITH_POST_SERVICE:
type = usbg_lookup_function_type(usb_func->name);
if (strlen(usb_func->instance) >= MAX_INSTANCE_LEN)
return -ENAMETOOLONG;
goto disable_gadget;
for (i = 0; gadget->funcs[i]; ++i) {
- if (gadget->funcs[i]->function_group !=
- USB_FUNCTION_GROUP_WITH_SERVICE)
+ if (gadget->funcs[i]->function_group == USB_FUNCTION_GROUP_SIMPLE)
continue;
fws = container_of(gadget->funcs[i],
return ret;
for (i = 0; gadget->funcs[i]; ++i) {
- if (gadget->funcs[i]->function_group != USB_FUNCTION_GROUP_WITH_SERVICE)
+ if (gadget->funcs[i]->function_group == USB_FUNCTION_GROUP_SIMPLE)
continue;
fws = container_of(gadget->funcs[i], struct usb_function_with_service, func);
/* Function IDX in array is number of trailing zeros */
#define FUNC_IDX_FROM_MASK(mask) _HELPER_CTZ(mask)
+/**
+ * USB_FUNCTION_GROUP_WITH_POST_SERVICE is the same as USB_FUNCTION_GROUP_SIMPLE
+ * except running the service as a post.
+ */
typedef enum {
USB_FUNCTION_GROUP_SIMPLE,
USB_FUNCTION_GROUP_WITH_SERVICE,
+ USB_FUNCTION_GROUP_WITH_POST_SERVICE,
} usb_function_group_e;
struct usb_function {
.service = _service, \
}
-DEFINE_USB_FUNCTION_WITH_SERVICE(USB_FUNCTION_ACM, acm, "data-router");
DEFINE_USB_FUNCTION_WITH_SERVICE(USB_FUNCTION_SDB, sdb, "sdbd");
DEFINE_USB_FUNCTION_WITH_SERVICE(USB_FUNCTION_MTP, mtp, "mtp-responder");
-DEFINE_USB_FUNCTION_WITH_SERVICE(USB_FUNCTION_RNDIS, rndis, "rndis");
+
+#define DEFINE_USB_FUNCTION_WITH_POST_SERVICE(_id, _name, _service) \
+ static struct usb_function_with_service _##_name##_function = { \
+ .func = { \
+ .function_group = USB_FUNCTION_GROUP_WITH_POST_SERVICE, \
+ .id = _id, \
+ .name = #_name, \
+ .instance = "default", \
+ .clone = clone_func_with_service, \
+ .free_func = free_func_with_service, \
+ }, \
+ .service = _service, \
+ }
+
+DEFINE_USB_FUNCTION_WITH_POST_SERVICE(USB_FUNCTION_ACM, acm, "data-router");
+DEFINE_USB_FUNCTION_WITH_POST_SERVICE(USB_FUNCTION_RNDIS, rndis, "rndis");
+
#define MAKE_FUNC_AVAILABLE(_name, _vname) \
[FUNC_IDX_FROM_MASK(USB_FUNCTION_##_name)] = &_##_vname##_function