diff options
author | mochel@digitalimplant.org <mochel@digitalimplant.org> | 2005-03-24 13:50:24 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-06-20 18:15:17 -0400 |
commit | 2287c322b61fced7e0c326a1a9606aa73147e3df (patch) | |
tree | 8241c7cab4172969f38d8b55852aca2e071a494f /drivers/base/dd.c | |
parent | cb85b6f1cc811ecb9ed4b950206d8941ba710e68 (diff) |
[PATCH] Use bus_for_each_{dev,drv} for driver binding.
- Now possible, since the lists are locked using the klist lock and not the
global rwsem.
Signed-off-by: Patrick Mochel <mochel@digitalimplant.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/dd.c')
-rw-r--r-- | drivers/base/dd.c | 72 |
1 files changed, 39 insertions, 33 deletions
diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 47cbb5641235..85042ada8a5b 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c | |||
@@ -82,6 +82,28 @@ int driver_probe_device(struct device_driver * drv, struct device * dev) | |||
82 | return 0; | 82 | return 0; |
83 | } | 83 | } |
84 | 84 | ||
85 | static int __device_attach(struct device_driver * drv, void * data) | ||
86 | { | ||
87 | struct device * dev = data; | ||
88 | int error; | ||
89 | |||
90 | error = driver_probe_device(drv, dev); | ||
91 | |||
92 | if (error == -ENODEV && error == -ENXIO) { | ||
93 | /* Driver matched, but didn't support device | ||
94 | * or device not found. | ||
95 | * Not an error; keep going. | ||
96 | */ | ||
97 | error = 0; | ||
98 | } else { | ||
99 | /* driver matched but the probe failed */ | ||
100 | printk(KERN_WARNING | ||
101 | "%s: probe of %s failed with error %d\n", | ||
102 | drv->name, dev->bus_id, error); | ||
103 | } | ||
104 | return 0; | ||
105 | } | ||
106 | |||
85 | /** | 107 | /** |
86 | * device_attach - try to attach device to a driver. | 108 | * device_attach - try to attach device to a driver. |
87 | * @dev: device. | 109 | * @dev: device. |
@@ -92,30 +114,31 @@ int driver_probe_device(struct device_driver * drv, struct device * dev) | |||
92 | */ | 114 | */ |
93 | int device_attach(struct device * dev) | 115 | int device_attach(struct device * dev) |
94 | { | 116 | { |
95 | struct bus_type * bus = dev->bus; | ||
96 | struct list_head * entry; | ||
97 | int error; | ||
98 | |||
99 | if (dev->driver) { | 117 | if (dev->driver) { |
100 | device_bind_driver(dev); | 118 | device_bind_driver(dev); |
101 | return 1; | 119 | return 1; |
102 | } | 120 | } |
103 | 121 | ||
104 | if (bus->match) { | 122 | return bus_for_each_drv(dev->bus, NULL, dev, __device_attach); |
105 | list_for_each(entry, &bus->drivers.list) { | 123 | } |
106 | struct device_driver * drv = to_drv(entry); | 124 | |
107 | error = driver_probe_device(drv, dev); | 125 | static int __driver_attach(struct device * dev, void * data) |
108 | if (!error) | 126 | { |
109 | /* success, driver matched */ | 127 | struct device_driver * drv = data; |
110 | return 1; | 128 | int error = 0; |
111 | if (error != -ENODEV && error != -ENXIO) | 129 | |
130 | if (!dev->driver) { | ||
131 | error = driver_probe_device(drv, dev); | ||
132 | if (error) { | ||
133 | if (error != -ENODEV) { | ||
112 | /* driver matched but the probe failed */ | 134 | /* driver matched but the probe failed */ |
113 | printk(KERN_WARNING | 135 | printk(KERN_WARNING |
114 | "%s: probe of %s failed with error %d\n", | 136 | "%s: probe of %s failed with error %d\n", |
115 | drv->name, dev->bus_id, error); | 137 | drv->name, dev->bus_id, error); |
138 | } else | ||
139 | error = 0; | ||
116 | } | 140 | } |
117 | } | 141 | } |
118 | |||
119 | return 0; | 142 | return 0; |
120 | } | 143 | } |
121 | 144 | ||
@@ -133,24 +156,7 @@ int device_attach(struct device * dev) | |||
133 | */ | 156 | */ |
134 | void driver_attach(struct device_driver * drv) | 157 | void driver_attach(struct device_driver * drv) |
135 | { | 158 | { |
136 | struct bus_type * bus = drv->bus; | 159 | bus_for_each_dev(drv->bus, NULL, drv, __driver_attach); |
137 | struct list_head * entry; | ||
138 | int error; | ||
139 | |||
140 | if (!bus->match) | ||
141 | return; | ||
142 | |||
143 | list_for_each(entry, &bus->devices.list) { | ||
144 | struct device * dev = container_of(entry, struct device, bus_list); | ||
145 | if (!dev->driver) { | ||
146 | error = driver_probe_device(drv, dev); | ||
147 | if (error && (error != -ENODEV)) | ||
148 | /* driver matched but the probe failed */ | ||
149 | printk(KERN_WARNING | ||
150 | "%s: probe of %s failed with error %d\n", | ||
151 | drv->name, dev->bus_id, error); | ||
152 | } | ||
153 | } | ||
154 | } | 160 | } |
155 | 161 | ||
156 | /** | 162 | /** |