LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/8] soc: Use custom soc attribute group and DEVICE_ATTR_RO
@ 2020-05-23 17:08 Sudeep Holla
  2020-05-23 17:08 ` [PATCH 1/8] soc: realview: Switch to use DEVICE_ATTR_RO() Sudeep Holla
                   ` (8 more replies)
  0 siblings, 9 replies; 19+ messages in thread
From: Sudeep Holla @ 2020-05-23 17:08 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Sudeep Holla, Arnd Bergmann, Greg Kroah-Hartman

Hi,

While trying to add SMCCC based SOC_ID support, I found the custom soc
attribute group which had no users in the tree and check if it can be
used or can be removed. I realised that it could clean up the custom
attributes that are added using device_create_file today.

Regards,
Sudeep

Sudeep Holla (8):
  soc: realview: Switch to use DEVICE_ATTR_RO()
  soc: realview: Use custom soc attribute group instead of device_create_file
  soc: integrator: Switch to use DEVICE_ATTR_RO()
  soc: integrator: Use custom soc attribute group instead of device_create_file
  soc: ux500: Switch to use DEVICE_ATTR_RO()
  soc: ux500: Use custom soc attribute group instead of device_create_file
  ARM: OMAP2: Switch to use DEVICE_ATTR_RO()
  ARM: OMAP2: Use custom soc attribute group instead of device_create_file

 arch/arm/mach-omap2/id.c               | 20 ++++++-----
 drivers/soc/ux500/ux500-soc-id.c       | 22 ++++++------
 drivers/soc/versatile/soc-integrator.c | 48 ++++++++++++--------------
 drivers/soc/versatile/soc-realview.c   | 48 ++++++++++++--------------
 4 files changed, 69 insertions(+), 69 deletions(-)

--
2.17.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 1/8] soc: realview: Switch to use DEVICE_ATTR_RO()
  2020-05-23 17:08 [PATCH 0/8] soc: Use custom soc attribute group and DEVICE_ATTR_RO Sudeep Holla
@ 2020-05-23 17:08 ` Sudeep Holla
  2020-05-25 11:44   ` Linus Walleij
  2020-05-23 17:08 ` [PATCH 2/8] soc: realview: Use custom soc attribute group instead of device_create_file Sudeep Holla
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Sudeep Holla @ 2020-05-23 17:08 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Sudeep Holla, Arnd Bergmann, Greg Kroah-Hartman, Linus Walleij

Move device attributes to DEVICE_ATTR_RO() as that would make things
a lot more "obvious" what is happening over the existing __ATTR usage.

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/soc/versatile/soc-realview.c | 40 +++++++++++-----------------
 1 file changed, 16 insertions(+), 24 deletions(-)

diff --git a/drivers/soc/versatile/soc-realview.c b/drivers/soc/versatile/soc-realview.c
index 9471353dd8c3..cb3bcb7dd824 100644
--- a/drivers/soc/versatile/soc-realview.c
+++ b/drivers/soc/versatile/soc-realview.c
@@ -39,45 +39,37 @@ static const char *realview_arch_str(u32 id)
 	}
 }
 
-static ssize_t realview_get_manf(struct device *dev,
-			      struct device_attribute *attr,
-			      char *buf)
+static ssize_t
+manufacturer_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
 	return sprintf(buf, "%02x\n", realview_coreid >> 24);
 }
 
-static struct device_attribute realview_manf_attr =
-	__ATTR(manufacturer,  S_IRUGO, realview_get_manf,  NULL);
+static DEVICE_ATTR_RO(manufacturer);
 
-static ssize_t realview_get_board(struct device *dev,
-			      struct device_attribute *attr,
-			      char *buf)
+static ssize_t
+board_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
 	return sprintf(buf, "HBI-%03x\n", ((realview_coreid >> 16) & 0xfff));
 }
 
-static struct device_attribute realview_board_attr =
-	__ATTR(board,  S_IRUGO, realview_get_board,  NULL);
+static DEVICE_ATTR_RO(board);
 
-static ssize_t realview_get_arch(struct device *dev,
-			      struct device_attribute *attr,
-			      char *buf)
+static ssize_t
+fpga_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
 	return sprintf(buf, "%s\n", realview_arch_str(realview_coreid));
 }
 
-static struct device_attribute realview_arch_attr =
-	__ATTR(fpga,  S_IRUGO, realview_get_arch,  NULL);
+static DEVICE_ATTR_RO(fpga);
 
-static ssize_t realview_get_build(struct device *dev,
-			       struct device_attribute *attr,
-			       char *buf)
+static ssize_t
+build_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
 	return sprintf(buf, "%02x\n", (realview_coreid & 0xFF));
 }
 
-static struct device_attribute realview_build_attr =
-	__ATTR(build,  S_IRUGO, realview_get_build,  NULL);
+static DEVICE_ATTR_RO(build);
 
 static int realview_soc_probe(struct platform_device *pdev)
 {
@@ -112,10 +104,10 @@ static int realview_soc_probe(struct platform_device *pdev)
 	if (ret)
 		return -ENODEV;
 
-	device_create_file(soc_device_to_device(soc_dev), &realview_manf_attr);
-	device_create_file(soc_device_to_device(soc_dev), &realview_board_attr);
-	device_create_file(soc_device_to_device(soc_dev), &realview_arch_attr);
-	device_create_file(soc_device_to_device(soc_dev), &realview_build_attr);
+	device_create_file(soc_device_to_device(soc_dev), &dev_attr_manufacturer);
+	device_create_file(soc_device_to_device(soc_dev), &dev_attr_board);
+	device_create_file(soc_device_to_device(soc_dev), &dev_attr_fpga);
+	device_create_file(soc_device_to_device(soc_dev), &dev_attr_build);
 
 	dev_info(&pdev->dev, "RealView Syscon Core ID: 0x%08x, HBI-%03x\n",
 		 realview_coreid,
-- 
2.17.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 2/8] soc: realview: Use custom soc attribute group instead of device_create_file
  2020-05-23 17:08 [PATCH 0/8] soc: Use custom soc attribute group and DEVICE_ATTR_RO Sudeep Holla
  2020-05-23 17:08 ` [PATCH 1/8] soc: realview: Switch to use DEVICE_ATTR_RO() Sudeep Holla
