* [PATCH 01/18] Input: joydev - use memdup_user() to duplicate memory from user-space
2015-10-02 13:40 [PATCH 00/18] Input - Fix make coccicheck warnings Javier Martinez Canillas
@ 2015-10-02 13:40 ` Javier Martinez Canillas
2015-10-02 18:21 ` Dmitry Torokhov
2015-10-02 13:40 ` [PATCH 02/18] Input: ads7846 - use PTR_ERR_OR_ZERO() Javier Martinez Canillas
` (17 subsequent siblings)
18 siblings, 1 reply; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-02 13:40 UTC (permalink / raw)
To: linux-kernel; +Cc: Javier Martinez Canillas, Dmitry Torokhov, linux-input
The memdup_user() helper function can be used to duplicate a memory region
from user-space to kernel-space. There is no need to open code the same
logic using kmalloc() and copy_from_user() instead. This was found with
make coccicheck that reported the following warning:
drivers/input/joydev.c:447:10-17: WARNING opportunity for memdup_user
drivers/input/joydev.c:483:10-17: WARNING opportunity for memdup_user
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/input/joydev.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 6cb5a3e5f9a1..e3dcd4abae18 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -444,12 +444,9 @@ static int joydev_handle_JSIOCSAXMAP(struct joydev *joydev,
len = min(len, sizeof(joydev->abspam));
/* Validate the map. */
- abspam = kmalloc(len, GFP_KERNEL);
- if (!abspam)
- return -ENOMEM;
-
- if (copy_from_user(abspam, argp, len)) {
- retval = -EFAULT;
+ abspam = memdup_user(argp, len);
+ if (IS_ERR(abspam)) {
+ retval = PTR_ERR(abspam);
goto out;
}
@@ -480,12 +477,9 @@ static int joydev_handle_JSIOCSBTNMAP(struct joydev *joydev,
len = min(len, sizeof(joydev->keypam));
/* Validate the map. */
- keypam = kmalloc(len, GFP_KERNEL);
- if (!keypam)
- return -ENOMEM;
-
- if (copy_from_user(keypam, argp, len)) {
- retval = -EFAULT;
+ keypam = memdup_user(argp, len);
+ if (IS_ERR(keypam)) {
+ retval = PTR_ERR(keypam);
goto out;
}
--
2.4.3
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH 01/18] Input: joydev - use memdup_user() to duplicate memory from user-space
2015-10-02 13:40 ` [PATCH 01/18] Input: joydev - use memdup_user() to duplicate memory from user-space Javier Martinez Canillas
@ 2015-10-02 18:21 ` Dmitry Torokhov
0 siblings, 0 replies; 32+ messages in thread
From: Dmitry Torokhov @ 2015-10-02 18:21 UTC (permalink / raw)
To: Javier Martinez Canillas; +Cc: linux-kernel, linux-input
On Fri, Oct 02, 2015 at 03:40:12PM +0200, Javier Martinez Canillas wrote:
> The memdup_user() helper function can be used to duplicate a memory region
> from user-space to kernel-space. There is no need to open code the same
> logic using kmalloc() and copy_from_user() instead. This was found with
> make coccicheck that reported the following warning:
>
> drivers/input/joydev.c:447:10-17: WARNING opportunity for memdup_user
> drivers/input/joydev.c:483:10-17: WARNING opportunity for memdup_user
>
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Applied, thank you.
> ---
>
> drivers/input/joydev.c | 18 ++++++------------
> 1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
> index 6cb5a3e5f9a1..e3dcd4abae18 100644
> --- a/drivers/input/joydev.c
> +++ b/drivers/input/joydev.c
> @@ -444,12 +444,9 @@ static int joydev_handle_JSIOCSAXMAP(struct joydev *joydev,
> len = min(len, sizeof(joydev->abspam));
>
> /* Validate the map. */
> - abspam = kmalloc(len, GFP_KERNEL);
> - if (!abspam)
> - return -ENOMEM;
> -
> - if (copy_from_user(abspam, argp, len)) {
> - retval = -EFAULT;
> + abspam = memdup_user(argp, len);
> + if (IS_ERR(abspam)) {
> + retval = PTR_ERR(abspam);
> goto out;
> }
>
> @@ -480,12 +477,9 @@ static int joydev_handle_JSIOCSBTNMAP(struct joydev *joydev,
> len = min(len, sizeof(joydev->keypam));
>
> /* Validate the map. */
> - keypam = kmalloc(len, GFP_KERNEL);
> - if (!keypam)
> - return -ENOMEM;
> -
> - if (copy_from_user(keypam, argp, len)) {
> - retval = -EFAULT;
> + keypam = memdup_user(argp, len);
> + if (IS_ERR(keypam)) {
> + retval = PTR_ERR(keypam);
> goto out;
> }
>
> --
> 2.4.3
>
--
Dmitry
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH 02/18] Input: ads7846 - use PTR_ERR_OR_ZERO()
2015-10-02 13:40 [PATCH 00/18] Input - Fix make coccicheck warnings Javier Martinez Canillas
2015-10-02 13:40 ` [PATCH 01/18] Input: joydev - use memdup_user() to duplicate memory from user-space Javier Martinez Canillas
@ 2015-10-02 13:40 ` Javier Martinez Canillas
2015-10-02 18:21 ` Dmitry Torokhov
2015-10-02 13:40 ` [PATCH 03/18] Input: cyttsp " Javier Martinez Canillas
` (16 subsequent siblings)
18 siblings, 1 reply; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-02 13:40 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, linux-input, Dmitry Torokhov,
Jingoo Han
The PTR_ERR_OR_ZERO() helper function checks if a pointer contains an
errno code and returns it or return 0 if that's not the case. Use the
helper instead of open coding the same logic in the driver. This was
found with make coccicheck that complains with the following warning:
drivers/input/touchscreen/ads7846.c:532:1-3: WARNING: PTR_ERR_OR_ZERO can be used
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/input/touchscreen/ads7846.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 0f5f968592bd..727d88c900c1 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -529,10 +529,8 @@ static int ads784x_hwmon_register(struct spi_device *spi, struct ads7846 *ts)
ts->hwmon = hwmon_device_register_with_groups(&spi->dev, spi->modalias,
ts, ads7846_attr_groups);
- if (IS_ERR(ts->hwmon))
- return PTR_ERR(ts->hwmon);
- return 0;
+ return PTR_ERR_OR_ZERO(ts->hwmon);
}
static void ads784x_hwmon_unregister(struct spi_device *spi,
--
2.4.3
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH 02/18] Input: ads7846 - use PTR_ERR_OR_ZERO()
2015-10-02 13:40 ` [PATCH 02/18] Input: ads7846 - use PTR_ERR_OR_ZERO() Javier Martinez Canillas
@ 2015-10-02 18:21 ` Dmitry Torokhov
0 siblings, 0 replies; 32+ messages in thread
From: Dmitry Torokhov @ 2015-10-02 18:21 UTC (permalink / raw)
To: Javier Martinez Canillas; +Cc: linux-kernel, linux-input, Jingoo Han
On Fri, Oct 02, 2015 at 03:40:13PM +0200, Javier Martinez Canillas wrote:
> The PTR_ERR_OR_ZERO() helper function checks if a pointer contains an
> errno code and returns it or return 0 if that's not the case. Use the
> helper instead of open coding the same logic in the driver. This was
> found with make coccicheck that complains with the following warning:
>
> drivers/input/touchscreen/ads7846.c:532:1-3: WARNING: PTR_ERR_OR_ZERO can be used
>
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Applied, thank you.
> ---
>
> drivers/input/touchscreen/ads7846.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
> index 0f5f968592bd..727d88c900c1 100644
> --- a/drivers/input/touchscreen/ads7846.c
> +++ b/drivers/input/touchscreen/ads7846.c
> @@ -529,10 +529,8 @@ static int ads784x_hwmon_register(struct spi_device *spi, struct ads7846 *ts)
>
> ts->hwmon = hwmon_device_register_with_groups(&spi->dev, spi->modalias,
> ts, ads7846_attr_groups);
> - if (IS_ERR(ts->hwmon))
> - return PTR_ERR(ts->hwmon);
>
> - return 0;
> + return PTR_ERR_OR_ZERO(ts->hwmon);
> }
>
> static void ads784x_hwmon_unregister(struct spi_device *spi,
> --
> 2.4.3
>
--
Dmitry
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH 03/18] Input: cyttsp - use PTR_ERR_OR_ZERO()
2015-10-02 13:40 [PATCH 00/18] Input - Fix make coccicheck warnings Javier Martinez Canillas
2015-10-02 13:40 ` [PATCH 01/18] Input: joydev - use memdup_user() to duplicate memory from user-space Javier Martinez Canillas
2015-10-02 13:40 ` [PATCH 02/18] Input: ads7846 - use PTR_ERR_OR_ZERO() Javier Martinez Canillas
@ 2015-10-02 13:40 ` Javier Martinez Canillas
2015-10-02 18:21 ` Dmitry Torokhov
2015-10-02 13:40 ` [PATCH 04/18] Input: kxtj9 - remove unneeded retval variable Javier Martinez Canillas
` (15 subsequent siblings)
18 siblings, 1 reply; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-02 13:40 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, Ferruh Yigit, Dmitry Torokhov,
linux-input
The PTR_ERR_OR_ZERO() helper function checks if a pointer contains an
errno code and returns it or return 0 if that's not the case. Use the
helper instead of open coding the same logic in the driver. This was
found with make coccicheck that complains with the following warning:
drivers/input/touchscreen/cyttsp4_i2c.c:53:1-3: WARNING: PTR_ERR_OR_ZERO can be used
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/input/touchscreen/cyttsp4_i2c.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/input/touchscreen/cyttsp4_i2c.c b/drivers/input/touchscreen/cyttsp4_i2c.c
index a9f95c7d3c00..564e49002d5d 100644
--- a/drivers/input/touchscreen/cyttsp4_i2c.c
+++ b/drivers/input/touchscreen/cyttsp4_i2c.c
@@ -50,10 +50,7 @@ static int cyttsp4_i2c_probe(struct i2c_client *client,
ts = cyttsp4_probe(&cyttsp4_i2c_bus_ops, &client->dev, client->irq,
CYTTSP4_I2C_DATA_SIZE);
- if (IS_ERR(ts))
- return PTR_ERR(ts);
-
- return 0;
+ return PTR_ERR_OR_ZERO(ts);
}
static int cyttsp4_i2c_remove(struct i2c_client *client)
--
2.4.3
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH 03/18] Input: cyttsp - use PTR_ERR_OR_ZERO()
2015-10-02 13:40 ` [PATCH 03/18] Input: cyttsp " Javier Martinez Canillas
@ 2015-10-02 18:21 ` Dmitry Torokhov
0 siblings, 0 replies; 32+ messages in thread
From: Dmitry Torokhov @ 2015-10-02 18:21 UTC (permalink / raw)
To: Javier Martinez Canillas; +Cc: linux-kernel, Ferruh Yigit, linux-input
On Fri, Oct 02, 2015 at 03:40:14PM +0200, Javier Martinez Canillas wrote:
> The PTR_ERR_OR_ZERO() helper function checks if a pointer contains an
> errno code and returns it or return 0 if that's not the case. Use the
> helper instead of open coding the same logic in the driver. This was
> found with make coccicheck that complains with the following warning:
>
> drivers/input/touchscreen/cyttsp4_i2c.c:53:1-3: WARNING: PTR_ERR_OR_ZERO can be used
>
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Applied, thank you.
> ---
>
> drivers/input/touchscreen/cyttsp4_i2c.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/input/touchscreen/cyttsp4_i2c.c b/drivers/input/touchscreen/cyttsp4_i2c.c
> index a9f95c7d3c00..564e49002d5d 100644
> --- a/drivers/input/touchscreen/cyttsp4_i2c.c
> +++ b/drivers/input/touchscreen/cyttsp4_i2c.c
> @@ -50,10 +50,7 @@ static int cyttsp4_i2c_probe(struct i2c_client *client,
> ts = cyttsp4_probe(&cyttsp4_i2c_bus_ops, &client->dev, client->irq,
> CYTTSP4_I2C_DATA_SIZE);
>
> - if (IS_ERR(ts))
> - return PTR_ERR(ts);
> -
> - return 0;
> + return PTR_ERR_OR_ZERO(ts);
> }
>
> static int cyttsp4_i2c_remove(struct i2c_client *client)
> --
> 2.4.3
>
--
Dmitry
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH 04/18] Input: kxtj9 - remove unneeded retval variable
2015-10-02 13:40 [PATCH 00/18] Input - Fix make coccicheck warnings Javier Martinez Canillas
` (2 preceding siblings ...)
2015-10-02 13:40 ` [PATCH 03/18] Input: cyttsp " Javier Martinez Canillas
@ 2015-10-02 13:40 ` Javier Martinez Canillas
2015-10-02 13:40 ` [PATCH 05/18] Input: retu-pwrbutton - simplify function return logic Javier Martinez Canillas
` (14 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-02 13:40 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, Jingoo Han, Krzysztof Kozlowski,
Dmitry Torokhov, linux-input
The retval variable isn't needed since isn't used in the
function. Remove the variable and just return 0 instead.
This also fixes the following make coccicheck warning:
drivers/input/misc/kxtj9.c:638:5-11: Unneeded variable: "retval". Return "0" on line 646
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/input/misc/kxtj9.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/input/misc/kxtj9.c b/drivers/input/misc/kxtj9.c
index e058d711256a..efaffcc57e36 100644
--- a/drivers/input/misc/kxtj9.c
+++ b/drivers/input/misc/kxtj9.c
@@ -635,7 +635,6 @@ static int __maybe_unused kxtj9_resume(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct kxtj9_data *tj9 = i2c_get_clientdata(client);
struct input_dev *input_dev = tj9->input_dev;
- int retval = 0;
mutex_lock(&input_dev->mutex);
@@ -643,7 +642,7 @@ static int __maybe_unused kxtj9_resume(struct device *dev)
kxtj9_enable(tj9);
mutex_unlock(&input_dev->mutex);
- return retval;
+ return 0;
}
static SIMPLE_DEV_PM_OPS(kxtj9_pm_ops, kxtj9_suspend, kxtj9_resume);
--
2.4.3
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 05/18] Input: retu-pwrbutton - simplify function return logic
2015-10-02 13:40 [PATCH 00/18] Input - Fix make coccicheck warnings Javier Martinez Canillas
` (3 preceding siblings ...)
2015-10-02 13:40 ` [PATCH 04/18] Input: kxtj9 - remove unneeded retval variable Javier Martinez Canillas
@ 2015-10-02 13:40 ` Javier Martinez Canillas
2015-10-02 13:40 ` [PATCH 06/18] Input: zforce " Javier Martinez Canillas
` (13 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-02 13:40 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, Fabio Estevam, Wolfram Sang,
Dmitry Torokhov, linux-input
The invoked function already returns zero on success or a negative
errno code so there is no need to open code the logic in the caller.
This also fixes the following make coccicheck warning:
drivers/input/misc/retu-pwrbutton.c:72:1-6: WARNING: end returns can be simplified
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/input/misc/retu-pwrbutton.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/input/misc/retu-pwrbutton.c b/drivers/input/misc/retu-pwrbutton.c
index 30b459b6b344..55ce68a6dcbf 100644
--- a/drivers/input/misc/retu-pwrbutton.c
+++ b/drivers/input/misc/retu-pwrbutton.c
@@ -69,11 +69,7 @@ static int retu_pwrbutton_probe(struct platform_device *pdev)
if (error)
return error;
- error = input_register_device(idev);
- if (error)
- return error;
-
- return 0;
+ return input_register_device(idev);
}
static int retu_pwrbutton_remove(struct platform_device *pdev)
--
2.4.3
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 06/18] Input: zforce - simplify function return logic
2015-10-02 13:40 [PATCH 00/18] Input - Fix make coccicheck warnings Javier Martinez Canillas
` (4 preceding siblings ...)
2015-10-02 13:40 ` [PATCH 05/18] Input: retu-pwrbutton - simplify function return logic Javier Martinez Canillas
@ 2015-10-02 13:40 ` Javier Martinez Canillas
2015-10-02 13:54 ` Heiko Stübner
2015-10-02 13:40 ` [PATCH 07/18] Input: cap11xx " Javier Martinez Canillas
` (12 subsequent siblings)
18 siblings, 1 reply; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-02 13:40 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, Jingoo Han, Dirk Behme, Wei Yongjun,
Heiko Stuebner, linux-input, Dmitry Torokhov
The invoked function already returns zero on success or a negative
errno code so there is no need to open code the logic in the caller.
This also fixes the following make coccicheck warning:
end returns can be simplified and declaration on line 602 can be dropped
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/input/touchscreen/zforce_ts.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c
index 781d0f83050a..9bbadaaf6bc3 100644
--- a/drivers/input/touchscreen/zforce_ts.c
+++ b/drivers/input/touchscreen/zforce_ts.c
@@ -599,13 +599,8 @@ static irqreturn_t zforce_irq_thread(int irq, void *dev_id)
static int zforce_input_open(struct input_dev *dev)
{
struct zforce_ts *ts = input_get_drvdata(dev);
- int ret;
- ret = zforce_start(ts);
- if (ret)
- return ret;
-
- return 0;
+ return zforce_start(ts);
}
static void zforce_input_close(struct input_dev *dev)
--
2.4.3
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH 06/18] Input: zforce - simplify function return logic
2015-10-02 13:40 ` [PATCH 06/18] Input: zforce " Javier Martinez Canillas
@ 2015-10-02 13:54 ` Heiko Stübner
2015-10-02 18:15 ` Dmitry Torokhov
0 siblings, 1 reply; 32+ messages in thread
From: Heiko Stübner @ 2015-10-02 13:54 UTC (permalink / raw)
To: Javier Martinez Canillas
Cc: linux-kernel, Jingoo Han, Dirk Behme, Wei Yongjun, linux-input,
Dmitry Torokhov
Am Freitag, 2. Oktober 2015, 15:40:17 schrieb Javier Martinez Canillas:
> The invoked function already returns zero on success or a negative
> errno code so there is no need to open code the logic in the caller.
>
> This also fixes the following make coccicheck warning:
>
> end returns can be simplified and declaration on line 602 can be dropped
>
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
I wonder what let me make that decision ... probably copy'n'paste from my auo-
pixcir driver ... but how that got into this one is still a mystery to me ;-)
anyway
Reviewed-by: Heiko Stuebner <heiko.stuebner@bq.com>
> ---
>
> drivers/input/touchscreen/zforce_ts.c | 7 +------
> 1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/drivers/input/touchscreen/zforce_ts.c
> b/drivers/input/touchscreen/zforce_ts.c index 781d0f83050a..9bbadaaf6bc3
> 100644
> --- a/drivers/input/touchscreen/zforce_ts.c
> +++ b/drivers/input/touchscreen/zforce_ts.c
> @@ -599,13 +599,8 @@ static irqreturn_t zforce_irq_thread(int irq, void
> *dev_id) static int zforce_input_open(struct input_dev *dev)
> {
> struct zforce_ts *ts = input_get_drvdata(dev);
> - int ret;
>
> - ret = zforce_start(ts);
> - if (ret)
> - return ret;
> -
> - return 0;
> + return zforce_start(ts);
> }
>
> static void zforce_input_close(struct input_dev *dev)
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 06/18] Input: zforce - simplify function return logic
2015-10-02 13:54 ` Heiko Stübner
@ 2015-10-02 18:15 ` Dmitry Torokhov
0 siblings, 0 replies; 32+ messages in thread
From: Dmitry Torokhov @ 2015-10-02 18:15 UTC (permalink / raw)
To: Heiko Stübner
Cc: Javier Martinez Canillas, linux-kernel, Jingoo Han, Dirk Behme,
Wei Yongjun, linux-input
On Fri, Oct 02, 2015 at 03:54:51PM +0200, Heiko Stübner wrote:
> Am Freitag, 2. Oktober 2015, 15:40:17 schrieb Javier Martinez Canillas:
> > The invoked function already returns zero on success or a negative
> > errno code so there is no need to open code the logic in the caller.
> >
> > This also fixes the following make coccicheck warning:
> >
> > end returns can be simplified and declaration on line 602 can be dropped
> >
> > Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
>
> I wonder what let me make that decision ... probably copy'n'paste from my auo-
> pixcir driver ... but how that got into this one is still a mystery to me ;-)
> anyway
>
> Reviewed-by: Heiko Stuebner <heiko.stuebner@bq.com>
Applied, thank you.
>
>
> > ---
> >
> > drivers/input/touchscreen/zforce_ts.c | 7 +------
> > 1 file changed, 1 insertion(+), 6 deletions(-)
> >
> > diff --git a/drivers/input/touchscreen/zforce_ts.c
> > b/drivers/input/touchscreen/zforce_ts.c index 781d0f83050a..9bbadaaf6bc3
> > 100644
> > --- a/drivers/input/touchscreen/zforce_ts.c
> > +++ b/drivers/input/touchscreen/zforce_ts.c
> > @@ -599,13 +599,8 @@ static irqreturn_t zforce_irq_thread(int irq, void
> > *dev_id) static int zforce_input_open(struct input_dev *dev)
> > {
> > struct zforce_ts *ts = input_get_drvdata(dev);
> > - int ret;
> >
> > - ret = zforce_start(ts);
> > - if (ret)
> > - return ret;
> > -
> > - return 0;
> > + return zforce_start(ts);
> > }
> >
> > static void zforce_input_close(struct input_dev *dev)
>
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH 07/18] Input: cap11xx - simplify function return logic
2015-10-02 13:40 [PATCH 00/18] Input - Fix make coccicheck warnings Javier Martinez Canillas
` (5 preceding siblings ...)
2015-10-02 13:40 ` [PATCH 06/18] Input: zforce " Javier Martinez Canillas
@ 2015-10-02 13:40 ` Javier Martinez Canillas
2015-10-02 13:41 ` Daniel Mack
2015-10-02 18:09 ` Dmitry Torokhov
2015-10-02 13:40 ` [PATCH 08/18] Input: goldfish " Javier Martinez Canillas
` (11 subsequent siblings)
18 siblings, 2 replies; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-02 13:40 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, Axel Lin, Krzysztof Kozlowski,
Daniel Mack, Dmitry Torokhov, linux-input, Matt Ranostay
The invoked function already returns zero on success or a negative
errno code so there is no need to open code the logic in the caller.
This also fixes the following make coccicheck warning:
drivers/input/keyboard/cap11xx.c:475:1-6: WARNING: end returns can be simplified
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/input/keyboard/cap11xx.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/input/keyboard/cap11xx.c b/drivers/input/keyboard/cap11xx.c
index 378db10001df..7240316ddfe3 100644
--- a/drivers/input/keyboard/cap11xx.c
+++ b/drivers/input/keyboard/cap11xx.c
@@ -472,12 +472,8 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client,
return -ENXIO;
}
- error = devm_request_threaded_irq(dev, irq, NULL, cap11xx_thread_func,
- IRQF_ONESHOT, dev_name(dev), priv);
- if (error)
- return error;
-
- return 0;
+ return devm_request_threaded_irq(dev, irq, NULL, cap11xx_thread_func,
+ IRQF_ONESHOT, dev_name(dev), priv);
}
static const struct of_device_id cap11xx_dt_ids[] = {
--
2.4.3
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH 07/18] Input: cap11xx - simplify function return logic
2015-10-02 13:40 ` [PATCH 07/18] Input: cap11xx " Javier Martinez Canillas
@ 2015-10-02 13:41 ` Daniel Mack
2015-10-02 18:09 ` Dmitry Torokhov
1 sibling, 0 replies; 32+ messages in thread
From: Daniel Mack @ 2015-10-02 13:41 UTC (permalink / raw)
To: Javier Martinez Canillas, linux-kernel
Cc: Axel Lin, Krzysztof Kozlowski, Daniel Mack, Dmitry Torokhov,
linux-input, Matt Ranostay
On 10/02/2015 03:40 PM, Javier Martinez Canillas wrote:
> The invoked function already returns zero on success or a negative
> errno code so there is no need to open code the logic in the caller.
>
> This also fixes the following make coccicheck warning:
>
> drivers/input/keyboard/cap11xx.c:475:1-6: WARNING: end returns can be simplified
>
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Acked-by: Daniel Mack <daniel@zonque.org>
> ---
>
> drivers/input/keyboard/cap11xx.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/input/keyboard/cap11xx.c b/drivers/input/keyboard/cap11xx.c
> index 378db10001df..7240316ddfe3 100644
> --- a/drivers/input/keyboard/cap11xx.c
> +++ b/drivers/input/keyboard/cap11xx.c
> @@ -472,12 +472,8 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client,
> return -ENXIO;
> }
>
> - error = devm_request_threaded_irq(dev, irq, NULL, cap11xx_thread_func,
> - IRQF_ONESHOT, dev_name(dev), priv);
> - if (error)
> - return error;
> -
> - return 0;
> + return devm_request_threaded_irq(dev, irq, NULL, cap11xx_thread_func,
> + IRQF_ONESHOT, dev_name(dev), priv);
> }
>
> static const struct of_device_id cap11xx_dt_ids[] = {
>
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 07/18] Input: cap11xx - simplify function return logic
2015-10-02 13:40 ` [PATCH 07/18] Input: cap11xx " Javier Martinez Canillas
2015-10-02 13:41 ` Daniel Mack
@ 2015-10-02 18:09 ` Dmitry Torokhov
2015-10-02 18:17 ` Javier Martinez Canillas
1 sibling, 1 reply; 32+ messages in thread
From: Dmitry Torokhov @ 2015-10-02 18:09 UTC (permalink / raw)
To: Javier Martinez Canillas
Cc: linux-kernel, Axel Lin, Krzysztof Kozlowski, Daniel Mack,
linux-input, Matt Ranostay
On Fri, Oct 02, 2015 at 03:40:18PM +0200, Javier Martinez Canillas wrote:
> The invoked function already returns zero on success or a negative
> errno code so there is no need to open code the logic in the caller.
>
> This also fixes the following make coccicheck warning:
>
> drivers/input/keyboard/cap11xx.c:475:1-6: WARNING: end returns can be simplified
>
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
> ---
>
> drivers/input/keyboard/cap11xx.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/input/keyboard/cap11xx.c b/drivers/input/keyboard/cap11xx.c
> index 378db10001df..7240316ddfe3 100644
> --- a/drivers/input/keyboard/cap11xx.c
> +++ b/drivers/input/keyboard/cap11xx.c
> @@ -472,12 +472,8 @@ static int cap11xx_i2c_probe(struct i2c_client *i2c_client,
> return -ENXIO;
> }
>
> - error = devm_request_threaded_irq(dev, irq, NULL, cap11xx_thread_func,
> - IRQF_ONESHOT, dev_name(dev), priv);
> - if (error)
> - return error;
> -
> - return 0;
> + return devm_request_threaded_irq(dev, irq, NULL, cap11xx_thread_func,
> + IRQF_ONESHOT, dev_name(dev), priv);
> }
For cases where we have multiple of potentially failing actions:
error = action1();
if (error)
return error;
error = action2();
if (error)
return error;
error = action3();
if (error)
return error;
return 0;
I prefer not to compress the last action check to "return action3()".
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 07/18] Input: cap11xx - simplify function return logic
2015-10-02 18:09 ` Dmitry Torokhov
@ 2015-10-02 18:17 ` Javier Martinez Canillas
0 siblings, 0 replies; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-02 18:17 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: linux-kernel, Axel Lin, Krzysztof Kozlowski, Daniel Mack,
linux-input, Matt Ranostay
Hello Dmitry,
On 10/02/2015 08:09 PM, Dmitry Torokhov wrote:
[snip]
>>
>> - error = devm_request_threaded_irq(dev, irq, NULL, cap11xx_thread_func,
>> - IRQF_ONESHOT, dev_name(dev), priv);
>> - if (error)
>> - return error;
>> -
>> - return 0;
>> + return devm_request_threaded_irq(dev, irq, NULL, cap11xx_thread_func,
>> + IRQF_ONESHOT, dev_name(dev), priv);
>> }
>
> For cases where we have multiple of potentially failing actions:
>
> error = action1();
> if (error)
> return error;
>
> error = action2();
> if (error)
> return error;
>
> error = action3();
> if (error)
> return error;
>
> return 0;
>
> I prefer not to compress the last action check to "return action3()".
>
Fair enough, I don't mind if you drop those patches then.
Thanks a lot for your feedback.
> Thanks.
>
Best regards,
--
Javier Martinez Canillas
Open Source Group
Samsung Research America
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH 08/18] Input: goldfish - simplify function return logic
2015-10-02 13:40 [PATCH 00/18] Input - Fix make coccicheck warnings Javier Martinez Canillas
` (6 preceding siblings ...)
2015-10-02 13:40 ` [PATCH 07/18] Input: cap11xx " Javier Martinez Canillas
@ 2015-10-02 13:40 ` Javier Martinez Canillas
2015-10-02 13:40 ` [PATCH 09/18] Input: jornada720_ts " Javier Martinez Canillas
` (10 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-02 13:40 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, Dmitry Torokhov, Wolfram Sang,
linux-input
The invoked function already returns zero on success or a negative
errno code so there is no need to open code the logic in the caller.
This also fixes the following make coccicheck warning:
drivers/input/keyboard/goldfish_events.c:174:1-6: WARNING: end returns can be simplified
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/input/keyboard/goldfish_events.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/input/keyboard/goldfish_events.c b/drivers/input/keyboard/goldfish_events.c
index 907e4e278fce..6dfdb574bd01 100644
--- a/drivers/input/keyboard/goldfish_events.c
+++ b/drivers/input/keyboard/goldfish_events.c
@@ -171,11 +171,7 @@ static int events_probe(struct platform_device *pdev)
if (error)
return error;
- error = input_register_device(input_dev);
- if (error)
- return error;
-
- return 0;
+ return input_register_device(input_dev);
}
static struct platform_driver events_driver = {
--
2.4.3
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 09/18] Input: jornada720_ts - simplify function return logic
2015-10-02 13:40 [PATCH 00/18] Input - Fix make coccicheck warnings Javier Martinez Canillas
` (7 preceding siblings ...)
2015-10-02 13:40 ` [PATCH 08/18] Input: goldfish " Javier Martinez Canillas
@ 2015-10-02 13:40 ` Javier Martinez Canillas
2015-10-02 13:40 ` [PATCH 10/18] Input: intel-mid-touch " Javier Martinez Canillas
` (9 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-02 13:40 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, Dmitry Torokhov, Wolfram Sang,
linux-input
The invoked function already returns zero on success or a negative
errno code so there is no need to open code the logic in the caller.
This also fixes the following make coccicheck warning:
drivers/input/touchscreen/jornada720_ts.c:137:1-6: WARNING: end returns can be simplified
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/input/touchscreen/jornada720_ts.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/input/touchscreen/jornada720_ts.c b/drivers/input/touchscreen/jornada720_ts.c
index ea3b6a5b83e6..177a1e92da03 100644
--- a/drivers/input/touchscreen/jornada720_ts.c
+++ b/drivers/input/touchscreen/jornada720_ts.c
@@ -134,11 +134,7 @@ static int jornada720_ts_probe(struct platform_device *pdev)
return error;
}
- error = input_register_device(jornada_ts->dev);
- if (error)
- return error;
-
- return 0;
+ return input_register_device(jornada_ts->dev);
}
/* work with hotplug and coldplug */
--
2.4.3
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 10/18] Input: intel-mid-touch - simplify function return logic
2015-10-02 13:40 [PATCH 00/18] Input - Fix make coccicheck warnings Javier Martinez Canillas
` (8 preceding siblings ...)
2015-10-02 13:40 ` [PATCH 09/18] Input: jornada720_ts " Javier Martinez Canillas
@ 2015-10-02 13:40 ` Javier Martinez Canillas
2015-10-02 13:40 ` [PATCH 11/18] Input: da9034-ts " Javier Martinez Canillas
` (8 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-02 13:40 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, Dmitry Torokhov, Wolfram Sang,
linux-input
The invoked function already returns zero on success or a negative
errno code so there is no need to open code the logic in the caller.
This also fixes the following make coccicheck warning:
drivers/input/touchscreen/intel-mid-touch.c:562:1-4: WARNING: end returns can be simplified
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/input/touchscreen/intel-mid-touch.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/input/touchscreen/intel-mid-touch.c b/drivers/input/touchscreen/intel-mid-touch.c
index b4f0725a1c3d..4c3ef2e47e3a 100644
--- a/drivers/input/touchscreen/intel-mid-touch.c
+++ b/drivers/input/touchscreen/intel-mid-touch.c
@@ -559,11 +559,7 @@ static int mrstouch_adc_init(struct mrstouch_dev *tsdev)
if (err)
return err;
- err = intel_scu_ipc_update_register(PMIC_REG_MADCINT, rm, 0x03);
- if (err)
- return err;
-
- return 0;
+ return intel_scu_ipc_update_register(PMIC_REG_MADCINT, rm, 0x03);
}
--
2.4.3
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 11/18] Input: da9034-ts - simplify function return logic
2015-10-02 13:40 [PATCH 00/18] Input - Fix make coccicheck warnings Javier Martinez Canillas
` (9 preceding siblings ...)
2015-10-02 13:40 ` [PATCH 10/18] Input: intel-mid-touch " Javier Martinez Canillas
@ 2015-10-02 13:40 ` Javier Martinez Canillas
2015-10-02 13:40 ` [PATCH 12/18] Input: pxa27x_keypad " Javier Martinez Canillas
` (7 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-02 13:40 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, Dmitry Torokhov, Wolfram Sang,
linux-input
The invoked function already returns zero on success or a negative
errno code so there is no need to open code the logic in the caller.
This also fixes the following make coccicheck warning:
end returns can be simplified and declaration on line 304 can be dropped
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/input/touchscreen/da9034-ts.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/input/touchscreen/da9034-ts.c b/drivers/input/touchscreen/da9034-ts.c
index 8264822dc4b9..f10887851674 100644
--- a/drivers/input/touchscreen/da9034-ts.c
+++ b/drivers/input/touchscreen/da9034-ts.c
@@ -301,7 +301,6 @@ static int da9034_touch_probe(struct platform_device *pdev)
struct da9034_touch_pdata *pdata = dev_get_platdata(&pdev->dev);
struct da9034_touch *touch;
struct input_dev *input_dev;
- int error;
touch = devm_kzalloc(&pdev->dev, sizeof(struct da9034_touch),
GFP_KERNEL);
@@ -347,11 +346,7 @@ static int da9034_touch_probe(struct platform_device *pdev)
touch->input_dev = input_dev;
input_set_drvdata(input_dev, touch);
- error = input_register_device(input_dev);
- if (error)
- return error;
-
- return 0;
+ return input_register_device(input_dev);
}
static struct platform_driver da9034_touch_driver = {
--
2.4.3
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 12/18] Input: pxa27x_keypad - simplify function return logic
2015-10-02 13:40 [PATCH 00/18] Input - Fix make coccicheck warnings Javier Martinez Canillas
` (10 preceding siblings ...)
2015-10-02 13:40 ` [PATCH 11/18] Input: da9034-ts " Javier Martinez Canillas
@ 2015-10-02 13:40 ` Javier Martinez Canillas
2015-10-02 13:40 ` [PATCH 13/18] Input: atmel_mxt_ts " Javier Martinez Canillas
` (6 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-02 13:40 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, Rob Herring, Pramod Gurav, Wolfram Sang,
Dmitry Torokhov, linux-input, Dan Carpenter
The invoked function already returns zero on success or a negative
errno code so there is no need to open code the logic in the caller.
This also fixes the following make coccicheck warning:
drivers/input/keyboard/pxa27x_keypad.c:141:1-6: WARNING: end returns can be simplified
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/input/keyboard/pxa27x_keypad.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
index fcef5d1365e2..436e8c2efbe5 100644
--- a/drivers/input/keyboard/pxa27x_keypad.c
+++ b/drivers/input/keyboard/pxa27x_keypad.c
@@ -138,14 +138,10 @@ static int pxa27x_keypad_matrix_key_parse_dt(struct pxa27x_keypad *keypad,
pdata->matrix_key_rows = rows;
pdata->matrix_key_cols = cols;
- error = matrix_keypad_build_keymap(NULL, NULL,
- pdata->matrix_key_rows,
- pdata->matrix_key_cols,
- keypad->keycodes, input_dev);
- if (error)
- return error;
-
- return 0;
+ return matrix_keypad_build_keymap(NULL, NULL,
+ pdata->matrix_key_rows,
+ pdata->matrix_key_cols,
+ keypad->keycodes, input_dev);
}
static int pxa27x_keypad_direct_key_parse_dt(struct pxa27x_keypad *keypad,
--
2.4.3
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 13/18] Input: atmel_mxt_ts - simplify function return logic
2015-10-02 13:40 [PATCH 00/18] Input - Fix make coccicheck warnings Javier Martinez Canillas
` (11 preceding siblings ...)
2015-10-02 13:40 ` [PATCH 12/18] Input: pxa27x_keypad " Javier Martinez Canillas
@ 2015-10-02 13:40 ` Javier Martinez Canillas
2015-10-02 13:40 ` [PATCH 14/18] Input: synaptics_i2c " Javier Martinez Canillas
` (5 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-02 13:40 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, Nick Dyer, Dmitry Torokhov, linux-input
The invoked functions already return zero on success or a negative
errno code so there is no need to open code the logic in the caller.
This also fixes the following make coccicheck warnings:
end returns can be simplified and declaration on line 1470 can be dropped
end returns can be simplified and declaration on line 1485 can be dropped
end returns can be simplified and declaration on line 515 can be dropped
end returns can be simplified
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/input/touchscreen/atmel_mxt_ts.c | 30 +++++-------------------------
1 file changed, 5 insertions(+), 25 deletions(-)
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c
index c5622058c22b..34ecbb64319f 100644
--- a/drivers/input/touchscreen/atmel_mxt_ts.c
+++ b/drivers/input/touchscreen/atmel_mxt_ts.c
@@ -512,7 +512,6 @@ recheck:
static int mxt_send_bootloader_cmd(struct mxt_data *data, bool unlock)
{
- int ret;
u8 buf[2];
if (unlock) {
@@ -523,11 +522,7 @@ static int mxt_send_bootloader_cmd(struct mxt_data *data, bool unlock)
buf[1] = 0x01;
}
- ret = mxt_bootloader_write(data, buf, 2);
- if (ret)
- return ret;
-
- return 0;
+ return mxt_bootloader_write(data, buf, 2);
}
static int __mxt_read_reg(struct i2c_client *client,
@@ -1112,12 +1107,8 @@ static int mxt_soft_reset(struct mxt_data *data)
enable_irq(data->irq);
- ret = mxt_wait_for_completion(data, &data->reset_completion,
- MXT_RESET_TIMEOUT);
- if (ret)
- return ret;
-
- return 0;
+ return mxt_wait_for_completion(data, &data->reset_completion,
+ MXT_RESET_TIMEOUT);
}
static void mxt_update_crc(struct mxt_data *data, u8 cmd, u8 value)
@@ -1467,29 +1458,18 @@ release_mem:
static int mxt_acquire_irq(struct mxt_data *data)
{
- int error;
-
enable_irq(data->irq);
- error = mxt_process_messages_until_invalid(data);
- if (error)
- return error;
-
- return 0;
+ return mxt_process_messages_until_invalid(data);
}
static int mxt_get_info(struct mxt_data *data)
{
struct i2c_client *client = data->client;
struct mxt_info *info = &data->info;
- int error;
/* Read 7-byte info block starting at address 0 */
- error = __mxt_read_reg(client, 0, sizeof(*info), info);
- if (error)
- return error;
-
- return 0;
+ return __mxt_read_reg(client, 0, sizeof(*info), info);
}
static void mxt_free_input_device(struct mxt_data *data)
--
2.4.3
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 14/18] Input: synaptics_i2c - simplify function return logic
2015-10-02 13:40 [PATCH 00/18] Input - Fix make coccicheck warnings Javier Martinez Canillas
` (12 preceding siblings ...)
2015-10-02 13:40 ` [PATCH 13/18] Input: atmel_mxt_ts " Javier Martinez Canillas
@ 2015-10-02 13:40 ` Javier Martinez Canillas
2015-10-02 13:40 ` [PATCH 15/18] Input: auo-pixcir-ts " Javier Martinez Canillas
` (4 subsequent siblings)
18 siblings, 0 replies; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-02 13:40 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, Jingoo Han, Shailendra Verma,
Krzysztof Kozlowski, Dmitry Torokhov, linux-input
The invoked function already returns zero on success or a negative
errno code so there is no need to open code the logic in the caller.
This also fixes the following make coccicheck warnings:
drivers/input/mouse/synaptics_i2c.c:298:1-4: WARNING: end returns can be simplified
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/input/mouse/synaptics_i2c.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/input/mouse/synaptics_i2c.c b/drivers/input/mouse/synaptics_i2c.c
index aa7c5da60800..9f69ce3de2f3 100644
--- a/drivers/input/mouse/synaptics_i2c.c
+++ b/drivers/input/mouse/synaptics_i2c.c
@@ -295,11 +295,7 @@ static int synaptics_i2c_config(struct i2c_client *client)
control |= reduce_report ? 1 << REDUCE_REPORTING : 0;
/* No Filter */
control |= no_filter ? 1 << NO_FILTER : 0;
- ret = synaptics_i2c_reg_set(client, GENERAL_2D_CONTROL_REG, control);
- if (ret)
- return ret;
-
- return 0;
+ return synaptics_i2c_reg_set(client, GENERAL_2D_CONTROL_REG, control);
}
static int synaptics_i2c_reset_config(struct i2c_client *client)
--
2.4.3
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 15/18] Input: auo-pixcir-ts - simplify function return logic
2015-10-02 13:40 [PATCH 00/18] Input - Fix make coccicheck warnings Javier Martinez Canillas
` (13 preceding siblings ...)
2015-10-02 13:40 ` [PATCH 14/18] Input: synaptics_i2c " Javier Martinez Canillas
@ 2015-10-02 13:40 ` Javier Martinez Canillas
2015-10-02 18:19 ` Dmitry Torokhov
2015-10-02 13:40 ` [PATCH 16/18] Input: elan_i2c " Javier Martinez Canillas
` (3 subsequent siblings)
18 siblings, 1 reply; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-02 13:40 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, Jingoo Han, Krzysztof Kozlowski,
Dmitry Torokhov, linux-input
The invoked function already returns zero on success or a negative
errno code so there is no need to open code the logic in the caller.
This also fixes the following make coccicheck warnings:
end returns can be simplified and declaration on line 402 can be dropped
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/input/touchscreen/auo-pixcir-ts.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/input/touchscreen/auo-pixcir-ts.c b/drivers/input/touchscreen/auo-pixcir-ts.c
index 38c06f754acd..6592fc5d48b4 100644
--- a/drivers/input/touchscreen/auo-pixcir-ts.c
+++ b/drivers/input/touchscreen/auo-pixcir-ts.c
@@ -399,13 +399,8 @@ static int auo_pixcir_stop(struct auo_pixcir_ts *ts)
static int auo_pixcir_input_open(struct input_dev *dev)
{
struct auo_pixcir_ts *ts = input_get_drvdata(dev);
- int ret;
-
- ret = auo_pixcir_start(ts);
- if (ret)
- return ret;
- return 0;
+ return auo_pixcir_start(ts);
}
static void auo_pixcir_input_close(struct input_dev *dev)
--
2.4.3
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH 15/18] Input: auo-pixcir-ts - simplify function return logic
2015-10-02 13:40 ` [PATCH 15/18] Input: auo-pixcir-ts " Javier Martinez Canillas
@ 2015-10-02 18:19 ` Dmitry Torokhov
0 siblings, 0 replies; 32+ messages in thread
From: Dmitry Torokhov @ 2015-10-02 18:19 UTC (permalink / raw)
To: Javier Martinez Canillas
Cc: linux-kernel, Jingoo Han, Krzysztof Kozlowski, linux-input
On Fri, Oct 02, 2015 at 03:40:26PM +0200, Javier Martinez Canillas wrote:
> The invoked function already returns zero on success or a negative
> errno code so there is no need to open code the logic in the caller.
>
> This also fixes the following make coccicheck warnings:
>
> end returns can be simplified and declaration on line 402 can be dropped
>
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Applied, thank you.
> ---
>
> drivers/input/touchscreen/auo-pixcir-ts.c | 7 +------
> 1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/drivers/input/touchscreen/auo-pixcir-ts.c b/drivers/input/touchscreen/auo-pixcir-ts.c
> index 38c06f754acd..6592fc5d48b4 100644
> --- a/drivers/input/touchscreen/auo-pixcir-ts.c
> +++ b/drivers/input/touchscreen/auo-pixcir-ts.c
> @@ -399,13 +399,8 @@ static int auo_pixcir_stop(struct auo_pixcir_ts *ts)
> static int auo_pixcir_input_open(struct input_dev *dev)
> {
> struct auo_pixcir_ts *ts = input_get_drvdata(dev);
> - int ret;
> -
> - ret = auo_pixcir_start(ts);
> - if (ret)
> - return ret;
>
> - return 0;
> + return auo_pixcir_start(ts);
> }
>
> static void auo_pixcir_input_close(struct input_dev *dev)
> --
> 2.4.3
>
--
Dmitry
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH 16/18] Input: elan_i2c - simplify function return logic
2015-10-02 13:40 [PATCH 00/18] Input - Fix make coccicheck warnings Javier Martinez Canillas
` (14 preceding siblings ...)
2015-10-02 13:40 ` [PATCH 15/18] Input: auo-pixcir-ts " Javier Martinez Canillas
@ 2015-10-02 13:40 ` Javier Martinez Canillas
2015-10-02 16:46 ` Benson Leung
2015-10-02 13:40 ` [PATCH 17/18] Input: cypress_ps2 " Javier Martinez Canillas
` (2 subsequent siblings)
18 siblings, 1 reply; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-02 13:40 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, Rasmus Villemoes, Benson Leung,
Dmitry Torokhov, linux-input, Duson Lin
The invoked function already returns zero on success or a negative
errno code so there is no need to open code the logic in the caller.
This also fixes the following make coccicheck warning:
drivers/input/mouse/elan_i2c_smbus.c:402:1-6: WARNING: end returns can be simplified
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/input/mouse/elan_i2c_smbus.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/input/mouse/elan_i2c_smbus.c b/drivers/input/mouse/elan_i2c_smbus.c
index cb6aecbc1dc2..e5b0adfac3d0 100644
--- a/drivers/input/mouse/elan_i2c_smbus.c
+++ b/drivers/input/mouse/elan_i2c_smbus.c
@@ -399,11 +399,7 @@ static int elan_smbus_prepare_fw_update(struct i2c_client *client)
return error;
/* Reset IC */
- error = elan_smbus_iap_reset(client);
- if (error)
- return error;
-
- return 0;
+ return elan_smbus_iap_reset(client);
}
--
2.4.3
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH 16/18] Input: elan_i2c - simplify function return logic
2015-10-02 13:40 ` [PATCH 16/18] Input: elan_i2c " Javier Martinez Canillas
@ 2015-10-02 16:46 ` Benson Leung
0 siblings, 0 replies; 32+ messages in thread
From: Benson Leung @ 2015-10-02 16:46 UTC (permalink / raw)
To: Javier Martinez Canillas
Cc: linux-kernel@vger.kernel.org, Rasmus Villemoes, Dmitry Torokhov,
linux-input@vger.kernel.org, Duson Lin
On Fri, Oct 2, 2015 at 6:40 AM, Javier Martinez Canillas
<javier@osg.samsung.com> wrote:
> The invoked function already returns zero on success or a negative
> errno code so there is no need to open code the logic in the caller.
>
> This also fixes the following make coccicheck warning:
>
> drivers/input/mouse/elan_i2c_smbus.c:402:1-6: WARNING: end returns can be simplified
>
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
Reviewed-by: Benson Leung <bleung@chromium.org>
--
Benson Leung
Software Engineer, Chrom* OS
bleung@chromium.org
^ permalink raw reply [flat|nested] 32+ messages in thread
* [PATCH 17/18] Input: cypress_ps2 - simplify function return logic
2015-10-02 13:40 [PATCH 00/18] Input - Fix make coccicheck warnings Javier Martinez Canillas
` (15 preceding siblings ...)
2015-10-02 13:40 ` [PATCH 16/18] Input: elan_i2c " Javier Martinez Canillas
@ 2015-10-02 13:40 ` Javier Martinez Canillas
2015-10-02 13:40 ` [PATCH 18/18] Input: tps6507x-ts " Javier Martinez Canillas
2015-10-02 18:25 ` [PATCH 00/18] Input - Fix make coccicheck warnings Dmitry Torokhov
18 siblings, 0 replies; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-02 13:40 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, Hans de Goede, Benjamin Tissoires,
Henrik Rydberg, linux-input, Dmitry Torokhov
The invoked function already returns zero on success or a negative
errno code so there is no need to open code the logic in the caller.
This also fixes the following make coccicheck warning:
drivers/input/mouse/cypress_ps2.c:333:1-4: WARNING: end returns can be simplified
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/input/mouse/cypress_ps2.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/input/mouse/cypress_ps2.c b/drivers/input/mouse/cypress_ps2.c
index 28dcfc822bf6..bca984f53434 100644
--- a/drivers/input/mouse/cypress_ps2.c
+++ b/drivers/input/mouse/cypress_ps2.c
@@ -330,11 +330,7 @@ static int cypress_query_hardware(struct psmouse *psmouse)
if (ret)
return ret;
- ret = cypress_read_tp_metrics(psmouse);
- if (ret)
- return ret;
-
- return 0;
+ return cypress_read_tp_metrics(psmouse);
}
static int cypress_set_absolute_mode(struct psmouse *psmouse)
--
2.4.3
^ permalink raw reply related [flat|nested] 32+ messages in thread
* [PATCH 18/18] Input: tps6507x-ts - simplify function return logic
2015-10-02 13:40 [PATCH 00/18] Input - Fix make coccicheck warnings Javier Martinez Canillas
` (16 preceding siblings ...)
2015-10-02 13:40 ` [PATCH 17/18] Input: cypress_ps2 " Javier Martinez Canillas
@ 2015-10-02 13:40 ` Javier Martinez Canillas
2015-10-02 18:20 ` Dmitry Torokhov
2015-10-02 18:25 ` [PATCH 00/18] Input - Fix make coccicheck warnings Dmitry Torokhov
18 siblings, 1 reply; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-02 13:40 UTC (permalink / raw)
To: linux-kernel
Cc: Javier Martinez Canillas, Dmitry Torokhov, Wolfram Sang,
linux-input
The invoked function already returns zero on success or a negative
errno code so there is no need to open code the logic in the caller.
This also fixes the following make coccicheck warning:
drivers/input/touchscreen/tps6507x-ts.c:57:5-8: WARNING: end returns can be simplified
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
---
drivers/input/touchscreen/tps6507x-ts.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/input/touchscreen/tps6507x-ts.c b/drivers/input/touchscreen/tps6507x-ts.c
index 4ffd829d1990..a340bfccdfb6 100644
--- a/drivers/input/touchscreen/tps6507x-ts.c
+++ b/drivers/input/touchscreen/tps6507x-ts.c
@@ -50,14 +50,7 @@ struct tps6507x_ts {
static int tps6507x_read_u8(struct tps6507x_ts *tsc, u8 reg, u8 *data)
{
- int err;
-
- err = tsc->mfd->read_dev(tsc->mfd, reg, 1, data);
-
- if (err)
- return err;
-
- return 0;
+ return tsc->mfd->read_dev(tsc->mfd, reg, 1, data);
}
static int tps6507x_write_u8(struct tps6507x_ts *tsc, u8 reg, u8 data)
--
2.4.3
^ permalink raw reply related [flat|nested] 32+ messages in thread
* Re: [PATCH 18/18] Input: tps6507x-ts - simplify function return logic
2015-10-02 13:40 ` [PATCH 18/18] Input: tps6507x-ts " Javier Martinez Canillas
@ 2015-10-02 18:20 ` Dmitry Torokhov
0 siblings, 0 replies; 32+ messages in thread
From: Dmitry Torokhov @ 2015-10-02 18:20 UTC (permalink / raw)
To: Javier Martinez Canillas; +Cc: linux-kernel, Wolfram Sang, linux-input
On Fri, Oct 02, 2015 at 03:40:29PM +0200, Javier Martinez Canillas wrote:
> The invoked function already returns zero on success or a negative
> errno code so there is no need to open code the logic in the caller.
>
> This also fixes the following make coccicheck warning:
>
> drivers/input/touchscreen/tps6507x-ts.c:57:5-8: WARNING: end returns can be simplified
>
> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com>
>
Applied, thank you.
> ---
>
> drivers/input/touchscreen/tps6507x-ts.c | 9 +--------
> 1 file changed, 1 insertion(+), 8 deletions(-)
>
> diff --git a/drivers/input/touchscreen/tps6507x-ts.c b/drivers/input/touchscreen/tps6507x-ts.c
> index 4ffd829d1990..a340bfccdfb6 100644
> --- a/drivers/input/touchscreen/tps6507x-ts.c
> +++ b/drivers/input/touchscreen/tps6507x-ts.c
> @@ -50,14 +50,7 @@ struct tps6507x_ts {
>
> static int tps6507x_read_u8(struct tps6507x_ts *tsc, u8 reg, u8 *data)
> {
> - int err;
> -
> - err = tsc->mfd->read_dev(tsc->mfd, reg, 1, data);
> -
> - if (err)
> - return err;
> -
> - return 0;
> + return tsc->mfd->read_dev(tsc->mfd, reg, 1, data);
> }
>
> static int tps6507x_write_u8(struct tps6507x_ts *tsc, u8 reg, u8 data)
> --
> 2.4.3
>
--
Dmitry
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 00/18] Input - Fix make coccicheck warnings
2015-10-02 13:40 [PATCH 00/18] Input - Fix make coccicheck warnings Javier Martinez Canillas
` (17 preceding siblings ...)
2015-10-02 13:40 ` [PATCH 18/18] Input: tps6507x-ts " Javier Martinez Canillas
@ 2015-10-02 18:25 ` Dmitry Torokhov
2015-10-03 11:13 ` Javier Martinez Canillas
18 siblings, 1 reply; 32+ messages in thread
From: Dmitry Torokhov @ 2015-10-02 18:25 UTC (permalink / raw)
To: Javier Martinez Canillas
Cc: linux-kernel, Ferruh Yigit, Axel Lin, Pramod Gurav,
Benjamin Tissoires, Heiko Stuebner, Fabio Estevam, Hans de Goede,
Rasmus Villemoes, Rob Herring, Dirk Behme, Benson Leung,
Shailendra Verma, Krzysztof Kozlowski, linux-input, Duson Lin,
Jingoo Han, Wolfram Sang, Wei Yongjun, Henrik Rydberg,
Daniel Mack, Nick Dyer, Matt Ranostay
Hi Javier,
On Fri, Oct 02, 2015 at 03:40:11PM +0200, Javier Martinez Canillas wrote:
> Hello Dmitry,
>
> This series contains trivial patches with fixes to different warnings
> reported by make coccichek M=drivers/input.
>
> The patches don't contain functional changes but makes the functions
> simpler and removes unnecessary lines of code.
I disagree with some "simplify function return logic" patches: when
there are several actions that may fail I prefer explicit:
error = actionN();
if (error)
return error;
return 0;
even on the last one as it keep with the code flow and makes it easier
to move stuff around.
Please consider patches that not explicitly replied to as applied a
dropped.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 32+ messages in thread
* Re: [PATCH 00/18] Input - Fix make coccicheck warnings
2015-10-02 18:25 ` [PATCH 00/18] Input - Fix make coccicheck warnings Dmitry Torokhov
@ 2015-10-03 11:13 ` Javier Martinez Canillas
0 siblings, 0 replies; 32+ messages in thread
From: Javier Martinez Canillas @ 2015-10-03 11:13 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: linux-kernel, Ferruh Yigit, Axel Lin, Pramod Gurav,
Benjamin Tissoires, Heiko Stuebner, Fabio Estevam, Hans de Goede,
Rasmus Villemoes, Rob Herring, Dirk Behme, Benson Leung,
Shailendra Verma, Krzysztof Kozlowski, linux-input, Duson Lin,
Jingoo Han, Wolfram Sang, Wei Yongjun, Henrik Rydberg,
Daniel Mack, Nick Dyer, Matt Ranostay
Hello Dmitry,
On 10/02/2015 08:25 PM, Dmitry Torokhov wrote:
> Hi Javier,
>
> On Fri, Oct 02, 2015 at 03:40:11PM +0200, Javier Martinez Canillas wrote:
>> Hello Dmitry,
>>
>> This series contains trivial patches with fixes to different warnings
>> reported by make coccichek M=drivers/input.
>>
>> The patches don't contain functional changes but makes the functions
>> simpler and removes unnecessary lines of code.
>
> I disagree with some "simplify function return logic" patches: when
> there are several actions that may fail I prefer explicit:
>
> error = actionN();
> if (error)
> return error;
>
> return 0;
>
> even on the last one as it keep with the code flow and makes it easier
> to move stuff around.
>
> Please consider patches that not explicitly replied to as applied a
> dropped.
Thanks a lot for taking the time to explain this. I understand your
rationale and I tend to agree.
I'll see if the scripts/coccinelle/misc/simple_return.cocci semantic
patch can be modified to take this into account and not report a
warning for that pattern.
>
> Thanks.
>
Best regards,
--
Javier Martinez Canillas
Open Source Group
Samsung Research America
^ permalink raw reply [flat|nested] 32+ messages in thread