aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/bus.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2008-01-25 01:50:12 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-01-25 01:50:12 -0500
commit4a3ad20ccd8f4d2a0535cf98fa83f7b561ba59a9 (patch)
tree8d0d147716466801b859a777472246ee5563f64b /drivers/base/bus.c
parente374a2bfebf359f846216336de91670be40499da (diff)
Driver core: coding style fixes
Fix up a number of coding style issues in the drivers/base/ directory that have annoyed me over the years. checkpatch.pl is now very happy. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/bus.c')
-rw-r--r--drivers/base/bus.c290
1 files changed, 140 insertions, 150 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index a377b65ba32..f484495b2ad 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
49static ssize_t 49static ssize_t drv_attr_show(struct kobject *kobj, struct attribute *attr,
50drv_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
61static ssize_t 61static ssize_t drv_attr_store(struct kobject *kobj, struct attribute *attr,
62drv_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 94static ssize_t bus_attr_show(struct kobject *kobj, struct attribute *attr,
97 95 char *buf)
98static ssize_t
99bus_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
110static ssize_t 106static ssize_t bus_attr_store(struct kobject *kobj, struct attribute *attr,
111bus_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
128int bus_create_file(struct bus_type * bus, struct bus_attribute * attr) 123int 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}
133EXPORT_SYMBOL_GPL(bus_create_file);
138 134
139void bus_remove_file(struct bus_type * bus, struct bus_attribute * attr) 135void 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}
142EXPORT_SYMBOL_GPL(bus_remove_file);
146 143
147static struct kobj_type bus_ktype = { 144static 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
262static struct device * next_device(struct klist_iter * i) 262static 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 287int bus_for_each_dev(struct bus_type *bus, struct device *start,
288int 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}
304EXPORT_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 */
321struct device * bus_find_device(struct bus_type *bus, 321struct 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}
339EXPORT_SYMBOL_GPL(bus_find_device);
339 340
340 341static struct device_driver *next_driver(struct klist_iter *i)
341static 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 372int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
373int 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}
389EXPORT_SYMBOL_GPL(bus_for_each_drv);
390 390
391static int device_add_attrs(struct bus_type *bus, struct device *dev) 391static 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
410static void device_remove_attrs(struct bus_type * bus, struct device * dev) 410static 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 */
443int bus_add_device(struct device * dev) 443int 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 */
485void bus_attach_device(struct device * dev) 485void 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 */
511void bus_remove_device(struct device * dev) 511void 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
528static int driver_add_attrs(struct bus_type * bus, struct device_driver * drv) 530static 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: 542done:
541 return error; 543 return error;
542 Err: 544err:
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 550static void driver_remove_attrs(struct bus_type *bus,
549static 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,
623static DRIVER_ATTR(uevent, S_IWUSR, NULL, driver_uevent_store); 625static 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 */
630int bus_add_driver(struct device_driver *drv) 631int 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 699void bus_remove_driver(struct device_driver *drv)
699void 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 */
717static int __must_check bus_rescan_devices_helper(struct device *dev, 716static 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 */
740int bus_rescan_devices(struct bus_type * bus) 739int 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}
743EXPORT_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)
765EXPORT_SYMBOL_GPL(device_reprobe); 765EXPORT_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
777struct bus_type * find_bus(char * name) 777struct 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
790static int bus_add_attrs(struct bus_type * bus) 790static 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: 802done:
803 return error; 803 return error;
804 Err: 804err:
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
810static void bus_remove_attrs(struct bus_type * bus) 810static 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,
843static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store); 843static 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 */
853int bus_register(struct bus_type * bus) 853int 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:
922out: 922out:
923 return retval; 923 return retval;
924} 924}
925EXPORT_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 */
933void bus_unregister(struct bus_type * bus) 934void 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}
945EXPORT_SYMBOL_GPL(bus_unregister);
944 946
945int bus_register_notifier(struct bus_type *bus, struct notifier_block *nb) 947int 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
978EXPORT_SYMBOL_GPL(bus_for_each_dev);
979EXPORT_SYMBOL_GPL(bus_find_device);
980EXPORT_SYMBOL_GPL(bus_for_each_drv);
981
982EXPORT_SYMBOL_GPL(bus_register);
983EXPORT_SYMBOL_GPL(bus_unregister);
984EXPORT_SYMBOL_GPL(bus_rescan_devices);
985
986EXPORT_SYMBOL_GPL(bus_create_file);
987EXPORT_SYMBOL_GPL(bus_remove_file);