@ 2020-05-23 17:08 ` Sudeep Holla
  2020-05-25 11:45   ` Linus Walleij
  2020-05-23 17:08 ` [PATCH 3/8] soc: integrator: Switch to use DEVICE_ATTR_RO() Sudeep Holla
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Sudeep Holla @ 2020-05-23 17:08 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Sudeep Holla, Arnd Bergmann, Greg Kroah-Hartman, Linus Walleij

Commit c31e73121f4c ("base: soc: Handle custom soc information sysfs
entries") introduced custom soc attribute group in soc_device_attribute
structure but there are no users treewide. While trying to understand
the motivation and tried to use it, it was found lot of existing custom
attributes can moved to use it instead of device_create_file.

Though most of these never remove/cleanup the custom attribute as they
never call soc_device_unregister, using these custom attribute group
eliminate the need for any cleanup as the driver infrastructure will
take care of that.

Let us remove device_create_file and start using the custom attribute
group in soc_device_attribute.

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/soc/versatile/soc-realview.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/soc/versatile/soc-realview.c b/drivers/soc/versatile/soc-realview.c
index cb3bcb7dd824..c6876d232d8f 100644
--- a/drivers/soc/versatile/soc-realview.c
+++ b/drivers/soc/versatile/soc-realview.c
@@ -71,6 +71,16 @@ build_show(struct device *dev, struct device_attribute *attr, char *buf)
 
 static DEVICE_ATTR_RO(build);
 
+static struct attribute *realview_attrs[] = {
+	&dev_attr_manufacturer.attr,
+	&dev_attr_board.attr,
+	&dev_attr_fpga.attr,
+	&dev_attr_build.attr,
+	NULL
+};
+
+ATTRIBUTE_GROUPS(realview);
+
 static int realview_soc_probe(struct platform_device *pdev)
 {
 	struct regmap *syscon_regmap;
@@ -94,6 +104,7 @@ static int realview_soc_probe(struct platform_device *pdev)
 
 	soc_dev_attr->machine = "RealView";
 	soc_dev_attr->family = "Versatile";
+	soc_dev_attr->custom_attr_group = realview_groups[0];
 	soc_dev = soc_device_register(soc_dev_attr);
 	if (IS_ERR(soc_dev)) {
 		kfree(soc_dev_attr);
@@ -104,11 +115,6 @@ static int realview_soc_probe(struct platform_device *pdev)
 	if (ret)
 		return -ENODEV;
 
-	device_create_file(soc_device_to_device(soc_dev), &dev_attr_manufacturer);
-	device_create_file(soc_device_to_device(soc_dev), &dev_attr_board);
-	device_create_file(soc_device_to_device(soc_dev), &dev_attr_fpga);
-	device_create_file(soc_device_to_device(soc_dev), &dev_attr_build);
-
 	dev_info(&pdev->dev, "RealView Syscon Core ID: 0x%08x, HBI-%03x\n",
 		 realview_coreid,
 		 ((realview_coreid >> 16) & 0xfff));
-- 
2.17.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 3/8] soc: integrator: Switch to use DEVICE_ATTR_RO()
  2020-05-23 17:08 [PATCH 0/8] soc: Use custom soc attribute group and DEVICE_ATTR_RO Sudeep Holla
  2020-05-23 17:08 ` [PATCH 1/8] soc: realview: Switch to use DEVICE_ATTR_RO() Sudeep Holla
  2020-05-23 17:08 ` [PATCH 2/8] soc: realview: Use custom soc attribute group instead of device_create_file Sudeep Holla
@ 2020-05-23 17:08 ` Sudeep Holla
  2020-05-25 11:45   ` Linus Walleij
  2020-05-23 17:08 ` [PATCH 4/8] soc: integrator: Use custom soc attribute group instead of device_create_file Sudeep Holla
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Sudeep Holla @ 2020-05-23 17:08 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Sudeep Holla, Arnd Bergmann, Greg Kroah-Hartman, Linus Walleij

Move device attributes to DEVICE_ATTR_RO() as that would make things
a lot more "obvious" what is happening over the existing __ATTR usage.

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/soc/versatile/soc-integrator.c | 40 +++++++++++---------------
 1 file changed, 16 insertions(+), 24 deletions(-)

