On Wed, 29 Jun 2005, matthieu castet wrote: > Hi, > > Alan Stern wrote: > > On Wed, 29 Jun 2005, matthieu castet wrote: > > > > > >>Hi, > >> > >>I am writing a driver for an usb device, and I want to support multi-device. > >>I want to allow some user configurations for the devices, so I use > >>module options and module_param_array. > >> > >>I would like to know if the device are always probed in the same order > >>if we don't plug/unplug device on the usb bus. > > > > > > The order of probing depends on several things, such as the order in which > > the host controller drivers are loaded. As long as those things don't > > change, the order of probing devices will remain the same. > > > > > >>In case I want to support plug/unplug, is there standard way to do it or > >>it is considerered as worthless/too complex ? > > > > > > A USB driver _has_ to support plug/unplug; you have no choice. Yes, > > there is a standard way to do it. Look at any of the USB drivers already > > in the kernel. > > > Sorry, I wasn't clear. > Of course, I support plug/unplug, but the configuration passed by module > options can be used by the wrong device. > > For example, in my probe I assign to the device the first free number > and I used it as index for module options. > So opt=1,2,3 will work if we don't plug/unplug the device as you said > the probe order is the same for a module. > > but if I unplug device 2, probe the devices and then plug device 3, the > configuration will be wrong as the order seen by the driver will be : > opt_device1=1, opt_device3=2, opt_device2=3 instead of opt_device1=1, > opt_device2=2, opt_device3=3. > > I have look in drivers/usb but there only 5 driver that use > module_param_array. And these drivers often increment a static device > number and fallback to 0 in case it is greater than the > module_param_array array size. But if you plug/unplug the device, after > 'module_param_array array size' only the defaut config will be used > unless you reload the module. And the configuration won't work in case > of missing device. > > That's why I was wondering if it worth to support a more complex > configuration for multi-device and if there are simple and working > implementation for that. > > > >>I was considering to use device serial number. > > > > > > Many USB devices don't have a serial number. > > > My usb device has one as it's contain its MAC adress.
I see. Yes, you should use the serial number to identify which device corresponds to which parameter value. I don't know of any examples of drivers doing that, but it should be easy enough to write. And it will be reliable, no matter what the order of probing is -- even if devices are unplugged and then replugged. Alan Stern ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ [email protected] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
