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.

There is no such parameter when using configfs.

What would be the correct way to fix it?

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

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

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
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to