gpio: xgene-sb: Improve ACPI and property related code
v2 cover gpio: xgene-sb: Improve ACPI and property related code
Improve ACPI and property related code in the driver.
v2: reorder the patchs so we want be sure ACPI_PTR() is defined.
Andy Shevchenko (4):
gpio: xgene-sb: Remove unneeded definitions for properties
gpio: xgene-sb: Drop ACPI_PTR() and CONFIG_ACPI guards
gpio: xgene-sb: Tidy up ACPI and OF ID tables
gpio: xgene-sb: don't use "proxy" headers
drivers/gpio/gpio-xgene-sb.c | 37 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 19 deletions(-)
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH v2 1/4 gpio: xgene-sb: Remove unneeded definitions for properties
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.
--- drivers/gpio/gpio-xgene-sb.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/gpio/gpio-xgene-sb.c +3 -9
@@ -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",
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH v2 2/4 gpio: xgene-sb: Drop ACPI_PTR() and CONFIG_ACPI guards
In reply to Andy ShevchenkoThe 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.
--- drivers/gpio/gpio-xgene-sb.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpio/gpio-xgene-sb.c +2 -4
@@ -304,20 +304,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, };
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH v2 3/4 gpio: xgene-sb: Tidy up ACPI and OF ID tables
In reply to Andy ShevchenkoTidy up the ACPI and OF ID tables:
- remove explicit driver_data initializer
- drop comma in the terminator entry
--- drivers/gpio/gpio-xgene-sb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpio/gpio-xgene-sb.c +4 -4
@@ -299,14 +299,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);
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH v2 4/4 gpio: xgene-sb: don't use "proxy" headers
In reply to Andy ShevchenkoUpdate header inclusions to follow IWYU (Include What You Use) principle.
--- drivers/gpio/gpio-xgene-sb.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpio/gpio-xgene-sb.c +9 -2
@@ -8,12 +8,19 @@* Quan Nguyen <[email protected]>. */ -#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"
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Bartosz Golaszewski
AppliedFrom: Bartosz Golaszewski <[email protected]>
Quoted 11 lines · Andy Shevchenko
Improve ACPI and property related code in the driver.
v2: reorder the patchs so we want be sure
ACPI_PTR()is defined.Andy Shevchenko (4):
gpio: xgene-sb: Remove unneeded definitions for properties
gpio: xgene-sb: DropACPI_PTR()andCONFIG_ACPIguards
gpio: xgene-sb: Tidy up ACPI and OF ID tables
gpio: xgene-sb: don't use "proxy" headers[...]
Applied, thanks!
[1/4] gpio: xgene-sb: Remove unneeded definitions for properties
commit: 8b26b8e8be3eac0a3beacf1f07bf2dfb4d679d37
[2/4] gpio: xgene-sb: Drop ACPI_PTR() and CONFIG_ACPI guards
commit: 33319f6d3416fa00e87e9abf41d9ac98a5d5185c
[3/4] gpio: xgene-sb: Tidy up ACPI and OF ID tables
commit: 6ebbe789fe7a65205f77289d1ace46d52f1089a3
[4/4] gpio: xgene-sb: don't use "proxy" headers
commit: 101b259bce5cb7c74c4f96712ecdc4d204d49360Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>