linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/4] gpio: xgene-sb: Improve ACPI and property related code
@ 2024-10-18 13:32 Andy Shevchenko
  2024-10-18 13:32 ` [PATCH v1 1/4] gpio: xgene-sb: Remove unneeded definitions for properties Andy Shevchenko
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-10-18 13:32 UTC (permalink / raw)
  To: Andy Shevchenko, linux-gpio, linux-kernel
  Cc: Linus Walleij, Bartosz Golaszewski

Improve ACPI and property related code in the driver.

Andy Shevchenko (4):
  gpio: xgene-sb: Remove unneeded definitions for properties
  gpio: xgene-sb: don't use "proxy" headers
  gpio: xgene-sb: Drop ACPI_PTR() and CONFIG_ACPI guards
  gpio: xgene-sb: Tidy up ACPI and OF ID tables

 drivers/gpio/gpio-xgene-sb.c | 37 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 19 deletions(-)

-- 
2.43.0.rc1.1336.g36b5255a03ac


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

* [PATCH v1 1/4] gpio: xgene-sb: Remove unneeded definitions for properties
  2024-10-18 13:32 [PATCH v1 0/4] gpio: xgene-sb: Improve ACPI and property related code Andy Shevchenko
@ 2024-10-18 13:32 ` Andy Shevchenko
  2024-10-18 13:32 ` [PATCH v1 2/4] gpio: xgene-sb: don't use "proxy" headers Andy Shevchenko
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-10-18 13:32 UTC (permalink / raw)
  To: Andy Shevchenko, linux-gpio, linux-kernel
  Cc: Linus Walleij, Bartosz Golaszewski

There are three definitions for the property names. Remove them as:
1) each of them is only used once;
2) in all cases the definition is longer than the value.

In the result code is better and grepping on the property immediately
gets the function in which is being used which helps to guess the type
of the value.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-xgene-sb.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/gpio/gpio-xgene-sb.c b/drivers/gpio/gpio-xgene-sb.c
index 836fcf1c82fe..ae592528001d 100644
--- a/drivers/gpio/gpio-xgene-sb.c
+++ b/drivers/gpio/gpio-xgene-sb.c
@@ -17,11 +17,6 @@
 
 #include "gpiolib-acpi.h"
 
-/* Common property names */
-#define XGENE_NIRQ_PROPERTY		"apm,nr-irqs"
-#define XGENE_NGPIO_PROPERTY		"apm,nr-gpios"
-#define XGENE_IRQ_START_PROPERTY	"apm,irq-start"
-
 #define XGENE_DFLT_MAX_NGPIO		22
 #define XGENE_DFLT_MAX_NIRQ		6
 #define XGENE_DFLT_IRQ_START_PIN	8
@@ -252,18 +247,17 @@ static int xgene_gpio_sb_probe(struct platform_device *pdev)
 
 	/* Retrieve start irq pin, use default if property not found */
 	priv->irq_start = XGENE_DFLT_IRQ_START_PIN;
-	if (!device_property_read_u32(&pdev->dev,
-					XGENE_IRQ_START_PROPERTY, &val32))
+	if (!device_property_read_u32(&pdev->dev, "apm,irq-start", &val32))
 		priv->irq_start = val32;
 
 	/* Retrieve number irqs, use default if property not found */
 	priv->nirq = XGENE_DFLT_MAX_NIRQ;
-	if (!device_property_read_u32(&pdev->dev, XGENE_NIRQ_PROPERTY, &val32))
+	if (!device_property_read_u32(&pdev->dev, "apm,nr-irqs", &val32))
 		priv->nirq = val32;
 
 	/* Retrieve number gpio, use default if property not found */
 	priv->gc.ngpio = XGENE_DFLT_MAX_NGPIO;
-	if (!device_property_read_u32(&pdev->dev, XGENE_NGPIO_PROPERTY, &val32))
+	if (!device_property_read_u32(&pdev->dev, "apm,nr-gpios", &val32))
 		priv->gc.ngpio = val32;
 
 	dev_info(&pdev->dev, "Support %d gpios, %d irqs start from pin %d\n",
-- 
2.43.0.rc1.1336.g36b5255a03ac


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

* [PATCH v1 2/4] gpio: xgene-sb: don't use "proxy" headers
  2024-10-18 13:32 [PATCH v1 0/4] gpio: xgene-sb: Improve ACPI and property related code Andy Shevchenko
  2024-10-18 13:32 ` [PATCH v1 1/4] gpio: xgene-sb: Remove unneeded definitions for properties Andy Shevchenko
