Originally, we have two functions named device_add_attrs() in drivers/base/bus.c and drivers/base/core.c. This will cause some confusion when reading the code.
And the one in drivers/base/bus.c do the same action as device_add_attributes() in drivers/base/core.c. That would be better to reuse this code. This patch just do some cleanup. Remove the device_add_attrs() in drivers/base/bus.c and call device_add_attributes() directly. Signed-off-by: Wei Yang <[email protected]> Reviewed-by: Gavin Shan <[email protected]> --- drivers/base/bus.c | 21 +-------------------- drivers/base/core.c | 2 +- include/linux/device.h | 2 ++ 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 24eb078..79c2a48 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -452,25 +452,6 @@ int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, } EXPORT_SYMBOL_GPL(bus_for_each_drv); -static int device_add_attrs(struct bus_type *bus, struct device *dev) -{ - int error = 0; - int i; - - if (!bus->dev_attrs) - return 0; - - for (i = 0; attr_name(bus->dev_attrs[i]); i++) { - error = device_create_file(dev, &bus->dev_attrs[i]); - if (error) { - while (--i >= 0) - device_remove_file(dev, &bus->dev_attrs[i]); - break; - } - } - return error; -} - static void device_remove_attrs(struct bus_type *bus, struct device *dev) { int i; @@ -496,7 +477,7 @@ int bus_add_device(struct device *dev) if (bus) { pr_debug("bus: '%s': add device %s\n", bus->name, dev_name(dev)); - error = device_add_attrs(bus, dev); + error = device_add_attributes(dev, bus->dev_attrs); if (error) goto out_put; error = sysfs_create_link(&bus->p->devices_kset->kobj, diff --git a/drivers/base/core.c b/drivers/base/core.c index a235085..369ae4e 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -397,7 +397,7 @@ static ssize_t store_uevent(struct device *dev, struct device_attribute *attr, static struct device_attribute uevent_attr = __ATTR(uevent, S_IRUGO | S_IWUSR, show_uevent, store_uevent); -static int device_add_attributes(struct device *dev, +int device_add_attributes(struct device *dev, struct device_attribute *attrs) { int error = 0; diff --git a/include/linux/device.h b/include/linux/device.h index 43dcda9..9cfe8e6 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -518,6 +518,8 @@ ssize_t device_store_bool(struct device *dev, struct device_attribute *attr, struct device_attribute dev_attr_##_name = \ __ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) +extern int device_add_attributes(struct device *dev, + struct device_attribute *attrs); extern int device_create_file(struct device *device, const struct device_attribute *entry); extern void device_remove_file(struct device *dev, -- 1.7.5.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/

