diff mbox series

HID: appletb-kbd: Replace msecs_to_jiffies with secs_to_jiffies for timer settings

Message ID 20250319101242304iR6PbYo3hAvFto8weR2Ps@zte.com.cn (mailing list archive)
State New
Delegated to: Jiri Kosina
Headers show
Series HID: appletb-kbd: Replace msecs_to_jiffies with secs_to_jiffies for timer settings | expand

Commit Message

xie.ludan@zte.com.cn March 19, 2025, 2:12 a.m. UTC
From: Peng Jiang <jiang.peng9@zte.com.cn>

The variables `appletb_tb_idle_timeout` and `appletb_tb_dim_timeout`
are already defined in seconds, so using `secs_to_jiffies` directly
makes the code more readable and consistent with the units used.

This is converted using scripts/coccinelle/misc/secs_to_jiffies.cocci with
the following Coccinelle rules:

@depends on patch@
expression E;
@@

-msecs_to_jiffies
+secs_to_jiffies
(E
- * \( 1000 \| MSEC_PER_SEC \)
)

Signed-off-by: Peng Jiang <jiang.peng9@zte.com.cn>
Signed-off-by: XieLudan <xie.ludan@zte.com.cn>
---
 drivers/hid/hid-appletb-kbd.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Krzysztof Kozlowski March 19, 2025, 7:26 a.m. UTC | #1
On 19/03/2025 03:12, xie.ludan@zte.com.cn wrote:
> From: Peng Jiang <jiang.peng9@zte.com.cn>
> 
> The variables `appletb_tb_idle_timeout` and `appletb_tb_dim_timeout`
> are already defined in seconds, so using `secs_to_jiffies` directly
> makes the code more readable and consistent with the units used.
> 
> This is converted using scripts/coccinelle/misc/secs_to_jiffies.cocci with
> the following Coccinelle rules:

Why do you need to paste here contentx of existing cocci script? It's
already mainlined, no?

> 
> @depends on patch@
> expression E;
> @@
> 
> -msecs_to_jiffies
> +secs_to_jiffies
> (E
> - * \( 1000 \| MSEC_PER_SEC \)
> )
> 
> Signed-off-by: Peng Jiang <jiang.peng9@zte.com.cn>
> Signed-off-by: XieLudan <xie.ludan@zte.com.cn>
Same comment as before. Did you respond to previous feedbacks? No.

Best regards,
Krzysztof
jiang.peng9@zte.com.cn March 19, 2025, 8:01 a.m. UTC | #2
> > From: Peng Jiang <jiang.peng9@zte.com.cn>
> >
> > The variables `appletb_tb_idle_timeout` and `appletb_tb_dim_timeout`
> > are already defined in seconds, so using `secs_to_jiffies` directly
> > makes the code more readable and consistent with the units used.
> >
> > This is converted using scripts/coccinelle/misc/secs_to_jiffies.cocci with
> > the following Coccinelle rules:
>
> Why do you need to paste here contentx of existing cocci script? It's
> already mainlined, no?
>
> >
> > @depends on patch@
> > expression E;
> > @@
> >
> > -msecs_to_jiffies
> > +secs_to_jiffies
> > (E
> > - * \( 1000 \| MSEC_PER_SEC \)
> > )
> >
I intended to refer to the source of the modifications. Therefore, removing the Coccinelle script is appropriate.

Thank you for your feedback!

Best regards,
Peng Jiang
diff mbox series

Patch

diff --git a/drivers/hid/hid-appletb-kbd.c b/drivers/hid/hid-appletb-kbd.c
index d4b95aa3eecb..2f78db891cb9 100644
--- a/drivers/hid/hid-appletb-kbd.c
+++ b/drivers/hid/hid-appletb-kbd.c
@@ -172,7 +172,8 @@  static void appletb_inactivity_timer(struct timer_list *t)
 		if (!kbd->has_dimmed) {
 			backlight_device_set_brightness(kbd->backlight_dev, 1);
 			kbd->has_dimmed = true;
-			mod_timer(&kbd->inactivity_timer, jiffies + msecs_to_jiffies(appletb_tb_idle_timeout * 1000));
+			mod_timer(&kbd->inactivity_timer,
+				  jiffies + secs_to_jiffies(appletb_tb_idle_timeout));
 		} else if (!kbd->has_turned_off) {
 			backlight_device_set_brightness(kbd->backlight_dev, 0);
 			kbd->has_turned_off = true;
@@ -188,7 +189,8 @@  static void reset_inactivity_timer(struct appletb_kbd *kbd)
 			kbd->has_dimmed = false;
 			kbd->has_turned_off = false;
 		}
-		mod_timer(&kbd->inactivity_timer, jiffies + msecs_to_jiffies(appletb_tb_dim_timeout * 1000));
+		mod_timer(&kbd->inactivity_timer,
+			  jiffies + secs_to_jiffies(appletb_tb_dim_timeout));
 	}
 }

@@ -407,7 +409,8 @@  static int appletb_kbd_probe(struct hid_device *hdev, const struct hid_device_id
 	} else {
 		backlight_device_set_brightness(kbd->backlight_dev, 2);
 		timer_setup(&kbd->inactivity_timer, appletb_inactivity_timer, 0);
-		mod_timer(&kbd->inactivity_timer, jiffies + msecs_to_jiffies(appletb_tb_dim_timeout * 1000));
+		mod_timer(&kbd->inactivity_timer,
+			  jiffies + secs_to_jiffies(appletb_tb_dim_timeout));
 	}

 	kbd->inp_handler.event = appletb_kbd_inp_event;