Linux-OMAP Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] gpio: omap: improve coding style for pin config flags
@ 2020-07-22 12:07 Drew Fustini
  2020-07-22 14:29 ` Gustavo A. R. Silva
  2020-07-23 13:05 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Drew Fustini @ 2020-07-22 12:07 UTC (permalink / raw)
  To: Tony Lindgren, Linus Walleij, Bartosz Golaszewski,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman, linux-omap,
	linux-gpio, linux-kernel, Gustavo A. R. Silva
  Cc: Drew Fustini

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;
-- 
2.25.1


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

* Re: [PATCH] gpio: omap: improve coding style for pin config flags
  2020-07-22 12:07 [PATCH] gpio: omap: improve coding style for pin config flags Drew Fustini
@ 2020-07-22 14:29 ` Gustavo A. R. Silva
  2020-07-23 13:05 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2020-07-22 14:29 UTC (permalink / raw)
  To: Drew Fustini
  Cc: Tony Lindgren, Linus Walleij, Bartosz Golaszewski,
	Grygorii Strashko, Santosh Shilimkar, Kevin Hilman, linux-omap,
	linux-gpio, linux-kernel, Gustavo A. R. Silva

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
> 

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

* Re: [PATCH] gpio: omap: improve coding style for pin config flags
  2020-07-22 12:07 [PATCH] gpio: omap: improve coding style for pin config flags Drew Fustini
  2020-07-22 14:29 ` Gustavo A. R. Silva
@ 2020-07-23 13:05 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2020-07-23 13:05 UTC (permalink / raw)
  To: Drew Fustini
  Cc: Tony Lindgren, Bartosz Golaszewski, Grygorii Strashko,
	Santosh Shilimkar, Kevin Hilman, Linux-OMAP,
	open list:GPIO SUBSYSTEM, linux-kernel, Gustavo A. R. Silva

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

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22 12:07 [PATCH] gpio: omap: improve coding style for pin config flags Drew Fustini
2020-07-22 14:29 ` Gustavo A. R. Silva
2020-07-23 13:05 ` Linus Walleij

Linux-OMAP Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-omap/0 linux-omap/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-omap linux-omap/ https://lore.kernel.org/linux-omap \
		linux-omap@vger.kernel.org
	public-inbox-index linux-omap

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-omap


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git