Message ID | 20201111084833.40995-2-alexandru.ardelean@analog.com |
---|---|
State | New |
Headers | show |
Series | Input: adp5589: cleanup and use device-managed functions | expand |
Hi Alexandru, On Wed, Nov 11, 2020 at 10:48:28AM +0200, Alexandru Ardelean wrote: > The 'error' & 'ret' variables are used. This is a bit of duplication. > This change replaces the use of error with the 'ret' variable since the > name is a bit more generic. I really prefer variables that carry error codes/success and are used in error paths to be called "error", and "ret" or "retval" to be used in cases where we may return actual data. Thanks. -- Dmitry
> -----Original Message----- > From: Dmitry Torokhov <dmitry.torokhov@gmail.com> > Sent: Thursday, November 12, 2020 2:38 AM > To: Ardelean, Alexandru <alexandru.Ardelean@analog.com> > Cc: linux-input@vger.kernel.org; linux-kernel@vger.kernel.org > Subject: Re: [PATCH 1/6] Input: adp5589: use a single variable for error in probe > > [External] > > Hi Alexandru, > > On Wed, Nov 11, 2020 at 10:48:28AM +0200, Alexandru Ardelean wrote: > > The 'error' & 'ret' variables are used. This is a bit of duplication. > > This change replaces the use of error with the 'ret' variable since > > the name is a bit more generic. > > I really prefer variables that carry error codes/success and are used in error > paths to be called "error", and "ret" or "retval" to be used in cases where we > may return actual data. > Ack. Will do it the other way around for v2. > Thanks. > > -- > Dmitry
> -----Original Message----- > From: Ardelean, Alexandru > Sent: Thursday, November 12, 2020 8:40 AM > To: Dmitry Torokhov <dmitry.torokhov@gmail.com> > Cc: linux-input@vger.kernel.org; linux-kernel@vger.kernel.org > Subject: RE: [PATCH 1/6] Input: adp5589: use a single variable for error in probe > > > > -----Original Message----- > > From: Dmitry Torokhov <dmitry.torokhov@gmail.com> > > Sent: Thursday, November 12, 2020 2:38 AM > > To: Ardelean, Alexandru <alexandru.Ardelean@analog.com> > > Cc: linux-input@vger.kernel.org; linux-kernel@vger.kernel.org > > Subject: Re: [PATCH 1/6] Input: adp5589: use a single variable for > > error in probe > > > > [External] > > > > Hi Alexandru, > > > > On Wed, Nov 11, 2020 at 10:48:28AM +0200, Alexandru Ardelean wrote: > > > The 'error' & 'ret' variables are used. This is a bit of duplication. > > > This change replaces the use of error with the 'ret' variable since > > > the name is a bit more generic. > > > > I really prefer variables that carry error codes/success and are used > > in error paths to be called "error", and "ret" or "retval" to be used > > in cases where we may return actual data. > > > > Ack. > Will do it the other way around for v2. > Wait. I just had some coffee. I think you're saying to drop this patch. Also fine from my side. > > Thanks. > > > > -- > > Dmitry
diff --git a/drivers/input/keyboard/adp5589-keys.c b/drivers/input/keyboard/adp5589-keys.c index eb0e9cd66bcb..4cfb26e3d79c 100644 --- a/drivers/input/keyboard/adp5589-keys.c +++ b/drivers/input/keyboard/adp5589-keys.c @@ -994,7 +994,7 @@ static int adp5589_probe(struct i2c_client *client, const struct adp5589_kpad_platform_data *pdata = dev_get_platdata(&client->dev); unsigned int revid; - int error, ret; + int ret; if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { @@ -1028,28 +1028,26 @@ static int adp5589_probe(struct i2c_client *client, } ret = adp5589_read(client, ADP5589_5_ID); - if (ret < 0) { - error = ret; + if (ret < 0) goto err_free_mem; - } revid = (u8) ret & ADP5589_5_DEVICE_ID_MASK; if (pdata->keymapsize) { - error = adp5589_keypad_add(kpad, revid); - if (error) + ret = adp5589_keypad_add(kpad, revid); + if (ret) goto err_free_mem; } - error = adp5589_setup(kpad); - if (error) + ret = adp5589_setup(kpad); + if (ret) goto err_keypad_remove; if (kpad->gpimapsize) adp5589_report_switch_state(kpad); - error = adp5589_gpio_add(kpad); - if (error) + ret = adp5589_gpio_add(kpad); + if (ret) goto err_keypad_remove; i2c_set_clientdata(client, kpad); @@ -1062,7 +1060,7 @@ static int adp5589_probe(struct i2c_client *client, err_free_mem: kfree(kpad); - return error; + return ret; } static int adp5589_remove(struct i2c_client *client)
The 'error' & 'ret' variables are used. This is a bit of duplication. This change replaces the use of error with the 'ret' variable since the name is a bit more generic. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> --- drivers/input/keyboard/adp5589-keys.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)