diff --git a/drivers/soc/versatile/soc-integrator.c b/drivers/soc/versatile/soc-integrator.c
index ae13fa2aa582..8ba98b3b4e8e 100644
--- a/drivers/soc/versatile/soc-integrator.c
+++ b/drivers/soc/versatile/soc-integrator.c
@@ -56,45 +56,37 @@ static const char *integrator_fpga_str(u32 id)
 	}
 }
 
-static ssize_t integrator_get_manf(struct device *dev,
-			      struct device_attribute *attr,
-			      char *buf)
+static ssize_t
+manufacturer_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
 	return sprintf(buf, "%02x\n", integrator_coreid >> 24);
 }
 
-static struct device_attribute integrator_manf_attr =
-	__ATTR(manufacturer,  S_IRUGO, integrator_get_manf,  NULL);
+static DEVICE_ATTR_RO(manufacturer);
 
-static ssize_t integrator_get_arch(struct device *dev,
-			      struct device_attribute *attr,
-			      char *buf)
+static ssize_t
+arch_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
 	return sprintf(buf, "%s\n", integrator_arch_str(integrator_coreid));
 }
 
-static struct device_attribute integrator_arch_attr =
-	__ATTR(arch,  S_IRUGO, integrator_get_arch,  NULL);
+static DEVICE_ATTR_RO(arch);
 
-static ssize_t integrator_get_fpga(struct device *dev,
-			      struct device_attribute *attr,
-			      char *buf)
+static ssize_t
+fpga_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
 	return sprintf(buf, "%s\n", integrator_fpga_str(integrator_coreid));
 }
 
-static struct device_attribute integrator_fpga_attr =
-	__ATTR(fpga,  S_IRUGO, integrator_get_fpga,  NULL);
+static DEVICE_ATTR_RO(fpga);
 
-static ssize_t integrator_get_build(struct device *dev,
-			       struct device_attribute *attr,
-			       char *buf)
+static ssize_t
+build_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
 	return sprintf(buf, "%02x\n", (integrator_coreid >> 4) & 0xFF);
 }
 
-static struct device_attribute integrator_build_attr =
-	__ATTR(build,  S_IRUGO, integrator_get_build,  NULL);
+static DEVICE_ATTR_RO(build);
 
 static int __init integrator_soc_init(void)
 {
@@ -134,10 +126,10 @@ static int __init integrator_soc_init(void)
 	}
 	dev = soc_device_to_device(soc_dev);
 
-	device_create_file(dev, &integrator_manf_attr);
-	device_create_file(dev, &integrator_arch_attr);
-	device_create_file(dev, &integrator_fpga_attr);
-	device_create_file(dev, &integrator_build_attr);
+	device_create_file(dev, &dev_attr_manufacturer);
+	device_create_file(dev, &dev_attr_arch);
+	device_create_file(dev, &dev_attr_fpga);
+	device_create_file(dev, &dev_attr_build);
 
 	dev_info(dev, "Detected ARM core module:\n");
 	dev_info(dev, "    Manufacturer: %02x\n", (val >> 24));
-- 
2.17.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 4/8] soc: integrator: Use custom soc attribute group instead of device_create_file
  2020-05-23 17:08 [PATCH 0/8] soc: Use custom soc attribute group and DEVICE_ATTR_RO Sudeep Holla
                   ` (2 preceding siblings ...)
  2020-05-23 17:08 ` [PATCH 3/8] soc: integrator: Switch to use DEVICE_ATTR_RO() Sudeep Holla
