2020-07-22 12:10:05

by Drew Fustini

[permalink] [raw]
Subject: [PATCH] gpio: omap: improve coding style for pin config flags

Change the handling of pin config flags from if/else to switch
statement to make the code more readable and cleaner.

Suggested-by: Gustavo A. R. Silva <[email protected]>
Signed-off-by: Drew Fustini <[email protected]>
---
drivers/gpio/gpio-omap.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index e0eada82178c..7fbe0c9e1fc1 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -899,13 +899,18 @@ static int omap_gpio_set_config(struct gpio_chip *chip, unsigned offset,
u32 debounce;
int ret = -ENOTSUPP;

- if ((pinconf_to_config_param(config) == PIN_CONFIG_BIAS_DISABLE) ||
- (pinconf_to_config_param(config) == PIN_CONFIG_BIAS_PULL_UP) ||
- (pinconf_to_config_param(config) == PIN_CONFIG_BIAS_PULL_DOWN)) {
+ switch (pinconf_to_config_param(config)) {
+ case PIN_CONFIG_BIAS_DISABLE:
+ case PIN_CONFIG_BIAS_PULL_UP:
+ case PIN_CONFIG_BIAS_PULL_DOWN:
ret = gpiochip_generic_config(chip, offset, config);
- } else if (pinconf_to_config_param(config) == PIN_CONFIG_INPUT_DEBOUNCE) {
+ break;
+ case PIN_CONFIG_INPUT_DEBOUNCE:
debounce = pinconf_to_config_argument(config);
ret = omap_gpio_debounce(chip, offset, debounce);
+ break;
+ default:
+ break;
}

return ret;
--
2.25.1


2020-07-22 14:26:43

by Gustavo A. R. Silva

[permalink] [raw]
Subject: Re: [PATCH] gpio: omap: improve coding style for pin config flags

On Wed, Jul 22, 2020 at 02:07:56PM +0200, Drew Fustini wrote:
> Change the handling of pin config flags from if/else to switch
> statement to make the code more readable and cleaner.
>
> Suggested-by: Gustavo A. R. Silva <[email protected]>
> Signed-off-by: Drew Fustini <[email protected]>

Acked-by: Gustavo A. R. Silva <[email protected]>

Thanks, Drew.
--
Gustavo

> ---
> drivers/gpio/gpio-omap.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index e0eada82178c..7fbe0c9e1fc1 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -899,13 +899,18 @@ static int omap_gpio_set_config(struct gpio_chip *chip, unsigned offset,
> u32 debounce;
> int ret = -ENOTSUPP;
>
> - if ((pinconf_to_config_param(config) == PIN_CONFIG_BIAS_DISABLE) ||
> - (pinconf_to_config_param(config) == PIN_CONFIG_BIAS_PULL_UP) ||
> - (pinconf_to_config_param(config) == PIN_CONFIG_BIAS_PULL_DOWN)) {
> + switch (pinconf_to_config_param(config)) {
> + case PIN_CONFIG_BIAS_DISABLE:
> + case PIN_CONFIG_BIAS_PULL_UP:
> + case PIN_CONFIG_BIAS_PULL_DOWN:
> ret = gpiochip_generic_config(chip, offset, config);
> - } else if (pinconf_to_config_param(config) == PIN_CONFIG_INPUT_DEBOUNCE) {
> + break;
> + case PIN_CONFIG_INPUT_DEBOUNCE:
> debounce = pinconf_to_config_argument(config);
> ret = omap_gpio_debounce(chip, offset, debounce);
> + break;
> + default:
> + break;
> }
>
> return ret;
> --
> 2.25.1
>

2020-07-23 13:07:30

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH] gpio: omap: improve coding style for pin config flags

On Wed, Jul 22, 2020 at 2:09 PM Drew Fustini <[email protected]> wrote:

> Change the handling of pin config flags from if/else to switch
> statement to make the code more readable and cleaner.
>
> Suggested-by: Gustavo A. R. Silva <[email protected]>
> Signed-off-by: Drew Fustini <[email protected]>

Patch applied!

Yours,
Linus Walleij

2020-08-19 06:32:31

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCH] gpio: omap: improve coding style for pin config flags

Hi,

* Drew Fustini <[email protected]> [200722 12:09]:
> Change the handling of pin config flags from if/else to switch
> statement to make the code more readable and cleaner.
>
> Suggested-by: Gustavo A. R. Silva <[email protected]>
> Signed-off-by: Drew Fustini <[email protected]>

This looks OK to me:

Acked-by: Tony Lindgren <[email protected]>

I've lost track of the pending pinctrl/gpio/dts patches you've
posted :) Care to also summarized the pending ones and repost
them now that v5.9-rc1 is out?

Regards,

Tony

> ---
> drivers/gpio/gpio-omap.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index e0eada82178c..7fbe0c9e1fc1 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -899,13 +899,18 @@ static int omap_gpio_set_config(struct gpio_chip *chip, unsigned offset,
> u32 debounce;
> int ret = -ENOTSUPP;
>
> - if ((pinconf_to_config_param(config) == PIN_CONFIG_BIAS_DISABLE) ||
> - (pinconf_to_config_param(config) == PIN_CONFIG_BIAS_PULL_UP) ||
> - (pinconf_to_config_param(config) == PIN_CONFIG_BIAS_PULL_DOWN)) {
> + switch (pinconf_to_config_param(config)) {
> + case PIN_CONFIG_BIAS_DISABLE:
> + case PIN_CONFIG_BIAS_PULL_UP:
> + case PIN_CONFIG_BIAS_PULL_DOWN:
> ret = gpiochip_generic_config(chip, offset, config);
> - } else if (pinconf_to_config_param(config) == PIN_CONFIG_INPUT_DEBOUNCE) {
> + break;
> + case PIN_CONFIG_INPUT_DEBOUNCE:
> debounce = pinconf_to_config_argument(config);
> ret = omap_gpio_debounce(chip, offset, debounce);
> + break;
> + default:
> + break;
> }
>
> return ret;
> --
> 2.25.1
>

2020-08-19 11:33:14

by Grygorii Strashko

[permalink] [raw]
Subject: Re: [PATCH] gpio: omap: improve coding style for pin config flags



On 22/07/2020 15:07, Drew Fustini wrote:
> Change the handling of pin config flags from if/else to switch
> statement to make the code more readable and cleaner.
>
> Suggested-by: Gustavo A. R. Silva <[email protected]>
> Signed-off-by: Drew Fustini <[email protected]>
> ---
> drivers/gpio/gpio-omap.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
> index e0eada82178c..7fbe0c9e1fc1 100644
> --- a/drivers/gpio/gpio-omap.c
> +++ b/drivers/gpio/gpio-omap.c
> @@ -899,13 +899,18 @@ static int omap_gpio_set_config(struct gpio_chip *chip, unsigned offset,
> u32 debounce;
> int ret = -ENOTSUPP;
>
> - if ((pinconf_to_config_param(config) == PIN_CONFIG_BIAS_DISABLE) ||
> - (pinconf_to_config_param(config) == PIN_CONFIG_BIAS_PULL_UP) ||
> - (pinconf_to_config_param(config) == PIN_CONFIG_BIAS_PULL_DOWN)) {
> + switch (pinconf_to_config_param(config)) {
> + case PIN_CONFIG_BIAS_DISABLE:
> + case PIN_CONFIG_BIAS_PULL_UP:
> + case PIN_CONFIG_BIAS_PULL_DOWN:
> ret = gpiochip_generic_config(chip, offset, config);
> - } else if (pinconf_to_config_param(config) == PIN_CONFIG_INPUT_DEBOUNCE) {
> + break;
> + case PIN_CONFIG_INPUT_DEBOUNCE:
> debounce = pinconf_to_config_argument(config);
> ret = omap_gpio_debounce(chip, offset, debounce);
> + break;
> + default:
> + break;
> }
>
> return ret;
>

Thank you.
Acked-by: Grygorii Strashko <[email protected]>

--
Best regards,
grygorii

2020-08-20 01:16:59

by Drew Fustini

[permalink] [raw]
Subject: Re: [PATCH] gpio: omap: improve coding style for pin config flags

On Wed, Aug 19, 2020 at 09:31:27AM +0300, Tony Lindgren wrote:
> Hi,
>
> * Drew Fustini <[email protected]> [200722 12:09]:
> > Change the handling of pin config flags from if/else to switch
> > statement to make the code more readable and cleaner.
> >
> > Suggested-by: Gustavo A. R. Silva <[email protected]>
> > Signed-off-by: Drew Fustini <[email protected]>
>
> This looks OK to me:
>
> Acked-by: Tony Lindgren <[email protected]>
>
> I've lost track of the pending pinctrl/gpio/dts patches you've
> posted :) Care to also summarized the pending ones and repost
> them now that v5.9-rc1 is out?

Everything appears to be in mainline already:

commit f1b206cf7c57561ea156798f323b0541a783bd2f
Author: Drew Fustini <[email protected]>
Date: Wed Jul 22 14:27:52 2020 +0200

pinctrl: core: print gpio in pins debugfs file

commit bde8c0e64c78633612aaf283692f72bef0bbc549
Author: Drew Fustini <[email protected]>
Date: Wed Jul 22 14:07:56 2020 +0200

gpio: omap: improve coding style for pin config flags

commit 75dec56710dfafd37daa95e756c5d1840932ba90
Author: Drew Fustini <[email protected]>
Date: Fri Jul 17 21:40:43 2020 +0200

gpio: omap: handle pin config bias flags

commit 40e30d26d909af89de2dcd0b4abdd27c47ac2235
Author: Drew Fustini <[email protected]>
Date: Wed Jul 15 23:37:38 2020 +0200

gpio: omap: handle pin config bias flags

commit abe4e4675dfc62b7f2328e2c4bce8b5bdcdff7c0
Author: Drew Fustini <[email protected]>
Date: Sun Jul 12 12:37:19 2020 +0200

ARM: dts: am335x-pocketbeagle: set default mux for gpio pins

commit bc6d201591344aa21d616179ee9ad406a7336267
Author: Drew Fustini <[email protected]>
Date: Wed Jun 17 20:05:43 2020 +0200

pinctrl: single: fix function name in documentation

commit 27c90e5e48d008bfda1cf6108eb699697317c67b
Author: Drew Fustini <[email protected]>
Date: Wed Jul 1 03:33:20 2020 +0200

ARM: dts: am33xx-l4: change #pinctrl-cells from 1 to 2

commit a133954188887a830b5ce438a287a5e4e234b1be
Author: Drew Fustini <[email protected]>
Date: Wed Jul 1 03:33:19 2020 +0200

pinctrl: single: parse #pinctrl-cells = 2

commit e14d2c766392ff1f226017fd62f0b6283a53bd0c
Author: Drew Fustini <[email protected]>
Date: Thu Jun 18 20:29:21 2020 +0200

ARM: dts: am335x-pocketbeagle: add gpio-line-names

commit aafd897a5ac4cb7f9b4f99acc5365a7df1f77aa0
Author: Drew Fustini <[email protected]>
Date: Thu May 21 22:09:26 2020 +0200

ARM: dts: am335x-boneblack: add gpio-line-names

commit ff82009fcc6ace774570107750f5af91c9081b0a
Author: Drew Fustini <[email protected]>
Date: Wed Jun 10 13:02:58 2020 +0200

ARM: dts: am33xx-l4: add gpio-ranges

commit 25fae752156db7253471347df08a2700501eafde
Author: Drew Fustini <[email protected]>
Date: Fri Jun 12 13:27:58 2020 +0200

pinctrl: single: fix function name in documentation

commit 80bf72598663496d08b3c0231377db6a99d7fd68
Author: Drew Fustini <[email protected]>
Date: Mon Jun 15 17:57:01 2020 +0200

ARM: dts: am5729: beaglebone-ai: fix rgmii phy-mode

commit d7af722344e6dc52d87649100516515263e15c75
Author: Drew Fustini <[email protected]>
Date: Tue Jun 9 23:45:21 2020 +0200

ARM: dts: am335x-pocketbeagle: Fix mmc0 Write Protect

commit f46fe79ff1b65692a65266a5bec6dbe2bf7fc70f
Author: Drew Fustini <[email protected]>
Date: Mon Jun 8 14:51:43 2020 +0200

pinctrl-single: fix pcs_parse_pinconf() return value

Author: Drew Fustini <[email protected]>
Date: Fri Apr 3 21:19:31 2020 +0200

dt-bindings: Add vendor prefix for BeagleBoard.org


The only thing that isn't would be "ARM: dts: am33xx: add ocp label"
which you applied to omap-for-v5.9/dt.

thanks,
drew