Commit efbf0af7 authored by Laurent Pinchart's avatar Laurent Pinchart
Browse files

usb: gadget: uvc: configfs: Allocate groups dynamically



The UVC configfs implementation creates all groups as global static
variables. This prevents creation of multiple UVC function instances,
as they would all require their own configfs group instances.

Fix this by allocating all groups dynamically. To avoid duplicating code
around, extend the config_item_type structure with group name and
children, and implement helper functions to create children
automatically for most groups.

Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarKieran Bingham <kieran.bingham@ideasonboard.com>
parent 86f3daed
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -792,6 +792,7 @@ static struct usb_function_instance *uvc_alloc_inst(void)
	struct uvc_output_terminal_descriptor *od;
	struct uvc_color_matching_descriptor *md;
	struct uvc_descriptor_header **ctl_cls;
	int ret;

	opts = kzalloc(sizeof(*opts), GFP_KERNEL);
	if (!opts)
@@ -868,7 +869,12 @@ static struct usb_function_instance *uvc_alloc_inst(void)
	opts->streaming_interval = 1;
	opts->streaming_maxpacket = 1024;

	uvcg_attach_configfs(opts);
	ret = uvcg_attach_configfs(opts);
	if (ret < 0) {
		kfree(opts);
		return ERR_PTR(ret);
	}

	return &opts->func_inst;
}

+331 −250

File changed.

Preview size limit exceeded, changes collapsed.