diff options
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/base.h | 14 | ||||
-rw-r--r-- | drivers/base/bus.c | 290 | ||||
-rw-r--r-- | drivers/base/class.c | 140 | ||||
-rw-r--r-- | drivers/base/core.c | 203 | ||||
-rw-r--r-- | drivers/base/dd.c | 119 | ||||
-rw-r--r-- | drivers/base/driver.c | 120 | ||||
-rw-r--r-- | drivers/base/init.c | 9 | ||||
-rw-r--r-- | drivers/base/platform.c | 233 |
8 files changed, 545 insertions, 583 deletions
diff --git a/drivers/base/base.h b/drivers/base/base.h index f7ad65a249cb..c0444146c09a 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h | |||
@@ -50,15 +50,15 @@ extern int platform_bus_init(void); | |||
50 | extern int system_bus_init(void); | 50 | extern int system_bus_init(void); |
51 | extern int cpu_dev_init(void); | 51 | extern int cpu_dev_init(void); |
52 | 52 | ||
53 | extern int bus_add_device(struct device * dev); | 53 | extern int bus_add_device(struct device *dev); |
54 | extern void bus_attach_device(struct device * dev); | 54 | extern void bus_attach_device(struct device *dev); |
55 | extern void bus_remove_device(struct device * dev); | 55 | extern void bus_remove_device(struct device *dev); |
56 | 56 | ||
57 | extern int bus_add_driver(struct device_driver *); | 57 | extern int bus_add_driver(struct device_driver *drv); |
58 | extern void bus_remove_driver(struct device_driver *); | 58 | extern void bus_remove_driver(struct device_driver *drv); |
59 | 59 | ||
60 | extern void driver_detach(struct device_driver * drv); | 60 | extern void driver_detach(struct device_driver *drv); |
61 | extern int driver_probe_device(struct device_driver *, struct device *); | 61 | extern int driver_probe_device(struct device_driver *drv, struct device *dev); |
62 | 62 | ||
63 | extern void sysdev_shutdown(void); | 63 | extern void sysdev_shutdown(void); |
64 | extern int sysdev_suspend(pm_message_t state); | 64 | extern int sysdev_suspend(pm_message_t state); |
diff --git a/drivers/base/bus.c b/drivers/base/bus.c index a377b65ba328..f484495b2ad1 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c | |||
@@ -46,10 +46,10 @@ static void bus_put(struct bus_type *bus) | |||
46 | kset_put(&bus->p->subsys); | 46 | kset_put(&bus->p->subsys); |
47 | } | 47 | } |
48 | 48 | ||
49 | static ssize_t | 49 | static ssize_t drv_attr_show(struct kobject *kobj, struct attribute *attr, |
50 | drv_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) | 50 | char *buf) |
51 | { | 51 | { |
52 | struct driver_attribute * drv_attr = to_drv_attr(attr); | 52 | struct driver_attribute *drv_attr = to_drv_attr(attr); |
53 | struct driver_private *drv_priv = to_driver(kobj); | 53 | struct driver_private *drv_priv = to_driver(kobj); |
54 | ssize_t ret = -EIO; | 54 | ssize_t ret = -EIO; |
55 | 55 | ||
@@ -58,11 +58,10 @@ drv_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) | |||
58 | return ret; | 58 | return ret; |
59 | } | 59 | } |
60 | 60 | ||
61 | static ssize_t | 61 | static ssize_t drv_attr_store(struct kobject *kobj, struct attribute *attr, |
62 | drv_attr_store(struct kobject * kobj, struct attribute * attr, | 62 | const char *buf, size_t count) |
63 | const char * buf, size_t count) | ||
64 | { | 63 | { |
65 | struct driver_attribute * drv_attr = to_drv_attr(attr); | 64 | struct driver_attribute *drv_attr = to_drv_attr(attr); |
66 | struct driver_private *drv_priv = to_driver(kobj); | 65 | struct driver_private *drv_priv = to_driver(kobj); |
67 | ssize_t ret = -EIO; | 66 | ssize_t ret = -EIO; |
68 | 67 | ||
@@ -89,16 +88,13 @@ static struct kobj_type driver_ktype = { | |||
89 | .release = driver_release, | 88 | .release = driver_release, |
90 | }; | 89 | }; |
91 | 90 | ||
92 | |||
93 | /* | 91 | /* |
94 | * sysfs bindings for buses | 92 | * sysfs bindings for buses |
95 | */ | 93 | */ |
96 | 94 | static ssize_t bus_attr_show(struct kobject *kobj, struct attribute *attr, | |
97 | 95 | char *buf) | |
98 | static ssize_t | ||
99 | bus_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) | ||
100 | { | 96 | { |
101 | struct bus_attribute * bus_attr = to_bus_attr(attr); | 97 | struct bus_attribute *bus_attr = to_bus_attr(attr); |
102 | struct bus_type_private *bus_priv = to_bus(kobj); | 98 | struct bus_type_private *bus_priv = to_bus(kobj); |
103 | ssize_t ret = 0; | 99 | ssize_t ret = 0; |
104 | 100 | ||
@@ -107,11 +103,10 @@ bus_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) | |||
107 | return ret; | 103 | return ret; |
108 | } | 104 | } |
109 | 105 | ||
110 | static ssize_t | 106 | static ssize_t bus_attr_store(struct kobject *kobj, struct attribute *attr, |
111 | bus_attr_store(struct kobject * kobj, struct attribute * attr, | 107 | const char *buf, size_t count) |
112 | const char * buf, size_t count) | ||
113 | { | 108 | { |
114 | struct bus_attribute * bus_attr = to_bus_attr(attr); | 109 | struct bus_attribute *bus_attr = to_bus_attr(attr); |
115 | struct bus_type_private *bus_priv = to_bus(kobj); | 110 | struct bus_type_private *bus_priv = to_bus(kobj); |
116 | ssize_t ret = 0; | 111 | ssize_t ret = 0; |
117 | 112 | ||
@@ -125,7 +120,7 @@ static struct sysfs_ops bus_sysfs_ops = { | |||
125 | .store = bus_attr_store, | 120 | .store = bus_attr_store, |
126 | }; | 121 | }; |
127 | 122 | ||
128 | int bus_create_file(struct bus_type * bus, struct bus_attribute * attr) | 123 | int bus_create_file(struct bus_type *bus, struct bus_attribute *attr) |
129 | { | 124 | { |
130 | int error; | 125 | int error; |
131 | if (bus_get(bus)) { | 126 | if (bus_get(bus)) { |
@@ -135,14 +130,16 @@ int bus_create_file(struct bus_type * bus, struct bus_attribute * attr) | |||
135 | error = -EINVAL; | 130 | error = -EINVAL; |
136 | return error; | 131 | return error; |
137 | } | 132 | } |
133 | EXPORT_SYMBOL_GPL(bus_create_file); | ||
138 | 134 | ||
139 | void bus_remove_file(struct bus_type * bus, struct bus_attribute * attr) | 135 | void bus_remove_file(struct bus_type *bus, struct bus_attribute *attr) |
140 | { | 136 | { |
141 | if (bus_get(bus)) { | 137 | if (bus_get(bus)) { |
142 | sysfs_remove_file(&bus->p->subsys.kobj, &attr->attr); | 138 | sysfs_remove_file(&bus->p->subsys.kobj, &attr->attr); |
143 | bus_put(bus); | 139 | bus_put(bus); |
144 | } | 140 | } |
145 | } | 141 | } |
142 | EXPORT_SYMBOL_GPL(bus_remove_file); | ||
146 | 143 | ||
147 | static struct kobj_type bus_ktype = { | 144 | static struct kobj_type bus_ktype = { |
148 | .sysfs_ops = &bus_sysfs_ops, | 145 | .sysfs_ops = &bus_sysfs_ops, |
@@ -219,10 +216,13 @@ static ssize_t driver_bind(struct device_driver *drv, | |||
219 | if (dev->parent) | 216 | if (dev->parent) |
220 | up(&dev->parent->sem); | 217 | up(&dev->parent->sem); |
221 | 218 | ||
222 | if (err > 0) /* success */ | 219 | if (err > 0) { |
220 | /* success */ | ||
223 | err = count; | 221 | err = count; |
224 | else if (err == 0) /* driver didn't accept device */ | 222 | } else if (err == 0) { |
223 | /* driver didn't accept device */ | ||
225 | err = -ENODEV; | 224 | err = -ENODEV; |
225 | } | ||
226 | } | 226 | } |
227 | put_device(dev); | 227 | put_device(dev); |
228 | bus_put(bus); | 228 | bus_put(bus); |
@@ -259,37 +259,36 @@ static ssize_t store_drivers_probe(struct bus_type *bus, | |||
259 | } | 259 | } |
260 | #endif | 260 | #endif |
261 | 261 | ||
262 | static struct device * next_device(struct klist_iter * i) | 262 | static struct device *next_device(struct klist_iter *i) |
263 | { | 263 | { |
264 | struct klist_node * n = klist_next(i); | 264 | struct klist_node *n = klist_next(i); |
265 | return n ? container_of(n, struct device, knode_bus) : NULL; | 265 | return n ? container_of(n, struct device, knode_bus) : NULL; |
266 | } | 266 | } |
267 | 267 | ||
268 | /** | 268 | /** |
269 | * bus_for_each_dev - device iterator. | 269 | * bus_for_each_dev - device iterator. |
270 | * @bus: bus type. | 270 | * @bus: bus type. |
271 | * @start: device to start iterating from. | 271 | * @start: device to start iterating from. |
272 | * @data: data for the callback. | 272 | * @data: data for the callback. |
273 | * @fn: function to be called for each device. | 273 | * @fn: function to be called for each device. |
274 | * | 274 | * |
275 | * Iterate over @bus's list of devices, and call @fn for each, | 275 | * Iterate over @bus's list of devices, and call @fn for each, |
276 | * passing it @data. If @start is not NULL, we use that device to | 276 | * passing it @data. If @start is not NULL, we use that device to |
277 | * begin iterating from. | 277 | * begin iterating from. |
278 | * | 278 | * |
279 | * We check the return of @fn each time. If it returns anything | 279 | * We check the return of @fn each time. If it returns anything |
280 | * other than 0, we break out and return that value. | 280 | * other than 0, we break out and return that value. |
281 | * | 281 | * |
282 | * NOTE: The device that returns a non-zero value is not retained | 282 | * NOTE: The device that returns a non-zero value is not retained |
283 | * in any way, nor is its refcount incremented. If the caller needs | 283 | * in any way, nor is its refcount incremented. If the caller needs |
284 | * to retain this data, it should do, and increment the reference | 284 | * to retain this data, it should do, and increment the reference |
285 | * count in the supplied callback. | 285 | * count in the supplied callback. |
286 | */ | 286 | */ |
287 | 287 | int bus_for_each_dev(struct bus_type *bus, struct device *start, | |
288 | int bus_for_each_dev(struct bus_type * bus, struct device * start, | 288 | void *data, int (*fn)(struct device *, void *)) |
289 | void * data, int (*fn)(struct device *, void *)) | ||
290 | { | 289 | { |
291 | struct klist_iter i; | 290 | struct klist_iter i; |
292 | struct device * dev; | 291 | struct device *dev; |
293 | int error = 0; | 292 | int error = 0; |
294 | 293 | ||
295 | if (!bus) | 294 | if (!bus) |
@@ -302,6 +301,7 @@ int bus_for_each_dev(struct bus_type * bus, struct device * start, | |||
302 | klist_iter_exit(&i); | 301 | klist_iter_exit(&i); |
303 | return error; | 302 | return error; |
304 | } | 303 | } |
304 | EXPORT_SYMBOL_GPL(bus_for_each_dev); | ||
305 | 305 | ||
306 | /** | 306 | /** |
307 | * bus_find_device - device iterator for locating a particular device. | 307 | * bus_find_device - device iterator for locating a particular device. |
@@ -318,9 +318,9 @@ int bus_for_each_dev(struct bus_type * bus, struct device * start, | |||
318 | * if it does. If the callback returns non-zero, this function will | 318 | * if it does. If the callback returns non-zero, this function will |
319 | * return to the caller and not iterate over any more devices. | 319 | * return to the caller and not iterate over any more devices. |
320 | */ | 320 | */ |
321 | struct device * bus_find_device(struct bus_type *bus, | 321 | struct device *bus_find_device(struct bus_type *bus, |
322 | struct device *start, void *data, | 322 | struct device *start, void *data, |
323 | int (*match)(struct device *, void *)) | 323 | int (*match)(struct device *dev, void *data)) |
324 | { | 324 | { |
325 | struct klist_iter i; | 325 | struct klist_iter i; |
326 | struct device *dev; | 326 | struct device *dev; |
@@ -336,11 +336,11 @@ struct device * bus_find_device(struct bus_type *bus, | |||
336 | klist_iter_exit(&i); | 336 | klist_iter_exit(&i); |
337 | return dev; | 337 | return dev; |
338 | } | 338 | } |
339 | EXPORT_SYMBOL_GPL(bus_find_device); | ||
339 | 340 | ||
340 | 341 | static struct device_driver *next_driver(struct klist_iter *i) | |
341 | static struct device_driver * next_driver(struct klist_iter * i) | ||
342 | { | 342 | { |
343 | struct klist_node * n = klist_next(i); | 343 | struct klist_node *n = klist_next(i); |
344 | struct driver_private *drv_priv; | 344 | struct driver_private *drv_priv; |
345 | 345 | ||
346 | if (n) { | 346 | if (n) { |
@@ -351,30 +351,29 @@ static struct device_driver * next_driver(struct klist_iter * i) | |||
351 | } | 351 | } |
352 | 352 | ||
353 | /** | 353 | /** |
354 | * bus_for_each_drv - driver iterator | 354 | * bus_for_each_drv - driver iterator |
355 | * @bus: bus we're dealing with. | 355 | * @bus: bus we're dealing with. |
356 | * @start: driver to start iterating on. | 356 | * @start: driver to start iterating on. |
357 | * @data: data to pass to the callback. | 357 | * @data: data to pass to the callback. |
358 | * @fn: function to call for each driver. | 358 | * @fn: function to call for each driver. |
359 | * | 359 | * |
360 | * This is nearly identical to the device iterator above. | 360 | * This is nearly identical to the device iterator above. |
361 | * We iterate over each driver that belongs to @bus, and call | 361 | * We iterate over each driver that belongs to @bus, and call |
362 | * @fn for each. If @fn returns anything but 0, we break out | 362 | * @fn for each. If @fn returns anything but 0, we break out |
363 | * and return it. If @start is not NULL, we use it as the head | 363 | * and return it. If @start is not NULL, we use it as the head |
364 | * of the list. | 364 | * of the list. |
365 | * | 365 | * |
366 | * NOTE: we don't return the driver that returns a non-zero | 366 | * NOTE: we don't return the driver that returns a non-zero |
367 | * value, nor do we leave the reference count incremented for that | 367 | * value, nor do we leave the reference count incremented for that |
368 | * driver. If the caller needs to know that info, it must set it | 368 | * driver. If the caller needs to know that info, it must set it |
369 | * in the callback. It must also be sure to increment the refcount | 369 | * in the callback. It must also be sure to increment the refcount |
370 | * so it doesn't disappear before returning to the caller. | 370 | * so it doesn't disappear before returning to the caller. |
371 | */ | 371 | */ |
372 | 372 | int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, | |
373 | int bus_for_each_drv(struct bus_type * bus, struct device_driver * start, | 373 | void *data, int (*fn)(struct device_driver *, void *)) |
374 | void * data, int (*fn)(struct device_driver *, void *)) | ||
375 | { | 374 | { |
376 | struct klist_iter i; | 375 | struct klist_iter i; |
377 | struct device_driver * drv; | 376 | struct device_driver *drv; |
378 | int error = 0; | 377 | int error = 0; |
379 | 378 | ||
380 | if (!bus) | 379 | if (!bus) |
@@ -387,6 +386,7 @@ int bus_for_each_drv(struct bus_type * bus, struct device_driver * start, | |||
387 | klist_iter_exit(&i); | 386 | klist_iter_exit(&i); |
388 | return error; | 387 | return error; |
389 | } | 388 | } |
389 | EXPORT_SYMBOL_GPL(bus_for_each_drv); | ||
390 | 390 | ||
391 | static int device_add_attrs(struct bus_type *bus, struct device *dev) | 391 | static int device_add_attrs(struct bus_type *bus, struct device *dev) |
392 | { | 392 | { |
@@ -397,7 +397,7 @@ static int device_add_attrs(struct bus_type *bus, struct device *dev) | |||
397 | return 0; | 397 | return 0; |
398 | 398 | ||
399 | for (i = 0; attr_name(bus->dev_attrs[i]); i++) { | 399 | for (i = 0; attr_name(bus->dev_attrs[i]); i++) { |
400 | error = device_create_file(dev,&bus->dev_attrs[i]); | 400 | error = device_create_file(dev, &bus->dev_attrs[i]); |
401 | if (error) { | 401 | if (error) { |
402 | while (--i >= 0) | 402 | while (--i >= 0) |
403 | device_remove_file(dev, &bus->dev_attrs[i]); | 403 | device_remove_file(dev, &bus->dev_attrs[i]); |
@@ -407,13 +407,13 @@ static int device_add_attrs(struct bus_type *bus, struct device *dev) | |||
407 | return error; | 407 | return error; |
408 | } | 408 | } |
409 | 409 | ||
410 | static void device_remove_attrs(struct bus_type * bus, struct device * dev) | 410 | static void device_remove_attrs(struct bus_type *bus, struct device *dev) |
411 | { | 411 | { |
412 | int i; | 412 | int i; |
413 | 413 | ||
414 | if (bus->dev_attrs) { | 414 | if (bus->dev_attrs) { |
415 | for (i = 0; attr_name(bus->dev_attrs[i]); i++) | 415 | for (i = 0; attr_name(bus->dev_attrs[i]); i++) |
416 | device_remove_file(dev,&bus->dev_attrs[i]); | 416 | device_remove_file(dev, &bus->dev_attrs[i]); |
417 | } | 417 | } |
418 | } | 418 | } |
419 | 419 | ||
@@ -434,15 +434,15 @@ static inline void remove_deprecated_bus_links(struct device *dev) { } | |||
434 | #endif | 434 | #endif |
435 | 435 | ||
436 | /** | 436 | /** |
437 | * bus_add_device - add device to bus | 437 | * bus_add_device - add device to bus |
438 | * @dev: device being added | 438 | * @dev: device being added |
439 | * | 439 | * |
440 | * - Add the device to its bus's list of devices. | 440 | * - Add the device to its bus's list of devices. |
441 | * - Create link to device's bus. | 441 | * - Create link to device's bus. |
442 | */ | 442 | */ |
443 | int bus_add_device(struct device * dev) | 443 | int bus_add_device(struct device *dev) |
444 | { | 444 | { |
445 | struct bus_type * bus = bus_get(dev->bus); | 445 | struct bus_type *bus = bus_get(dev->bus); |
446 | int error = 0; | 446 | int error = 0; |
447 | 447 | ||
448 | if (bus) { | 448 | if (bus) { |
@@ -476,13 +476,13 @@ out_put: | |||
476 | } | 476 | } |
477 | 477 | ||
478 | /** | 478 | /** |
479 | * bus_attach_device - add device to bus | 479 | * bus_attach_device - add device to bus |
480 | * @dev: device tried to attach to a driver | 480 | * @dev: device tried to attach to a driver |
481 | * | 481 | * |
482 | * - Add device to bus's list of devices. | 482 | * - Add device to bus's list of devices. |
483 | * - Try to attach to driver. | 483 | * - Try to attach to driver. |
484 | */ | 484 | */ |
485 | void bus_attach_device(struct device * dev) | 485 | void bus_attach_device(struct device *dev) |
486 | { | 486 | { |
487 | struct bus_type *bus = dev->bus; | 487 | struct bus_type *bus = dev->bus; |
488 | int ret = 0; | 488 | int ret = 0; |
@@ -500,32 +500,34 @@ void bus_attach_device(struct device * dev) | |||
500 | } | 500 | } |
501 | 501 | ||
502 | /** | 502 | /** |
503 | * bus_remove_device - remove device from bus | 503 | * bus_remove_device - remove device from bus |
504 | * @dev: device to be removed | 504 | * @dev: device to be removed |
505 | * | 505 | * |
506 | * - Remove symlink from bus's directory. | 506 | * - Remove symlink from bus's directory. |
507 | * - Delete device from bus's list. | 507 | * - Delete device from bus's list. |
508 | * - Detach from its driver. | 508 | * - Detach from its driver. |
509 | * - Drop reference taken in bus_add_device(). | 509 | * - Drop reference taken in bus_add_device(). |
510 | */ | 510 | */ |
511 | void bus_remove_device(struct device * dev) | 511 | void bus_remove_device(struct device *dev) |
512 | { | 512 | { |
513 | if (dev->bus) { | 513 | if (dev->bus) { |
514 | sysfs_remove_link(&dev->kobj, "subsystem"); | 514 | sysfs_remove_link(&dev->kobj, "subsystem"); |
515 | remove_deprecated_bus_links(dev); | 515 | remove_deprecated_bus_links(dev); |
516 | sysfs_remove_link(&dev->bus->p->devices_kset->kobj, dev->bus_id); | 516 | sysfs_remove_link(&dev->bus->p->devices_kset->kobj, |
517 | dev->bus_id); | ||
517 | device_remove_attrs(dev->bus, dev); | 518 | device_remove_attrs(dev->bus, dev); |
518 | if (dev->is_registered) { | 519 | if (dev->is_registered) { |
519 | dev->is_registered = 0; | 520 | dev->is_registered = 0; |
520 | klist_del(&dev->knode_bus); | 521 | klist_del(&dev->knode_bus); |
521 | } | 522 | } |
522 | pr_debug("bus: '%s': remove device %s\n", dev->bus->name, dev->bus_id); | 523 | pr_debug("bus: '%s': remove device %s\n", |
524 | dev->bus->name, dev->bus_id); | ||
523 | device_release_driver(dev); | 525 | device_release_driver(dev); |
524 | bus_put(dev->bus); | 526 | bus_put(dev->bus); |
525 | } | 527 | } |
526 | } | 528 | } |
527 | 529 | ||
528 | static int driver_add_attrs(struct bus_type * bus, struct device_driver * drv) | 530 | static int driver_add_attrs(struct bus_type *bus, struct device_driver *drv) |
529 | { | 531 | { |
530 | int error = 0; | 532 | int error = 0; |
531 | int i; | 533 | int i; |
@@ -534,19 +536,19 @@ static int driver_add_attrs(struct bus_type * bus, struct device_driver * drv) | |||
534 | for (i = 0; attr_name(bus->drv_attrs[i]); i++) { | 536 | for (i = 0; attr_name(bus->drv_attrs[i]); i++) { |
535 | error = driver_create_file(drv, &bus->drv_attrs[i]); | 537 | error = driver_create_file(drv, &bus->drv_attrs[i]); |
536 | if (error) | 538 | if (error) |
537 | goto Err; | 539 | goto err; |
538 | } | 540 | } |
539 | } | 541 | } |
540 | Done: | 542 | done: |
541 | return error; | 543 | return error; |
542 | Err: | 544 | err: |
543 | while (--i >= 0) | 545 | while (--i >= 0) |
544 | driver_remove_file(drv, &bus->drv_attrs[i]); | 546 | driver_remove_file(drv, &bus->drv_attrs[i]); |
545 | goto Done; | 547 | goto done; |
546 | } | 548 | } |
547 | 549 | ||
548 | 550 | static void driver_remove_attrs(struct bus_type *bus, | |
549 | static void driver_remove_attrs(struct bus_type * bus, struct device_driver * drv) | 551 | struct device_driver *drv) |
550 | { | 552 | { |
551 | int i; | 553 | int i; |
552 | 554 | ||
@@ -623,9 +625,8 @@ static ssize_t driver_uevent_store(struct device_driver *drv, | |||
623 | static DRIVER_ATTR(uevent, S_IWUSR, NULL, driver_uevent_store); | 625 | static DRIVER_ATTR(uevent, S_IWUSR, NULL, driver_uevent_store); |
624 | 626 | ||
625 | /** | 627 | /** |
626 | * bus_add_driver - Add a driver to the bus. | 628 | * bus_add_driver - Add a driver to the bus. |
627 | * @drv: driver. | 629 | * @drv: driver. |
628 | * | ||
629 | */ | 630 | */ |
630 | int bus_add_driver(struct device_driver *drv) | 631 | int bus_add_driver(struct device_driver *drv) |
631 | { | 632 | { |
@@ -688,15 +689,14 @@ out_put_bus: | |||
688 | } | 689 | } |
689 | 690 | ||
690 | /** | 691 | /** |
691 | * bus_remove_driver - delete driver from bus's knowledge. | 692 | * bus_remove_driver - delete driver from bus's knowledge. |
692 | * @drv: driver. | 693 | * @drv: driver. |
693 | * | 694 | * |
694 | * Detach the driver from the devices it controls, and remove | 695 | * Detach the driver from the devices it controls, and remove |
695 | * it from its bus's list of drivers. Finally, we drop the reference | 696 | * it from its bus's list of drivers. Finally, we drop the reference |
696 | * to the bus we took in bus_add_driver(). | 697 | * to the bus we took in bus_add_driver(). |
697 | */ | 698 | */ |
698 | 699 | void bus_remove_driver(struct device_driver *drv) | |
699 | void bus_remove_driver(struct device_driver * drv) | ||
700 | { | 700 | { |
701 | if (!drv->bus) | 701 | if (!drv->bus) |
702 | return; | 702 | return; |
@@ -712,10 +712,9 @@ void bus_remove_driver(struct device_driver * drv) | |||
712 | bus_put(drv->bus); | 712 | bus_put(drv->bus); |
713 | } | 713 | } |
714 | 714 | ||
715 | |||
716 | /* Helper for bus_rescan_devices's iter */ | 715 | /* Helper for bus_rescan_devices's iter */ |
717 | static int __must_check bus_rescan_devices_helper(struct device *dev, | 716 | static int __must_check bus_rescan_devices_helper(struct device *dev, |
718 | void *data) | 717 | void *data) |
719 | { | 718 | { |
720 | int ret = 0; | 719 | int ret = 0; |
721 | 720 | ||
@@ -737,10 +736,11 @@ static int __must_check bus_rescan_devices_helper(struct device *dev, | |||
737 | * attached and rescan it against existing drivers to see if it matches | 736 | * attached and rescan it against existing drivers to see if it matches |
738 | * any by calling device_attach() for the unbound devices. | 737 | * any by calling device_attach() for the unbound devices. |
739 | */ | 738 | */ |
740 | int bus_rescan_devices(struct bus_type * bus) | 739 | int bus_rescan_devices(struct bus_type *bus) |
741 | { | 740 | { |
742 | return bus_for_each_dev(bus, NULL, NULL, bus_rescan_devices_helper); | 741 | return bus_for_each_dev(bus, NULL, NULL, bus_rescan_devices_helper); |
743 | } | 742 | } |
743 | EXPORT_SYMBOL_GPL(bus_rescan_devices); | ||
744 | 744 | ||
745 | /** | 745 | /** |
746 | * device_reprobe - remove driver for a device and probe for a new driver | 746 | * device_reprobe - remove driver for a device and probe for a new driver |
@@ -765,55 +765,55 @@ int device_reprobe(struct device *dev) | |||
765 | EXPORT_SYMBOL_GPL(device_reprobe); | 765 | EXPORT_SYMBOL_GPL(device_reprobe); |
766 | 766 | ||
767 | /** | 767 | /** |
768 | * find_bus - locate bus by name. | 768 | * find_bus - locate bus by name. |
769 | * @name: name of bus. | 769 | * @name: name of bus. |
770 | * | 770 | * |
771 | * Call kset_find_obj() to iterate over list of buses to | 771 | * Call kset_find_obj() to iterate over list of buses to |
772 | * find a bus by name. Return bus if found. | 772 | * find a bus by name. Return bus if found. |
773 | * | 773 | * |
774 | * Note that kset_find_obj increments bus' reference count. | 774 | * Note that kset_find_obj increments bus' reference count. |
775 | */ | 775 | */ |
776 | #if 0 | 776 | #if 0 |
777 | struct bus_type * find_bus(char * name) | 777 | struct bus_type *find_bus(char *name) |
778 | { | 778 | { |
779 | struct kobject * k = kset_find_obj(bus_kset, name); | 779 | struct kobject *k = kset_find_obj(bus_kset, name); |
780 | return k ? to_bus(k) : NULL; | 780 | return k ? to_bus(k) : NULL; |
781 | } | 781 | } |
782 | #endif /* 0 */ | 782 | #endif /* 0 */ |
783 | 783 | ||
784 | 784 | ||
785 | /** | 785 | /** |
786 | * bus_add_attrs - Add default attributes for this bus. | 786 | * bus_add_attrs - Add default attributes for this bus. |
787 | * @bus: Bus that has just been registered. | 787 | * @bus: Bus that has just been registered. |
788 | */ | 788 | */ |
789 | 789 | ||
790 | static int bus_add_attrs(struct bus_type * bus) | 790 | static int bus_add_attrs(struct bus_type *bus) |
791 | { | 791 | { |
792 | int error = 0; | 792 | int error = 0; |
793 | int i; | 793 | int i; |
794 | 794 | ||
795 | if (bus->bus_attrs) { | 795 | if (bus->bus_attrs) { |
796 | for (i = 0; attr_name(bus->bus_attrs[i]); i++) { | 796 | for (i = 0; attr_name(bus->bus_attrs[i]); i++) { |
797 | error = bus_create_file(bus,&bus->bus_attrs[i]); | 797 | error = bus_create_file(bus, &bus->bus_attrs[i]); |
798 | if (error) | 798 | if (error) |
799 | goto Err; | 799 | goto err; |
800 | } | 800 | } |
801 | } | 801 | } |
802 | Done: | 802 | done: |
803 | return error; | 803 | return error; |
804 | Err: | 804 | err: |
805 | while (--i >= 0) | 805 | while (--i >= 0) |
806 | bus_remove_file(bus,&bus->bus_attrs[i]); | 806 | bus_remove_file(bus, &bus->bus_attrs[i]); |
807 | goto Done; | 807 | goto done; |
808 | } | 808 | } |
809 | 809 | ||
810 | static void bus_remove_attrs(struct bus_type * bus) | 810 | static void bus_remove_attrs(struct bus_type *bus) |
811 | { | 811 | { |
812 | int i; | 812 | int i; |
813 | 813 | ||
814 | if (bus->bus_attrs) { | 814 | if (bus->bus_attrs) { |
815 | for (i = 0; attr_name(bus->bus_attrs[i]); i++) | 815 | for (i = 0; attr_name(bus->bus_attrs[i]); i++) |
816 | bus_remove_file(bus,&bus->bus_attrs[i]); | 816 | bus_remove_file(bus, &bus->bus_attrs[i]); |
817 | } | 817 | } |
818 | } | 818 | } |
819 | 819 | ||
@@ -843,14 +843,14 @@ static ssize_t bus_uevent_store(struct bus_type *bus, | |||
843 | static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store); | 843 | static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store); |
844 | 844 | ||
845 | /** | 845 | /** |
846 | * bus_register - register a bus with the system. | 846 | * bus_register - register a bus with the system. |
847 | * @bus: bus. | 847 | * @bus: bus. |
848 | * | 848 | * |
849 | * Once we have that, we registered the bus with the kobject | 849 | * Once we have that, we registered the bus with the kobject |
850 | * infrastructure, then register the children subsystems it has: | 850 | * infrastructure, then register the children subsystems it has: |
851 | * the devices and drivers that belong to the bus. | 851 | * the devices and drivers that belong to the bus. |
852 | */ | 852 | */ |
853 | int bus_register(struct bus_type * bus) | 853 | int bus_register(struct bus_type *bus) |
854 | { | 854 | { |
855 | int retval; | 855 | int retval; |
856 | struct bus_type_private *priv; | 856 | struct bus_type_private *priv; |
@@ -922,15 +922,16 @@ bus_uevent_fail: | |||
922 | out: | 922 | out: |
923 | return retval; | 923 | return retval; |
924 | } | 924 | } |
925 | EXPORT_SYMBOL_GPL(bus_register); | ||
925 | 926 | ||
926 | /** | 927 | /** |
927 | * bus_unregister - remove a bus from the system | 928 | * bus_unregister - remove a bus from the system |
928 | * @bus: bus. | 929 | * @bus: bus. |
929 | * | 930 | * |
930 | * Unregister the child subsystems and the bus itself. | 931 | * Unregister the child subsystems and the bus itself. |
931 | * Finally, we call bus_put() to release the refcount | 932 | * Finally, we call bus_put() to release the refcount |
932 | */ | 933 | */ |
933 | void bus_unregister(struct bus_type * bus) | 934 | void bus_unregister(struct bus_type *bus) |
934 | { | 935 | { |
935 | pr_debug("bus: '%s': unregistering\n", bus->name); | 936 | pr_debug("bus: '%s': unregistering\n", bus->name); |
936 | bus_remove_attrs(bus); | 937 | bus_remove_attrs(bus); |
@@ -941,6 +942,7 @@ void bus_unregister(struct bus_type * bus) | |||
941 | kset_unregister(&bus->p->subsys); | 942 | kset_unregister(&bus->p->subsys); |
942 | kfree(bus->p); | 943 | kfree(bus->p); |
943 | } | 944 | } |
945 | EXPORT_SYMBOL_GPL(bus_unregister); | ||
944 | 946 | ||
945 | int bus_register_notifier(struct bus_type *bus, struct notifier_block *nb) | 947 | int bus_register_notifier(struct bus_type *bus, struct notifier_block *nb) |
946 | { | 948 | { |
@@ -973,15 +975,3 @@ int __init buses_init(void) | |||
973 | return -ENOMEM; | 975 | return -ENOMEM; |
974 | return 0; | 976 | return 0; |
975 | } | 977 | } |
976 | |||
977 | |||
978 | EXPORT_SYMBOL_GPL(bus_for_each_dev); | ||
979 | EXPORT_SYMBOL_GPL(bus_find_device); | ||
980 | EXPORT_SYMBOL_GPL(bus_for_each_drv); | ||
981 | |||
982 | EXPORT_SYMBOL_GPL(bus_register); | ||
983 | EXPORT_SYMBOL_GPL(bus_unregister); | ||
984 | EXPORT_SYMBOL_GPL(bus_rescan_devices); | ||
985 | |||
986 | EXPORT_SYMBOL_GPL(bus_create_file); | ||
987 | EXPORT_SYMBOL_GPL(bus_remove_file); | ||
diff --git a/drivers/base/class.c b/drivers/base/class.c index 9f737ff0fc71..59cf35894cfc 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -23,11 +23,11 @@ | |||
23 | #define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr) | 23 | #define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr) |
24 | #define to_class(obj) container_of(obj, struct class, subsys.kobj) | 24 | #define to_class(obj) container_of(obj, struct class, subsys.kobj) |
25 | 25 | ||
26 | static ssize_t | 26 | static ssize_t class_attr_show(struct kobject *kobj, struct attribute *attr, |
27 | class_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) | 27 | char *buf) |
28 | { | 28 | { |
29 | struct class_attribute * class_attr = to_class_attr(attr); | 29 | struct class_attribute *class_attr = to_class_attr(attr); |
30 | struct class * dc = to_class(kobj); | 30 | struct class *dc = to_class(kobj); |
31 | ssize_t ret = -EIO; | 31 | ssize_t ret = -EIO; |
32 | 32 | ||
33 | if (class_attr->show) | 33 | if (class_attr->show) |
@@ -35,12 +35,11 @@ class_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) | |||
35 | return ret; | 35 | return ret; |
36 | } | 36 | } |
37 | 37 | ||
38 | static ssize_t | 38 | static ssize_t class_attr_store(struct kobject *kobj, struct attribute *attr, |
39 | class_attr_store(struct kobject * kobj, struct attribute * attr, | 39 | const char *buf, size_t count) |
40 | const char * buf, size_t count) | ||
41 | { | 40 | { |
42 | struct class_attribute * class_attr = to_class_attr(attr); | 41 | struct class_attribute *class_attr = to_class_attr(attr); |
43 | struct class * dc = to_class(kobj); | 42 | struct class *dc = to_class(kobj); |
44 | ssize_t ret = -EIO; | 43 | ssize_t ret = -EIO; |
45 | 44 | ||
46 | if (class_attr->store) | 45 | if (class_attr->store) |
@@ -48,7 +47,7 @@ class_attr_store(struct kobject * kobj, struct attribute * attr, | |||
48 | return ret; | 47 | return ret; |
49 | } | 48 | } |
50 | 49 | ||
51 | static void class_release(struct kobject * kobj) | 50 | static void class_release(struct kobject *kobj) |
52 | { | 51 | { |
53 | struct class *class = to_class(kobj); | 52 | struct class *class = to_class(kobj); |
54 | 53 | ||
@@ -75,17 +74,17 @@ static struct kobj_type class_ktype = { | |||
75 | static struct kset *class_kset; | 74 | static struct kset *class_kset; |
76 | 75 | ||
77 | 76 | ||
78 | int class_create_file(struct class * cls, const struct class_attribute * attr) | 77 | int class_create_file(struct class *cls, const struct class_attribute *attr) |
79 | { | 78 | { |
80 | int error; | 79 | int error; |
81 | if (cls) { | 80 | if (cls) |
82 | error = sysfs_create_file(&cls->subsys.kobj, &attr->attr); | 81 | error = sysfs_create_file(&cls->subsys.kobj, &attr->attr); |
83 | } else | 82 | else |
84 | error = -EINVAL; | 83 | error = -EINVAL; |
85 | return error; | 84 | return error; |
86 | } | 85 | } |
87 | 86 | ||
88 | void class_remove_file(struct class * cls, const struct class_attribute * attr) | 87 | void class_remove_file(struct class *cls, const struct class_attribute *attr) |
89 | { | 88 | { |
90 | if (cls) | 89 | if (cls) |
91 | sysfs_remove_file(&cls->subsys.kobj, &attr->attr); | 90 | sysfs_remove_file(&cls->subsys.kobj, &attr->attr); |
@@ -94,48 +93,48 @@ void class_remove_file(struct class * cls, const struct class_attribute * attr) | |||
94 | static struct class *class_get(struct class *cls) | 93 | static struct class *class_get(struct class *cls) |
95 | { | 94 | { |
96 | if (cls) | 95 | if (cls) |
97 | return container_of(kset_get(&cls->subsys), struct class, subsys); | 96 | return container_of(kset_get(&cls->subsys), |
97 | struct class, subsys); | ||
98 | return NULL; | 98 | return NULL; |
99 | } | 99 | } |
100 | 100 | ||
101 | static void class_put(struct class * cls) | 101 | static void class_put(struct class *cls) |
102 | { | 102 | { |
103 | if (cls) | 103 | if (cls) |
104 | kset_put(&cls->subsys); | 104 | kset_put(&cls->subsys); |
105 | } | 105 | } |
106 | 106 | ||
107 | 107 | static int add_class_attrs(struct class *cls) | |
108 | static int add_class_attrs(struct class * cls) | ||
109 | { | 108 | { |
110 | int i; | 109 | int i; |
111 | int error = 0; | 110 | int error = 0; |
112 | 111 | ||
113 | if (cls->class_attrs) { | 112 | if (cls->class_attrs) { |
114 | for (i = 0; attr_name(cls->class_attrs[i]); i++) { | 113 | for (i = 0; attr_name(cls->class_attrs[i]); i++) { |
115 | error = class_create_file(cls,&cls->class_attrs[i]); | 114 | error = class_create_file(cls, &cls->class_attrs[i]); |
116 | if (error) | 115 | if (error) |
117 | goto Err; | 116 | goto error; |
118 | } | 117 | } |
119 | } | 118 | } |
120 | Done: | 119 | done: |
121 | return error; | 120 | return error; |
122 | Err: | 121 | error: |
123 | while (--i >= 0) | 122 | while (--i >= 0) |
124 | class_remove_file(cls,&cls->class_attrs[i]); | 123 | class_remove_file(cls, &cls->class_attrs[i]); |
125 | goto Done; | 124 | goto done; |
126 | } | 125 | } |
127 | 126 | ||
128 | static void remove_class_attrs(struct class * cls) | 127 | static void remove_class_attrs(struct class *cls) |
129 | { | 128 | { |
130 | int i; | 129 | int i; |
131 | 130 | ||
132 | if (cls->class_attrs) { | 131 | if (cls->class_attrs) { |
133 | for (i = 0; attr_name(cls->class_attrs[i]); i++) | 132 | for (i = 0; attr_name(cls->class_attrs[i]); i++) |
134 | class_remove_file(cls,&cls->class_attrs[i]); | 133 | class_remove_file(cls, &cls->class_attrs[i]); |
135 | } | 134 | } |
136 | } | 135 | } |
137 | 136 | ||
138 | int class_register(struct class * cls) | 137 | int class_register(struct class *cls) |
139 | { | 138 | { |
140 | int error; | 139 | int error; |
141 | 140 | ||
@@ -167,7 +166,7 @@ int class_register(struct class * cls) | |||
167 | return error; | 166 | return error; |
168 | } | 167 | } |
169 | 168 | ||
170 | void class_unregister(struct class * cls) | 169 | void class_unregister(struct class *cls) |
171 | { | 170 | { |
172 | pr_debug("device class '%s': unregistering\n", cls->name); | 171 | pr_debug("device class '%s': unregistering\n", cls->name); |
173 | remove_class_attrs(cls); | 172 | remove_class_attrs(cls); |
@@ -249,8 +248,8 @@ void class_destroy(struct class *cls) | |||
249 | 248 | ||
250 | /* Class Device Stuff */ | 249 | /* Class Device Stuff */ |
251 | 250 | ||
252 | int class_device_create_file(struct class_device * class_dev, | 251 | int class_device_create_file(struct class_device *class_dev, |
253 | const struct class_device_attribute * attr) | 252 | const struct class_device_attribute *attr) |
254 | { | 253 | { |
255 | int error = -EINVAL; | 254 | int error = -EINVAL; |
256 | if (class_dev) | 255 | if (class_dev) |
@@ -258,8 +257,8 @@ int class_device_create_file(struct class_device * class_dev, | |||
258 | return error; | 257 | return error; |
259 | } | 258 | } |
260 | 259 | ||
261 | void class_device_remove_file(struct class_device * class_dev, | 260 | void class_device_remove_file(struct class_device *class_dev, |
262 | const struct class_device_attribute * attr) | 261 | const struct class_device_attribute *attr) |
263 | { | 262 | { |
264 | if (class_dev) | 263 | if (class_dev) |
265 | sysfs_remove_file(&class_dev->kobj, &attr->attr); | 264 | sysfs_remove_file(&class_dev->kobj, &attr->attr); |
@@ -281,12 +280,11 @@ void class_device_remove_bin_file(struct class_device *class_dev, | |||
281 | sysfs_remove_bin_file(&class_dev->kobj, attr); | 280 | sysfs_remove_bin_file(&class_dev->kobj, attr); |
282 | } | 281 | } |
283 | 282 | ||
284 | static ssize_t | 283 | static ssize_t class_device_attr_show(struct kobject *kobj, |
285 | class_device_attr_show(struct kobject * kobj, struct attribute * attr, | 284 | struct attribute *attr, char *buf) |
286 | char * buf) | ||
287 | { | 285 | { |
288 | struct class_device_attribute * class_dev_attr = to_class_dev_attr(attr); | 286 | struct class_device_attribute *class_dev_attr = to_class_dev_attr(attr); |
289 | struct class_device * cd = to_class_dev(kobj); | 287 | struct class_device *cd = to_class_dev(kobj); |
290 | ssize_t ret = 0; | 288 | ssize_t ret = 0; |
291 | 289 | ||
292 | if (class_dev_attr->show) | 290 | if (class_dev_attr->show) |
@@ -294,12 +292,12 @@ class_device_attr_show(struct kobject * kobj, struct attribute * attr, | |||
294 | return ret; | 292 | return ret; |
295 | } | 293 | } |
296 | 294 | ||
297 | static ssize_t | 295 | static ssize_t class_device_attr_store(struct kobject *kobj, |
298 | class_device_attr_store(struct kobject * kobj, struct attribute * attr, | 296 | struct attribute *attr, |
299 | const char * buf, size_t count) | 297 | const char *buf, size_t count) |
300 | { | 298 | { |
301 | struct class_device_attribute * class_dev_attr = to_class_dev_attr(attr); | 299 | struct class_device_attribute *class_dev_attr = to_class_dev_attr(attr); |
302 | struct class_device * cd = to_class_dev(kobj); | 300 | struct class_device *cd = to_class_dev(kobj); |
303 | ssize_t ret = 0; | 301 | ssize_t ret = 0; |
304 | 302 | ||
305 | if (class_dev_attr->store) | 303 | if (class_dev_attr->store) |
@@ -312,10 +310,10 @@ static struct sysfs_ops class_dev_sysfs_ops = { | |||
312 | .store = class_device_attr_store, | 310 | .store = class_device_attr_store, |
313 | }; | 311 | }; |
314 | 312 | ||
315 | static void class_dev_release(struct kobject * kobj) | 313 | static void class_dev_release(struct kobject *kobj) |
316 | { | 314 | { |
317 | struct class_device *cd = to_class_dev(kobj); | 315 | struct class_device *cd = to_class_dev(kobj); |
318 | struct class * cls = cd->class; | 316 | struct class *cls = cd->class; |
319 | 317 | ||
320 | pr_debug("device class '%s': release.\n", cd->class_id); | 318 | pr_debug("device class '%s': release.\n", cd->class_id); |
321 | 319 | ||
@@ -324,8 +322,8 @@ static void class_dev_release(struct kobject * kobj) | |||
324 | else if (cls->release) | 322 | else if (cls->release) |
325 | cls->release(cd); | 323 | cls->release(cd); |
326 | else { | 324 | else { |
327 | printk(KERN_ERR "Class Device '%s' does not have a release() function, " | 325 | printk(KERN_ERR "Class Device '%s' does not have a release() " |
328 | "it is broken and must be fixed.\n", | 326 | "function, it is broken and must be fixed.\n", |
329 | cd->class_id); | 327 | cd->class_id); |
330 | WARN_ON(1); | 328 | WARN_ON(1); |
331 | } | 329 | } |
@@ -436,7 +434,8 @@ static int class_uevent(struct kset *kset, struct kobject *kobj, | |||
436 | add_uevent_var(env, "PHYSDEVBUS=%s", dev->bus->name); | 434 | add_uevent_var(env, "PHYSDEVBUS=%s", dev->bus->name); |
437 | 435 | ||
438 | if (dev->driver) | 436 | if (dev->driver) |
439 | add_uevent_var(env, "PHYSDEVDRIVER=%s", dev->driver->name); | 437 | add_uevent_var(env, "PHYSDEVDRIVER=%s", |
438 | dev->driver->name); | ||
440 | } | 439 | } |
441 | 440 | ||
442 | if (class_dev->uevent) { | 441 | if (class_dev->uevent) { |
@@ -469,40 +468,40 @@ static struct kset class_obj_subsys = { | |||
469 | .uevent_ops = &class_uevent_ops, | 468 | .uevent_ops = &class_uevent_ops, |
470 | }; | 469 | }; |
471 | 470 | ||
472 | static int class_device_add_attrs(struct class_device * cd) | 471 | static int class_device_add_attrs(struct class_device *cd) |
473 | { | 472 | { |
474 | int i; | 473 | int i; |
475 | int error = 0; | 474 | int error = 0; |
476 | struct class * cls = cd->class; | 475 | struct class *cls = cd->class; |
477 | 476 | ||
478 | if (cls->class_dev_attrs) { | 477 | if (cls->class_dev_attrs) { |
479 | for (i = 0; attr_name(cls->class_dev_attrs[i]); i++) { | 478 | for (i = 0; attr_name(cls->class_dev_attrs[i]); i++) { |
480 | error = class_device_create_file(cd, | 479 | error = class_device_create_file(cd, |
481 | &cls->class_dev_attrs[i]); | 480 | &cls->class_dev_attrs[i]); |
482 | if (error) | 481 | if (error) |
483 | goto Err; | 482 | goto err; |
484 | } | 483 | } |
485 | } | 484 | } |
486 | Done: | 485 | done: |
487 | return error; | 486 | return error; |
488 | Err: | 487 | err: |
489 | while (--i >= 0) | 488 | while (--i >= 0) |
490 | class_device_remove_file(cd,&cls->class_dev_attrs[i]); | 489 | class_device_remove_file(cd, &cls->class_dev_attrs[i]); |
491 | goto Done; | 490 | goto done; |
492 | } | 491 | } |
493 | 492 | ||
494 | static void class_device_remove_attrs(struct class_device * cd) | 493 | static void class_device_remove_attrs(struct class_device *cd) |
495 | { | 494 | { |
496 | int i; | 495 | int i; |
497 | struct class * cls = cd->class; | 496 | struct class *cls = cd->class; |
498 | 497 | ||
499 | if (cls->class_dev_attrs) { | 498 | if (cls->class_dev_attrs) { |
500 | for (i = 0; attr_name(cls->class_dev_attrs[i]); i++) | 499 | for (i = 0; attr_name(cls->class_dev_attrs[i]); i++) |
501 | class_device_remove_file(cd,&cls->class_dev_attrs[i]); | 500 | class_device_remove_file(cd, &cls->class_dev_attrs[i]); |
502 | } | 501 | } |
503 | } | 502 | } |
504 | 503 | ||
505 | static int class_device_add_groups(struct class_device * cd) | 504 | static int class_device_add_groups(struct class_device *cd) |
506 | { | 505 | { |
507 | int i; | 506 | int i; |
508 | int error = 0; | 507 | int error = 0; |
@@ -512,7 +511,8 @@ static int class_device_add_groups(struct class_device * cd) | |||
512 | error = sysfs_create_group(&cd->kobj, cd->groups[i]); | 511 | error = sysfs_create_group(&cd->kobj, cd->groups[i]); |
513 | if (error) { | 512 | if (error) { |
514 | while (--i >= 0) | 513 | while (--i >= 0) |
515 | sysfs_remove_group(&cd->kobj, cd->groups[i]); | 514 | sysfs_remove_group(&cd->kobj, |
515 | cd->groups[i]); | ||
516 | goto out; | 516 | goto out; |
517 | } | 517 | } |
518 | } | 518 | } |
@@ -521,14 +521,12 @@ out: | |||
521 | return error; | 521 | return error; |
522 | } | 522 | } |
523 | 523 | ||
524 | static void class_device_remove_groups(struct class_device * cd) | 524 | static void class_device_remove_groups(struct class_device *cd) |
525 | { | 525 | { |
526 | int i; | 526 | int i; |
527 | if (cd->groups) { | 527 | if (cd->groups) |
528 | for (i = 0; cd->groups[i]; i++) { | 528 | for (i = 0; cd->groups[i]; i++) |
529 | sysfs_remove_group(&cd->kobj, cd->groups[i]); | 529 | sysfs_remove_group(&cd->kobj, cd->groups[i]); |
530 | } | ||
531 | } | ||
532 | } | 530 | } |
533 | 531 | ||
534 | static ssize_t show_dev(struct class_device *class_dev, char *buf) | 532 | static ssize_t show_dev(struct class_device *class_dev, char *buf) |
@@ -653,7 +651,7 @@ int class_device_add(struct class_device *class_dev) | |||
653 | out3: | 651 | out3: |
654 | kobject_del(&class_dev->kobj); | 652 | kobject_del(&class_dev->kobj); |
655 | out2: | 653 | out2: |
656 | if(parent_class_dev) | 654 | if (parent_class_dev) |
657 | class_device_put(parent_class_dev); | 655 | class_device_put(parent_class_dev); |
658 | class_put(parent_class); | 656 | class_put(parent_class); |
659 | out1: | 657 | out1: |
@@ -670,9 +668,11 @@ int class_device_register(struct class_device *class_dev) | |||
670 | /** | 668 | /** |
671 | * class_device_create - creates a class device and registers it with sysfs | 669 | * class_device_create - creates a class device and registers it with sysfs |
672 | * @cls: pointer to the struct class that this device should be registered to. | 670 | * @cls: pointer to the struct class that this device should be registered to. |
673 | * @parent: pointer to the parent struct class_device of this new device, if any. | 671 | * @parent: pointer to the parent struct class_device of this new device, if |
672 | * any. | ||
674 | * @devt: the dev_t for the char device to be added. | 673 | * @devt: the dev_t for the char device to be added. |
675 | * @device: a pointer to a struct device that is assiociated with this class device. | 674 | * @device: a pointer to a struct device that is assiociated with this class |
675 | * device. | ||
676 | * @fmt: string for the class device's name | 676 | * @fmt: string for the class device's name |
677 | * | 677 | * |
678 | * This function can be used by char device classes. A struct | 678 | * This function can be used by char device classes. A struct |
@@ -796,7 +796,7 @@ void class_device_destroy(struct class *cls, dev_t devt) | |||
796 | class_device_unregister(class_dev); | 796 | class_device_unregister(class_dev); |
797 | } | 797 | } |
798 | 798 | ||
799 | struct class_device * class_device_get(struct class_device *class_dev) | 799 | struct class_device *class_device_get(struct class_device *class_dev) |
800 | { | 800 | { |
801 | if (class_dev) | 801 | if (class_dev) |
802 | return to_class_dev(kobject_get(&class_dev->kobj)); | 802 | return to_class_dev(kobject_get(&class_dev->kobj)); |
@@ -973,7 +973,7 @@ int class_interface_register(struct class_interface *class_intf) | |||
973 | 973 | ||
974 | void class_interface_unregister(struct class_interface *class_intf) | 974 | void class_interface_unregister(struct class_interface *class_intf) |
975 | { | 975 | { |
976 | struct class * parent = class_intf->class; | 976 | struct class *parent = class_intf->class; |
977 | struct class_device *class_dev; | 977 | struct class_device *class_dev; |
978 | struct device *dev; | 978 | struct device *dev; |
979 | 979 | ||
diff --git a/drivers/base/core.c b/drivers/base/core.c index f09dde3b1e27..edf3bbeb8d6a 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -24,8 +24,8 @@ | |||
24 | #include "base.h" | 24 | #include "base.h" |
25 | #include "power/power.h" | 25 | #include "power/power.h" |
26 | 26 | ||
27 | int (*platform_notify)(struct device * dev) = NULL; | 27 | int (*platform_notify)(struct device *dev) = NULL; |
28 | int (*platform_notify_remove)(struct device * dev) = NULL; | 28 | int (*platform_notify_remove)(struct device *dev) = NULL; |
29 | 29 | ||
30 | /* | 30 | /* |
31 | * sysfs bindings for devices. | 31 | * sysfs bindings for devices. |
@@ -51,11 +51,11 @@ EXPORT_SYMBOL(dev_driver_string); | |||
51 | #define to_dev(obj) container_of(obj, struct device, kobj) | 51 | #define to_dev(obj) container_of(obj, struct device, kobj) |
52 | #define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) | 52 | #define to_dev_attr(_attr) container_of(_attr, struct device_attribute, attr) |
53 | 53 | ||
54 | static ssize_t | 54 | static ssize_t dev_attr_show(struct kobject *kobj, struct attribute *attr, |
55 | dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) | 55 | char *buf) |
56 | { | 56 | { |
57 | struct device_attribute * dev_attr = to_dev_attr(attr); | 57 | struct device_attribute *dev_attr = to_dev_attr(attr); |
58 | struct device * dev = to_dev(kobj); | 58 | struct device *dev = to_dev(kobj); |
59 | ssize_t ret = -EIO; | 59 | ssize_t ret = -EIO; |
60 | 60 | ||
61 | if (dev_attr->show) | 61 | if (dev_attr->show) |
@@ -63,12 +63,11 @@ dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf) | |||
63 | return ret; | 63 | return ret; |
64 | } | 64 | } |
65 | 65 | ||
66 | static ssize_t | 66 | static ssize_t dev_attr_store(struct kobject *kobj, struct attribute *attr, |
67 | dev_attr_store(struct kobject * kobj, struct attribute * attr, | 67 | const char *buf, size_t count) |
68 | const char * buf, size_t count) | ||
69 | { | 68 | { |
70 | struct device_attribute * dev_attr = to_dev_attr(attr); | 69 | struct device_attribute *dev_attr = to_dev_attr(attr); |
71 | struct device * dev = to_dev(kobj); | 70 | struct device *dev = to_dev(kobj); |
72 | ssize_t ret = -EIO; | 71 | ssize_t ret = -EIO; |
73 | 72 | ||
74 | if (dev_attr->store) | 73 | if (dev_attr->store) |
@@ -90,9 +89,9 @@ static struct sysfs_ops dev_sysfs_ops = { | |||
90 | * reaches 0. We forward the call to the device's release | 89 | * reaches 0. We forward the call to the device's release |
91 | * method, which should handle actually freeing the structure. | 90 | * method, which should handle actually freeing the structure. |
92 | */ | 91 | */ |
93 | static void device_release(struct kobject * kobj) | 92 | static void device_release(struct kobject *kobj) |
94 | { | 93 | { |
95 | struct device * dev = to_dev(kobj); | 94 | struct device *dev = to_dev(kobj); |
96 | 95 | ||
97 | if (dev->release) | 96 | if (dev->release) |
98 | dev->release(dev); | 97 | dev->release(dev); |
@@ -101,8 +100,8 @@ static void device_release(struct kobject * kobj) | |||
101 | else if (dev->class && dev->class->dev_release) | 100 | else if (dev->class && dev->class->dev_release) |
102 | dev->class->dev_release(dev); | 101 | dev->class->dev_release(dev); |
103 | else { | 102 | else { |
104 | printk(KERN_ERR "Device '%s' does not have a release() function, " | 103 | printk(KERN_ERR "Device '%s' does not have a release() " |
105 | "it is broken and must be fixed.\n", | 104 | "function, it is broken and must be fixed.\n", |
106 | dev->bus_id); | 105 | dev->bus_id); |
107 | WARN_ON(1); | 106 | WARN_ON(1); |
108 | } | 107 | } |
@@ -185,7 +184,8 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, | |||
185 | add_uevent_var(env, "PHYSDEVBUS=%s", dev->bus->name); | 184 | add_uevent_var(env, "PHYSDEVBUS=%s", dev->bus->name); |
186 | 185 | ||
187 | if (dev->driver) | 186 | if (dev->driver) |
188 | add_uevent_var(env, "PHYSDEVDRIVER=%s", dev->driver->name); | 187 | add_uevent_var(env, "PHYSDEVDRIVER=%s", |
188 | dev->driver->name); | ||
189 | } | 189 | } |
190 | #endif | 190 | #endif |
191 | 191 | ||
@@ -327,7 +327,8 @@ static int device_add_groups(struct device *dev, | |||
327 | error = sysfs_create_group(&dev->kobj, groups[i]); | 327 | error = sysfs_create_group(&dev->kobj, groups[i]); |
328 | if (error) { | 328 | if (error) { |
329 | while (--i >= 0) | 329 | while (--i >= 0) |
330 | sysfs_remove_group(&dev->kobj, groups[i]); | 330 | sysfs_remove_group(&dev->kobj, |
331 | groups[i]); | ||
331 | break; | 332 | break; |
332 | } | 333 | } |
333 | } | 334 | } |
@@ -406,14 +407,12 @@ static struct device_attribute devt_attr = | |||
406 | /* kset to create /sys/devices/ */ | 407 | /* kset to create /sys/devices/ */ |
407 | struct kset *devices_kset; | 408 | struct kset *devices_kset; |
408 | 409 | ||
409 | |||
410 | /** | 410 | /** |
411 | * device_create_file - create sysfs attribute file for device. | 411 | * device_create_file - create sysfs attribute file for device. |
412 | * @dev: device. | 412 | * @dev: device. |
413 | * @attr: device attribute descriptor. | 413 | * @attr: device attribute descriptor. |
414 | */ | 414 | */ |
415 | 415 | int device_create_file(struct device *dev, struct device_attribute *attr) | |
416 | int device_create_file(struct device * dev, struct device_attribute * attr) | ||
417 | { | 416 | { |
418 | int error = 0; | 417 | int error = 0; |
419 | if (get_device(dev)) { | 418 | if (get_device(dev)) { |
@@ -424,12 +423,11 @@ int device_create_file(struct device * dev, struct device_attribute * attr) | |||
424 | } | 423 | } |
425 | 424 | ||
426 | /** | 425 | /** |
427 | * device_remove_file - remove sysfs attribute file. | 426 | * device_remove_file - remove sysfs attribute file. |
428 | * @dev: device. | 427 | * @dev: device. |
429 | * @attr: device attribute descriptor. | 428 | * @attr: device attribute descriptor. |
430 | */ | 429 | */ |
431 | 430 | void device_remove_file(struct device *dev, struct device_attribute *attr) | |
432 | void device_remove_file(struct device * dev, struct device_attribute * attr) | ||
433 | { | 431 | { |
434 | if (get_device(dev)) { | 432 | if (get_device(dev)) { |
435 | sysfs_remove_file(&dev->kobj, &attr->attr); | 433 | sysfs_remove_file(&dev->kobj, &attr->attr); |
@@ -510,18 +508,16 @@ static void klist_children_put(struct klist_node *n) | |||
510 | put_device(dev); | 508 | put_device(dev); |
511 | } | 509 | } |
512 | 510 | ||
513 | |||
514 | /** | 511 | /** |
515 | * device_initialize - init device structure. | 512 | * device_initialize - init device structure. |
516 | * @dev: device. | 513 | * @dev: device. |
517 | * | 514 | * |
518 | * This prepares the device for use by other layers, | 515 | * This prepares the device for use by other layers, |
519 | * including adding it to the device hierarchy. | 516 | * including adding it to the device hierarchy. |
520 | * It is the first half of device_register(), if called by | 517 | * It is the first half of device_register(), if called by |
521 | * that, though it can also be called separately, so one | 518 | * that, though it can also be called separately, so one |
522 | * may use @dev's fields (e.g. the refcount). | 519 | * may use @dev's fields (e.g. the refcount). |
523 | */ | 520 | */ |
524 | |||
525 | void device_initialize(struct device *dev) | 521 | void device_initialize(struct device *dev) |
526 | { | 522 | { |
527 | dev->kobj.kset = devices_kset; | 523 | dev->kobj.kset = devices_kset; |
@@ -754,15 +750,15 @@ static void device_remove_class_symlinks(struct device *dev) | |||
754 | } | 750 | } |
755 | 751 | ||
756 | /** | 752 | /** |
757 | * device_add - add device to device hierarchy. | 753 | * device_add - add device to device hierarchy. |
758 | * @dev: device. | 754 | * @dev: device. |
759 | * | 755 | * |
760 | * This is part 2 of device_register(), though may be called | 756 | * This is part 2 of device_register(), though may be called |
761 | * separately _iff_ device_initialize() has been called separately. | 757 | * separately _iff_ device_initialize() has been called separately. |
762 | * | 758 | * |
763 | * This adds it to the kobject hierarchy via kobject_add(), adds it | 759 | * This adds it to the kobject hierarchy via kobject_add(), adds it |
764 | * to the global and sibling lists for the device, then | 760 | * to the global and sibling lists for the device, then |
765 | * adds it to the other relevant subsystems of the driver model. | 761 | * adds it to the other relevant subsystems of the driver model. |
766 | */ | 762 | */ |
767 | int device_add(struct device *dev) | 763 | int device_add(struct device *dev) |
768 | { | 764 | { |
@@ -870,70 +866,63 @@ int device_add(struct device *dev) | |||
870 | goto Done; | 866 | goto Done; |
871 | } | 867 | } |
872 | 868 | ||
873 | |||
874 | /** | 869 | /** |
875 | * device_register - register a device with the system. | 870 | * device_register - register a device with the system. |
876 | * @dev: pointer to the device structure | 871 | * @dev: pointer to the device structure |
877 | * | 872 | * |
878 | * This happens in two clean steps - initialize the device | 873 | * This happens in two clean steps - initialize the device |
879 | * and add it to the system. The two steps can be called | 874 | * and add it to the system. The two steps can be called |
880 | * separately, but this is the easiest and most common. | 875 | * separately, but this is the easiest and most common. |
881 | * I.e. you should only call the two helpers separately if | 876 | * I.e. you should only call the two helpers separately if |
882 | * have a clearly defined need to use and refcount the device | 877 | * have a clearly defined need to use and refcount the device |
883 | * before it is added to the hierarchy. | 878 | * before it is added to the hierarchy. |
884 | */ | 879 | */ |
885 | |||
886 | int device_register(struct device *dev) | 880 | int device_register(struct device *dev) |
887 | { | 881 | { |
888 | device_initialize(dev); | 882 | device_initialize(dev); |
889 | return device_add(dev); | 883 | return device_add(dev); |
890 | } | 884 | } |
891 | 885 | ||
892 | |||
893 | /** | 886 | /** |
894 | * get_device - increment reference count for device. | 887 | * get_device - increment reference count for device. |
895 | * @dev: device. | 888 | * @dev: device. |
896 | * | 889 | * |
897 | * This simply forwards the call to kobject_get(), though | 890 | * This simply forwards the call to kobject_get(), though |
898 | * we do take care to provide for the case that we get a NULL | 891 | * we do take care to provide for the case that we get a NULL |
899 | * pointer passed in. | 892 | * pointer passed in. |
900 | */ | 893 | */ |
901 | 894 | struct device *get_device(struct device *dev) | |
902 | struct device * get_device(struct device * dev) | ||
903 | { | 895 | { |
904 | return dev ? to_dev(kobject_get(&dev->kobj)) : NULL; | 896 | return dev ? to_dev(kobject_get(&dev->kobj)) : NULL; |
905 | } | 897 | } |
906 | 898 | ||
907 | |||
908 | /** | 899 | /** |
909 | * put_device - decrement reference count. | 900 | * put_device - decrement reference count. |
910 | * @dev: device in question. | 901 | * @dev: device in question. |
911 | */ | 902 | */ |
912 | void put_device(struct device * dev) | 903 | void put_device(struct device *dev) |
913 | { | 904 | { |
914 | /* might_sleep(); */ | 905 | /* might_sleep(); */ |
915 | if (dev) | 906 | if (dev) |
916 | kobject_put(&dev->kobj); | 907 | kobject_put(&dev->kobj); |
917 | } | 908 | } |
918 | 909 | ||
919 | |||
920 | /** | 910 | /** |
921 | * device_del - delete device from system. | 911 | * device_del - delete device from system. |
922 | * @dev: device. | 912 | * @dev: device. |
923 | * | 913 | * |
924 | * This is the first part of the device unregistration | 914 | * This is the first part of the device unregistration |
925 | * sequence. This removes the device from the lists we control | 915 | * sequence. This removes the device from the lists we control |
926 | * from here, has it removed from the other driver model | 916 | * from here, has it removed from the other driver model |
927 | * subsystems it was added to in device_add(), and removes it | 917 | * subsystems it was added to in device_add(), and removes it |
928 | * from the kobject hierarchy. | 918 | * from the kobject hierarchy. |
929 | * | 919 | * |
930 | * NOTE: this should be called manually _iff_ device_add() was | 920 | * NOTE: this should be called manually _iff_ device_add() was |
931 | * also called manually. | 921 | * also called manually. |
932 | */ | 922 | */ |
933 | 923 | void device_del(struct device *dev) | |
934 | void device_del(struct device * dev) | ||
935 | { | 924 | { |
936 | struct device * parent = dev->parent; | 925 | struct device *parent = dev->parent; |
937 | struct class_interface *class_intf; | 926 | struct class_interface *class_intf; |
938 | 927 | ||
939 | device_pm_remove(dev); | 928 | device_pm_remove(dev); |
@@ -979,47 +968,46 @@ void device_del(struct device * dev) | |||
979 | } | 968 | } |
980 | 969 | ||
981 | /** | 970 | /** |
982 | * device_unregister - unregister device from system. | 971 | * device_unregister - unregister device from system. |
983 | * @dev: device going away. | 972 | * @dev: device going away. |
984 | * | 973 | * |
985 | * We do this in two parts, like we do device_register(). First, | 974 | * We do this in two parts, like we do device_register(). First, |
986 | * we remove it from all the subsystems with device_del(), then | 975 | * we remove it from all the subsystems with device_del(), then |
987 | * we decrement the reference count via put_device(). If that | 976 | * we decrement the reference count via put_device(). If that |
988 | * is the final reference count, the device will be cleaned up | 977 | * is the final reference count, the device will be cleaned up |
989 | * via device_release() above. Otherwise, the structure will | 978 | * via device_release() above. Otherwise, the structure will |
990 | * stick around until the final reference to the device is dropped. | 979 | * stick around until the final reference to the device is dropped. |
991 | */ | 980 | */ |
992 | void device_unregister(struct device * dev) | 981 | void device_unregister(struct device *dev) |
993 | { | 982 | { |
994 | pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__); | 983 | pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__); |
995 | device_del(dev); | 984 | device_del(dev); |
996 | put_device(dev); | 985 | put_device(dev); |
997 | } | 986 | } |
998 | 987 | ||
999 | 988 | static struct device *next_device(struct klist_iter *i) | |
1000 | static struct device * next_device(struct klist_iter * i) | ||
1001 | { | 989 | { |
1002 | struct klist_node * n = klist_next(i); | 990 | struct klist_node *n = klist_next(i); |
1003 | return n ? container_of(n, struct device, knode_parent) : NULL; | 991 | return n ? container_of(n, struct device, knode_parent) : NULL; |
1004 | } | 992 | } |
1005 | 993 | ||
1006 | /** | 994 | /** |
1007 | * device_for_each_child - device child iterator. | 995 | * device_for_each_child - device child iterator. |
1008 | * @parent: parent struct device. | 996 | * @parent: parent struct device. |
1009 | * @data: data for the callback. | 997 | * @data: data for the callback. |
1010 | * @fn: function to be called for each device. | 998 | * @fn: function to be called for each device. |
1011 | * | 999 | * |
1012 | * Iterate over @parent's child devices, and call @fn for each, | 1000 | * Iterate over @parent's child devices, and call @fn for each, |
1013 | * passing it @data. | 1001 | * passing it @data. |
1014 | * | 1002 | * |
1015 | * We check the return of @fn each time. If it returns anything | 1003 | * We check the return of @fn each time. If it returns anything |
1016 | * other than 0, we break out and return that value. | 1004 | * other than 0, we break out and return that value. |
1017 | */ | 1005 | */ |
1018 | int device_for_each_child(struct device * parent, void * data, | 1006 | int device_for_each_child(struct device *parent, void *data, |
1019 | int (*fn)(struct device *, void *)) | 1007 | int (*fn)(struct device *dev, void *data)) |
1020 | { | 1008 | { |
1021 | struct klist_iter i; | 1009 | struct klist_iter i; |
1022 | struct device * child; | 1010 | struct device *child; |
1023 | int error = 0; | 1011 | int error = 0; |
1024 | 1012 | ||
1025 | klist_iter_init(&parent->klist_children, &i); | 1013 | klist_iter_init(&parent->klist_children, &i); |
@@ -1044,8 +1032,8 @@ int device_for_each_child(struct device * parent, void * data, | |||
1044 | * current device can be obtained, this function will return to the caller | 1032 | * current device can be obtained, this function will return to the caller |
1045 | * and not iterate over any more devices. | 1033 | * and not iterate over any more devices. |
1046 | */ | 1034 | */ |
1047 | struct device * device_find_child(struct device *parent, void *data, | 1035 | struct device *device_find_child(struct device *parent, void *data, |
1048 | int (*match)(struct device *, void *)) | 1036 | int (*match)(struct device *dev, void *data)) |
1049 | { | 1037 | { |
1050 | struct klist_iter i; | 1038 | struct klist_iter i; |
1051 | struct device *child; | 1039 | struct device *child; |
@@ -1312,8 +1300,7 @@ static int device_move_class_links(struct device *dev, | |||
1312 | class_name); | 1300 | class_name); |
1313 | if (error) | 1301 | if (error) |
1314 | sysfs_remove_link(&dev->kobj, "device"); | 1302 | sysfs_remove_link(&dev->kobj, "device"); |
1315 | } | 1303 | } else |
1316 | else | ||
1317 | error = 0; | 1304 | error = 0; |
1318 | out: | 1305 | out: |
1319 | kfree(class_name); | 1306 | kfree(class_name); |
@@ -1344,7 +1331,7 @@ int device_move(struct device *dev, struct device *new_parent) | |||
1344 | return -EINVAL; | 1331 | return -EINVAL; |
1345 | 1332 | ||
1346 | new_parent = get_device(new_parent); | 1333 | new_parent = get_device(new_parent); |
1347 | new_parent_kobj = get_device_parent (dev, new_parent); | 1334 | new_parent_kobj = get_device_parent(dev, new_parent); |
1348 | 1335 | ||
1349 | pr_debug("device: '%s': %s: moving to '%s'\n", dev->bus_id, | 1336 | pr_debug("device: '%s': %s: moving to '%s'\n", dev->bus_id, |
1350 | __FUNCTION__, new_parent ? new_parent->bus_id : "<NULL>"); | 1337 | __FUNCTION__, new_parent ? new_parent->bus_id : "<NULL>"); |
@@ -1390,7 +1377,7 @@ EXPORT_SYMBOL_GPL(device_move); | |||
1390 | */ | 1377 | */ |
1391 | void device_shutdown(void) | 1378 | void device_shutdown(void) |
1392 | { | 1379 | { |
1393 | struct device * dev, *devn; | 1380 | struct device *dev, *devn; |
1394 | 1381 | ||
1395 | list_for_each_entry_safe_reverse(dev, devn, &devices_kset->list, | 1382 | list_for_each_entry_safe_reverse(dev, devn, &devices_kset->list, |
1396 | kobj.entry) { | 1383 | kobj.entry) { |
diff --git a/drivers/base/dd.c b/drivers/base/dd.c index b0726eb6405e..a5cde94bb982 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c | |||
@@ -1,20 +1,20 @@ | |||
1 | /* | 1 | /* |
2 | * drivers/base/dd.c - The core device/driver interactions. | 2 | * drivers/base/dd.c - The core device/driver interactions. |
3 | * | 3 | * |
4 | * This file contains the (sometimes tricky) code that controls the | 4 | * This file contains the (sometimes tricky) code that controls the |
5 | * interactions between devices and drivers, which primarily includes | 5 | * interactions between devices and drivers, which primarily includes |
6 | * driver binding and unbinding. | 6 | * driver binding and unbinding. |
7 | * | 7 | * |
8 | * All of this code used to exist in drivers/base/bus.c, but was | 8 | * All of this code used to exist in drivers/base/bus.c, but was |
9 | * relocated to here in the name of compartmentalization (since it wasn't | 9 | * relocated to here in the name of compartmentalization (since it wasn't |
10 | * strictly code just for the 'struct bus_type'. | 10 | * strictly code just for the 'struct bus_type'. |
11 | * | 11 | * |
12 | * Copyright (c) 2002-5 Patrick Mochel | 12 | * Copyright (c) 2002-5 Patrick Mochel |
13 | * Copyright (c) 2002-3 Open Source Development Labs | 13 | * Copyright (c) 2002-3 Open Source Development Labs |
14 | * Copyright (c) 2007 Greg Kroah-Hartman <gregkh@suse.de> | 14 | * Copyright (c) 2007 Greg Kroah-Hartman <gregkh@suse.de> |
15 | * Copyright (c) 2007 Novell Inc. | 15 | * Copyright (c) 2007 Novell Inc. |
16 | * | 16 | * |
17 | * This file is released under the GPLv2 | 17 | * This file is released under the GPLv2 |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/device.h> | 20 | #include <linux/device.h> |
@@ -71,18 +71,18 @@ static void driver_sysfs_remove(struct device *dev) | |||
71 | } | 71 | } |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * device_bind_driver - bind a driver to one device. | 74 | * device_bind_driver - bind a driver to one device. |
75 | * @dev: device. | 75 | * @dev: device. |
76 | * | 76 | * |
77 | * Allow manual attachment of a driver to a device. | 77 | * Allow manual attachment of a driver to a device. |
78 | * Caller must have already set @dev->driver. | 78 | * Caller must have already set @dev->driver. |
79 | * | 79 | * |
80 | * Note that this does not modify the bus reference count | 80 | * Note that this does not modify the bus reference count |
81 | * nor take the bus's rwsem. Please verify those are accounted | 81 | * nor take the bus's rwsem. Please verify those are accounted |
82 | * for before calling this. (It is ok to call with no other effort | 82 | * for before calling this. (It is ok to call with no other effort |
83 | * from a driver's probe() method.) | 83 | * from a driver's probe() method.) |
84 | * | 84 | * |
85 | * This function must be called with @dev->sem held. | 85 | * This function must be called with @dev->sem held. |
86 | */ | 86 | */ |
87 | int device_bind_driver(struct device *dev) | 87 | int device_bind_driver(struct device *dev) |
88 | { | 88 | { |
@@ -93,6 +93,7 @@ int device_bind_driver(struct device *dev) | |||
93 | driver_bound(dev); | 93 | driver_bound(dev); |
94 | return ret; | 94 | return ret; |
95 | } | 95 | } |
96 | EXPORT_SYMBOL_GPL(device_bind_driver); | ||
96 | 97 | ||
97 | static atomic_t probe_count = ATOMIC_INIT(0); | 98 | static atomic_t probe_count = ATOMIC_INIT(0); |
98 | static DECLARE_WAIT_QUEUE_HEAD(probe_waitqueue); | 99 | static DECLARE_WAIT_QUEUE_HEAD(probe_waitqueue); |
@@ -183,7 +184,7 @@ int driver_probe_done(void) | |||
183 | * This function must be called with @dev->sem held. When called for a | 184 | * This function must be called with @dev->sem held. When called for a |
184 | * USB interface, @dev->parent->sem must be held as well. | 185 | * USB interface, @dev->parent->sem must be held as well. |
185 | */ | 186 | */ |
186 | int driver_probe_device(struct device_driver * drv, struct device * dev) | 187 | int driver_probe_device(struct device_driver *drv, struct device *dev) |
187 | { | 188 | { |
188 | int ret = 0; | 189 | int ret = 0; |
189 | 190 | ||
@@ -201,27 +202,27 @@ done: | |||
201 | return ret; | 202 | return ret; |
202 | } | 203 | } |
203 | 204 | ||
204 | static int __device_attach(struct device_driver * drv, void * data) | 205 | static int __device_attach(struct device_driver *drv, void *data) |
205 | { | 206 | { |
206 | struct device * dev = data; | 207 | struct device *dev = data; |
207 | return driver_probe_device(drv, dev); | 208 | return driver_probe_device(drv, dev); |
208 | } | 209 | } |
209 | 210 | ||
210 | /** | 211 | /** |
211 | * device_attach - try to attach device to a driver. | 212 | * device_attach - try to attach device to a driver. |
212 | * @dev: device. | 213 | * @dev: device. |
213 | * | 214 | * |
214 | * Walk the list of drivers that the bus has and call | 215 | * Walk the list of drivers that the bus has and call |
215 | * driver_probe_device() for each pair. If a compatible | 216 | * driver_probe_device() for each pair. If a compatible |
216 | * pair is found, break out and return. | 217 | * pair is found, break out and return. |
217 | * | 218 | * |
218 | * Returns 1 if the device was bound to a driver; | 219 | * Returns 1 if the device was bound to a driver; |
219 | * 0 if no matching device was found; | 220 | * 0 if no matching device was found; |
220 | * -ENODEV if the device is not registered. | 221 | * -ENODEV if the device is not registered. |
221 | * | 222 | * |
222 | * When called for a USB interface, @dev->parent->sem must be held. | 223 | * When called for a USB interface, @dev->parent->sem must be held. |
223 | */ | 224 | */ |
224 | int device_attach(struct device * dev) | 225 | int device_attach(struct device *dev) |
225 | { | 226 | { |
226 | int ret = 0; | 227 | int ret = 0; |
227 | 228 | ||
@@ -240,10 +241,11 @@ int device_attach(struct device * dev) | |||
240 | up(&dev->sem); | 241 | up(&dev->sem); |
241 | return ret; | 242 | return ret; |
242 | } | 243 | } |
244 | EXPORT_SYMBOL_GPL(device_attach); | ||
243 | 245 | ||
244 | static int __driver_attach(struct device * dev, void * data) | 246 | static int __driver_attach(struct device *dev, void *data) |
245 | { | 247 | { |
246 | struct device_driver * drv = data; | 248 | struct device_driver *drv = data; |
247 | 249 | ||
248 | /* | 250 | /* |
249 | * Lock device and try to bind to it. We drop the error | 251 | * Lock device and try to bind to it. We drop the error |
@@ -268,26 +270,27 @@ static int __driver_attach(struct device * dev, void * data) | |||
268 | } | 270 | } |
269 | 271 | ||
270 | /** | 272 | /** |
271 | * driver_attach - try to bind driver to devices. | 273 | * driver_attach - try to bind driver to devices. |
272 | * @drv: driver. | 274 | * @drv: driver. |
273 | * | 275 | * |
274 | * Walk the list of devices that the bus has on it and try to | 276 | * Walk the list of devices that the bus has on it and try to |
275 | * match the driver with each one. If driver_probe_device() | 277 | * match the driver with each one. If driver_probe_device() |
276 | * returns 0 and the @dev->driver is set, we've found a | 278 | * returns 0 and the @dev->driver is set, we've found a |
277 | * compatible pair. | 279 | * compatible pair. |
278 | */ | 280 | */ |
279 | int driver_attach(struct device_driver * drv) | 281 | int driver_attach(struct device_driver *drv) |
280 | { | 282 | { |
281 | return bus_for_each_dev(drv->bus, NULL, drv, __driver_attach); | 283 | return bus_for_each_dev(drv->bus, NULL, drv, __driver_attach); |
282 | } | 284 | } |
285 | EXPORT_SYMBOL_GPL(driver_attach); | ||
283 | 286 | ||
284 | /* | 287 | /* |
285 | * __device_release_driver() must be called with @dev->sem held. | 288 | * __device_release_driver() must be called with @dev->sem held. |
286 | * When called for a USB interface, @dev->parent->sem must be held as well. | 289 | * When called for a USB interface, @dev->parent->sem must be held as well. |
287 | */ | 290 | */ |
288 | static void __device_release_driver(struct device * dev) | 291 | static void __device_release_driver(struct device *dev) |
289 | { | 292 | { |
290 | struct device_driver * drv; | 293 | struct device_driver *drv; |
291 | 294 | ||
292 | drv = dev->driver; | 295 | drv = dev->driver; |
293 | if (drv) { | 296 | if (drv) { |
@@ -310,13 +313,13 @@ static void __device_release_driver(struct device * dev) | |||
310 | } | 313 | } |
311 | 314 | ||
312 | /** | 315 | /** |
313 | * device_release_driver - manually detach device from driver. | 316 | * device_release_driver - manually detach device from driver. |
314 | * @dev: device. | 317 | * @dev: device. |
315 | * | 318 | * |
316 | * Manually detach device from driver. | 319 | * Manually detach device from driver. |
317 | * When called for a USB interface, @dev->parent->sem must be held. | 320 | * When called for a USB interface, @dev->parent->sem must be held. |
318 | */ | 321 | */ |
319 | void device_release_driver(struct device * dev) | 322 | void device_release_driver(struct device *dev) |
320 | { | 323 | { |
321 | /* | 324 | /* |
322 | * If anyone calls device_release_driver() recursively from | 325 | * If anyone calls device_release_driver() recursively from |
@@ -327,15 +330,15 @@ void device_release_driver(struct device * dev) | |||
327 | __device_release_driver(dev); | 330 | __device_release_driver(dev); |
328 | up(&dev->sem); | 331 | up(&dev->sem); |
329 | } | 332 | } |
330 | 333 | EXPORT_SYMBOL_GPL(device_release_driver); | |
331 | 334 | ||
332 | /** | 335 | /** |
333 | * driver_detach - detach driver from all devices it controls. | 336 | * driver_detach - detach driver from all devices it controls. |
334 | * @drv: driver. | 337 | * @drv: driver. |
335 | */ | 338 | */ |
336 | void driver_detach(struct device_driver * drv) | 339 | void driver_detach(struct device_driver *drv) |
337 | { | 340 | { |
338 | struct device * dev; | 341 | struct device *dev; |
339 | 342 | ||
340 | for (;;) { | 343 | for (;;) { |
341 | spin_lock(&drv->p->klist_devices.k_lock); | 344 | spin_lock(&drv->p->klist_devices.k_lock); |
@@ -359,9 +362,3 @@ void driver_detach(struct device_driver * drv) | |||
359 | put_device(dev); | 362 | put_device(dev); |
360 | } | 363 | } |
361 | } | 364 | } |
362 | |||
363 | EXPORT_SYMBOL_GPL(device_bind_driver); | ||
364 | EXPORT_SYMBOL_GPL(device_release_driver); | ||
365 | EXPORT_SYMBOL_GPL(device_attach); | ||
366 | EXPORT_SYMBOL_GPL(driver_attach); | ||
367 | |||
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 | ||
22 | static struct device * next_device(struct klist_iter * i) | 22 | static 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 | 37 | int driver_for_each_device(struct device_driver *drv, struct device *start, | |
38 | int 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 | |||
56 | EXPORT_SYMBOL_GPL(driver_for_each_device); | 54 | EXPORT_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 | */ |
74 | struct device * driver_find_device(struct device_driver *drv, | 71 | struct 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, | |||
92 | EXPORT_SYMBOL_GPL(driver_find_device); | 89 | EXPORT_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 | 96 | int driver_create_file(struct device_driver *drv, | |
100 | int 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 | 107 | EXPORT_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 | 114 | void driver_remove_file(struct device_driver *drv, | |
118 | void 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 | 122 | EXPORT_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, | |||
149 | EXPORT_SYMBOL_GPL(driver_add_kobj); | 146 | EXPORT_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 | */ |
155 | struct device_driver * get_driver(struct device_driver * drv) | 152 | struct 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 | 164 | EXPORT_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 | */ |
173 | void put_driver(struct device_driver * drv) | 170 | void put_driver(struct device_driver *drv) |
174 | { | 171 | { |
175 | kobject_put(&drv->p->kobj); | 172 | kobject_put(&drv->p->kobj); |
176 | } | 173 | } |
174 | EXPORT_SYMBOL_GPL(put_driver); | ||
177 | 175 | ||
178 | static int driver_add_groups(struct device_driver *drv, | 176 | static 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 | */ |
217 | int driver_register(struct device_driver * drv) | 214 | int 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 | } |
231 | EXPORT_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 | 239 | void driver_unregister(struct device_driver *drv) | |
242 | void 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 | } |
244 | EXPORT_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 | */ |
258 | struct device_driver *driver_find(const char *name, struct bus_type *bus) | 256 | struct 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 | |||
270 | EXPORT_SYMBOL_GPL(driver_register); | ||
271 | EXPORT_SYMBOL_GPL(driver_unregister); | ||
272 | EXPORT_SYMBOL_GPL(get_driver); | ||
273 | EXPORT_SYMBOL_GPL(put_driver); | ||
274 | EXPORT_SYMBOL_GPL(driver_find); | 267 | EXPORT_SYMBOL_GPL(driver_find); |
275 | |||
276 | EXPORT_SYMBOL_GPL(driver_create_file); | ||
277 | EXPORT_SYMBOL_GPL(driver_remove_file); | ||
diff --git a/drivers/base/init.c b/drivers/base/init.c index 1da88a10cfec..7bd9b6a5b01f 100644 --- a/drivers/base/init.c +++ b/drivers/base/init.c | |||
@@ -1,10 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * | ||
3 | * Copyright (c) 2002-3 Patrick Mochel | 2 | * Copyright (c) 2002-3 Patrick Mochel |
4 | * Copyright (c) 2002-3 Open Source Development Labs | 3 | * Copyright (c) 2002-3 Open Source Development Labs |
5 | * | 4 | * |
6 | * This file is released under the GPLv2 | 5 | * This file is released under the GPLv2 |
7 | * | ||
8 | */ | 6 | */ |
9 | 7 | ||
10 | #include <linux/device.h> | 8 | #include <linux/device.h> |
@@ -14,12 +12,11 @@ | |||
14 | #include "base.h" | 12 | #include "base.h" |
15 | 13 | ||
16 | /** | 14 | /** |
17 | * driver_init - initialize driver model. | 15 | * driver_init - initialize driver model. |
18 | * | 16 | * |
19 | * Call the driver model init functions to initialize their | 17 | * Call the driver model init functions to initialize their |
20 | * subsystems. Called early from init/main.c. | 18 | * subsystems. Called early from init/main.c. |
21 | */ | 19 | */ |
22 | |||
23 | void __init driver_init(void) | 20 | void __init driver_init(void) |
24 | { | 21 | { |
25 | /* These are the core pieces */ | 22 | /* These are the core pieces */ |
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 48d5db4f92ee..efaf282c438c 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
@@ -20,7 +20,8 @@ | |||
20 | 20 | ||
21 | #include "base.h" | 21 | #include "base.h" |
22 | 22 | ||
23 | #define to_platform_driver(drv) (container_of((drv), struct platform_driver, driver)) | 23 | #define to_platform_driver(drv) (container_of((drv), struct platform_driver, \ |
24 | driver)) | ||
24 | 25 | ||
25 | struct device platform_bus = { | 26 | struct device platform_bus = { |
26 | .bus_id = "platform", | 27 | .bus_id = "platform", |
@@ -28,14 +29,13 @@ struct device platform_bus = { | |||
28 | EXPORT_SYMBOL_GPL(platform_bus); | 29 | EXPORT_SYMBOL_GPL(platform_bus); |
29 | 30 | ||
30 | /** | 31 | /** |
31 | * platform_get_resource - get a resource for a device | 32 | * platform_get_resource - get a resource for a device |
32 | * @dev: platform device | 33 | * @dev: platform device |
33 | * @type: resource type | 34 | * @type: resource type |
34 | * @num: resource index | 35 | * @num: resource index |
35 | */ | 36 | */ |
36 | struct resource * | 37 | struct resource *platform_get_resource(struct platform_device *dev, |
37 | platform_get_resource(struct platform_device *dev, unsigned int type, | 38 | unsigned int type, unsigned int num) |
38 | unsigned int num) | ||
39 | { | 39 | { |
40 | int i; | 40 | int i; |
41 | 41 | ||
@@ -43,8 +43,7 @@ platform_get_resource(struct platform_device *dev, unsigned int type, | |||
43 | struct resource *r = &dev->resource[i]; | 43 | struct resource *r = &dev->resource[i]; |
44 | 44 | ||
45 | if ((r->flags & (IORESOURCE_IO|IORESOURCE_MEM| | 45 | if ((r->flags & (IORESOURCE_IO|IORESOURCE_MEM| |
46 | IORESOURCE_IRQ|IORESOURCE_DMA)) | 46 | IORESOURCE_IRQ|IORESOURCE_DMA)) == type) |
47 | == type) | ||
48 | if (num-- == 0) | 47 | if (num-- == 0) |
49 | return r; | 48 | return r; |
50 | } | 49 | } |
@@ -53,9 +52,9 @@ platform_get_resource(struct platform_device *dev, unsigned int type, | |||
53 | EXPORT_SYMBOL_GPL(platform_get_resource); | 52 | EXPORT_SYMBOL_GPL(platform_get_resource); |
54 | 53 | ||
55 | /** | 54 | /** |
56 | * platform_get_irq - get an IRQ for a device | 55 | * platform_get_irq - get an IRQ for a device |
57 | * @dev: platform device | 56 | * @dev: platform device |
58 | * @num: IRQ number index | 57 | * @num: IRQ number index |
59 | */ | 58 | */ |
60 | int platform_get_irq(struct platform_device *dev, unsigned int num) | 59 | int platform_get_irq(struct platform_device *dev, unsigned int num) |
61 | { | 60 | { |
@@ -66,14 +65,13 @@ int platform_get_irq(struct platform_device *dev, unsigned int num) | |||
66 | EXPORT_SYMBOL_GPL(platform_get_irq); | 65 | EXPORT_SYMBOL_GPL(platform_get_irq); |
67 | 66 | ||
68 | /** | 67 | /** |
69 | * platform_get_resource_byname - get a resource for a device by name | 68 | * platform_get_resource_byname - get a resource for a device by name |
70 | * @dev: platform device | 69 | * @dev: platform device |
71 | * @type: resource type | 70 | * @type: resource type |
72 | * @name: resource name | 71 | * @name: resource name |
73 | */ | 72 | */ |
74 | struct resource * | 73 | struct resource *platform_get_resource_byname(struct platform_device *dev, |
75 | platform_get_resource_byname(struct platform_device *dev, unsigned int type, | 74 | unsigned int type, char *name) |
76 | char *name) | ||
77 | { | 75 | { |
78 | int i; | 76 | int i; |
79 | 77 | ||
@@ -90,22 +88,23 @@ platform_get_resource_byname(struct platform_device *dev, unsigned int type, | |||
90 | EXPORT_SYMBOL_GPL(platform_get_resource_byname); | 88 | EXPORT_SYMBOL_GPL(platform_get_resource_byname); |
91 | 89 | ||
92 | /** | 90 | /** |
93 | * platform_get_irq - get an IRQ for a device | 91 | * platform_get_irq - get an IRQ for a device |
94 | * @dev: platform device | 92 | * @dev: platform device |
95 | * @name: IRQ name | 93 | * @name: IRQ name |
96 | */ | 94 | */ |
97 | int platform_get_irq_byname(struct platform_device *dev, char *name) | 95 | int platform_get_irq_byname(struct platform_device *dev, char *name) |
98 | { | 96 | { |
99 | struct resource *r = platform_get_resource_byname(dev, IORESOURCE_IRQ, name); | 97 | struct resource *r = platform_get_resource_byname(dev, IORESOURCE_IRQ, |
98 | name); | ||
100 | 99 | ||
101 | return r ? r->start : -ENXIO; | 100 | return r ? r->start : -ENXIO; |
102 | } | 101 | } |
103 | EXPORT_SYMBOL_GPL(platform_get_irq_byname); | 102 | EXPORT_SYMBOL_GPL(platform_get_irq_byname); |
104 | 103 | ||
105 | /** | 104 | /** |
106 | * platform_add_devices - add a numbers of platform devices | 105 | * platform_add_devices - add a numbers of platform devices |
107 | * @devs: array of platform devices to add | 106 | * @devs: array of platform devices to add |
108 | * @num: number of platform devices in array | 107 | * @num: number of platform devices in array |
109 | */ | 108 | */ |
110 | int platform_add_devices(struct platform_device **devs, int num) | 109 | int platform_add_devices(struct platform_device **devs, int num) |
111 | { | 110 | { |
@@ -130,12 +129,11 @@ struct platform_object { | |||
130 | }; | 129 | }; |
131 | 130 | ||
132 | /** | 131 | /** |
133 | * platform_device_put | 132 | * platform_device_put |
134 | * @pdev: platform device to free | 133 | * @pdev: platform device to free |
135 | * | 134 | * |
136 | * Free all memory associated with a platform device. This function | 135 | * Free all memory associated with a platform device. This function must |
137 | * must _only_ be externally called in error cases. All other usage | 136 | * _only_ be externally called in error cases. All other usage is a bug. |
138 | * is a bug. | ||
139 | */ | 137 | */ |
140 | void platform_device_put(struct platform_device *pdev) | 138 | void platform_device_put(struct platform_device *pdev) |
141 | { | 139 | { |
@@ -146,7 +144,8 @@ EXPORT_SYMBOL_GPL(platform_device_put); | |||
146 | 144 | ||
147 | static void platform_device_release(struct device *dev) | 145 | static void platform_device_release(struct device *dev) |
148 | { | 146 | { |
149 | struct platform_object *pa = container_of(dev, struct platform_object, pdev.dev); | 147 | struct platform_object *pa = container_of(dev, struct platform_object, |
148 | pdev.dev); | ||
150 | 149 | ||
151 | kfree(pa->pdev.dev.platform_data); | 150 | kfree(pa->pdev.dev.platform_data); |
152 | kfree(pa->pdev.resource); | 151 | kfree(pa->pdev.resource); |
@@ -154,12 +153,12 @@ static void platform_device_release(struct device *dev) | |||
154 | } | 153 | } |
155 | 154 | ||
156 | /** | 155 | /** |
157 | * platform_device_alloc | 156 | * platform_device_alloc |
158 | * @name: base name of the device we're adding | 157 | * @name: base name of the device we're adding |
159 | * @id: instance id | 158 | * @id: instance id |
160 | * | 159 | * |
161 | * Create a platform device object which can have other objects attached | 160 | * Create a platform device object which can have other objects attached |
162 | * to it, and which will have attached objects freed when it is released. | 161 | * to it, and which will have attached objects freed when it is released. |
163 | */ | 162 | */ |
164 | struct platform_device *platform_device_alloc(const char *name, int id) | 163 | struct platform_device *platform_device_alloc(const char *name, int id) |
165 | { | 164 | { |
@@ -179,16 +178,17 @@ struct platform_device *platform_device_alloc(const char *name, int id) | |||
179 | EXPORT_SYMBOL_GPL(platform_device_alloc); | 178 | EXPORT_SYMBOL_GPL(platform_device_alloc); |
180 | 179 | ||
181 | /** | 180 | /** |
182 | * platform_device_add_resources | 181 | * platform_device_add_resources |
183 | * @pdev: platform device allocated by platform_device_alloc to add resources to | 182 | * @pdev: platform device allocated by platform_device_alloc to add resources to |
184 | * @res: set of resources that needs to be allocated for the device | 183 | * @res: set of resources that needs to be allocated for the device |
185 | * @num: number of resources | 184 | * @num: number of resources |
186 | * | 185 | * |
187 | * Add a copy of the resources to the platform device. The memory | 186 | * Add a copy of the resources to the platform device. The memory |
188 | * associated with the resources will be freed when the platform | 187 | * associated with the resources will be freed when the platform device is |
189 | * device is released. | 188 | * released. |
190 | */ | 189 | */ |
191 | int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num) | 190 | int platform_device_add_resources(struct platform_device *pdev, |
191 | struct resource *res, unsigned int num) | ||
192 | { | 192 | { |
193 | struct resource *r; | 193 | struct resource *r; |
194 | 194 | ||
@@ -203,16 +203,17 @@ int platform_device_add_resources(struct platform_device *pdev, struct resource | |||
203 | EXPORT_SYMBOL_GPL(platform_device_add_resources); | 203 | EXPORT_SYMBOL_GPL(platform_device_add_resources); |
204 | 204 | ||
205 | /** | 205 | /** |
206 | * platform_device_add_data | 206 | * platform_device_add_data |
207 | * @pdev: platform device allocated by platform_device_alloc to add resources to | 207 | * @pdev: platform device allocated by platform_device_alloc to add resources to |
208 | * @data: platform specific data for this platform device | 208 | * @data: platform specific data for this platform device |
209 | * @size: size of platform specific data | 209 | * @size: size of platform specific data |
210 | * | 210 | * |
211 | * Add a copy of platform specific data to the platform device's platform_data | 211 | * Add a copy of platform specific data to the platform device's |
212 | * pointer. The memory associated with the platform data will be freed | 212 | * platform_data pointer. The memory associated with the platform data |
213 | * when the platform device is released. | 213 | * will be freed when the platform device is released. |
214 | */ | 214 | */ |
215 | int platform_device_add_data(struct platform_device *pdev, const void *data, size_t size) | 215 | int platform_device_add_data(struct platform_device *pdev, const void *data, |
216 | size_t size) | ||
216 | { | 217 | { |
217 | void *d; | 218 | void *d; |
218 | 219 | ||
@@ -226,11 +227,11 @@ int platform_device_add_data(struct platform_device *pdev, const void *data, siz | |||
226 | EXPORT_SYMBOL_GPL(platform_device_add_data); | 227 | EXPORT_SYMBOL_GPL(platform_device_add_data); |
227 | 228 | ||
228 | /** | 229 | /** |
229 | * platform_device_add - add a platform device to device hierarchy | 230 | * platform_device_add - add a platform device to device hierarchy |
230 | * @pdev: platform device we're adding | 231 | * @pdev: platform device we're adding |
231 | * | 232 | * |
232 | * This is part 2 of platform_device_register(), though may be called | 233 | * This is part 2 of platform_device_register(), though may be called |
233 | * separately _iff_ pdev was allocated by platform_device_alloc(). | 234 | * separately _iff_ pdev was allocated by platform_device_alloc(). |
234 | */ | 235 | */ |
235 | int platform_device_add(struct platform_device *pdev) | 236 | int platform_device_add(struct platform_device *pdev) |
236 | { | 237 | { |
@@ -289,13 +290,12 @@ int platform_device_add(struct platform_device *pdev) | |||
289 | EXPORT_SYMBOL_GPL(platform_device_add); | 290 | EXPORT_SYMBOL_GPL(platform_device_add); |
290 | 291 | ||
291 | /** | 292 | /** |
292 | * platform_device_del - remove a platform-level device | 293 | * platform_device_del - remove a platform-level device |
293 | * @pdev: platform device we're removing | 294 | * @pdev: platform device we're removing |
294 | * | 295 | * |
295 | * Note that this function will also release all memory- and port-based | 296 | * Note that this function will also release all memory- and port-based |
296 | * resources owned by the device (@dev->resource). This function | 297 | * resources owned by the device (@dev->resource). This function must |
297 | * must _only_ be externally called in error cases. All other usage | 298 | * _only_ be externally called in error cases. All other usage is a bug. |
298 | * is a bug. | ||
299 | */ | 299 | */ |
300 | void platform_device_del(struct platform_device *pdev) | 300 | void platform_device_del(struct platform_device *pdev) |
301 | { | 301 | { |
@@ -314,11 +314,10 @@ void platform_device_del(struct platform_device *pdev) | |||
314 | EXPORT_SYMBOL_GPL(platform_device_del); | 314 | EXPORT_SYMBOL_GPL(platform_device_del); |
315 | 315 | ||
316 | /** | 316 | /** |
317 | * platform_device_register - add a platform-level device | 317 | * platform_device_register - add a platform-level device |
318 | * @pdev: platform device we're adding | 318 | * @pdev: platform device we're adding |
319 | * | ||
320 | */ | 319 | */ |
321 | int platform_device_register(struct platform_device * pdev) | 320 | int platform_device_register(struct platform_device *pdev) |
322 | { | 321 | { |
323 | device_initialize(&pdev->dev); | 322 | device_initialize(&pdev->dev); |
324 | return platform_device_add(pdev); | 323 | return platform_device_add(pdev); |
@@ -326,14 +325,14 @@ int platform_device_register(struct platform_device * pdev) | |||
326 | EXPORT_SYMBOL_GPL(platform_device_register); | 325 | EXPORT_SYMBOL_GPL(platform_device_register); |
327 | 326 | ||
328 | /** | 327 | /** |
329 | * platform_device_unregister - unregister a platform-level device | 328 | * platform_device_unregister - unregister a platform-level device |
330 | * @pdev: platform device we're unregistering | 329 | * @pdev: platform device we're unregistering |
331 | * | 330 | * |
332 | * Unregistration is done in 2 steps. First we release all resources | 331 | * Unregistration is done in 2 steps. First we release all resources |
333 | * and remove it from the subsystem, then we drop reference count by | 332 | * and remove it from the subsystem, then we drop reference count by |
334 | * calling platform_device_put(). | 333 | * calling platform_device_put(). |
335 | */ | 334 | */ |
336 | void platform_device_unregister(struct platform_device * pdev) | 335 | void platform_device_unregister(struct platform_device *pdev) |
337 | { | 336 | { |
338 | platform_device_del(pdev); | 337 | platform_device_del(pdev); |
339 | platform_device_put(pdev); | 338 | platform_device_put(pdev); |
@@ -341,27 +340,29 @@ void platform_device_unregister(struct platform_device * pdev) | |||
341 | EXPORT_SYMBOL_GPL(platform_device_unregister); | 340 | EXPORT_SYMBOL_GPL(platform_device_unregister); |
342 | 341 | ||
343 | /** | 342 | /** |
344 | * platform_device_register_simple | 343 | * platform_device_register_simple |
345 | * @name: base name of the device we're adding | 344 | * @name: base name of the device we're adding |
346 | * @id: instance id | 345 | * @id: instance id |
347 | * @res: set of resources that needs to be allocated for the device | 346 | * @res: set of resources that needs to be allocated for the device |
348 | * @num: number of resources | 347 | * @num: number of resources |
349 | * | 348 | * |
350 | * This function creates a simple platform device that requires minimal | 349 | * This function creates a simple platform device that requires minimal |
351 | * resource and memory management. Canned release function freeing | 350 | * resource and memory management. Canned release function freeing memory |
352 | * memory allocated for the device allows drivers using such devices | 351 | * allocated for the device allows drivers using such devices to be |
353 | * to be unloaded without waiting for the last reference to the device | 352 | * unloaded without waiting for the last reference to the device to be |
354 | * to be dropped. | 353 | * dropped. |
355 | * | 354 | * |
356 | * This interface is primarily intended for use with legacy drivers | 355 | * This interface is primarily intended for use with legacy drivers which |
357 | * which probe hardware directly. Because such drivers create sysfs | 356 | * probe hardware directly. Because such drivers create sysfs device nodes |
358 | * device nodes themselves, rather than letting system infrastructure | 357 | * themselves, rather than letting system infrastructure handle such device |
359 | * handle such device enumeration tasks, they don't fully conform to | 358 | * enumeration tasks, they don't fully conform to the Linux driver model. |
360 | * the Linux driver model. In particular, when such drivers are built | 359 | * In particular, when such drivers are built as modules, they can't be |
361 | * as modules, they can't be "hotplugged". | 360 | * "hotplugged". |
362 | */ | 361 | */ |
363 | struct platform_device *platform_device_register_simple(const char *name, int id, | 362 | struct platform_device *platform_device_register_simple(const char *name, |
364 | struct resource *res, unsigned int num) | 363 | int id, |
364 | struct resource *res, | ||
365 | unsigned int num) | ||
365 | { | 366 | { |
366 | struct platform_device *pdev; | 367 | struct platform_device *pdev; |
367 | int retval; | 368 | int retval; |
@@ -436,8 +437,8 @@ static int platform_drv_resume(struct device *_dev) | |||
436 | } | 437 | } |
437 | 438 | ||
438 | /** | 439 | /** |
439 | * platform_driver_register | 440 | * platform_driver_register |
440 | * @drv: platform driver structure | 441 | * @drv: platform driver structure |
441 | */ | 442 | */ |
442 | int platform_driver_register(struct platform_driver *drv) | 443 | int platform_driver_register(struct platform_driver *drv) |
443 | { | 444 | { |
@@ -457,8 +458,8 @@ int platform_driver_register(struct platform_driver *drv) | |||
457 | EXPORT_SYMBOL_GPL(platform_driver_register); | 458 | EXPORT_SYMBOL_GPL(platform_driver_register); |
458 | 459 | ||
459 | /** | 460 | /** |
460 | * platform_driver_unregister | 461 | * platform_driver_unregister |
461 | * @drv: platform driver structure | 462 | * @drv: platform driver structure |
462 | */ | 463 | */ |
463 | void platform_driver_unregister(struct platform_driver *drv) | 464 | void platform_driver_unregister(struct platform_driver *drv) |
464 | { | 465 | { |
@@ -516,8 +517,8 @@ EXPORT_SYMBOL_GPL(platform_driver_probe); | |||
516 | * (b) sysfs attribute lets new-style coldplug recover from hotplug events | 517 | * (b) sysfs attribute lets new-style coldplug recover from hotplug events |
517 | * mishandled before system is fully running: "modprobe $(cat modalias)" | 518 | * mishandled before system is fully running: "modprobe $(cat modalias)" |
518 | */ | 519 | */ |
519 | static ssize_t | 520 | static ssize_t modalias_show(struct device *dev, struct device_attribute *a, |
520 | modalias_show(struct device *dev, struct device_attribute *a, char *buf) | 521 | char *buf) |
521 | { | 522 | { |
522 | struct platform_device *pdev = to_platform_device(dev); | 523 | struct platform_device *pdev = to_platform_device(dev); |
523 | int len = snprintf(buf, PAGE_SIZE, "platform:%s\n", pdev->name); | 524 | int len = snprintf(buf, PAGE_SIZE, "platform:%s\n", pdev->name); |
@@ -538,26 +539,24 @@ static int platform_uevent(struct device *dev, struct kobj_uevent_env *env) | |||
538 | return 0; | 539 | return 0; |
539 | } | 540 | } |
540 | 541 | ||
541 | |||
542 | /** | 542 | /** |
543 | * platform_match - bind platform device to platform driver. | 543 | * platform_match - bind platform device to platform driver. |
544 | * @dev: device. | 544 | * @dev: device. |
545 | * @drv: driver. | 545 | * @drv: driver. |
546 | * | 546 | * |
547 | * Platform device IDs are assumed to be encoded like this: | 547 | * Platform device IDs are assumed to be encoded like this: |
548 | * "<name><instance>", where <name> is a short description of the | 548 | * "<name><instance>", where <name> is a short description of the type of |
549 | * type of device, like "pci" or "floppy", and <instance> is the | 549 | * device, like "pci" or "floppy", and <instance> is the enumerated |
550 | * enumerated instance of the device, like '0' or '42'. | 550 | * instance of the device, like '0' or '42'. Driver IDs are simply |
551 | * Driver IDs are simply "<name>". | 551 | * "<name>". So, extract the <name> from the platform_device structure, |
552 | * So, extract the <name> from the platform_device structure, | 552 | * and compare it against the name of the driver. Return whether they match |
553 | * and compare it against the name of the driver. Return whether | 553 | * or not. |
554 | * they match or not. | ||
555 | */ | 554 | */ |
556 | 555 | static int platform_match(struct device *dev, struct device_driver *drv) | |
557 | static int platform_match(struct device * dev, struct device_driver * drv) | ||
558 | { | 556 | { |
559 | struct platform_device *pdev = container_of(dev, struct platform_device, dev); | 557 | struct platform_device *pdev; |
560 | 558 | ||
559 | pdev = container_of(dev, struct platform_device, dev); | ||
561 | return (strncmp(pdev->name, drv->name, BUS_ID_SIZE) == 0); | 560 | return (strncmp(pdev->name, drv->name, BUS_ID_SIZE) == 0); |
562 | } | 561 | } |
563 | 562 | ||
@@ -574,9 +573,10 @@ static int platform_suspend(struct device *dev, pm_message_t mesg) | |||
574 | static int platform_suspend_late(struct device *dev, pm_message_t mesg) | 573 | static int platform_suspend_late(struct device *dev, pm_message_t mesg) |
575 | { | 574 | { |
576 | struct platform_driver *drv = to_platform_driver(dev->driver); | 575 | struct platform_driver *drv = to_platform_driver(dev->driver); |
577 | struct platform_device *pdev = container_of(dev, struct platform_device, dev); | 576 | struct platform_device *pdev; |
578 | int ret = 0; | 577 | int ret = 0; |
579 | 578 | ||
579 | pdev = container_of(dev, struct platform_device, dev); | ||
580 | if (dev->driver && drv->suspend_late) | 580 | if (dev->driver && drv->suspend_late) |
581 | ret = drv->suspend_late(pdev, mesg); | 581 | ret = drv->suspend_late(pdev, mesg); |
582 | 582 | ||
@@ -586,16 +586,17 @@ static int platform_suspend_late(struct device *dev, pm_message_t mesg) | |||
586 | static int platform_resume_early(struct device *dev) | 586 | static int platform_resume_early(struct device *dev) |
587 | { | 587 | { |
588 | struct platform_driver *drv = to_platform_driver(dev->driver); | 588 | struct platform_driver *drv = to_platform_driver(dev->driver); |
589 | struct platform_device *pdev = container_of(dev, struct platform_device, dev); | 589 | struct platform_device *pdev; |
590 | int ret = 0; | 590 | int ret = 0; |
591 | 591 | ||
592 | pdev = container_of(dev, struct platform_device, dev); | ||
592 | if (dev->driver && drv->resume_early) | 593 | if (dev->driver && drv->resume_early) |
593 | ret = drv->resume_early(pdev); | 594 | ret = drv->resume_early(pdev); |
594 | 595 | ||
595 | return ret; | 596 | return ret; |
596 | } | 597 | } |
597 | 598 | ||
598 | static int platform_resume(struct device * dev) | 599 | static int platform_resume(struct device *dev) |
599 | { | 600 | { |
600 | int ret = 0; | 601 | int ret = 0; |
601 | 602 | ||