Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1660908 > unrolled thread

[PATCH 0/7] Driver core: remove class_attrs from struct class

Started byGreg Kroah-Hartman <gregkh@linuxfoundation.org>
First post2017-06-08 10:20 +0200
Last post2017-06-08 14:10 +0200
Articles 13 — 6 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/7] Driver core: remove class_attrs from struct class Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-08 10:20 +0200
    [PATCH 2/7] scsi: ibmvscsi_tgt: remove use of class_attrs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-08 10:20 +0200
      Re: [PATCH 2/7] scsi: ibmvscsi_tgt: remove use of class_attrs "Bryant G. Ly" <bryantly@linux.vnet.ibm.com> - 2017-06-08 14:40 +0200
    [PATCH 4/7] zram: use class_groups instead of class_attrs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-08 10:20 +0200
      Re: [PATCH 4/7] zram: use class_groups instead of class_attrs Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-06-09 07:40 +0200
    [PATCH 3/7] mtd: use class_groups instead of class_attrs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-08 10:20 +0200
      Re: [PATCH 3/7] mtd: use class_groups instead of class_attrs Richard Weinberger <richard@nod.at> - 2017-06-08 12:30 +0200
    [PATCH 7/7] driver core: remove class_attrs from struct class Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-08 10:20 +0200
    [PATCH 1/7] uwb: use class_groups instead of class_attrs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-08 10:20 +0200
    [PATCH 6/7] pktcdvd: use class_groups instead of class_attrs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-08 10:20 +0200
    [PATCH 5/7] gpio: use class_groups instead of class_attrs Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-08 10:20 +0200
      Re: [PATCH 5/7] gpio: use class_groups instead of class_attrs "Robert P. J. Day" <rpjday@crashcourse.ca> - 2017-06-08 11:40 +0200
      Re: [PATCH 5/7] gpio: use class_groups instead of class_attrs Linus Walleij <linus.walleij@linaro.org> - 2017-06-08 14:10 +0200

#1660908 — [PATCH 0/7] Driver core: remove class_attrs from struct class

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-06-08 10:20 +0200
Subject[PATCH 0/7] Driver core: remove class_attrs from struct class
Message-ID<tQ0PD-1Le-1@gated-at.bofh.it>
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(-)

-- 
2.13.1

[toc] | [next] | [standalone]


#1660909 — [PATCH 2/7] scsi: ibmvscsi_tgt: remove use of class_attrs

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-06-08 10:20 +0200
Subject[PATCH 2/7] scsi: ibmvscsi_tgt: remove use of class_attrs
Message-ID<tQ0PD-1Le-7@gated-at.bofh.it>
In reply to#1660908
The class_attrs pointer is going away and it's not even being used in
this driver, so just remove it entirely.

Cc: "Bryant G. Ly" <bryantly@linux.vnet.ibm.com>
Cc: Michael Cyr <mikecyr@linux.vnet.ibm.com>
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: <linux-scsi@vger.kernel.org>
Cc: <target-devel@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
index d390325c99ec..b480878e3258 100644
--- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
+++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
@@ -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,
 };
 
-- 
2.13.1

[toc] | [prev] | [next] | [standalone]


#1661118 — Re: [PATCH 2/7] scsi: ibmvscsi_tgt: remove use of class_attrs

From"Bryant G. Ly" <bryantly@linux.vnet.ibm.com>
Date2017-06-08 14:40 +0200
SubjectRe: [PATCH 2/7] scsi: ibmvscsi_tgt: remove use of class_attrs
Message-ID<tQ4Tf-4hK-5@gated-at.bofh.it>
In reply to#1660909
> The class_attrs pointer is going away and it's not even being used in
> this driver, so just remove it entirely.
>
> Cc: "Bryant G. Ly" <bryantly@linux.vnet.ibm.com>
> Cc: Michael Cyr <mikecyr@linux.vnet.ibm.com>
> Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: <linux-scsi@vger.kernel.org>
> Cc: <target-devel@vger.kernel.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>   drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 5 -----
>   1 file changed, 5 deletions(-)
>
> diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
> index d390325c99ec..b480878e3258 100644
> --- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
> +++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
> @@ -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,
>   };
>
Thanks Greg, ACK.

