All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers:hid: use swap() to make code cleaner
@ 2021-11-09  8:26 cgel.zte
  2021-12-14 12:29 ` Benjamin Tissoires
  0 siblings, 1 reply; 2+ messages in thread
From: cgel.zte @ 2021-11-09  8:26 UTC (permalink / raw)
  To: jikos
  Cc: benjamin.tissoires, linux-input, linux-kernel, chiminghao, Zeal Robot

From: chiminghao <chi.minghao@zte.com.cn>

Fix the following coccicheck REVIEW:
Use swap() instead of reimplementing it.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: chiminghao <chi.minghao@zte.com.cn>
---
 drivers/hid/hid-tmff.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/hid/hid-tmff.c b/drivers/hid/hid-tmff.c
index 90acef304536..4040cd98dafe 100644
--- a/drivers/hid/hid-tmff.c
+++ b/drivers/hid/hid-tmff.c
@@ -78,7 +78,6 @@ static int tmff_play(struct input_dev *dev, void *data,
 	struct hid_field *ff_field = tmff->ff_field;
 	int x, y;
 	int left, right;	/* Rumbling */
-	int motor_swap;
 
 	switch (effect->type) {
 	case FF_CONSTANT:
@@ -104,11 +103,8 @@ static int tmff_play(struct input_dev *dev, void *data,
 					ff_field->logical_maximum);
 
 		/* 2-in-1 strong motor is left */
-		if (hid->product == THRUSTMASTER_DEVICE_ID_2_IN_1_DT) {
-			motor_swap = left;
-			left = right;
-			right = motor_swap;
-		}
+		if (hid->product == THRUSTMASTER_DEVICE_ID_2_IN_1_DT)
+			swap(left, right);
 
 		dbg_hid("(left,right)=(%08x, %08x)\n", left, right);
 		ff_field->value[0] = left;
-- 
2.25.1


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

* Re: [PATCH] drivers:hid: use swap() to make code cleaner
  2021-11-09  8:26 [PATCH] drivers:hid: use swap() to make code cleaner cgel.zte
@ 2021-12-14 12:29 ` Benjamin Tissoires
  0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Tissoires @ 2021-12-14 12:29 UTC (permalink / raw)
  To: cgel.zte
  Cc: Jiri Kosina, open list:HID CORE LAYER, lkml, chiminghao, Zeal Robot

Hi,

On Tue, Nov 9, 2021 at 9:26 AM <cgel.zte@gmail.com> wrote:
>
> From: chiminghao <chi.minghao@zte.com.cn>
>
> Fix the following coccicheck REVIEW:
> Use swap() instead of reimplementing it.
>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: chiminghao <chi.minghao@zte.com.cn>
> ---

Amended the commit title to match what we do generally in the HID tree
and applied to for-5.17/thrustmaster.

Thanks for the patch!

Cheers,
Benjamin

>  drivers/hid/hid-tmff.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/hid/hid-tmff.c b/drivers/hid/hid-tmff.c
> index 90acef304536..4040cd98dafe 100644
> --- a/drivers/hid/hid-tmff.c
> +++ b/drivers/hid/hid-tmff.c
> @@ -78,7 +78,6 @@ static int tmff_play(struct input_dev *dev, void *data,
>         struct hid_field *ff_field = tmff->ff_field;
>         int x, y;
>         int left, right;        /* Rumbling */
> -       int motor_swap;
>
>         switch (effect->type) {
>         case FF_CONSTANT:
> @@ -104,11 +103,8 @@ static int tmff_play(struct input_dev *dev, void *data,
>                                         ff_field->logical_maximum);
>
>                 /* 2-in-1 strong motor is left */
> -               if (hid->product == THRUSTMASTER_DEVICE_ID_2_IN_1_DT) {
> -                       motor_swap = left;
> -                       left = right;
> -                       right = motor_swap;
> -               }
> +               if (hid->product == THRUSTMASTER_DEVICE_ID_2_IN_1_DT)
> +                       swap(left, right);
>
>                 dbg_hid("(left,right)=(%08x, %08x)\n", left, right);
>                 ff_field->value[0] = left;
> --
> 2.25.1
>


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

end of thread, other threads:[~2021-12-14 12:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-09  8:26 [PATCH] drivers:hid: use swap() to make code cleaner cgel.zte
2021-12-14 12:29 ` Benjamin Tissoires

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.