aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/bus.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/bus.c')
-rw-r--r--drivers/base/bus.c37
1 files changed, 7 insertions, 30 deletions
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index eb1b7fa20dce..000e7b2006f8 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -20,7 +20,6 @@
20#include "power/power.h" 20#include "power/power.h"
21 21
22#define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr) 22#define to_bus_attr(_attr) container_of(_attr, struct bus_attribute, attr)
23#define to_bus(obj) container_of(obj, struct bus_type_private, subsys.kobj)
24 23
25/* 24/*
26 * sysfs bindings for drivers 25 * sysfs bindings for drivers
@@ -96,11 +95,11 @@ static ssize_t bus_attr_show(struct kobject *kobj, struct attribute *attr,
96 char *buf) 95 char *buf)
97{ 96{
98 struct bus_attribute *bus_attr = to_bus_attr(attr); 97 struct bus_attribute *bus_attr = to_bus_attr(attr);
99 struct bus_type_private *bus_priv = to_bus(kobj); 98 struct subsys_private *subsys_priv = to_subsys_private(kobj);
100 ssize_t ret = 0; 99 ssize_t ret = 0;
101 100
102 if (bus_attr->show) 101 if (bus_attr->show)
103 ret = bus_attr->show(bus_priv->bus, buf); 102 ret = bus_attr->show(subsys_priv->bus, buf);
104 return ret; 103 return ret;
105} 104}
106 105
@@ -108,11 +107,11 @@ static ssize_t bus_attr_store(struct kobject *kobj, struct attribute *attr,
108 const char *buf, size_t count) 107 const char *buf, size_t count)
109{ 108{
110 struct bus_attribute *bus_attr = to_bus_attr(attr); 109 struct bus_attribute *bus_attr = to_bus_attr(attr);
111 struct bus_type_private *bus_priv = to_bus(kobj); 110 struct subsys_private *subsys_priv = to_subsys_private(kobj);
112 ssize_t ret = 0; 111 ssize_t ret = 0;
113 112
114 if (bus_attr->store) 113 if (bus_attr->store)
115 ret = bus_attr->store(bus_priv->bus, buf, count); 114 ret = bus_attr->store(subsys_priv->bus, buf, count);
116 return ret; 115 return ret;
117} 116}
118 117
@@ -440,22 +439,6 @@ static void device_remove_attrs(struct bus_type *bus, struct device *dev)
440 } 439 }
441} 440}
442 441
443#ifdef CONFIG_SYSFS_DEPRECATED
444static int make_deprecated_bus_links(struct device *dev)
445{
446 return sysfs_create_link(&dev->kobj,
447 &dev->bus->p->subsys.kobj, "bus");
448}
449
450static void remove_deprecated_bus_links(struct device *dev)
451{
452 sysfs_remove_link(&dev->kobj, "bus");
453}
454#else
455static inline int make_deprecated_bus_links(struct device *dev) { return 0; }
456static inline void remove_deprecated_bus_links(struct device *dev) { }
457#endif
458
459/** 442/**
460 * bus_add_device - add device to bus 443 * bus_add_device - add device to bus
461 * @dev: device being added 444 * @dev: device being added
@@ -482,15 +465,10 @@ int bus_add_device(struct device *dev)
482 &dev->bus->p->subsys.kobj, "subsystem"); 465 &dev->bus->p->subsys.kobj, "subsystem");
483 if (error) 466 if (error)
484 goto out_subsys; 467 goto out_subsys;
485 error = make_deprecated_bus_links(dev);
486 if (error)
487 goto out_deprecated;
488 klist_add_tail(&dev->p->knode_bus, &bus->p->klist_devices); 468 klist_add_tail(&dev->p->knode_bus, &bus->p->klist_devices);
489 } 469 }
490 return 0; 470 return 0;
491 471
492out_deprecated:
493 sysfs_remove_link(&dev->kobj, "subsystem");
494out_subsys: 472out_subsys:
495 sysfs_remove_link(&bus->p->devices_kset->kobj, dev_name(dev)); 473 sysfs_remove_link(&bus->p->devices_kset->kobj, dev_name(dev));
496out_id: 474out_id:
@@ -530,7 +508,6 @@ void bus_remove_device(struct device *dev)
530{ 508{
531 if (dev->bus) { 509 if (dev->bus) {
532 sysfs_remove_link(&dev->kobj, "subsystem"); 510 sysfs_remove_link(&dev->kobj, "subsystem");
533 remove_deprecated_bus_links(dev);
534 sysfs_remove_link(&dev->bus->p->devices_kset->kobj, 511 sysfs_remove_link(&dev->bus->p->devices_kset->kobj,
535 dev_name(dev)); 512 dev_name(dev));
536 device_remove_attrs(dev->bus, dev); 513 device_remove_attrs(dev->bus, dev);
@@ -880,9 +857,9 @@ static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store);
880int bus_register(struct bus_type *bus) 857int bus_register(struct bus_type *bus)
881{ 858{
882 int retval; 859 int retval;
883 struct bus_type_private *priv; 860 struct subsys_private *priv;
884 861
885 priv = kzalloc(sizeof(struct bus_type_private), GFP_KERNEL); 862 priv = kzalloc(sizeof(struct subsys_private), GFP_KERNEL);
886 if (!priv) 863 if (!priv)
887 return -ENOMEM; 864 return -ENOMEM;
888 865
@@ -998,7 +975,7 @@ struct klist *bus_get_device_klist(struct bus_type *bus)
998EXPORT_SYMBOL_GPL(bus_get_device_klist); 975EXPORT_SYMBOL_GPL(bus_get_device_klist);
999 976
1000/* 977/*
1001 * Yes, this forcably breaks the klist abstraction temporarily. It 978 * Yes, this forcibly breaks the klist abstraction temporarily. It
1002 * just wants to sort the klist, not change reference counts and 979 * just wants to sort the klist, not change reference counts and
1003 * take/drop locks rapidly in the process. It does all this while 980 * take/drop locks rapidly in the process. It does all this while
1004 * holding the lock for the list, so objects can't otherwise be 981 * holding the lock for the list, so objects can't otherwise be