-Bryant

[toc] | [prev] | [next] | [standalone]


#1660911 — [PATCH 4/7] zram: use class_groups instead of class_attrs

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-06-08 10:20 +0200
Subject[PATCH 4/7] zram: use class_groups instead of class_attrs
Message-ID<tQ0PD-1Le-9@gated-at.bofh.it>
In reply to#1660908
The class_attrs pointer is long depreciated, and is about to be finally
removed, so move to use the class_groups pointer instead.

Cc: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/block/zram/zram_drv.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index debee952dcc1..ebf5a45a0277 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -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)
-- 
2.13.1

[toc] | [prev] | [next] | [standalone]


#1661936 — Re: [PATCH 4/7] zram: use class_groups instead of class_attrs

FromSergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Date2017-06-09 07:40 +0200
SubjectRe: [PATCH 4/7] zram: use class_groups instead of class_attrs
Message-ID<tQkOm-5U4-7@gated-at.bofh.it>
In reply to#1660911
On (06/08/17 10:12), Greg Kroah-Hartman wrote:
> The class_attrs pointer is long depreciated, and is about to be finally
> removed, so move to use the class_groups pointer instead.
> 
> Cc: Minchan Kim <minchan@kernel.org>
> Cc: Nitin Gupta <ngupta@vflare.org>
> Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

FWIW, looks good to me.

Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

	-ss

[toc] | [prev] | [next] | [standalone]


#1660915 — [PATCH 3/7] mtd: use class_groups instead of class_attrs

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-06-08 10:20 +0200
Subject[PATCH 3/7] mtd: use class_groups instead of class_attrs
Message-ID<tQ0PE-1Le-21@gated-at.bofh.it>
In reply to#1660908
The class_attrs pointer is long depreciated, and is about to be finally
removed, so move to use the class_groups pointer instead.

Cc: Artem Bityutskiy <dedekind1@gmail.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: Marek Vasut <marek.vasut@gmail.com>
Cc: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>
Cc: <linux-mtd@lists.infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/mtd/ubi/build.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 93e5d251a9e4..d854521962ef 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -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,
-- 
2.13.1

[toc] | [prev] | [next] | [standalone]


#1661037 — Re: [PATCH 3/7] mtd: use class_groups instead of class_attrs

FromRichard Weinberger <richard@nod.at>
Date2017-06-08 12:30 +0200
SubjectRe: [PATCH 3/7] mtd: use class_groups instead of class_attrs
Message-ID<tQ2Rs-33b-23@gated-at.bofh.it>
In reply to#1660915
Am 08.06.2017 um 10:12 schrieb Greg Kroah-Hartman:
> The class_attrs pointer is long depreciated, and is about to be finally
> removed, so move to use the class_groups pointer instead.
> 
> Cc: Artem Bityutskiy <dedekind1@gmail.com>
> Cc: Richard Weinberger <richard@nod.at>
> Cc: David Woodhouse <dwmw2@infradead.org>
> Cc: Brian Norris <computersforpeace@gmail.com>
> Cc: Boris Brezillon <boris.brezillon@free-electrons.com>
> Cc: Marek Vasut <marek.vasut@gmail.com>
> Cc: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>
> Cc: <linux-mtd@lists.infradead.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Acked-by: Richard Weinberger <richard@nod.at>

Thanks,
//richard

[toc] | [prev] | [next] | [standalone]


#1660919 — [PATCH 7/7] driver core: remove class_attrs from struct class

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-06-08 10:20 +0200
Subject[PATCH 7/7] driver core: remove class_attrs from struct class
Message-ID<tQ0PE-1Le-25@gated-at.bofh.it>
In reply to#1660908
This 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.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/base/class.c   | 33 ---------------------------------
 include/linux/device.h |  2 --
 2 files changed, 35 deletions(-)

diff --git a/drivers/base/class.c b/drivers/base/class.c
index a2b2896693d6..52eb8e644acd 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -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);
 }