@ 2024-10-18 13:32 ` Andy Shevchenko
  2024-10-18 13:32 ` [PATCH v1 3/4] gpio: xgene-sb: Drop ACPI_PTR() and CONFIG_ACPI guards Andy Shevchenko
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-10-18 13:32 UTC (permalink / raw)
  To: Andy Shevchenko, linux-gpio, linux-kernel
  Cc: Linus Walleij, Bartosz Golaszewski

Update header inclusions to follow IWYU (Include What You Use)
principle.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-xgene-sb.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-xgene-sb.c b/drivers/gpio/gpio-xgene-sb.c
index ae592528001d..69faf9b8d460 100644
--- a/drivers/gpio/gpio-xgene-sb.c
+++ b/drivers/gpio/gpio-xgene-sb.c
@@ -8,12 +8,19 @@
  *		Quan Nguyen <qnguyen@apm.com>.
  */
 
-#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/err.h>
 #include <linux/io.h>
+#include <linux/irq.h>
+#include <linux/irqdomain.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
+#include <linux/types.h>
+
 #include <linux/gpio/driver.h>
-#include <linux/acpi.h>
 
 #include "gpiolib-acpi.h"
 
-- 
2.43.0.rc1.1336.g36b5255a03ac


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

* [PATCH v1 3/4] gpio: xgene-sb: Drop ACPI_PTR() and CONFIG_ACPI guards
  2024-10-18 13:32 [PATCH v1 0/4] gpio: xgene-sb: Improve ACPI and property related code Andy Shevchenko
  2024-10-18 13:32 ` [PATCH v1 1/4] gpio: xgene-sb: Remove unneeded definitions for properties Andy Shevchenko
  2024-10-18 13:32 ` [PATCH v1 2/4] gpio: xgene-sb: don't use "proxy" headers Andy Shevchenko
