Re: Provide information: All connected USB devices are enumerated at boot time

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

 



On Thu, Oct 15, 2015 at 05:23:21PM +0200, Stefan Reichör wrote:
> Alan Stern wrote:
> 
> > On Thu, 15 Oct 2015, Stefan Reichör wrote:
> >
> >> Hi there,
> >> 
> >> I am currently working on a problem that I need to know when all
> >> connected USB devices are enumerated when the system starts up.
> >> 
> >> The problem is the following:
> >> * After the kernel finished booting, some hardware testing is performed
> >> * This hardware testing involves various USB devices (e.g.: USB memory
> >>   stick, USB touch controllers, etc.)
> >> * The problem is that some USB devices appear after the test program has started
> >> 
> >> I could add a delay before the test is started. However the test should
> >> work on a broad range of platforms with different USB devices. Therefore
> >> it is difficult to find an optimal timeout value.
> >> 
> >> The desired solution is to wait on the enumeration of the connected USB
> >> devices and start the test program.
> >> 
> >> I found the following thread:
> >>   http://thread.gmane.org/gmane.linux.kernel/825135
> >> 
> >> In concrete: http://article.gmane.org/gmane.linux.kernel/826216
> >> ,----
> >> | From: Alan Stern <stern <at> rowland.harvard.edu>
> >> | Subject: Re: Wait for console to become available, v3.2
> >> | Newsgroups: gmane.linux.kernel.embedded, gmane.linux.kernel, gmane.linux.usb.general
> >> | Date: 2009-04-22 21:24:18 GMT (6 years, 25 weeks, 4 hours and 54 minutes ago)
> >> | On Wed, 22 Apr 2009, Alan Cox wrote:
> >> | 
> >> | > > 2.	All devices have been probed
> >> | > > If we exit for reason 2, it means that no such device is present,
> >> | > > and we go on to the do the appropriate thing for that device class.
> >> | > 
> >> | > USB has no notion of #2 really
> >> | 
> >> | That's true, it doesn't.  But it _does_ rather have a notion of "all 
> >> | devices that were present at boot time have been probed".  That should 
> >> | be good enough.
> >> | 
> >> | Alan Stern
> >> `----
> >> 
> >> So my question is whether the "all devices that were present at boot time have been probed"
> >> is already available in the current kernel sources.
> >
> > It isn't.  Nobody ever thought it was important enough to implement.
> >
> >> If it is not yet available: Is drivers/usb/core/hub.c the correct
> >> location to start the implementation of such a feature?
> >
> > It is the right place to implement "all devices attached to a 
> > particular hub have been probed".  But you're asking for more than 
> > that, because you also have to keep track of all the hubs that were 
> > present at boot time.  You also have to worry about all USB host 
> > controllers, which are detected outside of the USB stack.
> 
> Thanks for your fast response.
> 
> My idea is now to have a fixed and known set of USB hubs.
> This should be doable with my hardware configurations.
> 
> Each of these hubs provide the information that "all devices attached to
> this hub have been probed".
> 
> The test program waits for this information to be delivered from all known USB hubs.
> Then it starts with the tests.
> 
> Would you be so kind and give a short idea where to put the code in
> drivers/usb/core/hub.c that emits this information for me?
> 
> Would this kind of patch be useful for the mainline kernel?

You can do this all today in userspace, no need for any kernel changes.
Just link to libudev and register for all USB device events and then
start your test code up when you feel that you have seen all of the
devices you need/want to see.

hope this helps,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



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

  Powered by Linux