aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/device.h
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2007-02-16 11:33:36 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2007-04-27 13:57:28 -0400
commitb8c5cec23d5c33b767a1cddebd4f8813a9563e3c (patch)
treecffec2c5df58866aa6e7ed5540c2718a166c3246 /include/linux/device.h
parenta456b7023e0abf80bb03b0bdf5471b48878e5c49 (diff)
Driver core: udev triggered device-<>driver binding
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: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux/device.h')
-rw-r--r--include/linux/device.h34
1 files changed, 19 insertions, 15 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index de0e73eae6bc..9d54fe13eb2e 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -34,9 +34,24 @@ struct device;
34struct device_driver; 34struct device_driver;
35struct class; 35struct class;
36struct class_device; 36struct class_device;
37struct bus_type;
38
39struct bus_attribute {
40 struct attribute attr;
41 ssize_t (*show)(struct bus_type *, char * buf);
42 ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
43};
44
45#define BUS_ATTR(_name,_mode,_show,_store) \
46struct bus_attribute bus_attr_##_name = __ATTR(_name,_mode,_show,_store)
47
48extern int __must_check bus_create_file(struct bus_type *,
49 struct bus_attribute *);
50extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
37 51
38struct bus_type { 52struct bus_type {
39 const char * name; 53 const char * name;
54 struct module * owner;
40 55
41 struct subsystem subsys; 56 struct subsystem subsys;
42 struct kset drivers; 57 struct kset drivers;
@@ -49,6 +64,8 @@ struct bus_type {
49 struct bus_attribute * bus_attrs; 64 struct bus_attribute * bus_attrs;
50 struct device_attribute * dev_attrs; 65 struct device_attribute * dev_attrs;
51 struct driver_attribute * drv_attrs; 66 struct driver_attribute * drv_attrs;
67 struct bus_attribute drivers_autoprobe_attr;
68 struct bus_attribute drivers_probe_attr;
52 69
53 int (*match)(struct device * dev, struct device_driver * drv); 70 int (*match)(struct device * dev, struct device_driver * drv);
54 int (*uevent)(struct device *dev, char **envp, 71 int (*uevent)(struct device *dev, char **envp,
@@ -61,6 +78,8 @@ struct bus_type {
61 int (*suspend_late)(struct device * dev, pm_message_t state); 78 int (*suspend_late)(struct device * dev, pm_message_t state);
62 int (*resume_early)(struct device * dev); 79 int (*resume_early)(struct device * dev);
63 int (*resume)(struct device * dev); 80 int (*resume)(struct device * dev);
81
82 unsigned int drivers_autoprobe:1;
64}; 83};
65 84
66extern int __must_check bus_register(struct bus_type * bus); 85extern int __must_check bus_register(struct bus_type * bus);
@@ -102,21 +121,6 @@ extern int bus_unregister_notifier(struct bus_type *bus,
102#define BUS_NOTIFY_UNBIND_DRIVER 0x00000004 /* driver about to be 121#define BUS_NOTIFY_UNBIND_DRIVER 0x00000004 /* driver about to be
103 unbound */ 122 unbound */
104 123
105/* sysfs interface for exporting bus attributes */
106
107struct bus_attribute {
108 struct attribute attr;
109 ssize_t (*show)(struct bus_type *, char * buf);
110 ssize_t (*store)(struct bus_type *, const char * buf, size_t count);
111};
112
113#define BUS_ATTR(_name,_mode,_show,_store) \
114struct bus_attribute bus_attr_##_name = __ATTR(_name,_mode,_show,_store)
115
116extern int __must_check bus_create_file(struct bus_type *,
117 struct bus_attribute *);
118extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
119
120struct device_driver { 124struct device_driver {
121 const char * name; 125 const char * name;
122 struct bus_type * bus; 126 struct bus_type * bus;