@ 2020-05-23 17:08 ` Sudeep Holla
  2020-05-25 11:46   ` Linus Walleij
  2020-05-23 17:08 ` [PATCH 5/8] soc: ux500: Switch to use DEVICE_ATTR_RO() Sudeep Holla
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Sudeep Holla @ 2020-05-23 17:08 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Sudeep Holla, Arnd Bergmann, Greg Kroah-Hartman, Linus Walleij

Commit c31e73121f4c ("base: soc: Handle custom soc information sysfs
entries") introduced custom soc attribute group in soc_device_attribute
structure but there are no users treewide. While trying to understand
the motivation and tried to use it, it was found lot of existing custom
attributes can moved to use it instead of device_create_file.

Though most of these never remove/cleanup the custom attribute as they
never call soc_device_unregister, using these custom attribute group
eliminate the need for any cleanup as the driver infrastructure will
take care of that.

Let us remove device_create_file and start using the custom attribute
group in soc_device_attribute.

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/soc/versatile/soc-integrator.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/soc/versatile/soc-integrator.c b/drivers/soc/versatile/soc-integrator.c
index 8ba98b3b4e8e..7dcf77ccd31e 100644
--- a/drivers/soc/versatile/soc-integrator.c
+++ b/drivers/soc/versatile/soc-integrator.c
@@ -88,6 +88,16 @@ build_show(struct device *dev, struct device_attribute *attr, char *buf)
 
 static DEVICE_ATTR_RO(build);
 
+static struct attribute *integrator_attrs[] = {
+	&dev_attr_manufacturer.attr,
+	&dev_attr_arch.attr,
+	&dev_attr_fpga.attr,
+	&dev_attr_build.attr,
+	NULL
+};
+
+ATTRIBUTE_GROUPS(integrator);
+
 static int __init integrator_soc_init(void)
 {
 	static struct regmap *syscon_regmap;
@@ -119,6 +129,7 @@ static int __init integrator_soc_init(void)
 	soc_dev_attr->soc_id = "Integrator";
 	soc_dev_attr->machine = "Integrator";
 	soc_dev_attr->family = "Versatile";
+	soc_dev_attr->custom_attr_group = integrator_groups[0];
 	soc_dev = soc_device_register(soc_dev_attr);
 	if (IS_ERR(soc_dev)) {
 		kfree(soc_dev_attr);
@@ -126,11 +137,6 @@ static int __init integrator_soc_init(void)
 	}
 	dev = soc_device_to_device(soc_dev);
 
-	device_create_file(dev, &dev_attr_manufacturer);
-	device_create_file(dev, &dev_attr_arch);
-	device_create_file(dev, &dev_attr_fpga);
-	device_create_file(dev, &dev_attr_build);
-
 	dev_info(dev, "Detected ARM core module:\n");
 	dev_info(dev, "    Manufacturer: %02x\n", (val >> 24));
 	dev_info(dev, "    Architecture: %s\n", integrator_arch_str(val));
-- 
2.17.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 5/8] soc: ux500: Switch to use DEVICE_ATTR_RO()
  2020-05-23 17:08 [PATCH 0/8] soc: Use custom soc attribute group and DEVICE_ATTR_RO Sudeep Holla
                   ` (3 preceding siblings ...)
  2020-05-23 17:08 ` [PATCH 4/8] soc: integrator: Use custom soc attribute group instead of device_create_file Sudeep Holla
@ 2020-05-23 17:08 ` Sudeep Holla
  2020-05-25 11:46   ` Linus Walleij
  2020-05-23 17:08 ` [PATCH 6/8] soc: ux500: Use custom soc attribute group instead of device_create_file Sudeep Holla
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Sudeep Holla @ 2020-05-23 17:08 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Sudeep Holla, Arnd Bergmann, Greg Kroah-Hartman, Linus Walleij

Move device attributes to DEVICE_ATTR_RO() as that would make things
a lot more "obvious" what is happening over the existing __ATTR usage.

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/soc/ux500/ux500-soc-id.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/soc/ux500/ux500-soc-id.c b/drivers/soc/ux500/ux500-soc-id.c
index d64feeb51a40..55ceb67e066b 100644
--- a/drivers/soc/ux500/ux500-soc-id.c
+++ b/drivers/soc/ux500/ux500-soc-id.c
@@ -146,9 +146,8 @@ static const char * __init ux500_get_revision(void)
 	return kasprintf(GFP_KERNEL, "%s", "Unknown");
 }
 
-static ssize_t ux500_get_process(struct device *dev,
-					struct device_attribute *attr,
-					char *buf)
+static ssize_t
+process_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
 	if (dbx500_id.process == 0x00)
 		return sprintf(buf, "Standard\n");
@@ -156,6 +155,8 @@ static ssize_t ux500_get_process(struct device *dev,
 	return sprintf(buf, "%02xnm\n", dbx500_id.process);
 }
 
+static DEVICE_ATTR_RO(process);
+
 static const char *db8500_read_soc_id(struct device_node *backupram)
 {
 	void __iomem *base;
@@ -186,9 +187,6 @@ static void __init soc_info_populate(struct soc_device_attribute *soc_dev_attr,
 	soc_dev_attr->revision = ux500_get_revision();
 }
 
-static const struct device_attribute ux500_soc_attr =
-	__ATTR(process,  S_IRUGO, ux500_get_process,  NULL);
-
 static int __init ux500_soc_device_init(void)
 {
 	struct device *parent;
@@ -218,7 +216,7 @@ static int __init ux500_soc_device_init(void)
 	}
 
 	parent = soc_device_to_device(soc_dev);
-	device_create_file(parent, &ux500_soc_attr);
+	device_create_file(parent, &dev_attr_process);
 
 	return 0;
 }
-- 
2.17.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 6/8] soc: ux500: Use custom soc attribute group instead of device_create_file
  2020-05-23 17:08 [PATCH 0/8] soc: Use custom soc attribute group and DEVICE_ATTR_RO Sudeep Holla
                   ` (4 preceding siblings ...)
  2020-05-23 17:08 ` [PATCH 5/8] soc: ux500: Switch to use DEVICE_ATTR_RO() Sudeep Holla
