2004-04-26 19:10:31

by Patrick J. LoPresti

[permalink] [raw]
Subject: Load hid.o module synchronously?

I am using the 2.6.5 kernel on a modular boot disk. I am finding that
invocations of "modprobe" are returning sooner than I would like.

For example, I invoke "modprobe hid" to make my USB keyboard work.
This loads the module and exits immediately, causing my script to
proceed, before the USB keyboard is probed and ready.

I want to wait until the driver is finished initializing (i.e., a USB
keyboard is either found or not found) before my script continues.
How can I do that?

I seem to be having similar problems loading certain other modules
(PCMCIA, Ethernet), but hid.o is the only one for which I have not
found a convenient workaround.

I apologize if this is a stupid question. I have spent some time
searching both the Linux source code and the linux-kernel archives to
no avail.

Thanks!

- Pat


2004-04-26 19:42:32

by Chris Friesen

[permalink] [raw]
Subject: Re: Load hid.o module synchronously?

Patrick J. LoPresti wrote:

> For example, I invoke "modprobe hid" to make my USB keyboard work.
> This loads the module and exits immediately, causing my script to
> proceed, before the USB keyboard is probed and ready.
>
> I want to wait until the driver is finished initializing (i.e., a USB
> keyboard is either found or not found) before my script continues.
> How can I do that?

How about scanning the usb device tree to see if the keyboard is present and properly detected?

Chris

2004-04-26 19:51:06

by Patrick J. LoPresti

[permalink] [raw]
Subject: Re: Load hid.o module synchronously?

Chris Friesen <[email protected]> writes:

> Patrick J. LoPresti wrote:
>
> > For example, I invoke "modprobe hid" to make my USB keyboard work.
> > This loads the module and exits immediately, causing my script to
> > proceed, before the USB keyboard is probed and ready.
> > I want to wait until the driver is finished initializing (i.e., a USB
> > keyboard is either found or not found) before my script continues.
> > How can I do that?
>
> How about scanning the usb device tree to see if the keyboard is
> present and properly detected?

You mean under sysfs or usbfs? Or both?

I see how I can scan for a USB keyboard after loading the USB host
controller module. I think. But what do I look for, exactly, to tell
when hid.o has hooked itself up to the keyboard?

- Pat

2004-04-26 20:03:36

by Chris Friesen

[permalink] [raw]
Subject: Re: Load hid.o module synchronously?

Patrick J. LoPresti wrote:

> You mean under sysfs or usbfs? Or both?

Somewhere in there...

> I see how I can scan for a USB keyboard after loading the USB host
> controller module. I think. But what do I look for, exactly, to tell
> when hid.o has hooked itself up to the keyboard?

I don't know exactly what you'd look for. Greg K-H would be the guy to ask, I think.

Chris

2004-04-26 20:21:29

by Greg KH

[permalink] [raw]
Subject: Re: Load hid.o module synchronously?

On Mon, Apr 26, 2004 at 03:50:52PM -0400, Patrick J. LoPresti wrote:
>
> I see how I can scan for a USB keyboard after loading the USB host
> controller module. I think. But what do I look for, exactly, to tell
> when hid.o has hooked itself up to the keyboard?

I can think of at least 2 different ways (there are probably more):
- look at the device in /proc/bus/usb/devices and wait until the
driver is bound to that device "(hid)" will show up as the
driver bound to that interface
- look at the sysfs directory for the hid driver and wait for
the symlink to the device shows up. This should be at
/sys/bus/usb/drivers/hid

Hope this helps,

greg k-h

2004-04-27 06:02:05

by Kim Holviala

[permalink] [raw]
Subject: Re: Load hid.o module synchronously?

On Monday 26 April 2004 22:10, Patrick J. LoPresti wrote:

> For example, I invoke "modprobe hid" to make my USB keyboard work.
> This loads the module and exits immediately, causing my script to
> proceed, before the USB keyboard is probed and ready.
>
> I want to wait until the driver is finished initializing (i.e., a USB
> keyboard is either found or not found) before my script continues.
> How can I do that?
>
> I seem to be having similar problems loading certain other modules
> (PCMCIA, Ethernet), but hid.o is the only one for which I have not
> found a convenient workaround.

Well, this isn't what you wanted to hear :-) but I use sleep on my
PCMCIA/nfsroot boot initrds. Sleeping for 3-5 seconds is enough for the
modules to load properly and it won't slow down the boot too much either...




Kim

2004-04-28 14:04:15

by Bill Davidsen

[permalink] [raw]
Subject: Re: Load hid.o module synchronously?

Patrick J. LoPresti wrote:
> Chris Friesen <[email protected]> writes:
>
>
>>Patrick J. LoPresti wrote:
>>
>>
>>>For example, I invoke "modprobe hid" to make my USB keyboard work.
>>>This loads the module and exits immediately, causing my script to
>>>proceed, before the USB keyboard is probed and ready.
>>>I want to wait until the driver is finished initializing (i.e., a USB
>>>keyboard is either found or not found) before my script continues.
>>>How can I do that?
>>
>>How about scanning the usb device tree to see if the keyboard is
>>present and properly detected?
>
>
> You mean under sysfs or usbfs? Or both?
>
> I see how I can scan for a USB keyboard after loading the USB host
> controller module. I think. But what do I look for, exactly, to tell
> when hid.o has hooked itself up to the keyboard?

You need to be able to tell "not hooked yet" from "never saw it" for
reliable operation. I don't know how to do that, sorry.

--
-bill davidsen ([email protected])
"The secret to procrastination is to put things off until the
last possible moment - but no longer" -me