linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iInput: adp5588-keys - use guard notation when acquiring mutexes
@ 2024-07-01 17:57 Dmitry Torokhov
  2024-07-01 20:28 ` Uwe Kleine-König
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2024-07-01 17:57 UTC (permalink / raw)
  To: Michael Hennerich, Utsav Agarwal, Nuno Sá
  Cc: Christophe JAILLET, Uwe Kleine-König, linux-input,
	linux-kernel

This makes the code more compact and error handling more robust.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---

Sending this out because Utsav is working on the driver so he can rebase
the work on top of this.

 drivers/input/keyboard/adp5588-keys.c | 49 ++++++++++-----------------
 1 file changed, 17 insertions(+), 32 deletions(-)

diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
index 1b0279393df4..09bcfc6b9408 100644
--- a/drivers/input/keyboard/adp5588-keys.c
+++ b/drivers/input/keyboard/adp5588-keys.c
@@ -221,15 +221,13 @@ static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned int off)
 	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
 	int val;
 
-	mutex_lock(&kpad->gpio_lock);
+	guard(mutex)(&kpad->gpio_lock);
 
 	if (kpad->dir[bank] & bit)
 		val = kpad->dat_out[bank];
 	else
 		val = adp5588_read(kpad->client, GPIO_DAT_STAT1 + bank);
 
-	mutex_unlock(&kpad->gpio_lock);
-
 	return !!(val & bit);
 }
 
@@ -240,7 +238,7 @@ static void adp5588_gpio_set_value(struct gpio_chip *chip,
 	unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
 	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
 
-	mutex_lock(&kpad->gpio_lock);
+	guard(mutex)(&kpad->gpio_lock);
 
 	if (val)
 		kpad->dat_out[bank] |= bit;
@@ -248,8 +246,6 @@ static void adp5588_gpio_set_value(struct gpio_chip *chip,
 		kpad->dat_out[bank] &= ~bit;
 
 	adp5588_write(kpad->client, GPIO_DAT_OUT1 + bank, kpad->dat_out[bank]);
-
-	mutex_unlock(&kpad->gpio_lock);
 }
 
 static int adp5588_gpio_set_config(struct gpio_chip *chip,  unsigned int off,
@@ -259,7 +255,6 @@ static int adp5588_gpio_set_config(struct gpio_chip *chip,  unsigned int off,
 	unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
 	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
 	bool pull_disable;
-	int ret;
 
 	switch (pinconf_to_config_param(config)) {
 	case PIN_CONFIG_BIAS_PULL_UP:
@@ -272,19 +267,15 @@ static int adp5588_gpio_set_config(struct gpio_chip *chip,  unsigned int off,
 		return -ENOTSUPP;
 	}
 
-	mutex_lock(&kpad->gpio_lock);
+	guard(mutex)(&kpad->gpio_lock);
 
 	if (pull_disable)
 		kpad->pull_dis[bank] |= bit;
 	else
 		kpad->pull_dis[bank] &= bit;
 
-	ret = adp5588_write(kpad->client, GPIO_PULL1 + bank,
-			    kpad->pull_dis[bank]);
-
-	mutex_unlock(&kpad->gpio_lock);
-
-	return ret;
+	return adp5588_write(kpad->client, GPIO_PULL1 + bank,
+			     kpad->pull_dis[bank]);
 }
 
 static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned int off)
@@ -292,16 +283,11 @@ static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned int off
 	struct adp5588_kpad *kpad = gpiochip_get_data(chip);
 	unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
 	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
-	int ret;
 
-	mutex_lock(&kpad->gpio_lock);
+	guard(mutex)(&kpad->gpio_lock);
 
 	kpad->dir[bank] &= ~bit;
-	ret = adp5588_write(kpad->client, GPIO_DIR1 + bank, kpad->dir[bank]);
-
-	mutex_unlock(&kpad->gpio_lock);
-
-	return ret;
+	return adp5588_write(kpad->client, GPIO_DIR1 + bank, kpad->dir[bank]);
 }
 
 static int adp5588_gpio_direction_output(struct gpio_chip *chip,
@@ -310,9 +296,9 @@ static int adp5588_gpio_direction_output(struct gpio_chip *chip,
 	struct adp5588_kpad *kpad = gpiochip_get_data(chip);
 	unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
 	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
-	int ret;
+	int error;
 
-	mutex_lock(&kpad->gpio_lock);
+	guard(mutex)(&kpad->gpio_lock);
 
 	kpad->dir[bank] |= bit;
 
@@ -321,17 +307,16 @@ static int adp5588_gpio_direction_output(struct gpio_chip *chip,
 	else
 		kpad->dat_out[bank] &= ~bit;
 
-	ret = adp5588_write(kpad->client, GPIO_DAT_OUT1 + bank,
-			    kpad->dat_out[bank]);
-	if (ret)
-		goto out_unlock;
-
-	ret = adp5588_write(kpad->client, GPIO_DIR1 + bank, kpad->dir[bank]);
+	error = adp5588_write(kpad->client, GPIO_DAT_OUT1 + bank,
+			      kpad->dat_out[bank]);
+	if (error)
+		return error;
 
-out_unlock:
-	mutex_unlock(&kpad->gpio_lock);
+	error = adp5588_write(kpad->client, GPIO_DIR1 + bank, kpad->dir[bank]);
+	if (error)
+		return error;
 
-	return ret;
+	return 0;
 }
 
 static int adp5588_build_gpiomap(struct adp5588_kpad *kpad)
-- 
2.45.2.803.g4e1b14247a-goog


-- 
Dmitry

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

* Re: [PATCH] iInput: adp5588-keys - use guard notation when acquiring mutexes
  2024-07-01 17:57 [PATCH] iInput: adp5588-keys - use guard notation when acquiring mutexes Dmitry Torokhov
@ 2024-07-01 20:28 ` Uwe Kleine-König
  2024-07-01 22:51   ` Dmitry Torokhov
  2024-07-02  6:11 ` Hennerich, Michael
  2024-07-02  9:50 ` [PATCH] Input: " Markus Elfring
  2 siblings, 1 reply; 6+ messages in thread
From: Uwe Kleine-König @ 2024-07-01 20:28 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Michael Hennerich, Utsav Agarwal, Nuno Sá,
	Christophe JAILLET, linux-input, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 4019 bytes --]

Hello Dmitry,

$Subject ~= s/iI/I/

On Mon, Jul 01, 2024 at 10:57:18AM -0700, Dmitry Torokhov wrote:
> This makes the code more compact and error handling more robust.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> 
> Sending this out because Utsav is working on the driver so he can rebase
> the work on top of this.
> 
>  drivers/input/keyboard/adp5588-keys.c | 49 ++++++++++-----------------
>  1 file changed, 17 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
> index 1b0279393df4..09bcfc6b9408 100644
> --- a/drivers/input/keyboard/adp5588-keys.c
> +++ b/drivers/input/keyboard/adp5588-keys.c
> @@ -221,15 +221,13 @@ static int adp5588_gpio_get_value(struct gpio_chip *chip, unsigned int off)
>  	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
>  	int val;
>  
> -	mutex_lock(&kpad->gpio_lock);
> +	guard(mutex)(&kpad->gpio_lock);
>  
>  	if (kpad->dir[bank] & bit)
>  		val = kpad->dat_out[bank];
>  	else
>  		val = adp5588_read(kpad->client, GPIO_DAT_STAT1 + bank);
>  
> -	mutex_unlock(&kpad->gpio_lock);
> -
>  	return !!(val & bit);
>  }
>  
> @@ -240,7 +238,7 @@ static void adp5588_gpio_set_value(struct gpio_chip *chip,
>  	unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
>  	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
>  
> -	mutex_lock(&kpad->gpio_lock);
> +	guard(mutex)(&kpad->gpio_lock);
>  
>  	if (val)
>  		kpad->dat_out[bank] |= bit;
> @@ -248,8 +246,6 @@ static void adp5588_gpio_set_value(struct gpio_chip *chip,
>  		kpad->dat_out[bank] &= ~bit;
>  
>  	adp5588_write(kpad->client, GPIO_DAT_OUT1 + bank, kpad->dat_out[bank]);
> -
> -	mutex_unlock(&kpad->gpio_lock);
>  }
>  
>  static int adp5588_gpio_set_config(struct gpio_chip *chip,  unsigned int off,
> @@ -259,7 +255,6 @@ static int adp5588_gpio_set_config(struct gpio_chip *chip,  unsigned int off,
>  	unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
>  	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
>  	bool pull_disable;
> -	int ret;
>  
>  	switch (pinconf_to_config_param(config)) {
>  	case PIN_CONFIG_BIAS_PULL_UP:
> @@ -272,19 +267,15 @@ static int adp5588_gpio_set_config(struct gpio_chip *chip,  unsigned int off,
>  		return -ENOTSUPP;
>  	}
>  
> -	mutex_lock(&kpad->gpio_lock);
> +	guard(mutex)(&kpad->gpio_lock);
>  
>  	if (pull_disable)
>  		kpad->pull_dis[bank] |= bit;
>  	else
>  		kpad->pull_dis[bank] &= bit;
>  
> -	ret = adp5588_write(kpad->client, GPIO_PULL1 + bank,
> -			    kpad->pull_dis[bank]);
> -
> -	mutex_unlock(&kpad->gpio_lock);
> -
> -	return ret;
> +	return adp5588_write(kpad->client, GPIO_PULL1 + bank,
> +			     kpad->pull_dis[bank]);
>  }
>  
>  static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned int off)
> @@ -292,16 +283,11 @@ static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned int off
>  	struct adp5588_kpad *kpad = gpiochip_get_data(chip);
>  	unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
>  	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
> -	int ret;
>  
> -	mutex_lock(&kpad->gpio_lock);
> +	guard(mutex)(&kpad->gpio_lock);
>  
>  	kpad->dir[bank] &= ~bit;
> -	ret = adp5588_write(kpad->client, GPIO_DIR1 + bank, kpad->dir[bank]);
> -
> -	mutex_unlock(&kpad->gpio_lock);
> -
> -	return ret;
> +	return adp5588_write(kpad->client, GPIO_DIR1 + bank, kpad->dir[bank]);
>  }
>  
>  static int adp5588_gpio_direction_output(struct gpio_chip *chip,
> @@ -310,9 +296,9 @@ static int adp5588_gpio_direction_output(struct gpio_chip *chip,
>  	struct adp5588_kpad *kpad = gpiochip_get_data(chip);
>  	unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
>  	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
> -	int ret;
> +	int error;

If you keep ret it's consistent with the other functions in this driver
(at least the one you touched above).

Otherwise looks fine to me,
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] iInput: adp5588-keys - use guard notation when acquiring mutexes
  2024-07-01 20:28 ` Uwe Kleine-König