@ 2020-05-23 17:08 ` Sudeep Holla
  2020-05-25 11:46   ` Linus Walleij
  2020-05-23 17:08 ` [PATCH 7/8] ARM: OMAP2: Switch to use DEVICE_ATTR_RO() Sudeep Holla
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 19+ messages in thread
From: Sudeep Holla @ 2020-05-23 17:08 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Sudeep Holla, Arnd Bergmann, Greg Kroah-Hartman, Linus Walleij

Commit c31e73121f4c ("base: soc: Handle custom soc information sysfs
entries") introduced custom soc attribute group in soc_device_attribute
structure but there are no users treewide. While trying to understand
the motivation and tried to use it, it was found lot of existing custom
attributes can moved to use it instead of device_create_file.

Though most of these never remove/cleanup the custom attribute as they
never call soc_device_unregister, using these custom attribute group
eliminate the need for any cleanup as the driver infrastructure will
take care of that.

Let us remove device_create_file and start using the custom attribute
group in soc_device_attribute.

Cc: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/soc/ux500/ux500-soc-id.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/soc/ux500/ux500-soc-id.c b/drivers/soc/ux500/ux500-soc-id.c
index 55ceb67e066b..a9472e0e5d61 100644
--- a/drivers/soc/ux500/ux500-soc-id.c
+++ b/drivers/soc/ux500/ux500-soc-id.c
@@ -157,6 +157,13 @@ process_show(struct device *dev, struct device_attribute *attr, char *buf)
 
 static DEVICE_ATTR_RO(process);
 
+static struct attribute *ux500_soc_attrs[] = {
+	&dev_attr_process.attr,
+	NULL
+};
+
+ATTRIBUTE_GROUPS(ux500_soc);
+
 static const char *db8500_read_soc_id(struct device_node *backupram)
 {
 	void __iomem *base;
@@ -185,11 +192,11 @@ static void __init soc_info_populate(struct soc_device_attribute *soc_dev_attr,
 	soc_dev_attr->machine  = ux500_get_machine();
 	soc_dev_attr->family   = ux500_get_family();
 	soc_dev_attr->revision = ux500_get_revision();
+	soc_dev_attr->custom_attr_group = ux500_soc_groups[0];
 }
 
 static int __init ux500_soc_device_init(void)
 {
-	struct device *parent;
 	struct soc_device *soc_dev;
 	struct soc_device_attribute *soc_dev_attr;
 	struct device_node *backupram;
@@ -215,9 +222,6 @@ static int __init ux500_soc_device_init(void)
 		return PTR_ERR(soc_dev);
 	}
 
-	parent = soc_device_to_device(soc_dev);
-	device_create_file(parent, &dev_attr_process);
-
 	return 0;
 }
 subsys_initcall(ux500_soc_device_init);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 7/8] ARM: OMAP2: Switch to use DEVICE_ATTR_RO()
  2020-05-23 17:08 [PATCH 0/8] soc: Use custom soc attribute group and DEVICE_ATTR_RO Sudeep Holla
                   ` (5 preceding siblings ...)
  2020-05-23 17:08 ` [PATCH 6/8] soc: ux500: Use custom soc attribute group instead of device_create_file Sudeep Holla
@ 2020-05-23 17:08 ` Sudeep Holla
  2020-05-29 17:47   ` Tony Lindgren
  2020-05-23 17:08 ` [PATCH 8/8] ARM: OMAP2: Use custom soc attribute group instead of device_create_file Sudeep Holla
  2020-05-27  9:03 ` [PATCH 0/8] soc: Use custom soc attribute group and DEVICE_ATTR_RO Greg Kroah-Hartman
  8 siblings, 1 reply; 19+ messages in thread
From: Sudeep Holla @ 2020-05-23 17:08 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Sudeep Holla, Arnd Bergmann, Greg Kroah-Hartman, Tony Lindgren,
	linux-omap

Move device attributes to DEVICE_ATTR_RO() as that would make things
a lot more "obvious" what is happening over the existing __ATTR usage.

Cc: Tony Lindgren <tony@atomide.com>
Cc: linux-omap@vger.kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 arch/arm/mach-omap2/id.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
index 188ea5258c99..37ac2d103548 100644
--- a/arch/arm/mach-omap2/id.c
+++ b/arch/arm/mach-omap2/id.c
@@ -775,15 +775,13 @@ static const char * __init omap_get_family(void)
 		return kasprintf(GFP_KERNEL, "Unknown");
 }
 
-static ssize_t omap_get_type(struct device *dev,
-					struct device_attribute *attr,
-					char *buf)
+static ssize_t
+type_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
 	return sprintf(buf, "%s\n", omap_types[omap_type()]);
 }
 
-static struct device_attribute omap_soc_attr =
-	__ATTR(type,  S_IRUGO, omap_get_type,  NULL);
+static DEVICE_ATTR_RO(type);
 
 void __init omap_soc_device_init(void)
 {
@@ -806,6 +804,6 @@ void __init omap_soc_device_init(void)
 	}
 
 	parent = soc_device_to_device(soc_dev);
-	device_create_file(parent, &omap_soc_attr);
+	device_create_file(parent, &dev_attr_type);
 }
 #endif /* CONFIG_SOC_BUS */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 8/8] ARM: OMAP2: Use custom soc attribute group instead of device_create_file
  2020-05-23 17:08 [PATCH 0/8] soc: Use custom soc attribute group and DEVICE_ATTR_RO Sudeep Holla
                   ` (6 preceding siblings ...)
  2020-05-23 17:08 ` [PATCH 7/8] ARM: OMAP2: Switch to use DEVICE_ATTR_RO() Sudeep Holla
@ 2020-05-23 17:08 ` Sudeep Holla
  2020-05-29 18:01   ` Tony Lindgren
  2020-05-27  9:03 ` [PATCH 0/8] soc: Use custom soc attribute group and DEVICE_ATTR_RO Greg Kroah-Hartman
  8 siblings, 1 reply; 19+ messages in thread
