* [PATCH 1/1] HID-picoLCD: Deletion of unnecessary checks before three function calls
[not found] ` <5317A59D.4@users.sourceforge.net>
@ 2014-11-19 17:38 ` SF Markus Elfring
2015-06-28 11:54 ` [PATCH] " SF Markus Elfring
2014-11-29 14:33 ` [PATCH 1/1] HID: Wacom: Deletion of unnecessary checks before the function call "input_free_device" SF Markus Elfring
` (4 subsequent siblings)
5 siblings, 1 reply; 21+ messages in thread
From: SF Markus Elfring @ 2014-11-19 17:38 UTC (permalink / raw)
To: Bruno Prémont, Jiri Kosina, linux-input
Cc: LKML, kernel-janitors, Julia Lawall
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 19 Nov 2014 18:30:22 +0100
The functions backlight_device_unregister(), lcd_device_unregister() and
rc_unregister_device() test whether their argument is NULL and then
return immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/hid/hid-picolcd_backlight.c | 3 +--
drivers/hid/hid-picolcd_cir.c | 3 +--
drivers/hid/hid-picolcd_lcd.c | 3 +--
3 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/hid/hid-picolcd_backlight.c b/drivers/hid/hid-picolcd_backlight.c
index a32c5f8..808807a 100644
--- a/drivers/hid/hid-picolcd_backlight.c
+++ b/drivers/hid/hid-picolcd_backlight.c
@@ -94,8 +94,7 @@ void picolcd_exit_backlight(struct picolcd_data *data)
struct backlight_device *bdev = data->backlight;
data->backlight = NULL;
- if (bdev)
- backlight_device_unregister(bdev);
+ backlight_device_unregister(bdev);
}
int picolcd_resume_backlight(struct picolcd_data *data)
diff --git a/drivers/hid/hid-picolcd_cir.c b/drivers/hid/hid-picolcd_cir.c
index 045f8eb..9628651 100644
--- a/drivers/hid/hid-picolcd_cir.c
+++ b/drivers/hid/hid-picolcd_cir.c
@@ -145,7 +145,6 @@ void picolcd_exit_cir(struct picolcd_data *data)
struct rc_dev *rdev = data->rc_dev;
data->rc_dev = NULL;
- if (rdev)
- rc_unregister_device(rdev);
+ rc_unregister_device(rdev);
}
diff --git a/drivers/hid/hid-picolcd_lcd.c b/drivers/hid/hid-picolcd_lcd.c
index 89821c2..22dcbe1 100644
--- a/drivers/hid/hid-picolcd_lcd.c
+++ b/drivers/hid/hid-picolcd_lcd.c
@@ -92,8 +92,7 @@ void picolcd_exit_lcd(struct picolcd_data *data)
struct lcd_device *ldev = data->lcd;
data->lcd = NULL;
- if (ldev)
- lcd_device_unregister(ldev);
+ lcd_device_unregister(ldev);
}
int picolcd_resume_lcd(struct picolcd_data *data)
--
2.1.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 1/1] HID: Wacom: Deletion of unnecessary checks before the function call "input_free_device"
[not found] ` <5317A59D.4@users.sourceforge.net>
2014-11-19 17:38 ` [PATCH 1/1] HID-picoLCD: Deletion of unnecessary checks before three function calls SF Markus Elfring
@ 2014-11-29 14:33 ` SF Markus Elfring
2015-07-09 6:08 ` [PATCH v2] HID: Wacom: Delete " SF Markus Elfring
2015-02-05 16:40 ` [PATCH] Input: Delete an unnecessary check " SF Markus Elfring
` (3 subsequent siblings)
5 siblings, 1 reply; 21+ messages in thread
From: SF Markus Elfring @ 2014-11-29 14:33 UTC (permalink / raw)
To: Jiri Kosina, linux-input; +Cc: LKML, kernel-janitors, Coccinelle
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 29 Nov 2014 15:16:01 +0100
The input_free_device() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/hid/wacom_sys.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index eb55316..21ced00 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -1099,10 +1099,8 @@ static void wacom_free_inputs(struct wacom *wacom)
{
struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
- if (wacom_wac->input)
- input_free_device(wacom_wac->input);
- if (wacom_wac->pad_input)
- input_free_device(wacom_wac->pad_input);
+ input_free_device(wacom_wac->input);
+ input_free_device(wacom_wac->pad_input);
wacom_wac->input = NULL;
wacom_wac->pad_input = NULL;
}
--
2.1.3
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH] Input: Delete an unnecessary check before the function call "input_free_device"
[not found] ` <5317A59D.4@users.sourceforge.net>
2014-11-19 17:38 ` [PATCH 1/1] HID-picoLCD: Deletion of unnecessary checks before three function calls SF Markus Elfring
2014-11-29 14:33 ` [PATCH 1/1] HID: Wacom: Deletion of unnecessary checks before the function call "input_free_device" SF Markus Elfring
@ 2015-02-05 16:40 ` SF Markus Elfring
2015-02-11 18:11 ` Dmitry Torokhov
2015-07-08 20:30 ` [PATCH] i2c-HID: Delete unnecessary checks before the function call "gpiod_put" SF Markus Elfring
` (2 subsequent siblings)
5 siblings, 1 reply; 21+ messages in thread
From: SF Markus Elfring @ 2015-02-05 16:40 UTC (permalink / raw)
To: Dmitry Torokhov, linux-input; +Cc: LKML, kernel-janitors, Julia Lawall
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 5 Feb 2015 17:35:35 +0100
The input_free_device() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/input/joystick/adi.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
index b784257..d09cefa 100644
--- a/drivers/input/joystick/adi.c
+++ b/drivers/input/joystick/adi.c
@@ -535,8 +535,7 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv)
}
}
fail2: for (i = 0; i < 2; i++)
- if (port->adi[i].dev)
- input_free_device(port->adi[i].dev);
+ input_free_device(port->adi[i].dev);
gameport_close(gameport);
fail1: gameport_set_drvdata(gameport, NULL);
kfree(port);
--
2.2.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH] Input: Delete an unnecessary check before the function call "input_free_device"
2015-02-05 16:40 ` [PATCH] Input: Delete an unnecessary check " SF Markus Elfring
@ 2015-02-11 18:11 ` Dmitry Torokhov
0 siblings, 0 replies; 21+ messages in thread
From: Dmitry Torokhov @ 2015-02-11 18:11 UTC (permalink / raw)
To: SF Markus Elfring; +Cc: linux-input, LKML, kernel-janitors, Julia Lawall
On Thu, Feb 05, 2015 at 05:40:20PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 5 Feb 2015 17:35:35 +0100
>
> The input_free_device() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Applied, thank you.
> ---
> drivers/input/joystick/adi.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c
> index b784257..d09cefa 100644
> --- a/drivers/input/joystick/adi.c
> +++ b/drivers/input/joystick/adi.c
> @@ -535,8 +535,7 @@ static int adi_connect(struct gameport *gameport, struct gameport_driver *drv)
> }
> }
> fail2: for (i = 0; i < 2; i++)
> - if (port->adi[i].dev)
> - input_free_device(port->adi[i].dev);
> + input_free_device(port->adi[i].dev);
> gameport_close(gameport);
> fail1: gameport_set_drvdata(gameport, NULL);
> kfree(port);
> --
> 2.2.2
>
--
Dmitry
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] HID-picoLCD: Deletion of unnecessary checks before three function calls
2014-11-19 17:38 ` [PATCH 1/1] HID-picoLCD: Deletion of unnecessary checks before three function calls SF Markus Elfring
@ 2015-06-28 11:54 ` SF Markus Elfring
2015-06-29 6:34 ` Bruno Prémont
0 siblings, 1 reply; 21+ messages in thread
From: SF Markus Elfring @ 2015-06-28 11:54 UTC (permalink / raw)
To: Bruno Prémont, Jiri Kosina, linux-input
Cc: LKML, kernel-janitors, Julia Lawall
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 19 Nov 2014 18:30:22 +0100
>
> The functions backlight_device_unregister(), lcd_device_unregister() and
> rc_unregister_device() test whether their argument is NULL and then
> return immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/hid/hid-picolcd_backlight.c | 3 +--
> drivers/hid/hid-picolcd_cir.c | 3 +--
> drivers/hid/hid-picolcd_lcd.c | 3 +--
> 3 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/hid/hid-picolcd_backlight.c b/drivers/hid/hid-picolcd_backlight.c
> index a32c5f8..808807a 100644
> --- a/drivers/hid/hid-picolcd_backlight.c
> +++ b/drivers/hid/hid-picolcd_backlight.c
> @@ -94,8 +94,7 @@ void picolcd_exit_backlight(struct picolcd_data *data)
> struct backlight_device *bdev = data->backlight;
>
> data->backlight = NULL;
> - if (bdev)
> - backlight_device_unregister(bdev);
> + backlight_device_unregister(bdev);
> }
>
> int picolcd_resume_backlight(struct picolcd_data *data)
> diff --git a/drivers/hid/hid-picolcd_cir.c b/drivers/hid/hid-picolcd_cir.c
> index 045f8eb..9628651 100644
> --- a/drivers/hid/hid-picolcd_cir.c
> +++ b/drivers/hid/hid-picolcd_cir.c
> @@ -145,7 +145,6 @@ void picolcd_exit_cir(struct picolcd_data *data)
> struct rc_dev *rdev = data->rc_dev;
>
> data->rc_dev = NULL;
> - if (rdev)
> - rc_unregister_device(rdev);
> + rc_unregister_device(rdev);
> }
>
> diff --git a/drivers/hid/hid-picolcd_lcd.c b/drivers/hid/hid-picolcd_lcd.c
> index 89821c2..22dcbe1 100644
> --- a/drivers/hid/hid-picolcd_lcd.c
> +++ b/drivers/hid/hid-picolcd_lcd.c
> @@ -92,8 +92,7 @@ void picolcd_exit_lcd(struct picolcd_data *data)
> struct lcd_device *ldev = data->lcd;
>
> data->lcd = NULL;
> - if (ldev)
> - lcd_device_unregister(ldev);
> + lcd_device_unregister(ldev);
> }
>
> int picolcd_resume_lcd(struct picolcd_data *data)
>
Would you like to integrate this update suggestion
into another source code repository?
Regards,
Markus
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] HID-picoLCD: Deletion of unnecessary checks before three function calls
2015-06-28 11:54 ` [PATCH] " SF Markus Elfring
@ 2015-06-29 6:34 ` Bruno Prémont
2015-06-29 12:05 ` Jiri Kosina
0 siblings, 1 reply; 21+ messages in thread
From: Bruno Prémont @ 2015-06-29 6:34 UTC (permalink / raw)
To: SF Markus Elfring, Jiri Kosina
Cc: linux-input, LKML, kernel-janitors, Julia Lawall
On Sun, 28 Jun 2015 13:54:56 +0200 SF Markus Elfring wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Wed, 19 Nov 2014 18:30:22 +0100
> >
> > The functions backlight_device_unregister(), lcd_device_unregister() and
> > rc_unregister_device() test whether their argument is NULL and then
> > return immediately. Thus the test around the call is not needed.
> >
> > This issue was detected by using the Coccinelle software.
> >
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > ---
> > drivers/hid/hid-picolcd_backlight.c | 3 +--
> > drivers/hid/hid-picolcd_cir.c | 3 +--
> > drivers/hid/hid-picolcd_lcd.c | 3 +--
> > 3 files changed, 3 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/hid/hid-picolcd_backlight.c b/drivers/hid/hid-picolcd_backlight.c
> > index a32c5f8..808807a 100644
> > --- a/drivers/hid/hid-picolcd_backlight.c
> > +++ b/drivers/hid/hid-picolcd_backlight.c
> > @@ -94,8 +94,7 @@ void picolcd_exit_backlight(struct picolcd_data *data)
> > struct backlight_device *bdev = data->backlight;
> >
> > data->backlight = NULL;
> > - if (bdev)
> > - backlight_device_unregister(bdev);
> > + backlight_device_unregister(bdev);
> > }
> >
> > int picolcd_resume_backlight(struct picolcd_data *data)
> > diff --git a/drivers/hid/hid-picolcd_cir.c b/drivers/hid/hid-picolcd_cir.c
> > index 045f8eb..9628651 100644
> > --- a/drivers/hid/hid-picolcd_cir.c
> > +++ b/drivers/hid/hid-picolcd_cir.c
> > @@ -145,7 +145,6 @@ void picolcd_exit_cir(struct picolcd_data *data)
> > struct rc_dev *rdev = data->rc_dev;
> >
> > data->rc_dev = NULL;
> > - if (rdev)
> > - rc_unregister_device(rdev);
> > + rc_unregister_device(rdev);
> > }
> >
> > diff --git a/drivers/hid/hid-picolcd_lcd.c b/drivers/hid/hid-picolcd_lcd.c
> > index 89821c2..22dcbe1 100644
> > --- a/drivers/hid/hid-picolcd_lcd.c
> > +++ b/drivers/hid/hid-picolcd_lcd.c
> > @@ -92,8 +92,7 @@ void picolcd_exit_lcd(struct picolcd_data *data)
> > struct lcd_device *ldev = data->lcd;
> >
> > data->lcd = NULL;
> > - if (ldev)
> > - lcd_device_unregister(ldev);
> > + lcd_device_unregister(ldev);
> > }
> >
> > int picolcd_resume_lcd(struct picolcd_data *data)
> >
>
> Would you like to integrate this update suggestion
> into another source code repository?
Sorry for forgetting about this patch.
Looks good to me:
Reviewed-by: Bruno Prémont <bonbons@linux-vserver.org>
Jiri, can you take it?
Best regards,
Bruno
> Regards,
> Markus
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] HID-picoLCD: Deletion of unnecessary checks before three function calls
2015-06-29 6:34 ` Bruno Prémont
@ 2015-06-29 12:05 ` Jiri Kosina
0 siblings, 0 replies; 21+ messages in thread
From: Jiri Kosina @ 2015-06-29 12:05 UTC (permalink / raw)
To: Bruno Prémont
Cc: SF Markus Elfring, linux-input, LKML, kernel-janitors,
Julia Lawall
On Mon, 29 Jun 2015, Bruno Prémont wrote:
> Sorry for forgetting about this patch.
>
> Looks good to me:
> Reviewed-by: Bruno Prémont <bonbons@linux-vserver.org>
>
> Jiri, can you take it?
Could either of you please bounce me the original patch? I don't think
I've seen in in my mailbox (or it's too long time ago).
Thanks,
--
Jiri Kosina
SUSE Labs
--
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] 21+ messages in thread
* [PATCH] i2c-HID: Delete unnecessary checks before the function call "gpiod_put"
[not found] ` <5317A59D.4@users.sourceforge.net>
` (2 preceding siblings ...)
2015-02-05 16:40 ` [PATCH] Input: Delete an unnecessary check " SF Markus Elfring
@ 2015-07-08 20:30 ` SF Markus Elfring
2015-07-09 8:18 ` Dan Carpenter
2015-07-09 12:34 ` Jiri Kosina
2015-11-06 17:00 ` [PATCH] HID: Wacom: Delete an unnecessary check before the function call "kobject_put" SF Markus Elfring
2016-07-24 7:35 ` [PATCH] Input-rmi_bus: Delete an unnecessary check before the function call "of_node_put" SF Markus Elfring
5 siblings, 2 replies; 21+ messages in thread
From: SF Markus Elfring @ 2015-07-08 20:30 UTC (permalink / raw)
To: Jiri Kosina, linux-input
Cc: Linux Kernel Mailing List, kernel-janitors, Julia Lawall
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 8 Jul 2015 22:12:25 +0200
The gpiod_put() function performs also input parameter validation
by forwarding its single input pointer to the gpiod_free() function.
Thus the test around the calls is not needed.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/hid/i2c-hid/i2c-hid.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index f77469d..09ff4e7 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -1048,9 +1048,7 @@ err_pm:
pm_runtime_disable(&client->dev);
err:
- if (ihid->desc)
- gpiod_put(ihid->desc);
-
+ gpiod_put(ihid->desc);
i2c_hid_free_buffers(ihid);
kfree(ihid);
return ret;
@@ -1074,9 +1072,7 @@ static int i2c_hid_remove(struct i2c_client *client)
if (ihid->bufsize)
i2c_hid_free_buffers(ihid);
- if (ihid->desc)
- gpiod_put(ihid->desc);
-
+ gpiod_put(ihid->desc);
kfree(ihid);
acpi_dev_remove_driver_gpios(ACPI_COMPANION(&client->dev));
--
2.4.5
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v2] HID: Wacom: Delete unnecessary checks before the function call "input_free_device"
2014-11-29 14:33 ` [PATCH 1/1] HID: Wacom: Deletion of unnecessary checks before the function call "input_free_device" SF Markus Elfring
@ 2015-07-09 6:08 ` SF Markus Elfring
2015-07-09 12:28 ` Jiri Kosina
0 siblings, 1 reply; 21+ messages in thread
From: SF Markus Elfring @ 2015-07-09 6:08 UTC (permalink / raw)
To: Jiri Kosina, linux-input; +Cc: LKML, kernel-janitors, Julia Lawall
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 9 Jul 2015 08:00:10 +0200
The input_free_device() function tests whether its argument is NULL and
then returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/hid/wacom_sys.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 4c0ffca..936ad77 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -1149,12 +1149,9 @@ static void wacom_free_inputs(struct wacom *wacom)
{
struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
- if (wacom_wac->pen_input)
- input_free_device(wacom_wac->pen_input);
- if (wacom_wac->touch_input)
- input_free_device(wacom_wac->touch_input);
- if (wacom_wac->pad_input)
- input_free_device(wacom_wac->pad_input);
+ input_free_device(wacom_wac->pen_input);
+ input_free_device(wacom_wac->touch_input);
+ input_free_device(wacom_wac->pad_input);
wacom_wac->pen_input = NULL;
wacom_wac->touch_input = NULL;
wacom_wac->pad_input = NULL;
--
2.4.5
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH] i2c-HID: Delete unnecessary checks before the function call "gpiod_put"
2015-07-08 20:30 ` [PATCH] i2c-HID: Delete unnecessary checks before the function call "gpiod_put" SF Markus Elfring
@ 2015-07-09 8:18 ` Dan Carpenter
2015-07-09 12:34 ` Jiri Kosina
1 sibling, 0 replies; 21+ messages in thread
From: Dan Carpenter @ 2015-07-09 8:18 UTC (permalink / raw)
To: SF Markus Elfring
Cc: Jiri Kosina, linux-input, Linux Kernel Mailing List,
kernel-janitors, Julia Lawall
This one deserves some extra review because it introduces a call to:
WARN_ON(extra_checks);
in gpiod_free(). That may or may not matter...
regards,
dan carpenter
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v2] HID: Wacom: Delete unnecessary checks before the function call "input_free_device"
2015-07-09 6:08 ` [PATCH v2] HID: Wacom: Delete " SF Markus Elfring
@ 2015-07-09 12:28 ` Jiri Kosina
0 siblings, 0 replies; 21+ messages in thread
From: Jiri Kosina @ 2015-07-09 12:28 UTC (permalink / raw)
To: SF Markus Elfring; +Cc: linux-input, LKML, kernel-janitors, Julia Lawall
On Thu, 9 Jul 2015, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 9 Jul 2015 08:00:10 +0200
>
> The input_free_device() function tests whether its argument is NULL and
> then returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
This is really on a "is it worth it?" borderline, but anyway ... applied
to for-4.3/upstream.
Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] i2c-HID: Delete unnecessary checks before the function call "gpiod_put"
2015-07-08 20:30 ` [PATCH] i2c-HID: Delete unnecessary checks before the function call "gpiod_put" SF Markus Elfring
2015-07-09 8:18 ` Dan Carpenter
@ 2015-07-09 12:34 ` Jiri Kosina
2015-07-09 18:38 ` Benjamin Tissoires
1 sibling, 1 reply; 21+ messages in thread
From: Jiri Kosina @ 2015-07-09 12:34 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-input, Linux Kernel Mailing List, kernel-janitors,
Julia Lawall, Benjamin Tissoires
On Wed, 8 Jul 2015, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 8 Jul 2015 22:12:25 +0200
>
> The gpiod_put() function performs also input parameter validation
> by forwarding its single input pointer to the gpiod_free() function.
> Thus the test around the calls is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
As Dan correctly pointed out, this is not as straightforward as it might
seem on a firsr sight, because there is a WARN_ON() that might start
triggering in case of !ihid->desc.
Adding Benjamin. I am not applying this without his Ack.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH] i2c-HID: Delete unnecessary checks before the function call "gpiod_put"
2015-07-09 12:34 ` Jiri Kosina
@ 2015-07-09 18:38 ` Benjamin Tissoires
2015-07-09 20:49 ` SF Markus Elfring
0 siblings, 1 reply; 21+ messages in thread
From: Benjamin Tissoires @ 2015-07-09 18:38 UTC (permalink / raw)
To: Jiri Kosina
Cc: SF Markus Elfring, linux-input, Linux Kernel Mailing List,
kernel-janitors, Julia Lawall, Mika Westerberg
On Thu, Jul 9, 2015 at 8:34 AM, Jiri Kosina <jkosina@suse.com> wrote:
> On Wed, 8 Jul 2015, SF Markus Elfring wrote:
>
>> From: Markus Elfring <elfring@users.sourceforge.net>
>> Date: Wed, 8 Jul 2015 22:12:25 +0200
>>
>> The gpiod_put() function performs also input parameter validation
>> by forwarding its single input pointer to the gpiod_free() function.
>> Thus the test around the calls is not needed.
>>
>> This issue was detected by using the Coccinelle software.
>>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>
> As Dan correctly pointed out, this is not as straightforward as it might
> seem on a firsr sight, because there is a WARN_ON() that might start
> triggering in case of !ihid->desc.
>
> Adding Benjamin. I am not applying this without his Ack.
>
I think the gpiod case is the exception rather than the common rule
(most i2c-hid device we saw until recently were using irqs, not
gpios). So if I understand correctly, removing the check on ihid->desc
would raise a warning for most devices. This is IMO not a good thing,
so I would say NACK.
Mika might have a different opinion though.
Cheers,
Benjamin
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: i2c-HID: Delete unnecessary checks before the function call "gpiod_put"
2015-07-09 18:38 ` Benjamin Tissoires
@ 2015-07-09 20:49 ` SF Markus Elfring
2015-07-09 20:56 ` Benjamin Tissoires
0 siblings, 1 reply; 21+ messages in thread
From: SF Markus Elfring @ 2015-07-09 20:49 UTC (permalink / raw)
To: Benjamin Tissoires, Jiri Kosina, Mika Westerberg
Cc: linux-input, Linux Kernel Mailing List, kernel-janitors,
Julia Lawall
>>> The gpiod_put() function performs also input parameter validation
>>> by forwarding its single input pointer to the gpiod_free() function.
>>> Thus the test around the calls is not needed.
>>>
>>> This issue was detected by using the Coccinelle software.
>>>
>>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>>
>> As Dan correctly pointed out, this is not as straightforward as it might
>> seem on a firsr sight, because there is a WARN_ON() that might start
>> triggering in case of !ihid->desc.
>>
>> Adding Benjamin. I am not applying this without his Ack.
>>
>
> I think the gpiod case is the exception rather than the common rule
> (most i2c-hid device we saw until recently were using irqs, not
> gpios). So if I understand correctly, removing the check on ihid->desc
> would raise a warning for most devices. This is IMO not a good thing,
> so I would say NACK.
>
> Mika might have a different opinion though.
The proposed update candidates are contained in the source
file "drivers/hid/i2c-hid/i2c-hid.c" from Linux next-20150708.
* i2c_hid_remove() function:
Can it be tolerated here that the pointer "ihid->desc" might be eventually null?
* i2c_hid_probe() function:
Is this implementation structured in such a way that a pointer for valid data
will be usually passed for "ihid->desc" if the statements after the jump
label "err" will be reached?
Regards,
Markus
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: i2c-HID: Delete unnecessary checks before the function call "gpiod_put"
2015-07-09 20:49 ` SF Markus Elfring
@ 2015-07-09 20:56 ` Benjamin Tissoires
2015-07-09 21:10 ` SF Markus Elfring
0 siblings, 1 reply; 21+ messages in thread
From: Benjamin Tissoires @ 2015-07-09 20:56 UTC (permalink / raw)
To: SF Markus Elfring
Cc: Jiri Kosina, Mika Westerberg, linux-input,
Linux Kernel Mailing List, kernel-janitors, Julia Lawall
On Thu, Jul 9, 2015 at 4:49 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>>>> The gpiod_put() function performs also input parameter validation
>>>> by forwarding its single input pointer to the gpiod_free() function.
>>>> Thus the test around the calls is not needed.
>>>>
>>>> This issue was detected by using the Coccinelle software.
>>>>
>>>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>>>
>>> As Dan correctly pointed out, this is not as straightforward as it might
>>> seem on a firsr sight, because there is a WARN_ON() that might start
>>> triggering in case of !ihid->desc.
>>>
>>> Adding Benjamin. I am not applying this without his Ack.
>>>
>>
>> I think the gpiod case is the exception rather than the common rule
>> (most i2c-hid device we saw until recently were using irqs, not
>> gpios). So if I understand correctly, removing the check on ihid->desc
>> would raise a warning for most devices. This is IMO not a good thing,
>> so I would say NACK.
>>
>> Mika might have a different opinion though.
>
> The proposed update candidates are contained in the source
> file "drivers/hid/i2c-hid/i2c-hid.c" from Linux next-20150708.
>
> * i2c_hid_remove() function:
> Can it be tolerated here that the pointer "ihid->desc" might be eventually null?
>
> * i2c_hid_probe() function:
> Is this implementation structured in such a way that a pointer for valid data
> will be usually passed for "ihid->desc" if the statements after the jump
> label "err" will be reached?
>
Again, in both case it is completely normal to have "ihid->desc ==
NULL" given that this field is only retrieved in case of an ACPI
device which does not declares an IRQ but a GPIO. Most ACPI devices I
saw are using a simple IRQ, and the OF instantiations of the driver
will definitively have ihid->desc null. So I do not want to have a
warning for most of i2c-hid devices out there (because I will have to
explain that this is completely normal again and again).
Cheers,
Benjamin
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: i2c-HID: Delete unnecessary checks before the function call "gpiod_put"
2015-07-09 20:56 ` Benjamin Tissoires
@ 2015-07-09 21:10 ` SF Markus Elfring
2015-07-09 21:21 ` Benjamin Tissoires
0 siblings, 1 reply; 21+ messages in thread
From: SF Markus Elfring @ 2015-07-09 21:10 UTC (permalink / raw)
To: Benjamin Tissoires
Cc: Jiri Kosina, Mika Westerberg, linux-input,
Linux Kernel Mailing List, kernel-janitors, Julia Lawall
>> The proposed update candidates are contained in the source
>> file "drivers/hid/i2c-hid/i2c-hid.c" from Linux next-20150708.
>>
>> * i2c_hid_remove() function:
>> Can it be tolerated here that the pointer "ihid->desc" might be eventually null?
>>
>> * i2c_hid_probe() function:
>> Is this implementation structured in such a way that a pointer for valid data
>> will be usually passed for "ihid->desc" if the statements after the jump
>> label "err" will be reached?
>>
>
> Again, in both case it is completely normal to have "ihid->desc ==
> NULL" given that this field is only retrieved in case of an ACPI
> device which does not declares an IRQ but a GPIO. Most ACPI devices I
> saw are using a simple IRQ, and the OF instantiations of the driver
> will definitively have ihid->desc null. So I do not want to have a
> warning for most of i2c-hid devices out there (because I will have to
> explain that this is completely normal again and again).
Would it make sense to annotate checks before such function calls
as "unlikely" then?
Regards,
Markus
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: i2c-HID: Delete unnecessary checks before the function call "gpiod_put"
2015-07-09 21:10 ` SF Markus Elfring
@ 2015-07-09 21:21 ` Benjamin Tissoires
0 siblings, 0 replies; 21+ messages in thread
From: Benjamin Tissoires @ 2015-07-09 21:21 UTC (permalink / raw)
To: SF Markus Elfring
Cc: Jiri Kosina, Mika Westerberg, linux-input,
Linux Kernel Mailing List, kernel-janitors, Julia Lawall
On Thu, Jul 9, 2015 at 5:10 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>>> The proposed update candidates are contained in the source
>>> file "drivers/hid/i2c-hid/i2c-hid.c" from Linux next-20150708.
>>>
>>> * i2c_hid_remove() function:
>>> Can it be tolerated here that the pointer "ihid->desc" might be eventually null?
>>>
>>> * i2c_hid_probe() function:
>>> Is this implementation structured in such a way that a pointer for valid data
>>> will be usually passed for "ihid->desc" if the statements after the jump
>>> label "err" will be reached?
>>>
>>
>> Again, in both case it is completely normal to have "ihid->desc ==
>> NULL" given that this field is only retrieved in case of an ACPI
>> device which does not declares an IRQ but a GPIO. Most ACPI devices I
>> saw are using a simple IRQ, and the OF instantiations of the driver
>> will definitively have ihid->desc null. So I do not want to have a
>> warning for most of i2c-hid devices out there (because I will have to
>> explain that this is completely normal again and again).
>
> Would it make sense to annotate checks before such function calls
> as "unlikely" then?
>
I don't see the benefits of this right now. These calls are not time
critical and it's not because today they are few devices with GPIOs
rather than IRQs that it will be the case all the time.
You can always submit a patch preventing coccinelle to raise this
warning, but maybe a simple comment in the code would be enough.
Cheers,
Benjamin
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH] HID: Wacom: Delete an unnecessary check before the function call "kobject_put"
[not found] ` <5317A59D.4@users.sourceforge.net>
` (3 preceding siblings ...)
2015-07-08 20:30 ` [PATCH] i2c-HID: Delete unnecessary checks before the function call "gpiod_put" SF Markus Elfring
@ 2015-11-06 17:00 ` SF Markus Elfring
2015-11-19 15:53 ` Jiri Kosina
2016-07-24 7:35 ` [PATCH] Input-rmi_bus: Delete an unnecessary check before the function call "of_node_put" SF Markus Elfring
5 siblings, 1 reply; 21+ messages in thread
From: SF Markus Elfring @ 2015-11-06 17:00 UTC (permalink / raw)
To: Jiri Kosina, linux-input; +Cc: LKML, kernel-janitors, Julia Lawall
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 6 Nov 2015 17:55:23 +0100
The kobject_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/hid/wacom_sys.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 125e9d5..fb9b1d1 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -1353,8 +1353,7 @@ static void wacom_clean_inputs(struct wacom *wacom)
else
input_free_device(wacom->wacom_wac.pad_input);
}
- if (wacom->remote_dir)
- kobject_put(wacom->remote_dir);
+ kobject_put(wacom->remote_dir);
wacom->wacom_wac.pen_input = NULL;
wacom->wacom_wac.touch_input = NULL;
wacom->wacom_wac.pad_input = NULL;
--
2.6.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH] HID: Wacom: Delete an unnecessary check before the function call "kobject_put"
2015-11-06 17:00 ` [PATCH] HID: Wacom: Delete an unnecessary check before the function call "kobject_put" SF Markus Elfring
@ 2015-11-19 15:53 ` Jiri Kosina
0 siblings, 0 replies; 21+ messages in thread
From: Jiri Kosina @ 2015-11-19 15:53 UTC (permalink / raw)
To: SF Markus Elfring; +Cc: linux-input, LKML, kernel-janitors, Julia Lawall
On Fri, 6 Nov 2015, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 6 Nov 2015 17:55:23 +0100
>
> The kobject_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
Applied to for-4.5/wacom.
Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH] Input-rmi_bus: Delete an unnecessary check before the function call "of_node_put"
[not found] ` <5317A59D.4@users.sourceforge.net>
` (4 preceding siblings ...)
2015-11-06 17:00 ` [PATCH] HID: Wacom: Delete an unnecessary check before the function call "kobject_put" SF Markus Elfring
@ 2016-07-24 7:35 ` SF Markus Elfring
2016-07-25 18:30 ` Dmitry Torokhov
5 siblings, 1 reply; 21+ messages in thread
From: SF Markus Elfring @ 2016-07-24 7:35 UTC (permalink / raw)
To: linux-input, Andrew Duggan, Christopher Heiny, Dmitry Torokhov
Cc: LKML, kernel-janitors, Julia Lawall
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 24 Jul 2016 07:37:23 +0200
The of_node_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/input/rmi4/rmi_bus.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
index 253df96..a735806 100644
--- a/drivers/input/rmi4/rmi_bus.c
+++ b/drivers/input/rmi4/rmi_bus.c
@@ -232,10 +232,7 @@ err_put_device:
void rmi_unregister_function(struct rmi_function *fn)
{
device_del(&fn->dev);
-
- if (fn->dev.of_node)
- of_node_put(fn->dev.of_node);
-
+ of_node_put(fn->dev.of_node);
put_device(&fn->dev);
}
--
2.9.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH] Input-rmi_bus: Delete an unnecessary check before the function call "of_node_put"
2016-07-24 7:35 ` [PATCH] Input-rmi_bus: Delete an unnecessary check before the function call "of_node_put" SF Markus Elfring
@ 2016-07-25 18:30 ` Dmitry Torokhov
0 siblings, 0 replies; 21+ messages in thread
From: Dmitry Torokhov @ 2016-07-25 18:30 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-input, Andrew Duggan, Christopher Heiny, LKML,
kernel-janitors, Julia Lawall
On Sun, Jul 24, 2016 at 09:35:56AM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 24 Jul 2016 07:37:23 +0200
>
> The of_node_put() function tests whether its argument is NULL and then
> returns immediately. Thus the test around the call is not needed.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Applied, thank you.
> ---
> drivers/input/rmi4/rmi_bus.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
> index 253df96..a735806 100644
> --- a/drivers/input/rmi4/rmi_bus.c
> +++ b/drivers/input/rmi4/rmi_bus.c
> @@ -232,10 +232,7 @@ err_put_device:
> void rmi_unregister_function(struct rmi_function *fn)
> {
> device_del(&fn->dev);
> -
> - if (fn->dev.of_node)
> - of_node_put(fn->dev.of_node);
> -
> + of_node_put(fn->dev.of_node);
> put_device(&fn->dev);
> }
>
> --
> 2.9.2
>
--
Dmitry
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2016-07-25 18:30 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <5307CAA2.8060406@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402212321410.2043@localhost6.localdomain6>
[not found] ` <530A086E.8010901@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402231635510.1985@localhost6.localdomain6>
[not found] ` <530A72AA.3000601@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402240658210.2090@localhost6.localdomain6>
[not found] ` <530B5FB6.6010207@users.sourceforge.net>
[not found] ` <alpine.DEB.2.10.1402241710370.2074@hadrien>
[not found] ` <530C5E18.1020800@users.sourceforge.net>
[not found] ` <alpine.DEB.2.10.1402251014170.2080@hadrien>
[not found] ` <530CD2C4.4050903@users.sourceforge.net>
[not found] ` <alpine.DEB.2.10.1402251840450.7035@hadrien>
[not found] ` <530CF8FF.8080600@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402252117150.2047@localhost6.localdomain6>
[not found] ` <530DD06F.4090703@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402262129250.2221@localhost6.localdomain6>
[not found] ` <5317A59D.4@users.so urceforge.net>
[not found] ` <5317A59D.4@users.sourceforge.net>
2014-11-19 17:38 ` [PATCH 1/1] HID-picoLCD: Deletion of unnecessary checks before three function calls SF Markus Elfring
2015-06-28 11:54 ` [PATCH] " SF Markus Elfring
2015-06-29 6:34 ` Bruno Prémont
2015-06-29 12:05 ` Jiri Kosina
2014-11-29 14:33 ` [PATCH 1/1] HID: Wacom: Deletion of unnecessary checks before the function call "input_free_device" SF Markus Elfring
2015-07-09 6:08 ` [PATCH v2] HID: Wacom: Delete " SF Markus Elfring
2015-07-09 12:28 ` Jiri Kosina
2015-02-05 16:40 ` [PATCH] Input: Delete an unnecessary check " SF Markus Elfring
2015-02-11 18:11 ` Dmitry Torokhov
2015-07-08 20:30 ` [PATCH] i2c-HID: Delete unnecessary checks before the function call "gpiod_put" SF Markus Elfring
2015-07-09 8:18 ` Dan Carpenter
2015-07-09 12:34 ` Jiri Kosina
2015-07-09 18:38 ` Benjamin Tissoires
2015-07-09 20:49 ` SF Markus Elfring
2015-07-09 20:56 ` Benjamin Tissoires
2015-07-09 21:10 ` SF Markus Elfring
2015-07-09 21:21 ` Benjamin Tissoires
2015-11-06 17:00 ` [PATCH] HID: Wacom: Delete an unnecessary check before the function call "kobject_put" SF Markus Elfring
2015-11-19 15:53 ` Jiri Kosina
2016-07-24 7:35 ` [PATCH] Input-rmi_bus: Delete an unnecessary check before the function call "of_node_put" SF Markus Elfring
2016-07-25 18:30 ` Dmitry Torokhov
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).