@ 2024-07-01 22:51   ` Dmitry Torokhov
  2024-07-02  7:31     ` Uwe Kleine-König
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Torokhov @ 2024-07-01 22:51 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Michael Hennerich, Utsav Agarwal, Nuno Sá,
	Christophe JAILLET, linux-input, linux-kernel

On Mon, Jul 01, 2024 at 10:28:09PM +0200, Uwe Kleine-König wrote:
> Hello Dmitry,
> 
> $Subject ~= s/iI/I/

Oops, vim strikes again ;)

> >  
> >  static int adp5588_gpio_direction_output(struct gpio_chip *chip,
> > @@ -310,9 +296,9 @@ static int adp5588_gpio_direction_output(struct gpio_chip *chip,
> >  	struct adp5588_kpad *kpad = gpiochip_get_data(chip);
> >  	unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
> >  	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
> > -	int ret;
> > +	int error;
> 
> If you keep ret it's consistent with the other functions in this driver
> (at least the one you touched above).

This is part of my quest to have variables that hold error codes (i.e.
when we do not return them in case of success) to be called "error".
"ret" or "retval" is to be used when it is returned in both error and
success cases; before the guard notation we needed to use the same
variable in both success and failure.

> 
> Otherwise looks fine to me,

Thanks for the review!

-- 
Dmitry

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

* RE: [PATCH] iInput: adp5588-keys - use guard notation when acquiring mutexes
  2024-07-01 17:57 [PATCH] iInput: adp5588-keys - use guard notation when acquiring mutexes Dmitry Torokhov
  2024-07-01 20:28 ` Uwe Kleine-König
@ 2024-07-02  6:11 ` Hennerich, Michael
  2024-07-02  9:50 ` [PATCH] Input: " Markus Elfring
  2 siblings, 0 replies; 6+ messages in thread
From: Hennerich, Michael @ 2024-07-02  6:11 UTC (permalink / raw)
  To: Dmitry Torokhov, Agarwal, Utsav, Nuno Sá
  Cc: Christophe JAILLET, Uwe Kleine-König,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org



> -----Original Message-----
> From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Sent: Monday, July 1, 2024 7:57 PM
> To: Hennerich, Michael <Michael.Hennerich@analog.com>; Agarwal, Utsav
> <Utsav.Agarwal@analog.com>; Nuno Sá <noname.nuno@gmail.com>
> Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>; Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de>; linux-input@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Subject: [PATCH] iInput: adp5588-keys - use guard notation when acquiring
> mutexes
> 
> 
> This makes the code more compact and error handling more robust.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

> ---
> 
> Sending this out because Utsav is working on the driver so he can rebase the
> work on top of this.
> 
>  drivers/input/keyboard/adp5588-keys.c | 49 ++++++++++-----------------
>  1 file changed, 17 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/input/keyboard/adp5588-keys.c
> b/drivers/input/keyboard/adp5588-keys.c
> index 1b0279393df4..09bcfc6b9408 100644
> --- a/drivers/input/keyboard/adp5588-keys.c
> +++ b/drivers/input/keyboard/adp5588-keys.c
> @@ -221,15 +221,13 @@ static int adp5588_gpio_get_value(struct gpio_chip
> *chip, unsigned int off)
>  	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
>  	int val;
> 
> -	mutex_lock(&kpad->gpio_lock);
> +	guard(mutex)(&kpad->gpio_lock);
> 
>  	if (kpad->dir[bank] & bit)
>  		val = kpad->dat_out[bank];
>  	else
>  		val = adp5588_read(kpad->client, GPIO_DAT_STAT1 + bank);
> 
> -	mutex_unlock(&kpad->gpio_lock);
> -
>  	return !!(val & bit);
>  }
> 
> @@ -240,7 +238,7 @@ static void adp5588_gpio_set_value(struct gpio_chip
> *chip,
>  	unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
>  	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
> 
> -	mutex_lock(&kpad->gpio_lock);
> +	guard(mutex)(&kpad->gpio_lock);
> 
>  	if (val)
>  		kpad->dat_out[bank] |= bit;
> @@ -248,8 +246,6 @@ static void adp5588_gpio_set_value(struct gpio_chip
> *chip,
>  		kpad->dat_out[bank] &= ~bit;
> 
>  	adp5588_write(kpad->client, GPIO_DAT_OUT1 + bank, kpad-
> >dat_out[bank]);
> -
> -	mutex_unlock(&kpad->gpio_lock);
>  }
> 
>  static int adp5588_gpio_set_config(struct gpio_chip *chip,  unsigned int off,
> @@ -259,7 +255,6 @@ static int adp5588_gpio_set_config(struct gpio_chip
> *chip,  unsigned int off,
>  	unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
>  	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
>  	bool pull_disable;
> -	int ret;
> 
>  	switch (pinconf_to_config_param(config)) {
>  	case PIN_CONFIG_BIAS_PULL_UP:
> @@ -272,19 +267,15 @@ static int adp5588_gpio_set_config(struct gpio_chip
> *chip,  unsigned int off,
>  		return -ENOTSUPP;
>  	}
> 
> -	mutex_lock(&kpad->gpio_lock);
> +	guard(mutex)(&kpad->gpio_lock);
> 
>  	if (pull_disable)
>  		kpad->pull_dis[bank] |= bit;
>  	else
>  		kpad->pull_dis[bank] &= bit;
> 
> -	ret = adp5588_write(kpad->client, GPIO_PULL1 + bank,
> -			    kpad->pull_dis[bank]);
> -
> -	mutex_unlock(&kpad->gpio_lock);
> -
> -	return ret;
> +	return adp5588_write(kpad->client, GPIO_PULL1 + bank,
> +			     kpad->pull_dis[bank]);
>  }
> 
>  static int adp5588_gpio_direction_input(struct gpio_chip *chip, unsigned int
> off) @@ -292,16 +283,11 @@ static int adp5588_gpio_direction_input(struct
> gpio_chip *chip, unsigned int off
>  	struct adp5588_kpad *kpad = gpiochip_get_data(chip);
>  	unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
>  	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
> -	int ret;
> 
> -	mutex_lock(&kpad->gpio_lock);
> +	guard(mutex)(&kpad->gpio_lock);
> 
>  	kpad->dir[bank] &= ~bit;
> -	ret = adp5588_write(kpad->client, GPIO_DIR1 + bank, kpad->dir[bank]);
> -
> -	mutex_unlock(&kpad->gpio_lock);
> -
> -	return ret;
> +	return adp5588_write(kpad->client, GPIO_DIR1 + bank, kpad-
> >dir[bank]);
>  }
> 
>  static int adp5588_gpio_direction_output(struct gpio_chip *chip, @@ -310,9
> +296,9 @@ static int adp5588_gpio_direction_output(struct gpio_chip *chip,
>  	struct adp5588_kpad *kpad = gpiochip_get_data(chip);
>  	unsigned int bank = ADP5588_BANK(kpad->gpiomap[off]);
>  	unsigned int bit = ADP5588_BIT(kpad->gpiomap[off]);
> -	int ret;
> +	int error;
> 
> -	mutex_lock(&kpad->gpio_lock);
> +	guard(mutex)(&kpad->gpio_lock);
> 
>  	kpad->dir[bank] |= bit;
> 
> @@ -321,17 +307,16 @@ static int adp5588_gpio_direction_output(struct
> gpio_chip *chip,
>  	else
>  		kpad->dat_out[bank] &= ~bit;
> 
> -	ret = adp5588_write(kpad->client, GPIO_DAT_OUT1 + bank,
> -			    kpad->dat_out[bank]);
> -	if (ret)
> -		goto out_unlock;
> -
> -	ret = adp5588_write(kpad->client, GPIO_DIR1 + bank, kpad->dir[bank]);
> +	error = adp5588_write(kpad->client, GPIO_DAT_OUT1 + bank,
> +			      kpad->dat_out[bank]);
> +	if (error)
> +		return error;
> 
> -out_unlock:
> -	mutex_unlock(&kpad->gpio_lock);
> +	error = adp5588_write(kpad->client, GPIO_DIR1 + bank, kpad-
> >dir[bank]);
> +	if (error)
> +		return error;
> 
> -	return ret;
> +	return 0;
>  }
> 
>  static int adp5588_build_gpiomap(struct adp5588_kpad *kpad)
> --
> 2.45.2.803.g4e1b14247a-goog
> 
> 
> --
> Dmitry

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

* Re: [PATCH] iInput: adp5588-keys - use guard notation when acquiring mutexes
  2024-07-01 22:51   ` Dmitry Torokhov
@ 2024-07-02  7:31     ` Uwe Kleine-König
  0 siblings, 0 replies; 6+ messages in thread
From: Uwe Kleine-König @ 2024-07-02  7:31 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Michael Hennerich, Utsav Agarwal, Nuno Sá,
	Christophe JAILLET, linux-input, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1833 bytes --]

Hello Dmitry,

On Mon, Jul 01, 2024 at 03:51:43PM -0700, Dmitry Torokhov wrote:
> On Mon, Jul 01, 2024 at 10:28:09PM +0200, Uwe Kleine-König wrote:
> > If you keep ret it's consistent with the other functions in this driver
> > (at least the one you touched above).
> 
> This is part of my quest to have variables that hold error codes (i.e.
> when we do not return them in case of success) to be called "error".
> "ret" or "retval" is to be used when it is returned in both error and
> success cases; before the guard notation we needed to use the same
> variable in both success and failure.

That seems to be a bit artificial to me, given that you changed the
variable "ret" in adp5588_gpio_direction_output() to "error" and the
resulting code can be further simplified using

diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
index 09bcfc6b9408..5c8f07bbc452 100644
--- a/drivers/input/keyboard/adp5588-keys.c
+++ b/drivers/input/keyboard/adp5588-keys.c
@@ -313,10 +313,8 @@ static int adp5588_gpio_direction_output(struct gpio_chip *chip,
 		return error;
 
 	error = adp5588_write(kpad->client, GPIO_DIR1 + bank, kpad->dir[bank]);
-	if (error)
-		return error;
 
-	return 0;
+	return error;
 }
 
 static int adp5588_build_gpiomap(struct adp5588_kpad *kpad)

There are further inconsistencies in this driver, e.g. ret in
adp5588_fw_parse() isn't returned in the success path. adp5588_probe()
has both, error and ret, neither is used in the success path and a
single variable would be enough.

Given that, I'd suggest to make two commits: Let the driver use guards
without unmentioned and incomplete cleanups in the variable naming and
then in an additional changeset unify the error variable naming in the
complete driver.

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] Input: adp5588-keys - use guard notation when acquiring mutexes
  2024-07-01 17:57 [PATCH] iInput: adp5588-keys - use guard notation when acquiring mutexes Dmitry Torokhov
  2024-07-01 20:28 ` Uwe Kleine-König
  2024-07-02  6:11 ` Hennerich, Michael
@ 2024-07-02  9:50 ` Markus Elfring
  2 siblings, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2024-07-02  9:50 UTC (permalink / raw)
  To: Dmitry Torokhov, linux-input, Michael Hennerich, Nuno Sá,
	Utsav Agarwal
  Cc: LKML, Christophe Jaillet, Uwe Kleine-König

> This makes the code more compact and error handling more robust.

I suggest to improve such a change description another bit.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.10-rc6#n45

Regards,
Markus

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

end of thread, other threads:[~2024-07-02  9:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-01 17:57 [PATCH] iInput: adp5588-keys - use guard notation when acquiring mutexes Dmitry Torokhov
2024-07-01 20:28 ` Uwe Kleine-König
2024-07-01 22:51   ` Dmitry Torokhov
2024-07-02  7:31     ` Uwe Kleine-König
2024-07-02  6:11 ` Hennerich, Michael
2024-07-02  9:50 ` [PATCH] Input: " Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).