[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <axu72rveax4ipfzdmm6mcl5g4wt2u3ptcmho25jgqafgmfg7fa@sqlzffrgmxhk>
Date: Tue, 2 Jul 2024 09:31:53 +0200
From: Uwe Kleine-König <u.kleine-koenig@...libre.com>
To: Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc: Michael Hennerich <michael.hennerich@...log.com>,
Utsav Agarwal <utsav.agarwal@...log.com>, Nuno Sá <noname.nuno@...il.com>,
Christophe JAILLET <christophe.jaillet@...adoo.fr>, linux-input@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iInput: adp5588-keys - use guard notation when acquiring
mutexes
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
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists