aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/driver.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2008-01-25 01:50:12 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-01-25 01:50:12 -0500
commit4a3ad20ccd8f4d2a0535cf98fa83f7b561ba59a9 (patch)
tree8d0d147716466801b859a777472246ee5563f64b /drivers/base/driver.c
parente374a2bfebf359f846216336de91670be40499da (diff)
Driver core: coding style fixes
Fix up a number of coding style issues in the drivers/base/ directory that have annoyed me over the years. checkpatch.pl is now very happy. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/driver.c')
-rw-r--r--drivers/base/driver.c120
1 files changed, 55 insertions, 65 deletions
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 94b697a9b4e0..a35f04121a00 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -19,27 +19,26 @@
19#define to_dev(node) container_of(node, struct device, driver_list) 19#define to_dev(node) container_of(node, struct device, driver_list)
20 20
21 21
22static struct device * next_device(struct klist_iter * i) 22static struct device *next_device(struct klist_iter *i)
23{ 23{
24 struct klist_node * n = klist_next(i); 24 struct klist_node *n = klist_next(i);
25 return n ? container_of(n, struct device, knode_driver) : NULL; 25 return n ? container_of(n, struct device, knode_driver) : NULL;
26} 26}
27 27
28/** 28/**
29 * driver_for_each_device - Iterator for devices bound to a driver. 29 * driver_for_each_device - Iterator for devices bound to a driver.
30 * @drv: Driver we're iterating. 30 * @drv: Driver we're iterating.
31 * @start: Device to begin with 31 * @start: Device to begin with
32 * @data: Data to pass to the callback. 32 * @data: Data to pass to the callback.
33 * @fn: Function to call for each device. 33 * @fn: Function to call for each device.
34 * 34 *
35 * Iterate over the @drv's list of devices calling @fn for each one. 35 * Iterate over the @drv's list of devices calling @fn for each one.
36 */ 36 */
37 37int driver_for_each_device(struct device_driver *drv, struct device *start,
38int driver_for_each_device(struct device_driver * drv, struct device * start, 38 void *data, int (*fn)(struct device *, void *))
39 void * data, int (*fn)(struct device *, void *))
40{ 39{
41 struct klist_iter i; 40 struct klist_iter i;
42 struct device * dev; 41 struct device *dev;
43 int error = 0; 42 int error = 0;
44 43
45 if (!drv) 44 if (!drv)
@@ -52,10 +51,8 @@ int driver_for_each_device(struct device_driver * drv, struct device * start,
52 klist_iter_exit(&i); 51 klist_iter_exit(&i);
53 return error; 52 return error;
54} 53}
55
56EXPORT_SYMBOL_GPL(driver_for_each_device); 54EXPORT_SYMBOL_GPL(driver_for_each_device);
57 55
58
59/** 56/**
60 * driver_find_device - device iterator for locating a particular device. 57 * driver_find_device - device iterator for locating a particular device.
61 * @drv: The device's driver 58 * @drv: The device's driver
@@ -71,9 +68,9 @@ EXPORT_SYMBOL_GPL(driver_for_each_device);
71 * if it does. If the callback returns non-zero, this function will 68 * if it does. If the callback returns non-zero, this function will
72 * return to the caller and not iterate over any more devices. 69 * return to the caller and not iterate over any more devices.
73 */ 70 */
74struct device * driver_find_device(struct device_driver *drv, 71struct device *driver_find_device(struct device_driver *drv,
75 struct device * start, void * data, 72 struct device *start, void *data,
76 int (*match)(struct device *, void *)) 73 int (*match)(struct device *dev, void *data))
77{ 74{
78 struct klist_iter i; 75 struct klist_iter i;
79 struct device *dev; 76 struct device *dev;
@@ -92,12 +89,12 @@ struct device * driver_find_device(struct device_driver *drv,
92EXPORT_SYMBOL_GPL(driver_find_device); 89EXPORT_SYMBOL_GPL(driver_find_device);
93 90
94/** 91/**
95 * driver_create_file - create sysfs file for driver. 92 * driver_create_file - create sysfs file for driver.
96 * @drv: driver. 93 * @drv: driver.
97 * @attr: driver attribute descriptor. 94 * @attr: driver attribute descriptor.
98 */ 95 */
99 96int driver_create_file(struct device_driver *drv,
100int driver_create_file(struct device_driver * drv, struct driver_attribute * attr) 97 struct driver_attribute *attr)
101{ 98{
102 int error; 99 int error;
103 if (get_driver(drv)) { 100 if (get_driver(drv)) {
@@ -107,22 +104,22 @@ int driver_create_file(struct device_driver * drv, struct driver_attribute * att
107 error = -EINVAL; 104 error = -EINVAL;
108 return error; 105 return error;
109} 106}
110 107EXPORT_SYMBOL_GPL(driver_create_file);
111 108
112/** 109/**
113 * driver_remove_file - remove sysfs file for driver. 110 * driver_remove_file - remove sysfs file for driver.
114 * @drv: driver. 111 * @drv: driver.
115 * @attr: driver attribute descriptor. 112 * @attr: driver attribute descriptor.
116 */ 113 */
117 114void driver_remove_file(struct device_driver *drv,
118void driver_remove_file(struct device_driver * drv, struct driver_attribute * attr) 115 struct driver_attribute *attr)
119{ 116{
120 if (get_driver(drv)) { 117 if (get_driver(drv)) {
121 sysfs_remove_file(&drv->p->kobj, &attr->attr); 118 sysfs_remove_file(&drv->p->kobj, &attr->attr);
122 put_driver(drv); 119 put_driver(drv);
123 } 120 }
124} 121}
125 122EXPORT_SYMBOL_GPL(driver_remove_file);
126 123
127/** 124/**
128 * driver_add_kobj - add a kobject below the specified driver 125 * driver_add_kobj - add a kobject below the specified driver
@@ -149,10 +146,10 @@ int driver_add_kobj(struct device_driver *drv, struct kobject *kobj,
149EXPORT_SYMBOL_GPL(driver_add_kobj); 146EXPORT_SYMBOL_GPL(driver_add_kobj);
150 147
151/** 148/**
152 * get_driver - increment driver reference count. 149 * get_driver - increment driver reference count.
153 * @drv: driver. 150 * @drv: driver.
154 */ 151 */
155struct device_driver * get_driver(struct device_driver * drv) 152struct device_driver *get_driver(struct device_driver *drv)
156{ 153{
157 if (drv) { 154 if (drv) {
158 struct driver_private *priv; 155 struct driver_private *priv;
@@ -164,16 +161,17 @@ struct device_driver * get_driver(struct device_driver * drv)
164 } 161 }
165 return NULL; 162 return NULL;
166} 163}
167 164EXPORT_SYMBOL_GPL(get_driver);
168 165
169/** 166/**
170 * put_driver - decrement driver's refcount. 167 * put_driver - decrement driver's refcount.
171 * @drv: driver. 168 * @drv: driver.
172 */ 169 */
173void put_driver(struct device_driver * drv) 170void put_driver(struct device_driver *drv)
174{ 171{
175 kobject_put(&drv->p->kobj); 172 kobject_put(&drv->p->kobj);
176} 173}
174EXPORT_SYMBOL_GPL(put_driver);
177 175
178static int driver_add_groups(struct device_driver *drv, 176static int driver_add_groups(struct device_driver *drv,
179 struct attribute_group **groups) 177 struct attribute_group **groups)
@@ -205,24 +203,23 @@ static void driver_remove_groups(struct device_driver *drv,
205 sysfs_remove_group(&drv->p->kobj, groups[i]); 203 sysfs_remove_group(&drv->p->kobj, groups[i]);
206} 204}
207 205
208
209/** 206/**
210 * driver_register - register driver with bus 207 * driver_register - register driver with bus
211 * @drv: driver to register 208 * @drv: driver to register
212 * 209 *
213 * We pass off most of the work to the bus_add_driver() call, 210 * We pass off most of the work to the bus_add_driver() call,
214 * since most of the things we have to do deal with the bus 211 * since most of the things we have to do deal with the bus
215 * structures. 212 * structures.
216 */ 213 */
217int driver_register(struct device_driver * drv) 214int driver_register(struct device_driver *drv)
218{ 215{
219 int ret; 216 int ret;
220 217
221 if ((drv->bus->probe && drv->probe) || 218 if ((drv->bus->probe && drv->probe) ||
222 (drv->bus->remove && drv->remove) || 219 (drv->bus->remove && drv->remove) ||
223 (drv->bus->shutdown && drv->shutdown)) { 220 (drv->bus->shutdown && drv->shutdown))
224 printk(KERN_WARNING "Driver '%s' needs updating - please use bus_type methods\n", drv->name); 221 printk(KERN_WARNING "Driver '%s' needs updating - please use "
225 } 222 "bus_type methods\n", drv->name);
226 ret = bus_add_driver(drv); 223 ret = bus_add_driver(drv);
227 if (ret) 224 if (ret)
228 return ret; 225 return ret;
@@ -231,29 +228,30 @@ int driver_register(struct device_driver * drv)
231 bus_remove_driver(drv); 228 bus_remove_driver(drv);
232 return ret; 229 return ret;
233} 230}
231EXPORT_SYMBOL_GPL(driver_register);
234 232
235/** 233/**
236 * driver_unregister - remove driver from system. 234 * driver_unregister - remove driver from system.
237 * @drv: driver. 235 * @drv: driver.
238 * 236 *
239 * Again, we pass off most of the work to the bus-level call. 237 * Again, we pass off most of the work to the bus-level call.
240 */ 238 */
241 239void driver_unregister(struct device_driver *drv)
242void driver_unregister(struct device_driver * drv)
243{ 240{
244 driver_remove_groups(drv, drv->groups); 241 driver_remove_groups(drv, drv->groups);
245 bus_remove_driver(drv); 242 bus_remove_driver(drv);
246} 243}
244EXPORT_SYMBOL_GPL(driver_unregister);
247 245
248/** 246/**
249 * driver_find - locate driver on a bus by its name. 247 * driver_find - locate driver on a bus by its name.
250 * @name: name of the driver. 248 * @name: name of the driver.
251 * @bus: bus to scan for the driver. 249 * @bus: bus to scan for the driver.
252 * 250 *
253 * Call kset_find_obj() to iterate over list of drivers on 251 * Call kset_find_obj() to iterate over list of drivers on
254 * a bus to find driver by name. Return driver if found. 252 * a bus to find driver by name. Return driver if found.
255 * 253 *
256 * Note that kset_find_obj increments driver's reference count. 254 * Note that kset_find_obj increments driver's reference count.
257 */ 255 */
258struct device_driver *driver_find(const char *name, struct bus_type *bus) 256struct device_driver *driver_find(const char *name, struct bus_type *bus)
259{ 257{
@@ -266,12 +264,4 @@ struct device_driver *driver_find(const char *name, struct bus_type *bus)
266 } 264 }
267 return NULL; 265 return NULL;
268} 266}
269
270EXPORT_SYMBOL_GPL(driver_register);
271EXPORT_SYMBOL_GPL(driver_unregister);
272EXPORT_SYMBOL_GPL(get_driver);
273EXPORT_SYMBOL_GPL(put_driver);
274EXPORT_SYMBOL_GPL(driver_find); 267EXPORT_SYMBOL_GPL(driver_find);
275
276EXPORT_SYMBOL_GPL(driver_create_file);
277EXPORT_SYMBOL_GPL(driver_remove_file);