@ 2024-10-18 13:32 ` Andy Shevchenko
  2024-10-18 13:32 ` [PATCH v1 4/4] gpio: xgene-sb: Tidy up ACPI and OF ID tables Andy Shevchenko
  2024-10-18 13:44 ` [PATCH v1 0/4] gpio: xgene-sb: Improve ACPI and property related code Andy Shevchenko
  4 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-10-18 13:32 UTC (permalink / raw)
  To: Andy Shevchenko, linux-gpio, linux-kernel
  Cc: Linus Walleij, Bartosz Golaszewski

The complexity of config guards needed for ACPI_PTR() is not worthwhile
for the small amount of saved data. This example was doing it correctly
but I am proposing dropping this so as to reduce chance of cut and paste
where it is done wrong.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-xgene-sb.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-xgene-sb.c b/drivers/gpio/gpio-xgene-sb.c
index 69faf9b8d460..0ebe3b215634 100644
--- a/drivers/gpio/gpio-xgene-sb.c
+++ b/drivers/gpio/gpio-xgene-sb.c
@@ -311,20 +311,18 @@ static const struct of_device_id xgene_gpio_sb_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, xgene_gpio_sb_of_match);
 
-#ifdef CONFIG_ACPI
 static const struct acpi_device_id xgene_gpio_sb_acpi_match[] = {
 	{"APMC0D15", 0},
 	{},
 };
 MODULE_DEVICE_TABLE(acpi, xgene_gpio_sb_acpi_match);
-#endif
 
 static struct platform_driver xgene_gpio_sb_driver = {
 	.driver = {
 		   .name = "xgene-gpio-sb",
 		   .of_match_table = xgene_gpio_sb_of_match,
-		   .acpi_match_table = ACPI_PTR(xgene_gpio_sb_acpi_match),
-		   },
+		   .acpi_match_table = xgene_gpio_sb_acpi_match,
+	},
 	.probe = xgene_gpio_sb_probe,
 	.remove = xgene_gpio_sb_remove,
 };
-- 
2.43.0.rc1.1336.g36b5255a03ac


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

* [PATCH v1 4/4] gpio: xgene-sb: Tidy up ACPI and OF ID tables
  2024-10-18 13:32 [PATCH v1 0/4] gpio: xgene-sb: Improve ACPI and property related code Andy Shevchenko
                   ` (2 preceding siblings ...)
  2024-10-18 13:32 ` [PATCH v1 3/4] gpio: xgene-sb: Drop ACPI_PTR() and CONFIG_ACPI guards Andy Shevchenko
@ 2024-10-18 13:32 ` Andy Shevchenko
  2024-10-18 13:44 ` [PATCH v1 0/4] gpio: xgene-sb: Improve ACPI and property related code Andy Shevchenko
  4 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-10-18 13:32 UTC (permalink / raw)
  To: Andy Shevchenko, linux-gpio, linux-kernel
  Cc: Linus Walleij, Bartosz Golaszewski

Tidy up the ACPI and OF ID tables:
- remove explicit driver_data initializer
- drop comma in the terminator entry

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-xgene-sb.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-xgene-sb.c b/drivers/gpio/gpio-xgene-sb.c
index 0ebe3b215634..48b829733b15 100644
--- a/drivers/gpio/gpio-xgene-sb.c
+++ b/drivers/gpio/gpio-xgene-sb.c
@@ -306,14 +306,14 @@ static void xgene_gpio_sb_remove(struct platform_device *pdev)
 }
 
 static const struct of_device_id xgene_gpio_sb_of_match[] = {
-	{.compatible = "apm,xgene-gpio-sb", },
-	{},
+	{ .compatible = "apm,xgene-gpio-sb" },
+	{}
 };
 MODULE_DEVICE_TABLE(of, xgene_gpio_sb_of_match);
 
 static const struct acpi_device_id xgene_gpio_sb_acpi_match[] = {
-	{"APMC0D15", 0},
-	{},
+	{ "APMC0D15" },
+	{}
 };
 MODULE_DEVICE_TABLE(acpi, xgene_gpio_sb_acpi_match);
 
-- 
2.43.0.rc1.1336.g36b5255a03ac


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

* Re: [PATCH v1 0/4] gpio: xgene-sb: Improve ACPI and property related code
  2024-10-18 13:32 [PATCH v1 0/4] gpio: xgene-sb: Improve ACPI and property related code Andy Shevchenko
                   ` (3 preceding siblings ...)
  2024-10-18 13:32 ` [PATCH v1 4/4] gpio: xgene-sb: Tidy up ACPI and OF ID tables Andy Shevchenko
@ 2024-10-18 13:44 ` Andy Shevchenko
  4 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2024-10-18 13:44 UTC (permalink / raw)
  To: linux-gpio, linux-kernel; +Cc: Linus Walleij, Bartosz Golaszewski

On Fri, Oct 18, 2024 at 04:32:31PM +0300, Andy Shevchenko wrote:
> Improve ACPI and property related code in the driver.
> 
> Andy Shevchenko (4):
>   gpio: xgene-sb: Remove unneeded definitions for properties

>   gpio: xgene-sb: don't use "proxy" headers

Ah, patch order is wrong (we will see CIs are not being happy),
the above should be the last one.

>   gpio: xgene-sb: Drop ACPI_PTR() and CONFIG_ACPI guards
>   gpio: xgene-sb: Tidy up ACPI and OF ID tables

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2024-10-18 13:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-18 13:32 [PATCH v1 0/4] gpio: xgene-sb: Improve ACPI and property related code Andy Shevchenko
2024-10-18 13:32 ` [PATCH v1 1/4] gpio: xgene-sb: Remove unneeded definitions for properties Andy Shevchenko
2024-10-18 13:32 ` [PATCH v1 2/4] gpio: xgene-sb: don't use "proxy" headers Andy Shevchenko
2024-10-18 13:32 ` [PATCH v1 3/4] gpio: xgene-sb: Drop ACPI_PTR() and CONFIG_ACPI guards Andy Shevchenko
2024-10-18 13:32 ` [PATCH v1 4/4] gpio: xgene-sb: Tidy up ACPI and OF ID tables Andy Shevchenko
2024-10-18 13:44 ` [PATCH v1 0/4] gpio: xgene-sb: Improve ACPI and property related code Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).