* [PATCH v1 1/3] gpio: 74xx-mmio: Make use of device properties
@ 2022-07-18 22:02 Andy Shevchenko
2022-07-18 22:02 ` [PATCH v1 2/3] gpio: 74xx-mmio: Check MMIO_74XX_DIR_IN flag in mmio_74xx_dir_in() Andy Shevchenko
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Andy Shevchenko @ 2022-07-18 22:02 UTC (permalink / raw)
To: Andy Shevchenko, linux-gpio, linux-kernel
Cc: Linus Walleij, Bartosz Golaszewski
Convert the module to be property provider agnostic and allow
it to be used on non-OF platforms.
Add mod_devicetable.h include.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-74xx-mmio.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-74xx-mmio.c b/drivers/gpio/gpio-74xx-mmio.c
index 173e06758e6c..5e3c948ddb73 100644
--- a/drivers/gpio/gpio-74xx-mmio.c
+++ b/drivers/gpio/gpio-74xx-mmio.c
@@ -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))
--
2.35.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v1 2/3] gpio: 74xx-mmio: Check MMIO_74XX_DIR_IN flag in mmio_74xx_dir_in()
2022-07-18 22:02 [PATCH v1 1/3] gpio: 74xx-mmio: Make use of device properties Andy Shevchenko
@ 2022-07-18 22:02 ` Andy Shevchenko
2022-07-18 22:46 ` Linus Walleij
2022-07-18 22:02 ` [PATCH v1 3/3] gpio: 74xx-mmio: use bits.h macros for all masks Andy Shevchenko
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2022-07-18 22:02 UTC (permalink / raw)
To: Andy Shevchenko, linux-gpio, linux-kernel
Cc: Linus Walleij, Bartosz Golaszewski
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().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-74xx-mmio.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-74xx-mmio.c b/drivers/gpio/gpio-74xx-mmio.c
index 5e3c948ddb73..b2cc8a55c257 100644
--- a/drivers/gpio/gpio-74xx-mmio.c
+++ b/drivers/gpio/gpio-74xx-mmio.c
@@ -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)
--
2.35.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v1 3/3] gpio: 74xx-mmio: use bits.h macros for all masks
2022-07-18 22:02 [PATCH v1 1/3] gpio: 74xx-mmio: Make use of device properties Andy Shevchenko
2022-07-18 22:02 ` [PATCH v1 2/3] gpio: 74xx-mmio: Check MMIO_74XX_DIR_IN flag in mmio_74xx_dir_in() Andy Shevchenko
@ 2022-07-18 22:02 ` Andy Shevchenko
2022-07-18 22:47 ` Linus Walleij
2022-07-18 22:44 ` [PATCH v1 1/3] gpio: 74xx-mmio: Make use of device properties Linus Walleij
2022-07-19 8:16 ` Bartosz Golaszewski
3 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2022-07-18 22:02 UTC (permalink / raw)
To: Andy Shevchenko, linux-gpio, linux-kernel
Cc: Linus Walleij, Bartosz Golaszewski
Make use of the GENMASK() (far less error-prone, far more concise).
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-74xx-mmio.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-74xx-mmio.c b/drivers/gpio/gpio-74xx-mmio.c
index b2cc8a55c257..cd399898ed12 100644
--- a/drivers/gpio/gpio-74xx-mmio.c
+++ b/drivers/gpio/gpio-74xx-mmio.c
@@ -5,6 +5,7 @@
* Copyright (C) 2014 Alexander Shiyan <shc_work@mail.ru>
*/
+#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;
--
2.35.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/3] gpio: 74xx-mmio: Make use of device properties
2022-07-18 22:02 [PATCH v1 1/3] gpio: 74xx-mmio: Make use of device properties Andy Shevchenko
2022-07-18 22:02 ` [PATCH v1 2/3] gpio: 74xx-mmio: Check MMIO_74XX_DIR_IN flag in mmio_74xx_dir_in() Andy Shevchenko
2022-07-18 22:02 ` [PATCH v1 3/3] gpio: 74xx-mmio: use bits.h macros for all masks Andy Shevchenko
@ 2022-07-18 22:44 ` Linus Walleij
2022-07-19 8:16 ` Bartosz Golaszewski
3 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2022-07-18 22:44 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-gpio, linux-kernel, Bartosz Golaszewski
On Tue, Jul 19, 2022 at 12:02 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> Convert the module to be property provider agnostic and allow
> it to be used on non-OF platforms.
>
> Add mod_devicetable.h include.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 2/3] gpio: 74xx-mmio: Check MMIO_74XX_DIR_IN flag in mmio_74xx_dir_in()
2022-07-18 22:02 ` [PATCH v1 2/3] gpio: 74xx-mmio: Check MMIO_74XX_DIR_IN flag in mmio_74xx_dir_in() Andy Shevchenko
@ 2022-07-18 22:46 ` Linus Walleij
0 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2022-07-18 22:46 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-gpio, linux-kernel, Bartosz Golaszewski
On Tue, Jul 19, 2022 at 12:02 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> 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().
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Yep this is better.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 3/3] gpio: 74xx-mmio: use bits.h macros for all masks
2022-07-18 22:02 ` [PATCH v1 3/3] gpio: 74xx-mmio: use bits.h macros for all masks Andy Shevchenko
@ 2022-07-18 22:47 ` Linus Walleij
0 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2022-07-18 22:47 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-gpio, linux-kernel, Bartosz Golaszewski
On Tue, Jul 19, 2022 at 12:02 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> Make use of the GENMASK() (far less error-prone, far more concise).
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/3] gpio: 74xx-mmio: Make use of device properties
2022-07-18 22:02 [PATCH v1 1/3] gpio: 74xx-mmio: Make use of device properties Andy Shevchenko
` (2 preceding siblings ...)
2022-07-18 22:44 ` [PATCH v1 1/3] gpio: 74xx-mmio: Make use of device properties Linus Walleij
@ 2022-07-19 8:16 ` Bartosz Golaszewski
3 siblings, 0 replies; 7+ messages in thread
From: Bartosz Golaszewski @ 2022-07-19 8:16 UTC (permalink / raw)
To: Andy Shevchenko
Cc: open list:GPIO SUBSYSTEM, Linux Kernel Mailing List, Linus Walleij
On Tue, Jul 19, 2022 at 12:02 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> Convert the module to be property provider agnostic and allow
> it to be used on non-OF platforms.
>
> Add mod_devicetable.h include.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> drivers/gpio/gpio-74xx-mmio.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpio-74xx-mmio.c b/drivers/gpio/gpio-74xx-mmio.c
> index 173e06758e6c..5e3c948ddb73 100644
> --- a/drivers/gpio/gpio-74xx-mmio.c
> +++ b/drivers/gpio/gpio-74xx-mmio.c
> @@ -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))
> --
> 2.35.1
>
All three applied, thanks!
Bart
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-07-19 8:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-18 22:02 [PATCH v1 1/3] gpio: 74xx-mmio: Make use of device properties Andy Shevchenko
2022-07-18 22:02 ` [PATCH v1 2/3] gpio: 74xx-mmio: Check MMIO_74XX_DIR_IN flag in mmio_74xx_dir_in() Andy Shevchenko
2022-07-18 22:46 ` Linus Walleij
2022-07-18 22:02 ` [PATCH v1 3/3] gpio: 74xx-mmio: use bits.h macros for all masks Andy Shevchenko
2022-07-18 22:47 ` Linus Walleij
2022-07-18 22:44 ` [PATCH v1 1/3] gpio: 74xx-mmio: Make use of device properties Linus Walleij
2022-07-19 8:16 ` Bartosz Golaszewski
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.