gpio: omap: improve coding style for pin config flags
diff mbox series

Message ID 20200722120755.230741-1-drew@beagleboard.org
State New
Headers show
Series
  • gpio: omap: improve coding style for pin config flags
Related show

Commit Message

Drew Fustini July 22, 2020, 12:07 p.m. UTC
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 <gustavo@embeddedor.com>
Signed-off-by: Drew Fustini <drew@beagleboard.org>
---
 drivers/gpio/gpio-omap.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Comments

Gustavo A. R. Silva July 22, 2020, 2:29 p.m. UTC | #1
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 <gustavo@embeddedor.com>
> Signed-off-by: Drew Fustini <drew@beagleboard.org>

Acked-by: Gustavo A. R. Silva <gustavoars@kernel.org>

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
>
Linus Walleij July 23, 2020, 1:05 p.m. UTC | #2
On Wed, Jul 22, 2020 at 2:09 PM Drew Fustini <drew@beagleboard.org> 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 <gustavo@embeddedor.com>
> Signed-off-by: Drew Fustini <drew@beagleboard.org>

Patch applied!

Yours,
Linus Walleij
Tony Lindgren Aug. 19, 2020, 6:31 a.m. UTC | #3
Hi,

* Drew Fustini <drew@beagleboard.org> [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 <gustavo@embeddedor.com>
> Signed-off-by: Drew Fustini <drew@beagleboard.org>

This looks OK to me:

Acked-by: Tony Lindgren <tony@atomide.com>

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
>
Grygorii Strashko Aug. 19, 2020, 11:29 a.m. UTC | #4
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 <gustavo@embeddedor.com>
> Signed-off-by: Drew Fustini <drew@beagleboard.org>
> ---
>   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 <grygorii.strashko@ti.com>
Drew Fustini Aug. 20, 2020, 1:15 a.m. UTC | #5
On Wed, Aug 19, 2020 at 09:31:27AM +0300, Tony Lindgren wrote:
> Hi,
> 
> * Drew Fustini <drew@beagleboard.org> [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 <gustavo@embeddedor.com>
> > Signed-off-by: Drew Fustini <drew@beagleboard.org>
> 
> This looks OK to me:
> 
> Acked-by: Tony Lindgren <tony@atomide.com>
> 
> 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 <drew@beagleboard.org>
Date:   Wed Jul 22 14:27:52 2020 +0200

    pinctrl: core: print gpio in pins debugfs file

commit bde8c0e64c78633612aaf283692f72bef0bbc549
Author: Drew Fustini <drew@beagleboard.org>
Date:   Wed Jul 22 14:07:56 2020 +0200

    gpio: omap: improve coding style for pin config flags
        
commit 75dec56710dfafd37daa95e756c5d1840932ba90
Author: Drew Fustini <drew@beagleboard.org>
Date:   Fri Jul 17 21:40:43 2020 +0200

    gpio: omap: handle pin config bias flags

commit 40e30d26d909af89de2dcd0b4abdd27c47ac2235
Author: Drew Fustini <drew@beagleboard.org>
Date:   Wed Jul 15 23:37:38 2020 +0200

    gpio: omap: handle pin config bias flags

commit abe4e4675dfc62b7f2328e2c4bce8b5bdcdff7c0
Author: Drew Fustini <drew@beagleboard.org>
Date:   Sun Jul 12 12:37:19 2020 +0200

    ARM: dts: am335x-pocketbeagle: set default mux for gpio pins
    
commit bc6d201591344aa21d616179ee9ad406a7336267
Author: Drew Fustini <drew@beagleboard.org>
Date:   Wed Jun 17 20:05:43 2020 +0200

    pinctrl: single: fix function name in documentation

commit 27c90e5e48d008bfda1cf6108eb699697317c67b
Author: Drew Fustini <drew@beagleboard.org>
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 <drew@beagleboard.org>
Date:   Wed Jul 1 03:33:19 2020 +0200

    pinctrl: single: parse #pinctrl-cells = 2
    
commit e14d2c766392ff1f226017fd62f0b6283a53bd0c
Author: Drew Fustini <drew@beagleboard.org>
Date:   Thu Jun 18 20:29:21 2020 +0200

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

commit aafd897a5ac4cb7f9b4f99acc5365a7df1f77aa0
Author: Drew Fustini <drew@beagleboard.org>
Date:   Thu May 21 22:09:26 2020 +0200

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

commit ff82009fcc6ace774570107750f5af91c9081b0a
Author: Drew Fustini <drew@beagleboard.org>
Date:   Wed Jun 10 13:02:58 2020 +0200

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

commit 25fae752156db7253471347df08a2700501eafde
Author: Drew Fustini <drew@beagleboard.org>
Date:   Fri Jun 12 13:27:58 2020 +0200

    pinctrl: single: fix function name in documentation

commit 80bf72598663496d08b3c0231377db6a99d7fd68
Author: Drew Fustini <drew@beagleboard.org>
Date:   Mon Jun 15 17:57:01 2020 +0200

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

commit d7af722344e6dc52d87649100516515263e15c75
Author: Drew Fustini <drew@beagleboard.org>
Date:   Tue Jun 9 23:45:21 2020 +0200

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

commit f46fe79ff1b65692a65266a5bec6dbe2bf7fc70f
Author: Drew Fustini <drew@beagleboard.org>
Date:   Mon Jun 8 14:51:43 2020 +0200

    pinctrl-single: fix pcs_parse_pinconf() return value

Author: Drew Fustini <drew@beagleboard.org>
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

Patch
diff mbox series

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;