All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kay Sievers <kay.sievers@vrfy.org>
To: linux-hotplug@vger.kernel.org
Subject: Re: USB driver assignment with udev
Date: Thu, 12 Mar 2009 23:59:29 +0000	[thread overview]
Message-ID: <ac3eb2510903121659xef74dd5vb4d40f9ed5e71b17@mail.gmail.com> (raw)
In-Reply-To: <loom.20090311T231825-449@post.gmane.org>

On Fri, Mar 13, 2009 at 00:01, Steve Calfee <nospamcalfee@yahoo.com> wrote:
> Kay Sievers <kay.sievers <at> vrfy.org> writes:
>> You can use udev rules to unbind a driver, and rebind a different one
>> to a specific device.
>>
>> Or you can disable kernel-driver-autobinding per bus, and let udev do
>> all the driver binding for this bus. A default rule would trigger the
>> in-kernel driver binding, and any custom rule added before that, could
>> bind a specific driver to a specific device. What's not covered with
>> disabled in-kernel driver binding is the device scanning at the time
>> of loading of a module, which would need to be implemented.
>>
>> Both setups should work. We did not see a lot of interest in offering
>> any solution like that. We added:
>> /sys/bus/*/{drivers_autoprobe,drivers_probe} long ago, because we
>> thought it might be useful, but it's never got really used so far, and
>> the missing pieces never got added to the kernel and udev.

> I tried your suggestion about manually binding and unbinding. That sort of
> works, but I would like to avoid the handling by the first module until udev can
> switch it out.
>
> So I have been trying this manually. Turning off drivers_autoprobe sounded like
> a good idea, the problem is that device id for a newly plugged in device is not
> fully formed. IE usually in sys/.../1-1/1-1:1.0 the 1-1:1.0 is the number used
> to bind and unbind a device, but the 1.0 which I guess is
> configuration.interface does not appear in the /sys/..../1-1/ device directory.
> So the bind fails because there is no proper device yet.

Oh, you will not need to know a device name in advance. You can just
hook into the event for "1-1" and trigger the binding with that name,
and the "1-1:1:0" will show up. If you disable autobinding, the
"usb_device" will need to be attached manually to the "usb" driver,
which will create the "usb_interface" devices.

In the events for the "usb_interface", which are the ones you are
interested in, you can plug your custom rules, which would look like
this for a device with vendor "1234", and a driver named "foo":
  ACTION="add", SUBSYSTEM="usb", \
     ENV{DEVTYPE}="usb_interface", \
     ATTRS{idVendor}="1234", ATTR{[drivers/usb:foo]bind}="$kernel"

And then you fall-back to a "default" rule, which will do what the
kernel does today, and which will also cover the interface creation.
It would look like:
  ACTION="add", SUBSYSTEM="usb", \
    ATTR{[subsystem/usb]drivers_probe}="$kernel"

As pointed out in the earlier mail, the missing piece is the case you
load a module later, and want to scan for devices which might be
interesting for the newly added driver. This is not covered at all and
will do nothing today with disabled autobinding.

Kay

      parent reply	other threads:[~2009-03-12 23:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-11 23:20 USB driver assignment with udev Steve Calfee
2009-03-11 23:37 ` Greg KH
2009-03-12  0:32 ` Steve Calfee
2009-03-12  0:35 ` Kay Sievers
2009-03-12  2:01 ` Greg KH
2009-03-12 10:21 ` Scott James Remnant
2009-03-12 23:01 ` Steve Calfee
2009-03-12 23:59 ` Kay Sievers [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ac3eb2510903121659xef74dd5vb4d40f9ed5e71b17@mail.gmail.com \
    --to=kay.sievers@vrfy.org \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.