Re: [PATCHv2] usb: gadget: composite: Provide a list of available functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 10, 2014 at 12:30:59PM +0200, Andrzej Pietrasiewicz wrote:
> When gadgets are composed with configfs the user must know what are the
> available function names. The names are parts of usb_f_*.ko
> modules' aliases. If a function is compiled as a module, the information
> can be found in modules.alias file. But if a function is compiled-in,
> there is no way to know the function's name.
> 
> This patch adds a sysfs attribute in libcomposite's sys directory to
> show functions which are already registered. Functions which are
> compiled-in will be in this list as well.
> 
> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx>
> ---
> This time there should be no obvious mistakes: potential
> buffer overrun is checked and THIS_MODULE is not dereferenced at all.
> Tested with libcomposite compiled-in and modular.
> 
> v1..v2:
> - changed the location in sysfs: usb_gadget class is added
> 
>  drivers/usb/gadget/configfs.c  | 25 +++++++++++++++++++++++++
>  drivers/usb/gadget/functions.c | 25 +++++++++++++++++++++++++
>  drivers/usb/gadget/u_f.h       |  2 ++
>  3 files changed, 52 insertions(+)
> 
> diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
> index bcc2a62..358242a 100644
> --- a/drivers/usb/gadget/configfs.c
> +++ b/drivers/usb/gadget/configfs.c
> @@ -1553,13 +1553,37 @@ void unregister_gadget_item(struct config_item *item)
>  }
>  EXPORT_SYMBOL_GPL(unregister_gadget_item);
>  
> +static ssize_t gadget_func_list_show(struct class *c,
> +				     struct class_attribute *a, char *buf)
> +{
> +	return usb_function_list_functions(buf, PAGE_SIZE);
> +}
> +
> +static struct class_attribute usb_gadget_attrs[] = {
> +	__ATTR(func_list, S_IRUGO, gadget_func_list_show, NULL),
> +	__ATTR_NULL,
> +};
> +
> +static struct class usb_gadget_class = {

another class ? Please don't, we already have the udc class, we could
find a way to just use that instead.

-- 
balbi

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux