Skip to content

Commit b35108a

Browse files
easwarhKAGA-KOKO
authored andcommitted
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
1 parent 1550dde commit b35108a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

include/linux/jiffies.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,19 @@ static __always_inline unsigned long msecs_to_jiffies(const unsigned int m)
526526
}
527527
}
528528

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+
529542
extern unsigned long __usecs_to_jiffies(const unsigned int u);
530543
#if !(USEC_PER_SEC % HZ)
531544
static inline unsigned long _usecs_to_jiffies(const unsigned int u)

net/bluetooth/hci_event.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
#define ZERO_KEY "\x00\x00\x00\x00\x00\x00\x00\x00" \
4343
"\x00\x00\x00\x00\x00\x00\x00\x00"
4444

45-
#define secs_to_jiffies(_secs) msecs_to_jiffies((_secs) * 1000)
46-
4745
/* Handle HCI Event packets */
4846

4947
static void *hci_ev_skb_pull(struct hci_dev *hdev, struct sk_buff *skb,

0 commit comments

Comments
 (0)