Driver core: remove class_attrs from struct class
Subsystems (8)
Greg Kroah-Hartman
maintainerPATCH 2/7 scsi: ibmvscsi_tgt: remove use of class_attrs
In reply to Greg Kroah-HartmanThe class_attrs pointer is going away and it's not even being used in this driver, so just remove it entirely.
--- drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +0 -5
@@ -3915,10 +3915,6 @@ static const struct target_core_fabric_ops ibmvscsis_ops = {static void ibmvscsis_dev_release (struct device *dev) {}; -static struct class_attribute ibmvscsis_class_attrs[] = { - __ATTR_NULL, -}; -static struct device_attribute dev_attr_system_id =__ATTR (system_id,S_IRUGO , system_id_show,NULL );
@@ -3938,7 +3934,6 @@ ATTRIBUTE_GROUPS(ibmvscsis_dev);static struct class ibmvscsis_class = { .name ="ibmvscsis" , .dev_release = ibmvscsis_dev_release, - .class_attrs = ibmvscsis_class_attrs, .dev_groups = ibmvscsis_dev_groups, };
Signature · 1 line
2.13.1
Greg Kroah-Hartman
maintainerPATCH 1/7 uwb: use class_groups instead of class_attrs
In reply to Greg Kroah-HartmanThe class_attrs pointer is long depreciated, and is about to be finally removed, so move to use the class_groups pointer instead.
--- drivers/uwb/driver.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/uwb/driver.c +6 -5
@@ -94,17 +94,18 @@ ssize_t beacon_timeout_ms_store(struct class *class, beacon_timeout_ms = bt;return size; } +static CLASS_ATTR_RW (beacon_timeout_ms); -static struct class_attribute uwb_class_attrs[] = { -__ATTR (beacon_timeout_ms,S_IWUSR |S_IRUGO , - beacon_timeout_ms_show, beacon_timeout_ms_store), - __ATTR_NULL, +static struct attribute *uwb_class_attrs[] = { + &class_attr_beacon_timeout_ms.attr, +NULL , }; +ATTRIBUTE_GROUPS (uwb_class);/** Device model classes */ struct class uwb_rc_class = { .name ="uwb_rc" , - .class_attrs = uwb_class_attrs, + .class_groups = uwb_class_groups, };
Signature · 1 line
2.13.1
Greg Kroah-Hartman
maintainercover Driver core: remove class_attrs from struct class
Some more patches that have long been sitting in a local tree...
The class_attrs field in struct class duplicates the same effort that class_groups implements, so let's finally get rid of the last few users of this field, and delete it, and the duplicated logic in the driver core.
Subsystem maintainers, I'm glad to take this series in my driver core tree, if you just want to ack your respective patches, that's fine with me.
This series has passed 0-day test-builds from what I can tell.
Greg Kroah-Hartman (7):
uwb: use class_groups instead of class_attrs
scsi: ibmvscsi_tgt: remove use of class_attrs
mtd: use class_groups instead of class_attrs
zram: use class_groups instead of class_attrs
gpio: use class_groups instead of class_attrs
pktcdvd: use class_groups instead of class_attrs driver core: remove class_attrs from struct class
drivers/base/class.c | 33 ------------------------------ drivers/block/pktcdvd.c | 35 ++++++++++++++++---------------- drivers/block/zram/zram_drv.c | 26 ++++++++++++++---------- drivers/gpio/gpiolib-sysfs.c | 13 +++++++----- drivers/mtd/ubi/build.c | 16 ++++++++------- drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 5 ----- drivers/uwb/driver.c | 11 +++++----- include/linux/device.h | 2 -- 8 files changed, 55 insertions(+), 86 deletions(-)
Signature · 1 line
2.13.1
Greg Kroah-Hartman
maintainerPATCH 5/7 gpio: use class_groups instead of class_attrs
The class_attrs pointer is long depreciated, and is about to be finally removed, so move to use the class_groups pointer instead.
--- drivers/gpio/gpiolib-sysfs.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/gpio/gpiolib-sysfs.c +8 -5
@@ -479,6 +479,7 @@ static ssize_t export_store(struct class *class,pr_debug ("%s: status %d\n" , __func__, status);return status ? : len; } +static CLASS_ATTR_WO (export); static ssize_t unexport_store(struct class *class, struct class_attribute *attr,
@@ -514,18 +515,20 @@ static ssize_t unexport_store(struct class *class,pr_debug ("%s: status %d\n" , __func__, status);return status ? : len; } +static CLASS_ATTR_WO (unexport); -static struct class_attribute gpio_class_attrs[] = { -__ATTR (export,0200 ,NULL , export_store), -__ATTR (unexport,0200 ,NULL , unexport_store), - __ATTR_NULL, +static struct attribute *gpio_class_attrs[] = { + &class_attr_export.attr, + &class_attr_unexport.attr, +NULL , }; +ATTRIBUTE_GROUPS (gpio_class);static struct class gpio_class = { .name ="gpio" , .owner =THIS_MODULE , - .class_attrs = gpio_class_attrs, + .class_groups = gpio_class_groups, };
Signature · 1 line
2.13.1
Greg Kroah-Hartman
maintainerPATCH 4/7 zram: use class_groups instead of class_attrs
In reply to Greg Kroah-HartmanThe class_attrs pointer is long depreciated, and is about to be finally removed, so move to use the class_groups pointer instead.
--- drivers/block/zram/zram_drv.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
drivers/block/zram/zram_drv.c +15 -11
@@ -1272,6 +1272,13 @@ static int zram_remove(struct zram *zram) }/* zram-control sysfs attributes */ + +/* +* NOTE: hot_add attribute is not the usual read-only sysfs attribute. In a +* sense that reading from this file does alter the state of your system -- it +* creates a new un-initialized zram device and returns back this device's +* device_id (or an error code if it fails to create a new device). +*/ static ssize_t hot_add_show (struct class *class,struct class_attribute *attr,char *buf)
@@ -1286,6 +1293,7 @@ static ssize_t hot_add_show(struct class *class,return ret;return scnprintf (buf,PAGE_SIZE ,"%d\n" , ret); } +static CLASS_ATTR(hot_add, 0400, hot_add_show, NULL); static ssize_t hot_remove_store(struct class *class, struct class_attribute *attr,
@@ -1316,23 +1324,19 @@ static ssize_t hot_remove_store(struct class *class,mutex_unlock (&zram_index_mutex);return ret ? ret : count; } +static CLASS_ATTR_WO (hot_remove); -/* -* NOTE: hot_add attribute is not the usual read-only sysfs attribute. In a -* sense that reading from this file does alter the state of your system -- it -* creates a new un-initialized zram device and returns back this device's -* device_id (or an error code if it fails to create a new device). -*/ -static struct class_attribute zram_control_class_attrs[] = { -__ATTR (hot_add,0400 , hot_add_show,NULL ), -__ATTR_WO (hot_remove), - __ATTR_NULL, +static struct attribute *zram_control_class_attrs[] = { + &class_attr_hot_add.attr, + &class_attr_hot_remove.attr, +NULL , }; +ATTRIBUTE_GROUPS (zram_control_class);static struct class zram_control_class = { .name ="zram-control" , .owner =THIS_MODULE , - .class_attrs = zram_control_class_attrs, + .class_groups = zram_control_class_groups, };static int zram_remove_cb (int id,void *ptr,void *data)
Signature · 1 line
2.13.1
Greg Kroah-Hartman
maintainerPATCH 6/7 pktcdvd: use class_groups instead of class_attrs
In reply to Greg Kroah-HartmanThe class_attrs pointer is long depreciated, and is about to be finally removed, so move to use the class_groups pointer instead.
--- drivers/block/pktcdvd.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-)
drivers/block/pktcdvd.c +17 -18
@@ -348,9 +348,9 @@ static void class_pktcdvd_release(struct class *cls) {kfree (cls); } -static ssize_t class_pktcdvd_show_map (struct class *c, -struct class_attribute *attr, -char *data) + +static ssize_t device_map_show (struct class *c,struct class_attribute *attr, +char *data) {int n =0 ;int idx;
@@ -368,11 +368,10 @@ static ssize_t class_pktcdvd_show_map(struct class *c,mutex_unlock (&ctl_mutex);return n; } +static CLASS_ATTR_RO (device_map); -static ssize_t class_pktcdvd_store_add (struct class *c, -struct class_attribute *attr, -const char *buf, -size_t count) +static ssize_t add_store (struct class *c,struct class_attribute *attr, +const char *buf,size_t count) {unsigned int major, minor;
@@ -390,11 +389,10 @@ static ssize_t class_pktcdvd_store_add(struct class *c,return -EINVAL ; } +static CLASS_ATTR_WO (add); -static ssize_t class_pktcdvd_store_remove (struct class *c, -struct class_attribute *attr, -const char *buf, -size_t count) +static ssize_t remove_store (struct class *c,struct class_attribute *attr, +const char *buf,size_t count) {unsigned int major, minor;if (sscanf (buf,"%u:%u" , &major, &minor) ==2 ) {
@@ -403,14 +401,15 @@ static ssize_t class_pktcdvd_store_remove(struct class *c, }return -EINVAL ; } +static CLASS_ATTR_WO (remove); -static struct class_attribute class_pktcdvd_attrs[] = { -__ATTR (add,0200 ,NULL , class_pktcdvd_store_add), -__ATTR (remove,0200 ,NULL , class_pktcdvd_store_remove), -__ATTR (device_map,0444 , class_pktcdvd_show_map,NULL ), - __ATTR_NULL +static struct attribute *class_pktcdvd_attrs[] = { + &class_attr_add.attr, + &class_attr_remove.attr, + &class_attr_device_map.attr, +NULL , }; - +ATTRIBUTE_GROUPS (class_pktcdvd);static int pkt_sysfs_init (void ) {
@@ -426,7 +425,7 @@ static int pkt_sysfs_init(void) class_pktcdvd->name =DRIVER_NAME ; class_pktcdvd->owner =THIS_MODULE ; class_pktcdvd->class_release = class_pktcdvd_release; - class_pktcdvd->class_attrs = class_pktcdvd_attrs; + class_pktcdvd->class_groups = class_pktcdvd_groups; ret =class_register (class_pktcdvd);if (ret) {kfree (class_pktcdvd);
Signature · 1 line
2.13.1
Greg Kroah-Hartman
maintainerPATCH 7/7 driver core: remove class_attrs from struct class
In reply to Greg Kroah-HartmanThis field is no longer used or needed (use class_groups instead), so it can be removed along with the driver core functionality that created and removed these files.
--- drivers/base/class.c | 33 --------------------------------- include/linux/device.h | 2 -- 2 files changed, 35 deletions(-)
drivers/base/class.c +0 -33
@@ -119,36 +119,6 @@ static void class_put(struct class *cls)kset_put (&cls->p->subsys); } -static int add_class_attrs (struct class *cls) -{ -int i; -int error =0 ; - -if (cls->class_attrs) { -for (i =0 ; cls->class_attrs[i].attr.name; i++) { - error =class_create_file (cls, &cls->class_attrs[i]); -if (error) - goto error; - } - } -done: -return error; -error: -while (--i >=0 ) -class_remove_file (cls, &cls->class_attrs[i]); - goto done; -} - -static void remove_class_attrs (struct class *cls) -{ -int i; - -if (cls->class_attrs) { -for (i =0 ; cls->class_attrs[i].attr.name; i++) -class_remove_file (cls, &cls->class_attrs[i]); - } -} -static void klist_class_dev_get (struct klist_node *n) { struct device *dev = container_of(n, struct device, knode_class);
@@ -217,8 +187,6 @@ int __class_register(struct class *cls, struct lock_class_key *key) } error =class_add_groups (class_get (cls), cls->class_groups);class_put (cls); - error =add_class_attrs (class_get (cls)); -class_put (cls);return error; }EXPORT_SYMBOL_GPL (__class_register);
@@ -226,7 +194,6 @@ EXPORT_SYMBOL_GPL(__class_register);void class_unregister (struct class *cls) {pr_debug ("device class '%s': unregistering\n" , cls->name); -remove_class_attrs (cls);class_remove_groups (cls, cls->class_groups);kset_unregister (&cls->p->subsys); }
include/linux/device.h +0 -2
@@ -365,7 +365,6 @@ int subsys_virtual_register(struct bus_type *subsys,* struct class - device classes * @name: Name of the class. * @owner: The module owner. -* @class_attrs: Default attributes of this class. * @class_groups: Default attributes of this class. * @dev_groups: Default attributes of the devices that belong to the class. * @dev_kobj: The kobject that represents this class and links it into the hierarchy.
@@ -394,7 +393,6 @@ struct class {const char *name;struct module *owner; -struct class_attribute *class_attrs;const struct attribute_group **class_groups;const struct attribute_group **dev_groups;struct kobject *dev_kobj;
Signature · 1 line
2.13.1
Greg Kroah-Hartman
maintainerPATCH 3/7 mtd: use class_groups instead of class_attrs
In reply to Greg Kroah-HartmanThe class_attrs pointer is long depreciated, and is about to be finally removed, so move to use the class_groups pointer instead.
--- drivers/mtd/ubi/build.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/mtd/ubi/build.c +9 -7
@@ -104,23 +104,25 @@ DEFINE_MUTEX(ubi_devices_mutex);static DEFINE_SPINLOCK (ubi_devices_lock);/* "Show" method for files in '/<sysfs>/class/ubi/' */ -static ssize_t ubi_version_show (struct class *class, -struct class_attribute *attr,char *buf) +/* UBI version attribute ('/<sysfs>/class/ubi/version') */ +static ssize_t version_show (struct class *class,struct class_attribute *attr, +char *buf) {return sprintf (buf,"%d\n" ,UBI_VERSION ); } +static CLASS_ATTR_RO (version); -/* UBI version attribute ('/<sysfs>/class/ubi/version') */ -static struct class_attribute ubi_class_attrs[] = { -__ATTR (version,S_IRUGO , ubi_version_show,NULL ), - __ATTR_NULL +static struct attribute *ubi_class_attrs[] = { + &class_attr_version.attr, +NULL , }; +ATTRIBUTE_GROUPS (ubi_class);/* Root UBI "class" object (corresponds to '/<sysfs>/class/ubi/') */ struct class ubi_class = { .name =UBI_NAME_STR , .owner =THIS_MODULE , - .class_attrs = ubi_class_attrs, + .class_groups = ubi_class_groups, }; static ssize_t dev_attribute_show(struct device *dev,
Signature · 1 line
2.13.1
Re: [PATCH 5/7] gpio: use class_groups instead of class_attrs
In reply to Greg Kroah-HartmanQuoted 1 line · Greg Kroah-Hartman
The
class_attrspointer is long depreciated, and is about to be finally
^^^^^^^^^^^ deprecated
rday
Signature · 7 lines
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================Re: [PATCH 3/7] mtd: use class_groups instead of class_attrs
In reply to Greg Kroah-HartmanAm 08.06.2017 um 10:12 schrieb Greg Kroah-Hartman:
Quoted 12 lines
The
class_attrspointer is long depreciated, and is about to be finally removed, so move to use theclass_groupspointer instead.Cc Artem Bityutskiy <[email protected]>Cc Richard Weinberger <[email protected]>Cc David Woodhouse <[email protected]>Cc Brian Norris <[email protected]>Cc Boris Brezillon <[email protected]>Cc Marek Vasut <[email protected]>Cc Cyrille Pitchen <[email protected]>Cc <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Thanks,
//richard
Re: [PATCH 5/7] gpio: use class_groups instead of class_attrs
In reply to Greg Kroah-HartmanQuoted 7 lines · Greg Kroah-Hartman
The
class_attrspointer is long depreciated, and is about to be finally removed, so move to use theclass_groupspointer instead.Cc Linus Walleij <[email protected]>Cc Alexandre Courbot <[email protected]>Cc <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Please take this through the driver core tree.
Yours,
Linus Walleij
Re: [PATCH 2/7] scsi: ibmvscsi_tgt: remove use of class_attrs
In reply to Greg Kroah-HartmanQuoted 31 lines
The
class_attrspointer is going away and it's not even being used in this driver, so just remove it entirely.Cc "Bryant G. Ly" <[email protected]>Cc Michael Cyr <[email protected]>Cc "James E.J. Bottomley" <[email protected]>Cc "Martin K. Petersen" <[email protected]>Cc <[email protected]>Cc <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>--- drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 5 ----- 1 file changed, 5 deletions(-)drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +0
-4@@ -3915,10 +3915,6 @@ static const struct target_core_fabric_ops ibmvscsis_ops = {static void ibmvscsis_dev_release (struct device *dev) {}; -static struct class_attribute ibmvscsis_class_attrs[] = { - __ATTR_NULL, -}; -static struct device_attribute dev_attr_system_id =__ATTR (system_id,S_IRUGO , system_id_show,NULL );
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c ATTRIBUTE_GROUPS(ibmvscsis_dev); · line 3939
Quoted 7 lines
drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +0
-1@@ -3938,7 +3934,6 @@ ATTRIBUTE_GROUPS(ibmvscsis_dev);static struct class ibmvscsis_class = { .name ="ibmvscsis" , .dev_release = ibmvscsis_dev_release, - .class_attrs = ibmvscsis_class_attrs, .dev_groups = ibmvscsis_dev_groups, };
Thanks Greg, ACK.
-Bryant
Re: [PATCH 6/7] pktcdvd: use class_groups instead of class_attrs
In reply to Greg Kroah-HartmanQuoted 2 lines · Greg Kroah-Hartman
The
class_attrspointer is long depreciated, and is about to be finally removed, so move to use theclass_groupspointer instead.
Feel free to add my Acked-by to this.
Signature · 1 line
Jens Axboe
Re: [PATCH 4/7] zram: use class_groups instead of class_attrs
In reply to Greg Kroah-HartmanQuoted 7 lines · Greg Kroah-Hartman
The
class_attrspointer is long depreciated, and is about to be finally removed, so move to use theclass_groupspointer instead.Cc Minchan Kim <[email protected]>Cc Nitin Gupta <[email protected]>Cc Sergey Senozhatsky <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
FWIW, looks good to me.
-ss