• Kay Sievers's avatar
    Driver core: udev triggered device-<>driver binding · b8c5cec2
    Kay Sievers authored
    We get two per-bus sysfs files:
      ls-l /sys/subsystem/usb
      drwxr-xr-x 2 root root    0 2007-02-16 16:42 devices
      drwxr-xr-x 7 root root    0 2007-02-16 14:55 drivers
      -rw-r--r-- 1 root root 4096 2007-02-16 16:42 drivers_autoprobe
      --w------- 1 root root 4096 2007-02-16 16:42 drivers_probe
    
    The flag "drivers_autoprobe" controls the behavior of the bus to bind
    devices by default, or just initialize the device and leave it alone.
    
    The command "drivers_probe" accepts a bus_id and the bus tries to bind a
    driver to this device.
    
    Systems who want to control the driver binding with udev, switch off the
    bus initiated probing:
      echo 0 > /sys/subsystem/usb/drivers_autoprobe
      echo 0 > /sys/subsystem/pcmcia/drivers_autoprobe
      ...
    
    and initiate the probing with udev rules like:
      ACTION=="add", SUBSYSTEM=="usb", ATTR{subsystem/drivers_probe}="$kernel"
      ACTION=="add", SUBSYSTEM=="pcmcia", ATTR{subsystem/drivers_probe}="$kernel"
      ...
    
    Custom driver binding can happen in earlier rules by something like:
      ACTION=="add", SUBSYSTEM=="usb", \
      ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678" \
      ATTR{subsystem/drivers/<custom-driver>/bind}="$kernel"
    
    This is intended to solve the modprobe.conf mess with "install-rules", custom
    bind/unbind-scripts and all the weird things people invented over the years.
    It should also provide the functionality "libusual" was supposed to do.
    
    With udev, one can just write a udev rule to drive all USB-disks at the
    third port of USB-hub by the "ub" driver, and everything else by
    usb-storage. One can also instruct udev to bind different wireless
    drivers to identical cards - just selected by the pcmcia slot-number, and
    whatever ...
    
    To use the mentioned rules, it needs udev version 106, to be able to
    write ATTR{}="$kernel" to sysfs files.
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
    b8c5cec2
bus.c 21.4 KB