From nobody Mon Nov 25 05:18:19 2024 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A9A1199FA0; Wed, 30 Oct 2024 17:47:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730310478; cv=none; b=ooB7/y73xlhyGj1ptocOT95SaPxqu/V1XUXQJJTZ4i29M3vCBrvxPawaBsjp+Du4rWbhL5CV9PomblJAOs85UDkls31eVr0VW3TvnvO+r3FlhIcetDTgK65DzciOtiC6wXOIAheLtYAjqdE0h/LgIpMiG6ywyJlF6KF8HAGJ7gQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730310478; c=relaxed/simple; bh=Sy/XcrnSG/n3m2XPnVo6TJ1sAr986PE5hlaj5H9ahsQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tndFdA21f9mGs5/LLfWhZyI+iZUHhRYxxA7WjZXubQWgAlxWEWf/gUTLgAsEX2HogGCmN/WsFVi3V0sAspBk8PGynEMNdOGOmIkWyuaEsowkRpRODvRmultzhqd5RsPAYTm0rH0zFCV3b+Lz/WgiQRfflbimX9W+QEBl38JA3LI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=tCCRp7Bb; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="tCCRp7Bb" Received: from eahariha-devbox.internal.cloudapp.net (unknown [40.91.112.99]) by linux.microsoft.com (Postfix) with ESMTPSA id 9C60E2054B68; Wed, 30 Oct 2024 10:47:50 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 9C60E2054B68 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1730310470; bh=mrrwKYSM5C8NsFUuz9eD0QAcHgQ/zcwrN5HhAbKheYA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tCCRp7BbtrTVmfK05wpvWDk/LSQlwAxWacYodBBq7jlVVJcbvqxQHe+Cp57/p3SiC vsCbrBpkmYoYPXGfQs0exj1WHQ9LXJfYFfosuvAaz6OZ7itEaZbF+DKuQUsvPucVBd T9Zr5xKvjc9VnaYadxN7zUnvUISkpH0OtQ0nE+yc= From: Easwar Hariharan Date: Wed, 30 Oct 2024 17:47:35 +0000 Subject: [PATCH v3 1/2] jiffies: Define secs_to_jiffies() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241030-open-coded-timeouts-v3-1-9ba123facf88@linux.microsoft.com> References: <20241030-open-coded-timeouts-v3-0-9ba123facf88@linux.microsoft.com> In-Reply-To: <20241030-open-coded-timeouts-v3-0-9ba123facf88@linux.microsoft.com> To: "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , linux-hyperv@vger.kernel.org, Anna-Maria Behnsen , Thomas Gleixner , Geert Uytterhoeven , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, Praveen Kumar , Naman Jain Cc: Michael Kelley , Easwar Hariharan , Luiz Augusto von Dentz X-Mailer: b4 0.14.2 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) This will also allow conversion of yet more sites that use (sec * HZ) directly, and improve their readability. TO: K. Y. Srinivasan TO: Haiyang Zhang TO: Wei Liu TO: Dexuan Cui TO: linux-hyperv@vger.kernel.org TO: Anna-Maria Behnsen TO: Thomas Gleixner TO: Geert Uytterhoeven TO: Marcel Holtmann TO: Johan Hedberg TO: Luiz Augusto von Dentz TO: linux-bluetooth@vger.kernel.org TO: linux-kernel@vger.kernel.org Suggested-by: Michael Kelley Reviewed-by: Luiz Augusto von Dentz Signed-off-by: Easwar Hariharan --- include/linux/jiffies.h | 12 ++++++++++++ net/bluetooth/hci_event.c | 2 -- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h index 1220f0fbe5bf9fb6c559b4efd603db3e97db9b65..e17c220ed56e587fd55fb9cf4a1= 33a53588af940 100644 --- a/include/linux/jiffies.h +++ b/include/linux/jiffies.h @@ -526,6 +526,18 @@ static __always_inline unsigned long msecs_to_jiffies(= const unsigned int m) } } =20 +/** + * secs_to_jiffies: - convert seconds to jiffies + * @_secs: time in seconds + * + * Conversion is done by simple multiplication with HZ + * secs_to_jiffies() is defined as a macro rather than a static inline + * function due to its potential application in struct initializers. + * + * Return: jiffies value + */ +#define secs_to_jiffies(_secs) ((_secs) * HZ) + extern unsigned long __usecs_to_jiffies(const unsigned int u); #if !(USEC_PER_SEC % HZ) static inline unsigned long _usecs_to_jiffies(const unsigned int u) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 0bbad90ddd6f87e87c03859bae48a7901d39b634..7b35c58bbbeb79f2b50a0221277= 1fb283ba5643d 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -42,8 +42,6 @@ #define ZERO_KEY "\x00\x00\x00\x00\x00\x00\x00\x00" \ "\x00\x00\x00\x00\x00\x00\x00\x00" =20 -#define secs_to_jiffies(_secs) msecs_to_jiffies((_secs) * 1000) - /* Handle HCI Event packets */ =20 static void *hci_ev_skb_pull(struct hci_dev *hdev, struct sk_buff *skb, --=20 2.34.1