gpio: 74xx-mmio: Make use of device properties
PATCH 1/3 gpio: 74xx-mmio: Make use of device properties
Convert the module to be property provider agnostic and allow it to be used on non-OF platforms.
Add mod_devicetable.h include.
--- drivers/gpio/gpio-74xx-mmio.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpio/gpio-74xx-mmio.c +4 -3
@@ -6,10 +6,11 @@*/ #include <linux/err.h> -#include <linux/module.h> -#include <linux/of_device.h> #include <linux/gpio/driver.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> #include <linux/platform_device.h> +#include <linux/property.h> #define MMIO_74XX_DIR_IN (0 << 8)#define MMIO_74XX_DIR_OUT (1 << 8)
@@ -112,7 +113,7 @@ static int mmio_74xx_gpio_probe(struct platform_device *pdev)if (!priv)return -ENOMEM ; - priv->flags = (uintptr_t )of_device_get_match_data (&pdev->dev); + priv->flags = (uintptr_t )device_get_match_data (&pdev->dev); dat =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (dat))
Signature · 1 line
2.35.1
PATCH 2/3 gpio: 74xx-mmio: Check MMIO_74XX_DIR_IN flag in mmio_74xx_dir_in()
It's logically better to check the IN in ->direction_input() and _OUT in ->direction_output().
While at it, replace ternary with plain if-conditional for the sake of consistency with mmio_74xx_dir_out().
--- drivers/gpio/gpio-74xx-mmio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpio/gpio-74xx-mmio.c +4 -1
@@ -88,7 +88,10 @@ static int mmio_74xx_dir_in(struct gpio_chip *gc, unsigned int gpio) {struct mmio_74xx_gpio_priv *priv =gpiochip_get_data (gc); -return (priv->flags &MMIO_74XX_DIR_OUT ) ? -ENOTSUPP :0 ; +if (priv->flags &MMIO_74XX_DIR_IN ) +return 0 ; + +return -ENOTSUPP ; }static int mmio_74xx_dir_out (struct gpio_chip *gc,unsigned int gpio,int val)
Signature · 1 line
2.35.1
Re: [PATCH v1 2/3] gpio: 74xx-mmio: Check MMIO_74XX_DIR_IN flag in mmio_74xx_dir_in()
Quoted 7 lines · Andy Shevchenko
It's logically better to check the IN in ->direction_input() and
_OUTin ->direction_output().While at it, replace ternary with plain if-conditional for the sake of consistency with
mmio_74xx_dir_out().Signed-off-by Andy Shevchenko <[email protected]>
Yep this is better.
Yours,
Linus Walleij
PATCH 3/3 gpio: 74xx-mmio: use bits.h macros for all masks
In reply to Andy ShevchenkoMake use of the GENMASK() (far less error-prone, far more concise).
--- drivers/gpio/gpio-74xx-mmio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpio/gpio-74xx-mmio.c +2 -1
@@ -5,6 +5,7 @@* Copyright (C) 2014 Alexander Shiyan <[email protected]> */ +#include <linux/bits.h> #include <linux/err.h> #include <linux/gpio/driver.h> #include <linux/mod_devicetable.h>
@@ -14,7 +15,7 @@#define MMIO_74XX_DIR_IN (0 << 8)#define MMIO_74XX_DIR_OUT (1 << 8) -#define MMIO_74XX_BIT_CNT (x) ((x) & 0xff) +#define MMIO_74XX_BIT_CNT (x) ((x) & GENMASK(7, 0))struct mmio_74xx_gpio_priv {struct gpio_chip gc;
Signature · 1 line
2.35.1
Re: [PATCH v1 3/3] gpio: 74xx-mmio: use bits.h macros for all masks
Quoted 3 lines · Andy Shevchenko
Make use of the
GENMASK()(far less error-prone, far more concise).Signed-off-by Andy Shevchenko <[email protected]>
Yours,
Linus Walleij
Quoted 6 lines · Andy Shevchenko
Convert the module to be property provider agnostic and allow it to be used on non-OF platforms.
Add
mod_devicetable.hinclude.Signed-off-by Andy Shevchenko <[email protected]>
Yours,
Linus Walleij
Quoted 39 lines · Andy Shevchenko
Convert the module to be property provider agnostic and allow it to be used on non-OF platforms.
Add
mod_devicetable.hinclude.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/gpio/gpio-74xx-mmio.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/gpio/gpio-74xx-mmio.c +4
-4@@ -6,10 +6,11 @@*/ #include <linux/err.h> -#include <linux/module.h> -#include <linux/of_device.h> #include <linux/gpio/driver.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> #include <linux/platform_device.h> +#include <linux/property.h> #define MMIO_74XX_DIR_IN (0 << 8)#define MMIO_74XX_DIR_OUT (1 << 8)@@ -112,7 +113,7 @@ static int mmio_74xx_gpio_probe(struct platform_device *pdev)if (!priv)return -ENOMEM ; - priv->flags = (uintptr_t )of_device_get_match_data (&pdev->dev); + priv->flags = (uintptr_t )device_get_match_data (&pdev->dev); dat =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (dat)) --
Quoted 2 lines
2.35.1
All three applied, thanks!
Bart