Re: Viewing many gadgets in error under Windows with mass storage function and configfs

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

 



Hi,

On Thu, Jul 02, 2015 at 12:51:54PM +0200, Gregory CLEMENT wrote:
> Hello,
> 
> When I use configs to configure the mass storage function for the
> gadget, and when the device is plugged under Windows, then the
> partition that I expose is well managed, but I also see 7 other gadget
> in the device manager with error.
> 
> This seven bogus gadget seems to be the 7 other LUN that are not
> used. Indeed if I apply this dirty patch:
> 
> diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
> index 3cc109f..2b4ae98 100644
> --- a/drivers/usb/gadget/function/f_mass_storage.c
> +++ b/drivers/usb/gadget/function/f_mass_storage.c
> @@ -3511,7 +3511,8 @@ static struct usb_function_instance *fsg_alloc_inst(void)
>                 rc = PTR_ERR(opts->common);
>                 goto release_opts;
>         }
> -       rc = fsg_common_set_nluns(opts->common, FSG_MAX_LUNS);
> +//     rc = fsg_common_set_nluns(opts->common, FSG_MAX_LUNS);
> +       rc = fsg_common_set_nluns(opts->common, 1);
>         if (rc)
>                 goto release_opts;
> 
> Then there is no more gadget error under Windows. As the value of
> FSG_MAX_LUNS is 8 and in my configuration I only use one partition,
> then it makes sens that I see 7 bogus gadgets.
> 
> I also saw that in the legacy driver, it was possible to modify the
> number of LUN using the module parameter file_count.

This has been reported. Michal was working on a fix, but the patch
hasn't been applied yet.

> There is no such parameter when using configfs.
> 
> What would be the correct way to fix it?

Making sure you don't lie to the other side of the cable :-)

> I thought about enumerate how many LUN where configured through
> configfs and then setting the exact number using fsg_common_set_nluns.

yeah, that should be the way.

> There is no problem at all under Linux so maybe it is jut the way how
> the gadget is exposed through USB.

no, we shouldn't really lie, this really needs fixing.

> 
> I tested it on the kernel 3.17 and 4.1 using the musb of the SoC
> AM335x.
> 
> Thanks for your feedback.
> 
> Gregory
> 
> -- 
> Gregory Clement, Free Electrons
> Kernel, drivers, real-time and embedded Linux
> development, consulting, training and support.
> http://free-electrons.com

-- 
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