diff --git a/include/linux/device.h b/include/linux/device.h
index 9ef518af5515..000d94b03964 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -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;
-- 
2.13.1

[toc] | [prev] | [next] | [standalone]


#1660921 — [PATCH 1/7] uwb: use class_groups instead of class_attrs

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-06-08 10:20 +0200
Subject[PATCH 1/7] uwb: use class_groups instead of class_attrs
Message-ID<tQ0PE-1Le-33@gated-at.bofh.it>
In reply to#1660908
The class_attrs pointer is long depreciated, and is about to be finally
removed, so move to use the class_groups pointer instead.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/uwb/driver.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/uwb/driver.c b/drivers/uwb/driver.c
index 776bcb3c2140..ff2d4240b24a 100644
--- a/drivers/uwb/driver.c
+++ b/drivers/uwb/driver.c
@@ -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,
 };
 
 
-- 
2.13.1

[toc] | [prev] | [next] | [standalone]


#1660922 — [PATCH 6/7] pktcdvd: use class_groups instead of class_attrs

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-06-08 10:20 +0200
Subject[PATCH 6/7] pktcdvd: use class_groups instead of class_attrs
Message-ID<tQ0PE-1Le-37@gated-at.bofh.it>
In reply to#1660908
The class_attrs pointer is long depreciated, and is about to be finally
removed, so move to use the class_groups pointer instead.

Cc: <linux-block@vger.kernel.org>
Cc: Jens Axboe <axboe@fb.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Mike Christie <mchristi@redhat.com>
Cc: Bart Van Assche <Bart.VanAssche@sandisk.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/block/pktcdvd.c | 35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 205b865ebeb9..98939ee97476 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -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);
-- 
2.13.1

[toc] | [prev] | [next] | [standalone]


#1660923 — [PATCH 5/7] gpio: use class_groups instead of class_attrs

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-06-08 10:20 +0200
Subject[PATCH 5/7] gpio: use class_groups instead of class_attrs
Message-ID<tQ0PF-1Le-39@gated-at.bofh.it>
In reply to#1660908
The class_attrs pointer is long depreciated, and is about to be finally
removed, so move to use the class_groups pointer instead.

Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Alexandre Courbot <gnurou@gmail.com>
Cc: <linux-gpio@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpio/gpiolib-sysfs.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c
index 4b44dd97c07f..16fe9742597b 100644
--- a/drivers/gpio/gpiolib-sysfs.c
+++ b/drivers/gpio/gpiolib-sysfs.c
@@ -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,
 };
 
 
-- 
2.13.1

[toc] | [prev] | [next] | [standalone]


#1660980 — Re: [PATCH 5/7] gpio: use class_groups instead of class_attrs

From"Robert P. J. Day" <rpjday@crashcourse.ca>
Date2017-06-08 11:40 +0200
SubjectRe: [PATCH 5/7] gpio: use class_groups instead of class_attrs
Message-ID<tQ254-2wu-19@gated-at.bofh.it>
In reply to#1660923
On Thu, 8 Jun 2017, Greg Kroah-Hartman wrote:

> The class_attrs pointer is long depreciated, and is about to be finally
                                  ^^^^^^^^^^^ deprecated

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

[toc] | [prev] | [next] | [standalone]


#1661091 — Re: [PATCH 5/7] gpio: use class_groups instead of class_attrs

FromLinus Walleij <linus.walleij@linaro.org>
Date2017-06-08 14:10 +0200
SubjectRe: [PATCH 5/7] gpio: use class_groups instead of class_attrs
Message-ID<tQ4qd-45j-7@gated-at.bofh.it>
In reply to#1660923
On Thu, Jun 8, 2017 at 10:12 AM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:

> The class_attrs pointer is long depreciated, and is about to be finally
> removed, so move to use the class_groups pointer instead.
>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Alexandre Courbot <gnurou@gmail.com>
> Cc: <linux-gpio@vger.kernel.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Please take this through the driver core tree.

Yours,
Linus Walleij

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web