gpio: xgene-sb: Improve ACPI and property related code
cover gpio: xgene-sb: Improve ACPI and property related code
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(-)
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH 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 2/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
PATCH 3/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
@@ -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, };
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
PATCH 4/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
@@ -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);
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Quoted 6 lines · Andy Shevchenko
Improve ACPI and property related code in the driver.
Andy Shevchenko (4):
gpio: xgene-sb: Remove unneeded definitions for propertiesgpio: 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.
Quoted 2 lines
gpio: xgene-sb: Drop
ACPI_PTR()andCONFIG_ACPIguards
gpio: xgene-sb: Tidy up ACPI and OF ID tables
Signature · 2 lines
With Best Regards, Andy Shevchenko