Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

jiffies: Define secs_to_jiffies()

secs_to_jiffies() is defined in hci_event.c and cannot be reused by
other call sites. Hoist it into the core code to allow conversion of the
~1150 usages of msecs_to_jiffies() that either:

- use a multiplier value of 1000 or equivalently MSEC_PER_SEC, or
- have timeouts that are denominated in seconds (i.e. end in 000)

It's implemented as a macro to allow usage in static initializers.

This will also allow conversion of yet more sites that use (sec * HZ)
directly, and improve their readability.

Suggested-by: Michael Kelley <mhklinux@outlook.com>
Signed-off-by: Easwar Hariharan <eahariha@linux.microsoft.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Link: https://lore.kernel.org/all/20241030-open-coded-timeouts-v3-1-9ba123facf88@linux.microsoft.com

authored by

Easwar Hariharan and committed by
Thomas Gleixner
b35108a5 1550dde8

+13 -2
+13
include/linux/jiffies.h
··· 526 526 } 527 527 } 528 528 529 + /** 530 + * secs_to_jiffies: - convert seconds to jiffies 531 + * @_secs: time in seconds 532 + * 533 + * Conversion is done by simple multiplication with HZ 534 + * 535 + * secs_to_jiffies() is defined as a macro rather than a static inline 536 + * function so it can be used in static initializers. 537 + * 538 + * Return: jiffies value 539 + */ 540 + #define secs_to_jiffies(_secs) ((_secs) * HZ) 541 + 529 542 extern unsigned long __usecs_to_jiffies(const unsigned int u); 530 543 #if !(USEC_PER_SEC % HZ) 531 544 static inline unsigned long _usecs_to_jiffies(const unsigned int u)
-2
net/bluetooth/hci_event.c
··· 42 42 #define ZERO_KEY "\x00\x00\x00\x00\x00\x00\x00\x00" \ 43 43 "\x00\x00\x00\x00\x00\x00\x00\x00" 44 44 45 - #define secs_to_jiffies(_secs) msecs_to_jiffies((_secs) * 1000) 46 - 47 45 /* Handle HCI Event packets */ 48 46 49 47 static void *hci_ev_skb_pull(struct hci_dev *hdev, struct sk_buff *skb,