From patchwork Thu May 18 15:46:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobriyan X-Patchwork-Id: 95978 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp597463vqo; Thu, 18 May 2023 08:58:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ipVWuJ+cLk5j7vkuX3slJ5ZrgH3MyUt7rxHNQHWJUTr7BJ/foJsn5NPchp7rfmdPCxklK X-Received: by 2002:a05:6a00:21d5:b0:641:d9b:a458 with SMTP id t21-20020a056a0021d500b006410d9ba458mr5331438pfj.18.1684425485914; Thu, 18 May 2023 08:58:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684425485; cv=none; d=google.com; s=arc-20160816; b=tx8GXeFV0Ks9H/LYjGC8FEkL8RZjfaEDOfC72DT3vDFwRYsIipu/7HSjf8bSDibAa2 DZ2l4wevPm0UpveHdQbPQWhZmFaSyCh0gmuBFFJkju6z46mxUQFGq8oSsRCH/v/OLAm5 mNDNAajFVfmEl3zjw+ZRReipBV7NTNUgxrcyNnQ2P6NDwn1BZmca9KYYghLMES94Z+uO uzo/hGBnIN6s4uIq8XQIqoW2ZgAP9M8elERyHtc3j4VY1y5gNG0AjyXEWiAE7geU4cM3 qJZXshoRC2uTQJxAsokycmKEU6klpnawPk8ZyOoEcZyP9tfDcQPNCGW0ZK7DquN326nA cdFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tye9L3auG/VYuq8Wu4br+PZRvWyj+Q5KoqkXJFSM6kY=; b=E5koZ+wUiwZ7D3WNzXnrFmhoAEe/hn7821GA5gPerI/a7ePY8JM8S+r6RMZA9/1hRj +rT9rQQjtiM5Lq1Gz+iXfOMF8GZK+22ylmcr4AAhx3i7euxHR4x1n55wwdg/+T32Iiuh QzTZx9dud3qc2IzjZ7ljEbbYo8Wtoo2rtJ3UepcrNwSyPMEvsus56MIwK8RqVA18Pl6T 3f/BV+CttcuIKgFxo2fUdTO5iP2bchYf0t0KiQAYUj8WSKanq9MqRBeOSo2hUWpr8LqB 1PZGLZtFfUfR9gwk7WQ8X+46m8c1otcp+s5asc/gqS6H29PAfMzhHFXe0QIwiBlXndVb YDGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=nm9gUVFy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a24-20020aa794b8000000b0063806e9892fsi1952761pfl.243.2023.05.18.08.57.50; Thu, 18 May 2023 08:58:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=nm9gUVFy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231964AbjERPrY (ORCPT + 99 others); Thu, 18 May 2023 11:47:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230257AbjERPrI (ORCPT ); Thu, 18 May 2023 11:47:08 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91DD718C for ; Thu, 18 May 2023 08:47:07 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3f417ea5252so15541265e9.0 for ; Thu, 18 May 2023 08:47:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684424826; x=1687016826; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tye9L3auG/VYuq8Wu4br+PZRvWyj+Q5KoqkXJFSM6kY=; b=nm9gUVFy6rjGJIT0KFUSVbQLlAiWcMvEAfmiDxi166GZPFhyV2otVC463q3ZtwqWiF 4RI3AzxUxTCnFdmOnAyUaUzJPyeaMmYg+u4muNSWI6Ez0UoC6bkWbYm2ERQHrTS9nLjf RzMpp3BhCIbLsbmqTsWHJJoLcBUmYIetei5/GjwQraTQ91CFWn38bW37nt0eY8grkVn6 CJY78GDl0OIT/h9Y94IMkIy91TxLw+vym23pti8A1uFusT4qJM+K3iu0BZ7TUPPirOdO GKYnvbngLrR+4IOPEXB4N6HtbZ06nrck3h4NbCCXToQ+LZZ3o9LvWRzkigM26IA3aawK gxKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684424826; x=1687016826; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tye9L3auG/VYuq8Wu4br+PZRvWyj+Q5KoqkXJFSM6kY=; b=YfWASBDVrKQjN0s0cHwJ5E6p+vnCqpLDGFtBXECJ/eO34G7XPJzuJWtMYxR1tL3HsI 7TuoWKc3wag6Xam8/pyxIkuaXayIUHWBnKnJzsau8yKQPbukQZe7Fm9YZd8NTj0CFqKP roUbOtrkUMUE0dgj1Vc9cV8/6oTYZ+xO3KkZnqwd8iQvbzHW6bmEmok7iAxRgyH7cdkX Xxz6fecztSuMTeRFhtnT1DRiEZKJKLolKXwNY5oOQBuS/DXWvc1GsatLP/FS6621vNk7 V2WJzuz1wpkjEZ92cTGWQkJA09MjaHhlempWO2CZXcP/PYhyblF2pIK6SCykAzxJdxLC CN0g== X-Gm-Message-State: AC+VfDwgW53bgyX/xNgOSM+zGtH+nzrNoCspmN9Q9oEktD0wNGGVKBOh Ft/Z7bYnKGpp4MfS/kOCbo3J5u30Yw== X-Received: by 2002:a05:600c:b4f:b0:3f4:f0c2:125 with SMTP id k15-20020a05600c0b4f00b003f4f0c20125mr1788676wmr.23.1684424826040; Thu, 18 May 2023 08:47:06 -0700 (PDT) Received: from p183.Dlink ([46.53.250.37]) by smtp.gmail.com with ESMTPSA id h2-20020a1ccc02000000b003f421979398sm5671769wmb.26.2023.05.18.08.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 08:47:05 -0700 (PDT) From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, adobriyan@gmail.com Subject: [PATCH 6/8] auto: promote DIV_U64_ROUND_CLOSEST macro to function Date: Thu, 18 May 2023 18:46:47 +0300 Message-Id: <20230518154648.581643-6-adobriyan@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230518154648.581643-1-adobriyan@gmail.com> References: <20230518154648.581643-1-adobriyan@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766248138236091589?= X-GMAIL-MSGID: =?utf-8?q?1766248138236091589?= Both arguments are cast to specific types, so moving cast earlier is OK. Signed-off-by: Alexey Dobriyan --- include/linux/math64.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/math64.h b/include/linux/math64.h index d8770c8a9cff..3ab235c8a94c 100644 --- a/include/linux/math64.h +++ b/include/linux/math64.h @@ -328,8 +328,10 @@ static inline u64 DIV64_U64_ROUND_CLOSEST(u64 dividend, u64 divisor) * * Return: dividend / divisor rounded to nearest integer */ -#define DIV_U64_ROUND_CLOSEST(dividend, divisor) \ - ({ u32 _tmp = (divisor); div_u64((u64)(dividend) + _tmp / 2, _tmp); }) +static inline u64 DIV_U64_ROUND_CLOSEST(u64 dividend, u32 divisor) +{ + return div_u64(dividend + divisor / 2, divisor); +} /** * DIV_S64_ROUND_CLOSEST - signed 64bit divide with 32bit divisor rounded to nearest integer