From: Sudeep Holla @ 2020-05-23 17:08 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel
  Cc: Sudeep Holla, Arnd Bergmann, Greg Kroah-Hartman, Tony Lindgren,
	linux-omap

Commit c31e73121f4c ("base: soc: Handle custom soc information sysfs
entries") introduced custom soc attribute group in soc_device_attribute
structure but there are no users treewide. While trying to understand
the motivation and tried to use it, it was found lot of existing custom
attributes can moved to use it instead of device_create_file.

Though most of these never remove/cleanup the custom attribute as they
never call soc_device_unregister, using these custom attribute group
eliminate the need for any cleanup as the driver infrastructure will
take care of that.

Let us remove device_create_file and start using the custom attribute
group in soc_device_attribute.

Cc: Tony Lindgren <tony@atomide.com>
Cc: linux-omap@vger.kernel.org
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 arch/arm/mach-omap2/id.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
index 37ac2d103548..1d119b974f5f 100644
--- a/arch/arm/mach-omap2/id.c
+++ b/arch/arm/mach-omap2/id.c
@@ -783,9 +783,15 @@ type_show(struct device *dev, struct device_attribute *attr, char *buf)
 
 static DEVICE_ATTR_RO(type);
 
+static struct attribute *omap_soc_attrs[] = {
+	&dev_attr_type.attr,
+	NULL
+};
+
+ATTRIBUTE_GROUPS(omap_soc);
+
 void __init omap_soc_device_init(void)
 {
-	struct device *parent;
 	struct soc_device *soc_dev;
 	struct soc_device_attribute *soc_dev_attr;
 
@@ -796,14 +802,12 @@ void __init omap_soc_device_init(void)
 	soc_dev_attr->machine  = soc_name;
 	soc_dev_attr->family   = omap_get_family();
 	soc_dev_attr->revision = soc_rev;
+	soc_dev_attr->custom_attr_group = omap_soc_groups[0];
 
 	soc_dev = soc_device_register(soc_dev_attr);
 	if (IS_ERR(soc_dev)) {
 		kfree(soc_dev_attr);
 		return;
 	}
-
-	parent = soc_device_to_device(soc_dev);
-	device_create_file(parent, &dev_attr_type);
 }
 #endif /* CONFIG_SOC_BUS */
-- 
2.17.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/8] soc: realview: Switch to use DEVICE_ATTR_RO()
  2020-05-23 17:08 ` [PATCH 1/8] soc: realview: Switch to use DEVICE_ATTR_RO() Sudeep Holla
@ 2020-05-25 11:44   ` Linus Walleij
  0 siblings, 0 replies; 19+ messages in thread
From: Linus Walleij @ 2020-05-25 11:44 UTC (permalink / raw)
  To: Sudeep Holla; +Cc: linux-kernel, Linux ARM, Arnd Bergmann, Greg Kroah-Hartman

On Sat, May 23, 2020 at 7:09 PM Sudeep Holla <sudeep.holla@arm.com> wrote:

> Move device attributes to DEVICE_ATTR_RO() as that would make things
> a lot more "obvious" what is happening over the existing __ATTR usage.
>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

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

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 2/8] soc: realview: Use custom soc attribute group instead of device_create_file
  2020-05-23 17:08 ` [PATCH 2/8] soc: realview: Use custom soc attribute group instead of device_create_file Sudeep Holla
@ 2020-05-25 11:45   ` Linus Walleij
  0 siblings, 0 replies; 19+ messages in thread
From: Linus Walleij @ 2020-05-25 11:45 UTC (permalink / raw)
  To: Sudeep Holla; +Cc: linux-kernel, Linux ARM, Arnd Bergmann, Greg Kroah-Hartman

On Sat, May 23, 2020 at 7:09 PM Sudeep Holla <sudeep.holla@arm.com> wrote:

> Commit c31e73121f4c ("base: soc: Handle custom soc information sysfs
> entries") introduced custom soc attribute group in soc_device_attribute
> structure but there are no users treewide. While trying to understand
> the motivation and tried to use it, it was found lot of existing custom
> attributes can moved to use it instead of device_create_file.
>
> Though most of these never remove/cleanup the custom attribute as they
> never call soc_device_unregister, using these custom attribute group
> eliminate the need for any cleanup as the driver infrastructure will
> take care of that.
>
> Let us remove device_create_file and start using the custom attribute
> group in soc_device_attribute.
>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

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

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 3/8] soc: integrator: Switch to use DEVICE_ATTR_RO()
  2020-05-23 17:08 ` [PATCH 3/8] soc: integrator: Switch to use DEVICE_ATTR_RO() Sudeep Holla
@ 2020-05-25 11:45   ` Linus Walleij
  0 siblings, 0 replies; 19+ messages in thread
From: Linus Walleij @ 2020-05-25 11:45 UTC (permalink / raw)
  To: Sudeep Holla; +Cc: linux-kernel, Linux ARM, Arnd Bergmann, Greg Kroah-Hartman

On Sat, May 23, 2020 at 7:09 PM Sudeep Holla <sudeep.holla@arm.com> wrote:

> Move device attributes to DEVICE_ATTR_RO() as that would make things
> a lot more "obvious" what is happening over the existing __ATTR usage.
>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

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

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 4/8] soc: integrator: Use custom soc attribute group instead of device_create_file
  2020-05-23 17:08 ` [PATCH 4/8] soc: integrator: Use custom soc attribute group instead of device_create_file Sudeep Holla
@ 2020-05-25 11:46   ` Linus Walleij
  0 siblings, 0 replies; 19+ messages in thread
From: Linus Walleij @ 2020-05-25 11:46 UTC (permalink / raw)
  To: Sudeep Holla; +Cc: linux-kernel, Linux ARM, Arnd Bergmann, Greg Kroah-Hartman

On Sat, May 23, 2020 at 7:09 PM Sudeep Holla <sudeep.holla@arm.com> wrote:

> Commit c31e73121f4c ("base: soc: Handle custom soc information sysfs
> entries") introduced custom soc attribute group in soc_device_attribute
> structure but there are no users treewide. While trying to understand
> the motivation and tried to use it, it was found lot of existing custom
> attributes can moved to use it instead of device_create_file.
>
> Though most of these never remove/cleanup the custom attribute as they
> never call soc_device_unregister, using these custom attribute group
> eliminate the need for any cleanup as the driver infrastructure will
> take care of that.
>
> Let us remove device_create_file and start using the custom attribute
> group in soc_device_attribute.
>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

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

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 5/8] soc: ux500: Switch to use DEVICE_ATTR_RO()
  2020-05-23 17:08 ` [PATCH 5/8] soc: ux500: Switch to use DEVICE_ATTR_RO() Sudeep Holla
@ 2020-05-25 11:46   ` Linus Walleij
  0 siblings, 0 replies; 19+ messages in thread
From: Linus Walleij @ 2020-05-25 11:46 UTC (permalink / raw)
  To: Sudeep Holla; +Cc: linux-kernel, Linux ARM, Arnd Bergmann, Greg Kroah-Hartman

On Sat, May 23, 2020 at 7:09 PM Sudeep Holla <sudeep.holla@arm.com> wrote:

> Move device attributes to DEVICE_ATTR_RO() as that would make things
> a lot more "obvious" what is happening over the existing __ATTR usage.
>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

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

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 6/8] soc: ux500: Use custom soc attribute group instead of device_create_file
  2020-05-23 17:08 ` [PATCH 6/8] soc: ux500: Use custom soc attribute group instead of device_create_file Sudeep Holla
@ 2020-05-25 11:46   ` Linus Walleij
  0 siblings, 0 replies; 19+ messages in thread
From: Linus Walleij @ 2020-05-25 11:46 UTC (permalink / raw)
  To: Sudeep Holla; +Cc: linux-kernel, Linux ARM, Arnd Bergmann, Greg Kroah-Hartman

On Sat, May 23, 2020 at 7:09 PM Sudeep Holla <sudeep.holla@arm.com> wrote:

> Commit c31e73121f4c ("base: soc: Handle custom soc information sysfs
> entries") introduced custom soc attribute group in soc_device_attribute
> structure but there are no users treewide. While trying to understand
> the motivation and tried to use it, it was found lot of existing custom
> attributes can moved to use it instead of device_create_file.
>
> Though most of these never remove/cleanup the custom attribute as they
> never call soc_device_unregister, using these custom attribute group
> eliminate the need for any cleanup as the driver infrastructure will
> take care of that.
>
> Let us remove device_create_file and start using the custom attribute
> group in soc_device_attribute.
>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>

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

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 0/8] soc: Use custom soc attribute group and DEVICE_ATTR_RO
  2020-05-23 17:08 [PATCH 0/8] soc: Use custom soc attribute group and DEVICE_ATTR_RO Sudeep Holla
                   ` (7 preceding siblings ...)
  2020-05-23 17:08 ` [PATCH 8/8] ARM: OMAP2: Use custom soc attribute group instead of device_create_file Sudeep Holla
@ 2020-05-27  9:03 ` Greg Kroah-Hartman
  2020-05-27 16:52   ` Sudeep Holla
  8 siblings, 1 reply; 19+ messages in thread
From: Greg Kroah-Hartman @ 2020-05-27  9:03 UTC (permalink / raw)
  To: Sudeep Holla; +Cc: linux-kernel, linux-arm-kernel, Arnd Bergmann

On Sat, May 23, 2020 at 06:08:51PM +0100, Sudeep Holla wrote:
> Hi,
> 
> While trying to add SMCCC based SOC_ID support, I found the custom soc
> attribute group which had no users in the tree and check if it can be
> used or can be removed. I realised that it could clean up the custom
> attributes that are added using device_create_file today.

Whole series looks good, nice job.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 0/8] soc: Use custom soc attribute group and DEVICE_ATTR_RO
  2020-05-27  9:03 ` [PATCH 0/8] soc: Use custom soc attribute group and DEVICE_ATTR_RO Greg Kroah-Hartman
@ 2020-05-27 16:52   ` Sudeep Holla
  0 siblings, 0 replies; 19+ messages in thread
From: Sudeep Holla @ 2020-05-27 16:52 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Greg Kroah-Hartman, Sudeep Holla, linux-kernel, linux-arm-kernel

Hi Arnd,

On Wed, May 27, 2020 at 11:03:05AM +0200, Greg Kroah-Hartman wrote:
> On Sat, May 23, 2020 at 06:08:51PM +0100, Sudeep Holla wrote:
> > Hi,
> > 
> > While trying to add SMCCC based SOC_ID support, I found the custom soc
> > attribute group which had no users in the tree and check if it can be
> > used or can be removed. I realised that it could clean up the custom
> > attributes that are added using device_create_file today.
> 
> Whole series looks good, nice job.
> 
> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Both Linus Walleij and Greg have provided Reviewed-by meaning I need to
take this via ARM SoC. I assume it is late for v5.8 now, do you want me
to resend later for you to pick this directly or need pull request ?

--
Regards,
Sudeep

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 7/8] ARM: OMAP2: Switch to use DEVICE_ATTR_RO()
  2020-05-23 17:08 ` [PATCH 7/8] ARM: OMAP2: Switch to use DEVICE_ATTR_RO() Sudeep Holla
@ 2020-05-29 17:47   ` Tony Lindgren
  0 siblings, 0 replies; 19+ messages in thread
From: Tony Lindgren @ 2020-05-29 17:47 UTC (permalink / raw)
  To: Sudeep Holla
  Cc: linux-kernel, linux-arm-kernel, Arnd Bergmann,
	Greg Kroah-Hartman, linux-omap

* Sudeep Holla <sudeep.holla@arm.com> [200523 17:10]:
> Move device attributes to DEVICE_ATTR_RO() as that would make things
> a lot more "obvious" what is happening over the existing __ATTR usage.

Acked-by: Tony Lindgren <tony@atomide.com>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 8/8] ARM: OMAP2: Use custom soc attribute group instead of device_create_file
  2020-05-23 17:08 ` [PATCH 8/8] ARM: OMAP2: Use custom soc attribute group instead of device_create_file Sudeep Holla
@ 2020-05-29 18:01   ` Tony Lindgren
  0 siblings, 0 replies; 19+ messages in thread
From: Tony Lindgren @ 2020-05-29 18:01 UTC (permalink / raw)
  To: Sudeep Holla
  Cc: linux-kernel, linux-arm-kernel, Arnd Bergmann,
	Greg Kroah-Hartman, linux-omap

* Sudeep Holla <sudeep.holla@arm.com> [200523 17:10]:
> Commit c31e73121f4c ("base: soc: Handle custom soc information sysfs
> entries") introduced custom soc attribute group in soc_device_attribute
> structure but there are no users treewide. While trying to understand
> the motivation and tried to use it, it was found lot of existing custom
> attributes can moved to use it instead of device_create_file.
> 
> Though most of these never remove/cleanup the custom attribute as they
> never call soc_device_unregister, using these custom attribute group
> eliminate the need for any cleanup as the driver infrastructure will
> take care of that.
> 
> Let us remove device_create_file and start using the custom attribute
> group in soc_device_attribute.

Acked-by: Tony Lindgren <tony@atomide.com>

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, back to index

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-23 17:08 [PATCH 0/8] soc: Use custom soc attribute group and DEVICE_ATTR_RO Sudeep Holla
2020-05-23 17:08 ` [PATCH 1/8] soc: realview: Switch to use DEVICE_ATTR_RO() Sudeep Holla
2020-05-25 11:44   ` Linus Walleij
2020-05-23 17:08 ` [PATCH 2/8] soc: realview: Use custom soc attribute group instead of device_create_file Sudeep Holla
2020-05-25 11:45   ` Linus Walleij
2020-05-23 17:08 ` [PATCH 3/8] soc: integrator: Switch to use DEVICE_ATTR_RO() Sudeep Holla
2020-05-25 11:45   ` Linus Walleij
2020-05-23 17:08 ` [PATCH 4/8] soc: integrator: Use custom soc attribute group instead of device_create_file Sudeep Holla
2020-05-25 11:46   ` Linus Walleij
2020-05-23 17:08 ` [PATCH 5/8] soc: ux500: Switch to use DEVICE_ATTR_RO() Sudeep Holla
2020-05-25 11:46   ` Linus Walleij
2020-05-23 17:08 ` [PATCH 6/8] soc: ux500: Use custom soc attribute group instead of device_create_file Sudeep Holla
2020-05-25 11:46   ` Linus Walleij
2020-05-23 17:08 ` [PATCH 7/8] ARM: OMAP2: Switch to use DEVICE_ATTR_RO() Sudeep Holla
2020-05-29 17:47   ` Tony Lindgren
2020-05-23 17:08 ` [PATCH 8/8] ARM: OMAP2: Use custom soc attribute group instead of device_create_file Sudeep Holla
2020-05-29 18:01   ` Tony Lindgren
2020-05-27  9:03 ` [PATCH 0/8] soc: Use custom soc attribute group and DEVICE_ATTR_RO Greg Kroah-Hartman
2020-05-27 16:52   ` Sudeep Holla

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git