zorro: stop creating attributes by hand
PATCH 1/1 zorro: stop creating attributes by hand
Instead of creating attributes one by one, define attribute_group array and attach it to bus->dev_groups, so that all needed attributes are created automatically when a new device is registered on the bus.
Also switch to using standard DEVICE_ATTR_RO() macros.
Signed-off-by Dmitry Torokhov <[email protected]>
---
Not tested.
drivers/zorro/zorro-driver.c | 15 +++++---- drivers/zorro/zorro-sysfs.c | 76 +++++++++++++++++++++++--------------------- drivers/zorro/zorro.c | 3 -- drivers/zorro/zorro.h | 3 +- 4 files changed, 50 insertions(+), 47 deletions(-)
drivers/zorro/zorro-driver.c +9 -6
@@ -14,6 +14,8 @@#include <linux/module.h> #include <linux/zorro.h> +#include "zorro.h" +/** * zorro_match_device - Tell if a Zorro device structure has a matching
@@ -161,12 +163,13 @@ static int zorro_uevent(struct device *dev, struct kobj_uevent_env *env) }struct bus_type zorro_bus_type = { - .name ="zorro" , - .dev_name ="zorro" , - .match = zorro_bus_match, - .uevent = zorro_uevent, - .probe = zorro_device_probe, - .remove = zorro_device_remove, + .name ="zorro" , + .dev_name ="zorro" , + .dev_groups = zorro_device_attribute_groups, + .match = zorro_bus_match, + .uevent = zorro_uevent, + .probe = zorro_device_probe, + .remove = zorro_device_remove, };EXPORT_SYMBOL (zorro_bus_type);
drivers/zorro/zorro-sysfs.c +40 -36
113 lines not on this page · raw message
drivers/zorro/zorro.c +0 -3
@@ -197,9 +197,6 @@ static int __init amiga_zorro_probe(struct platform_device *pdev)put_device (&z->dev);continue ; } - error =zorro_create_sysfs_dev_files (z); -if (error) -dev_err (&z->dev,"Error creating sysfs files\n" ); }/* Mark all available Zorro II memory */
drivers/zorro/zorro.h +1 -2
@@ -5,5 +5,4 @@ extern void zorro_name_device(struct zorro_dev *z);static inline void zorro_name_device (struct zorro_dev *dev) { }#endif -extern int zorro_create_sysfs_dev_files (struct zorro_dev *z); - +extern const struct attribute_group *zorro_device_attribute_groups[];
Signature · 5 lines
2.11.0.483.g087da7b7c-goog -- Dmitry