All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] gpio: dwapb: clarify usage of the register file version
@ 2021-11-30 16:49 Andy Shevchenko
  2021-12-01  8:29 ` Bartosz Golaszewski
  2021-12-01 12:27 ` Serge Semin
  0 siblings, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2021-11-30 16:49 UTC (permalink / raw)
  To: Andy Shevchenko, linux-gpio, linux-kernel
  Cc: Hoan Tran, Serge Semin, Linus Walleij, Bartosz Golaszewski

First of all, it's obvious that different versions can't be provided
simultaneously. Hence, versions can't be bit masks.

Second, due to above we have to mask out the version field in the flags
and only that can be evaluated against the certain version.

Clarify all above by:
 - introducing GPIO_REG_OFFSET_V1 and GPIO_REG_OFFSET_MASK
 - replacing conditional to mask out bits and compare to a version

Luckily there is no functional change (at least intended), so no need
to backport this.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-dwapb.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
index f98fa33e1679..ec0767d7800d 100644
--- a/drivers/gpio/gpio-dwapb.c
+++ b/drivers/gpio/gpio-dwapb.c
@@ -53,7 +53,9 @@
 #define GPIO_SWPORT_DR_STRIDE	0x0c /* register stride 3*32 bits */
 #define GPIO_SWPORT_DDR_STRIDE	0x0c /* register stride 3*32 bits */
 
+#define GPIO_REG_OFFSET_V1	0
 #define GPIO_REG_OFFSET_V2	1
+#define GPIO_REG_OFFSET_MASK	BIT(0)
 
 #define GPIO_INTMASK_V2		0x44
 #define GPIO_INTTYPE_LEVEL_V2	0x34
