gpio: ge: fixes and cleanups
cover gpio: ge: fixes and cleanups
Randy reported a couple of problems, the first two patches fix that. On top are a few cleanups.
Andy Shevchenko (6):
gpio: ge: Add missing header
gpio: ge: Fix English spelling and grammar
gpio: ge: Make driver OF-independent
gpio: ge: Utilise temporary variable for struct device
gpio: ge: Replace GPLv2 boilerplate with SPDX
gpio: ge: Enable COMPILE_TEST for the driver
drivers/gpio/Kconfig | 2 +- drivers/gpio/gpio-ge.c | 66 +++++++++++++++++++----------------------- 2 files changed, 30 insertions(+), 38 deletions(-)
Signature · 1 line
2.40.0.1.gaa8946217a0b
PATCH 1/6 gpio: ge: Add missing header
Add missing platform_device.h that used to be implied by of_device.h.
While at it, sort headers alphabetically for better maintenance.
--- drivers/gpio/gpio-ge.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/gpio/gpio-ge.c +6 -5
@@ -17,13 +17,14 @@* the I/O interrupt controllers mask to stop them propergating */ -#include <linux/kernel.h> +#include <linux/gpio/driver.h> #include <linux/io.h> -#include <linux/slab.h> -#include <linux/of.h> -#include <linux/of_address.h> +#include <linux/kernel.h> #include <linux/module.h> -#include <linux/gpio/driver.h> +#include <linux/of_address.h> +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/slab.h> #define GEF_GPIO_DIRECT 0x00#define GEF_GPIO_IN 0x04
Signature · 1 line
2.40.0.1.gaa8946217a0b
Re: [PATCH v1 1/6] gpio: ge: Add missing header
Quoted 11 lines · Andy Shevchenko
Add missing
platform_device.hthat used to be implied byof_device.h.While at it, sort headers alphabetically for better maintenance.
Reported-by Randy Dunlap <[email protected]>Fixes e91d0f05e66a ("gpio: Explicitly include correct DT includes")Signed-off-by Andy Shevchenko <[email protected]>--- drivers/gpio/gpio-ge.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
Thanks for fixing.
PATCH 2/6 gpio: ge: Fix English spelling and grammar
In reply to Andy ShevchenkoFix English spelling and grammar in the comments. While at it, fix the MODULE_AUTHOR() email address format.
--- drivers/gpio/gpio-ge.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/gpio/gpio-ge.c +6 -5
@@ -10,11 +10,12 @@* kind, whether express or implied. */ -/* TODO +/* +* TODO: * -* Configuration of output modes (totem-pole/open-drain) -* Interrupt configuration - interrupts are always generated the FPGA relies on -* the I/O interrupt controllers mask to stop them propergating +* Configuration of output modes (totem-pole/open-drain). +* Interrupt configuration - interrupts are always generated, the FPGA relies +* on the I/O interrupt controllers mask to stop them from being propagated. */ #include <linux/gpio/driver.h>
@@ -104,5 +105,5 @@ static struct platform_driver gef_gpio_driver = {module_platform_driver_probe (gef_gpio_driver, gef_gpio_probe);MODULE_DESCRIPTION ("GE I/O FPGA GPIO driver" ); -MODULE_AUTHOR ("Martyn Welch <[email protected]" ); +MODULE_AUTHOR ("Martyn Welch <[email protected]>" );MODULE_LICENSE ("GPL" );
Signature · 1 line
2.40.0.1.gaa8946217a0b
PATCH 3/6 gpio: ge: Make driver OF-independent
In reply to Andy ShevchenkoThere is nothing in the driver that requires OF APIs, make the driver OF independent.
--- drivers/gpio/gpio-ge.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-)
drivers/gpio/gpio-ge.c +13 -20
@@ -21,10 +21,10 @@#include <linux/gpio/driver.h> #include <linux/io.h> #include <linux/kernel.h> +#include <linux/mod_devicetable.h> #include <linux/module.h> -#include <linux/of_address.h> -#include <linux/of.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/slab.h> #define GEF_GPIO_DIRECT 0x00
@@ -54,6 +54,7 @@ MODULE_DEVICE_TABLE(of, gef_gpio_ids);static int __init gef_gpio_probe (struct platform_device *pdev) { +struct device *dev = &pdev->dev;struct gpio_chip *gc;void __iomem *regs;int ret;
@@ -62,38 +63,30 @@ static int __init gef_gpio_probe(struct platform_device *pdev)if (!gc)return -ENOMEM ; - regs =of_iomap (pdev->dev.of_node,0 ); -if (!regs) -return -ENOMEM ; + regs =devm_platform_ioremap_resource (pdev,0 ); +if (IS_ERR (regs)) +return PTR_ERR (regs); ret =bgpio_init (gc, &pdev->dev,4 , regs +GEF_GPIO_IN , regs +GEF_GPIO_OUT ,NULL ,NULL , regs +GEF_GPIO_DIRECT ,BGPIOF_BIG_ENDIAN_BYTE_ORDER ); -if (ret) { -dev_err (&pdev->dev,"bgpio_init failed\n" ); - goto err0; - } +if (ret) +return dev_err_probe (dev, ret,"bgpio_init failed\n" );/* Setup pointers to chip functions */ - gc->label =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"%pOF" , pdev->dev.of_node); -if (!gc->label) { - ret = -ENOMEM ; - goto err0; - } + gc->label =devm_kasprintf (dev,GFP_KERNEL ,"%pfw" ,dev_fwnode (dev)); +if (!gc->label) +return -ENOMEM ; gc->base =-1 ; - gc->ngpio = (u16 )(uintptr_t )of_device_get_match_data (&pdev->dev); + gc->ngpio = (uintptr_t )device_get_match_data (dev);/* This function adds a memory mapped GPIO chip */ ret =devm_gpiochip_add_data (&pdev->dev, gc,NULL );if (ret) - goto err0; +return dev_err_probe (dev, ret,"GPIO chip registration failed\n" );return 0 ; -err0: -iounmap (regs); -pr_err ("%pOF: GPIO chip registration failed\n" , pdev->dev.of_node); -return ret; };static struct platform_driver gef_gpio_driver = {
Signature · 1 line
2.40.0.1.gaa8946217a0b
PATCH 4/6 gpio: ge: Utilise temporary variable for struct device
In reply to Andy ShevchenkoWe have a temporary variable to keep pointer to struct device. Utilise it inside the ->probe() implementation.
--- drivers/gpio/gpio-ge.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpio/gpio-ge.c +5 -5
@@ -59,7 +59,7 @@ static int __init gef_gpio_probe(struct platform_device *pdev)void __iomem *regs;int ret; - gc =devm_kzalloc (&pdev->dev,sizeof (*gc),GFP_KERNEL ); + gc =devm_kzalloc (dev,sizeof (*gc),GFP_KERNEL );if (!gc)return -ENOMEM ;
@@ -67,9 +67,9 @@ static int __init gef_gpio_probe(struct platform_device *pdev)if (IS_ERR (regs))return PTR_ERR (regs); - ret =bgpio_init (gc, &pdev->dev,4 , regs +GEF_GPIO_IN , - regs +GEF_GPIO_OUT ,NULL ,NULL , - regs +GEF_GPIO_DIRECT ,BGPIOF_BIG_ENDIAN_BYTE_ORDER ); + ret =bgpio_init (gc, dev,4 , regs +GEF_GPIO_IN , regs +GEF_GPIO_OUT , +NULL ,NULL , regs +GEF_GPIO_DIRECT , +BGPIOF_BIG_ENDIAN_BYTE_ORDER );if (ret)return dev_err_probe (dev, ret,"bgpio_init failed\n" );
@@ -82,7 +82,7 @@ static int __init gef_gpio_probe(struct platform_device *pdev) gc->ngpio = (uintptr_t )device_get_match_data (dev);/* This function adds a memory mapped GPIO chip */ - ret =devm_gpiochip_add_data (&pdev->dev, gc,NULL ); + ret =devm_gpiochip_add_data (dev, gc,NULL );if (ret)return dev_err_probe (dev, ret,"GPIO chip registration failed\n" );
Signature · 1 line
2.40.0.1.gaa8946217a0b
PATCH 5/6 gpio: ge: Replace GPLv2 boilerplate with SPDX
In reply to Andy ShevchenkoReplace the GPLv2 boilerplate text with a nice and short SPDX header.
--- drivers/gpio/gpio-ge.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpio/gpio-ge.c +1 -4
@@ -1,13 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * Driver for GE FPGA based GPIO * * Author: Martyn Welch <[email protected]> * * 2008 (c) GE Intelligent Platforms Embedded Systems, Inc. -* -* This file is licensed under the terms of the GNU General Public License -* version 2. This program is licensed "as is" without any warranty of any -* kind, whether express or implied. */ /*
Signature · 1 line
2.40.0.1.gaa8946217a0b
PATCH 6/6 gpio: ge: Enable COMPILE_TEST for the driver
In reply to Andy ShevchenkoDriver is so simple, yet there was a room for mistakes. Reduce their appearance in the future by enabling COMPILE_TEST option.
--- drivers/gpio/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/Kconfig +1 -1
@@ -282,7 +282,7 @@ config GPIO_EXAR config GPIO_GE_FPGA bool "GE FPGA based GPIO" - depends on GE_FPGA + depends on GE_FPGA || COMPILE_TEST select GPIO_GENERIC help Support for common GPIO functionality provided on some GE Single Board
Signature · 1 line
2.40.0.1.gaa8946217a0b
Quoted 3 lines · Andy Shevchenko
Randy reported a couple of problems, the first two patches fix that. On top are a few cleanups.
For the series:
Thanks.
Quoted 12 lines
Andy Shevchenko (6):
gpio: ge: Add missing header
gpio: ge: Fix English spelling and grammar
gpio: ge: Make driver OF-independent
gpio: ge: Utilise temporary variable for struct device
gpio: ge: Replace GPLv2 boilerplate with SPDX
gpio: ge: EnableCOMPILE_TESTfor the driverdrivers/gpio/Kconfig | 2 +- drivers/gpio/gpio-ge.c | 66 +++++++++++++++++++----------------------- 2 files changed, 30 insertions(+), 38 deletions(-)
Signature · 1 line
~Randy
Quoted 12 lines · Andy Shevchenko
Randy reported a couple of problems, the first two patches fix that. On top are a few cleanups.
Andy Shevchenko (6):
gpio: ge: Add missing header
gpio: ge: Fix English spelling and grammar
gpio: ge: Make driver OF-independent
gpio: ge: Utilise temporary variable for struct device
gpio: ge: Replace GPLv2 boilerplate with SPDX
gpio: ge: EnableCOMPILE_TESTfor the driver
Quoted 7 lines
drivers/gpio/Kconfig | 2 +- drivers/gpio/gpio-ge.c | 66 +++++++++++++++++++----------------------- 2 files changed, 30 insertions(+), 38 deletions(-)--
2.40.0.1.gaa8946217a0b
Sweet! Applied the entire thing.
Bart