diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-10 17:02:41 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-10 17:02:41 -0700 |
commit | e96e039272610e5716f4cccb31b7ceb9c4a4c44c (patch) | |
tree | bfeafc2e2a602106d27bdbc53e5869422bcf8f46 | |
parent | 71dc29f11ecf9b2d046caa36ae09f233b6fbcb8c (diff) | |
download | patches-e96e039272610e5716f4cccb31b7ceb9c4a4c44c.tar.gz |
updates
-rw-r--r-- | driver-core-add-device_attr_rw-and-device_attr_ro-macros.patch | 60 | ||||
-rw-r--r-- | f1.patch | 95 | ||||
-rw-r--r-- | f2.patch | 82 | ||||
-rw-r--r-- | f3.patch | 32 | ||||
-rw-r--r-- | series | 3 |
5 files changed, 268 insertions, 4 deletions
diff --git a/driver-core-add-device_attr_rw-and-device_attr_ro-macros.patch b/driver-core-add-device_attr_rw-and-device_attr_ro-macros.patch index e2e979cdd8e7aa..492bb0de5cc31a 100644 --- a/driver-core-add-device_attr_rw-and-device_attr_ro-macros.patch +++ b/driver-core-add-device_attr_rw-and-device_attr_ro-macros.patch @@ -2,7 +2,7 @@ From foo@baz Mon Jul 8 22:44:37 PDT 2013 Date: Mon, 08 Jul 2013 22:44:37 -0700 To: Greg KH <gregkh@linuxfoundation.org> From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> -Subject: driver core: add DEVICE_ATTR_RW and DEVICE_ATTR_RO macros +Subject: driver core: device.h: add RW and RO attribute macros Make it easier to create attributes without having to always audit the mode settings. @@ -10,12 +10,64 @@ mode settings. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- - include/linux/device.h | 4 ++++ - 1 file changed, 4 insertions(+) + include/linux/device.h | 28 +++++++++++++++++++++------- + 1 file changed, 21 insertions(+), 7 deletions(-) --- a/include/linux/device.h +++ b/include/linux/device.h -@@ -512,6 +512,10 @@ ssize_t device_store_bool(struct device +@@ -47,7 +47,11 @@ struct bus_attribute { + }; + + #define BUS_ATTR(_name, _mode, _show, _store) \ +-struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store) ++ struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store) ++#define BUS_ATTR_RW(_name) \ ++ struct bus_attribute bus_attr_##_name = __ATTR_RW(_name) ++#define BUS_ATTR_RO(_name) \ ++ struct bus_attribute bus_attr_##_name = __ATTR_RO(_name) + + extern int __must_check bus_create_file(struct bus_type *, + struct bus_attribute *); +@@ -261,9 +265,12 @@ struct driver_attribute { + size_t count); + }; + +-#define DRIVER_ATTR(_name, _mode, _show, _store) \ +-struct driver_attribute driver_attr_##_name = \ +- __ATTR(_name, _mode, _show, _store) ++#define DRIVER_ATTR(_name, _mode, _show, _store) \ ++ struct driver_attribute driver_attr_##_name = __ATTR(_name, _mode, _show, _store) ++#define DRIVER_ATTR_RW(_name) \ ++ struct driver_attribute driver_attr_##_name = __ATTR_RW(_name) ++#define DRIVER_ATTR_RO(_name) \ ++ struct driver_attribute driver_attr_##_name = __ATTR_RO(_name) + + extern int __must_check driver_create_file(struct device_driver *driver, + const struct driver_attribute *attr); +@@ -414,8 +421,12 @@ struct class_attribute { + const struct class_attribute *attr); + }; + +-#define CLASS_ATTR(_name, _mode, _show, _store) \ +-struct class_attribute class_attr_##_name = __ATTR(_name, _mode, _show, _store) ++#define CLASS_ATTR(_name, _mode, _show, _store) \ ++ struct class_attribute class_attr_##_name = __ATTR(_name, _mode, _show, _store) ++#define CLASS_ATTR_RW(_name) \ ++ struct class_attribute class_attr_##_name = __ATTR_RW(_name) ++#define CLASS_ATTR_RO(_name) \ ++ struct class_attribute class_attr_##_name = __ATTR_RO(_name) + + extern int __must_check class_create_file(struct class *class, + const struct class_attribute *attr); +@@ -423,7 +434,6 @@ extern void class_remove_file(struct cla + const struct class_attribute *attr); + + /* Simple class attribute that is just a static string */ +- + struct class_attribute_string { + struct class_attribute attr; + char *str; +@@ -512,6 +522,10 @@ ssize_t device_store_bool(struct device #define DEVICE_ATTR(_name, _mode, _show, _store) \ struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store) diff --git a/f1.patch b/f1.patch new file mode 100644 index 00000000000000..150c799693b67a --- /dev/null +++ b/f1.patch @@ -0,0 +1,95 @@ +--- + drivers/base/bus.c | 42 ------------------------------------------ + include/linux/device.h | 2 -- + 2 files changed, 44 deletions(-) + +--- a/drivers/base/bus.c ++++ b/drivers/base/bus.c +@@ -845,42 +845,6 @@ struct bus_type *find_bus(char *name) + } + #endif /* 0 */ + +- +-/** +- * bus_add_attrs - Add default attributes for this bus. +- * @bus: Bus that has just been registered. +- */ +- +-static int bus_add_attrs(struct bus_type *bus) +-{ +- int error = 0; +- int i; +- +- if (bus->bus_attrs) { +- for (i = 0; attr_name(bus->bus_attrs[i]); i++) { +- error = bus_create_file(bus, &bus->bus_attrs[i]); +- if (error) +- goto err; +- } +- } +-done: +- return error; +-err: +- while (--i >= 0) +- bus_remove_file(bus, &bus->bus_attrs[i]); +- goto done; +-} +- +-static void bus_remove_attrs(struct bus_type *bus) +-{ +- int i; +- +- if (bus->bus_attrs) { +- for (i = 0; attr_name(bus->bus_attrs[i]); i++) +- bus_remove_file(bus, &bus->bus_attrs[i]); +- } +-} +- + static int bus_add_groups(struct bus_type *bus, + const struct attribute_group **groups) + { +@@ -1001,9 +965,6 @@ int bus_register(struct bus_type *bus) + if (retval) + goto bus_probe_files_fail; + +- retval = bus_add_attrs(bus); +- if (retval) +- goto bus_attrs_fail; + retval = bus_add_groups(bus, bus->bus_groups); + if (retval) + goto bus_groups_fail; +@@ -1012,8 +973,6 @@ int bus_register(struct bus_type *bus) + return 0; + + bus_groups_fail: +- bus_remove_attrs(bus); +-bus_attrs_fail: + remove_probe_files(bus); + bus_probe_files_fail: + kset_unregister(bus->p->drivers_kset); +@@ -1042,7 +1001,6 @@ void bus_unregister(struct bus_type *bus + pr_debug("bus: '%s': unregistering\n", bus->name); + if (bus->dev_root) + device_unregister(bus->dev_root); +- bus_remove_attrs(bus); + bus_remove_groups(bus, bus->bus_groups); + remove_probe_files(bus); + kset_unregister(bus->p->drivers_kset); +--- a/include/linux/device.h ++++ b/include/linux/device.h +@@ -59,7 +59,6 @@ extern void bus_remove_file(struct bus_t + * @name: The name of the bus. + * @dev_name: Used for subsystems to enumerate devices like ("foo%u", dev->id). + * @dev_root: Default device to use as the parent. +- * @bus_attrs: Default attributes of the bus. + * @dev_attrs: Default attributes of the devices on the bus. + * @drv_attrs: Default attributes of the device drivers on the bus. + * @bus_groups: Default attributes of the bus. +@@ -102,7 +101,6 @@ struct bus_type { + const char *name; + const char *dev_name; + struct device *dev_root; +- struct bus_attribute *bus_attrs; /* use bus_groups instead */ + struct device_attribute *dev_attrs; /* use dev_groups instead */ + struct driver_attribute *drv_attrs; /* use drv_groups instead */ + const struct attribute_group **bus_groups; diff --git a/f2.patch b/f2.patch new file mode 100644 index 00000000000000..e403b42486b5f1 --- /dev/null +++ b/f2.patch @@ -0,0 +1,82 @@ +--- + drivers/block/rbd.c | 14 +++++++++----- + drivers/pci/pci-driver.c | 2 +- + drivers/pci/pci-sysfs.c | 16 +++++++++++++--- + drivers/pci/pci.h | 2 +- + 4 files changed, 24 insertions(+), 10 deletions(-) + +--- a/drivers/block/rbd.c ++++ b/drivers/block/rbd.c +@@ -397,15 +397,19 @@ static ssize_t rbd_remove(struct bus_typ + static int rbd_dev_image_probe(struct rbd_device *rbd_dev, bool mapping); + static void rbd_spec_put(struct rbd_spec *spec); + +-static struct bus_attribute rbd_bus_attrs[] = { +- __ATTR(add, S_IWUSR, NULL, rbd_add), +- __ATTR(remove, S_IWUSR, NULL, rbd_remove), +- __ATTR_NULL ++static BUS_ATTR(add, S_IWUSR, NULL, rbd_add); ++static BUS_ATTR(remove, S_IWUSR, NULL, rbd_remove); ++ ++static struct attribute *rbd_bus_attrs[] = { ++ &bus_attr_add.attr, ++ &bus_attr_remove.attr, ++ NULL, + }; ++ATTRIBUTE_GROUPS(rbd_bus); + + static struct bus_type rbd_bus_type = { + .name = "rbd", +- .bus_attrs = rbd_bus_attrs, ++ .bus_groups = rbd_bus_groups, + }; + + static void rbd_root_dev_release(struct device *dev) +--- a/drivers/pci/pci-driver.c ++++ b/drivers/pci/pci-driver.c +@@ -1274,7 +1274,7 @@ struct bus_type pci_bus_type = { + .remove = pci_device_remove, + .shutdown = pci_device_shutdown, + .dev_attrs = pci_dev_attrs, +- .bus_attrs = pci_bus_attrs, ++ .bus_groups = pci_bus_groups, + .drv_attrs = pci_drv_attrs, + .pm = PCI_PM_OPS_PTR, + }; +--- a/drivers/pci/pci-sysfs.c ++++ b/drivers/pci/pci-sysfs.c +@@ -302,10 +302,20 @@ static ssize_t bus_rescan_store(struct b + } + return count; + } ++static BUS_ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, bus_rescan_store); + +-struct bus_attribute pci_bus_attrs[] = { +- __ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, bus_rescan_store), +- __ATTR_NULL ++struct attribute *pci_bus_attrs[] = { ++ &bus_attr_rescan.attr, ++ NULL, ++}; ++ ++static const struct attribute_group pci_bus_group = { ++ .attrs = pci_bus_attrs, ++}; ++ ++const struct attribute_group *pci_bus_groups[] = { ++ &pci_bus_group, ++ NULL, + }; + + static ssize_t +--- a/drivers/pci/pci.h ++++ b/drivers/pci/pci.h +@@ -153,7 +153,7 @@ static inline int pci_no_d1d2(struct pci + extern struct device_attribute pci_dev_attrs[]; + extern const struct attribute_group *pcibus_groups[]; + extern struct device_type pci_dev_type; +-extern struct bus_attribute pci_bus_attrs[]; ++extern const struct attribute_group *pci_bus_groups[]; + + + /** diff --git a/f3.patch b/f3.patch new file mode 100644 index 00000000000000..169d5d7933cccc --- /dev/null +++ b/f3.patch @@ -0,0 +1,32 @@ +--- + drivers/base/platform.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +--- a/drivers/base/platform.c ++++ b/drivers/base/platform.c +@@ -671,11 +671,13 @@ static ssize_t modalias_show(struct devi + + return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len; + } ++static DEVICE_ATTR_RO(modalias); + +-static struct device_attribute platform_dev_attrs[] = { +- __ATTR_RO(modalias), +- __ATTR_NULL, ++static struct attribute *platform_dev_attrs[] = { ++ &dev_attr_modalias.attr, ++ NULL, + }; ++ATTRIBUTE_GROUPS(platform_dev); + + static int platform_uevent(struct device *dev, struct kobj_uevent_env *env) + { +@@ -892,7 +894,7 @@ static const struct dev_pm_ops platform_ + + struct bus_type platform_bus_type = { + .name = "platform", +- .dev_attrs = platform_dev_attrs, ++ .dev_groups = platform_dev_groups, + .match = platform_match, + .uevent = platform_uevent, + .pm = &platform_dev_pm_ops, @@ -92,3 +92,6 @@ driver-core-bus_type-add-drv_groups.patch driver-core-bus_type-add-bus_groups.patch +f1.patch +f2.patch +f3.patch |