@@ -141,7 +143,7 @@ static inline u32 gpio_reg_v2_convert(unsigned int offset)
 
 static inline u32 gpio_reg_convert(struct dwapb_gpio *gpio, unsigned int offset)
 {
-	if (gpio->flags & GPIO_REG_OFFSET_V2)
+	if ((gpio->flags & GPIO_REG_OFFSET_MASK) == GPIO_REG_OFFSET_V2)
 		return gpio_reg_v2_convert(offset);
 
 	return offset;
@@ -668,15 +670,15 @@ static int dwapb_get_clks(struct dwapb_gpio *gpio)
 }
 
 static const struct of_device_id dwapb_of_match[] = {
-	{ .compatible = "snps,dw-apb-gpio", .data = (void *)0},
+	{ .compatible = "snps,dw-apb-gpio", .data = (void *)GPIO_REG_OFFSET_V1},
 	{ .compatible = "apm,xgene-gpio-v2", .data = (void *)GPIO_REG_OFFSET_V2},
 	{ /* Sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, dwapb_of_match);
 
 static const struct acpi_device_id dwapb_acpi_match[] = {
-	{"HISI0181", 0},
-	{"APMC0D07", 0},
+	{"HISI0181", GPIO_REG_OFFSET_V1},
+	{"APMC0D07", GPIO_REG_OFFSET_V1},
 	{"APMC0D81", GPIO_REG_OFFSET_V2},
 	{ }
 };
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] gpio: dwapb: clarify usage of the register file version
  2021-11-30 16:49 [PATCH v1 1/1] gpio: dwapb: clarify usage of the register file version Andy Shevchenko
@ 2021-12-01  8:29 ` Bartosz Golaszewski
  2021-12-01 13:12   ` Andy Shevchenko
  2021-12-01 12:27 ` Serge Semin
  1 sibling, 1 reply; 5+ messages in thread
From: Bartosz Golaszewski @ 2021-12-01  8:29 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: open list:GPIO SUBSYSTEM, Linux Kernel Mailing List, Hoan Tran,
	Serge Semin, Linus Walleij

On Tue, Nov 30, 2021 at 5:50 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> First of all, it's obvious that different versions can't be provided
> simultaneously. Hence, versions can't be bit masks.
>
> Second, due to above we have to mask out the version field in the flags
> and only that can be evaluated against the certain version.
>
> Clarify all above by:
>  - introducing GPIO_REG_OFFSET_V1 and GPIO_REG_OFFSET_MASK
>  - replacing conditional to mask out bits and compare to a version
>
> Luckily there is no functional change (at least intended), so no need
> to backport this.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/gpio/gpio-dwapb.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
> index f98fa33e1679..ec0767d7800d 100644
> --- a/drivers/gpio/gpio-dwapb.c
> +++ b/drivers/gpio/gpio-dwapb.c
> @@ -53,7 +53,9 @@
>  #define GPIO_SWPORT_DR_STRIDE  0x0c /* register stride 3*32 bits */
>  #define GPIO_SWPORT_DDR_STRIDE 0x0c /* register stride 3*32 bits */
>
> +#define GPIO_REG_OFFSET_V1     0
>  #define GPIO_REG_OFFSET_V2     1
> +#define GPIO_REG_OFFSET_MASK   BIT(0)
>
>  #define GPIO_INTMASK_V2                0x44
>  #define GPIO_INTTYPE_LEVEL_V2  0x34
> @@ -141,7 +143,7 @@ static inline u32 gpio_reg_v2_convert(unsigned int offset)
>
>  static inline u32 gpio_reg_convert(struct dwapb_gpio *gpio, unsigned int offset)
>  {
> -       if (gpio->flags & GPIO_REG_OFFSET_V2)
> +       if ((gpio->flags & GPIO_REG_OFFSET_MASK) == GPIO_REG_OFFSET_V2)
>                 return gpio_reg_v2_convert(offset);
>
>         return offset;
> @@ -668,15 +670,15 @@ static int dwapb_get_clks(struct dwapb_gpio *gpio)
>  }
>
>  static const struct of_device_id dwapb_of_match[] = {
> -       { .compatible = "snps,dw-apb-gpio", .data = (void *)0},
> +       { .compatible = "snps,dw-apb-gpio", .data = (void *)GPIO_REG_OFFSET_V1},
>         { .compatible = "apm,xgene-gpio-v2", .data = (void *)GPIO_REG_OFFSET_V2},
>         { /* Sentinel */ }
>  };
>  MODULE_DEVICE_TABLE(of, dwapb_of_match);
>
>  static const struct acpi_device_id dwapb_acpi_match[] = {
> -       {"HISI0181", 0},
> -       {"APMC0D07", 0},
> +       {"HISI0181", GPIO_REG_OFFSET_V1},
> +       {"APMC0D07", GPIO_REG_OFFSET_V1},
>         {"APMC0D81", GPIO_REG_OFFSET_V2},
>         { }
>  };
> --
> 2.33.0
>

Reviewed-by: Bartosz Golaszewski <brgl@bgdev.pl>

Please send it with your PR.

Bart

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] gpio: dwapb: clarify usage of the register file version
  2021-11-30 16:49 [PATCH v1 1/1] gpio: dwapb: clarify usage of the register file version Andy Shevchenko
  2021-12-01  8:29 ` Bartosz Golaszewski
@ 2021-12-01 12:27 ` Serge Semin
  2021-12-01 13:13   ` Andy Shevchenko
  1 sibling, 1 reply; 5+ messages in thread
From: Serge Semin @ 2021-12-01 12:27 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Serge Semin, linux-gpio, linux-kernel, Hoan Tran, Linus Walleij,
	Bartosz Golaszewski

On Tue, Nov 30, 2021 at 06:49:56PM +0200, Andy Shevchenko wrote:
> First of all, it's obvious that different versions can't be provided
> simultaneously. Hence, versions can't be bit masks.
> 
> Second, due to above we have to mask out the version field in the flags
> and only that can be evaluated against the certain version.
> 
> Clarify all above by:
>  - introducing GPIO_REG_OFFSET_V1 and GPIO_REG_OFFSET_MASK
>  - replacing conditional to mask out bits and compare to a version
> 
> Luckily there is no functional change (at least intended), so no need
> to backport this.

Seems reasonable. Thanks.
Acked-by: Serge Semin <fancer.lancer@gmail.com>

-Sergey

> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/gpio/gpio-dwapb.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-dwapb.c b/drivers/gpio/gpio-dwapb.c
> index f98fa33e1679..ec0767d7800d 100644
> --- a/drivers/gpio/gpio-dwapb.c
> +++ b/drivers/gpio/gpio-dwapb.c
> @@ -53,7 +53,9 @@
>  #define GPIO_SWPORT_DR_STRIDE	0x0c /* register stride 3*32 bits */
>  #define GPIO_SWPORT_DDR_STRIDE	0x0c /* register stride 3*32 bits */
>  
> +#define GPIO_REG_OFFSET_V1	0
>  #define GPIO_REG_OFFSET_V2	1
> +#define GPIO_REG_OFFSET_MASK	BIT(0)
>  
>  #define GPIO_INTMASK_V2		0x44
>  #define GPIO_INTTYPE_LEVEL_V2	0x34
> @@ -141,7 +143,7 @@ static inline u32 gpio_reg_v2_convert(unsigned int offset)
>  
>  static inline u32 gpio_reg_convert(struct dwapb_gpio *gpio, unsigned int offset)
>  {
> -	if (gpio->flags & GPIO_REG_OFFSET_V2)
> +	if ((gpio->flags & GPIO_REG_OFFSET_MASK) == GPIO_REG_OFFSET_V2)
>  		return gpio_reg_v2_convert(offset);
>  
>  	return offset;
> @@ -668,15 +670,15 @@ static int dwapb_get_clks(struct dwapb_gpio *gpio)
>  }
>  
>  static const struct of_device_id dwapb_of_match[] = {
> -	{ .compatible = "snps,dw-apb-gpio", .data = (void *)0},
> +	{ .compatible = "snps,dw-apb-gpio", .data = (void *)GPIO_REG_OFFSET_V1},
>  	{ .compatible = "apm,xgene-gpio-v2", .data = (void *)GPIO_REG_OFFSET_V2},
>  	{ /* Sentinel */ }
>  };
>  MODULE_DEVICE_TABLE(of, dwapb_of_match);
>  
>  static const struct acpi_device_id dwapb_acpi_match[] = {
> -	{"HISI0181", 0},
> -	{"APMC0D07", 0},
> +	{"HISI0181", GPIO_REG_OFFSET_V1},
> +	{"APMC0D07", GPIO_REG_OFFSET_V1},
>  	{"APMC0D81", GPIO_REG_OFFSET_V2},
>  	{ }
>  };
> -- 
> 2.33.0
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] gpio: dwapb: clarify usage of the register file version
  2021-12-01  8:29 ` Bartosz Golaszewski
@ 2021-12-01 13:12   ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2021-12-01 13:12 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: open list:GPIO SUBSYSTEM, Linux Kernel Mailing List, Hoan Tran,
	Serge Semin, Linus Walleij

On Wed, Dec 01, 2021 at 09:29:54AM +0100, Bartosz Golaszewski wrote:
> On Tue, Nov 30, 2021 at 5:50 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:

> Reviewed-by: Bartosz Golaszewski <brgl@bgdev.pl>

Thanks!

> Please send it with your PR.

Will do.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] gpio: dwapb: clarify usage of the register file version
  2021-12-01 12:27 ` Serge Semin
@ 2021-12-01 13:13   ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2021-12-01 13:13 UTC (permalink / raw)
  To: Serge Semin
  Cc: Serge Semin, linux-gpio, linux-kernel, Hoan Tran, Linus Walleij,
	Bartosz Golaszewski

On Wed, Dec 01, 2021 at 03:27:34PM +0300, Serge Semin wrote:
> On Tue, Nov 30, 2021 at 06:49:56PM +0200, Andy Shevchenko wrote:
> > First of all, it's obvious that different versions can't be provided
> > simultaneously. Hence, versions can't be bit masks.
> > 
> > Second, due to above we have to mask out the version field in the flags
> > and only that can be evaluated against the certain version.
> > 
> > Clarify all above by:
> >  - introducing GPIO_REG_OFFSET_V1 and GPIO_REG_OFFSET_MASK
> >  - replacing conditional to mask out bits and compare to a version
> > 
> > Luckily there is no functional change (at least intended), so no need
> > to backport this.
> 
> Seems reasonable. Thanks.
> Acked-by: Serge Semin <fancer.lancer@gmail.com>

Pushed to my review and testing queue, thanks!

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-12-01 13:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-30 16:49 [PATCH v1 1/1] gpio: dwapb: clarify usage of the register file version Andy Shevchenko
2021-12-01  8:29 ` Bartosz Golaszewski
2021-12-01 13:12   ` Andy Shevchenko
2021-12-01 12:27 ` Serge Semin
2021-12-01 13:13   ` Andy Shevchenko

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.