Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Aditya Garg <gargaditya08@live.com>
To: Jiri Kosina <jikos@kernel.org>, Benjamin Tissoires <bentiss@kernel.org>
Cc: "linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>,
	"José Expósito" <jose.exposito89@gmail.com>
Subject: [PATCH v2 4/4] HID: magicmouse: use secs_to_jiffies() for battery timeout
Date: Mon, 30 Jun 2025 12:37:14 +0000	[thread overview]
Message-ID: <20250630123649.80395-5-gargaditya08@live.com> (raw)
In-Reply-To: <20250630123649.80395-1-gargaditya08@live.com>

The kernel now has a secs_to_jiffies() function which expands to a simpler
code than msecs_to_jiffies(). Use the same for battery timeout which was
using 60000 milliseconds (60 seconds).

Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
 drivers/hid/hid-magicmouse.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index 4ca0cbac9..e933bebf6 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -60,7 +60,7 @@ MODULE_PARM_DESC(report_undeciphered, "Report undeciphered multi-touch state fie
 #define MOUSE_REPORT_ID    0x29
 #define MOUSE2_REPORT_ID   0x12
 #define DOUBLE_REPORT_ID   0xf7
-#define USB_BATTERY_TIMEOUT_MS 60000
+#define USB_BATTERY_TIMEOUT_SEC 60
 
 /* These definitions are not precise, but they're close enough.  (Bits
  * 0x03 seem to indicate the aspect ratio of the touch, bits 0x70 seem
@@ -841,7 +841,7 @@ static void magicmouse_battery_timer_tick(struct timer_list *t)
 
 	if (magicmouse_fetch_battery(hdev) == 0) {
 		mod_timer(&msc->battery_timer,
-			  jiffies + msecs_to_jiffies(USB_BATTERY_TIMEOUT_MS));
+			  jiffies + secs_to_jiffies(USB_BATTERY_TIMEOUT_SEC));
 	}
 }
 
@@ -881,7 +881,7 @@ static int magicmouse_probe(struct hid_device *hdev,
 	    is_usb_magictrackpad2(id->vendor, id->product)) {
 		timer_setup(&msc->battery_timer, magicmouse_battery_timer_tick, 0);
 		mod_timer(&msc->battery_timer,
-			  jiffies + msecs_to_jiffies(USB_BATTERY_TIMEOUT_MS));
+			  jiffies + secs_to_jiffies(USB_BATTERY_TIMEOUT_SEC));
 		magicmouse_fetch_battery(hdev);
 	}
 
-- 
2.49.0


  parent reply	other threads:[~2025-06-30 12:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-30 12:37 [PATCH v2 0/4] HID: avoid setting up battery timer when not needed in hid-apple and magicmouse Aditya Garg
2025-06-30 12:37 ` [PATCH v2 1/4] HID: apple: avoid setting up battery timer for devices without battery Aditya Garg
2025-06-30 12:37 ` [PATCH v2 2/4] HID: magicmouse: avoid setting up battery timer when not needed Aditya Garg
2025-06-30 12:37 ` [PATCH v2 3/4] HID: apple: use secs_to_jiffies() for battery timeout Aditya Garg
2025-06-30 12:37 ` Aditya Garg [this message]
2025-06-30 12:39   ` [PATCH v2 4/4] HID: magicmouse: " kernel test robot
2025-06-30 12:49     ` Aditya Garg
2025-07-03  7:42 ` [PATCH v2 0/4] HID: avoid setting up battery timer when not needed in hid-apple and magicmouse Jiri Kosina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250630123649.80395-5-gargaditya08@live.com \
    --to=gargaditya08@live.com \
    --cc=bentiss@kernel.org \
    --cc=jikos@kernel.org \
    --cc=jose.exposito89@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox