From patchwork Thu Aug 24 18:32:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Halaney X-Patchwork-Id: 13364564 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3D9E0C6FA8F for ; Thu, 24 Aug 2023 18:33:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oKn7gDUedCy4ov4wwhHRShKXac6S3M3XTJsuazRsbWo=; b=eWJ+sG7Lj+5Y8o QLDgq5JX4K3tR0HSb0cdQPjgKhC8/u+E9kWeMKq8yMDN+nL3qkq6+3MtupvfYtCGUpJd3gmDOiVT8 GWLh3OmsZq0XAFPGAkj4d1rO3Z+7Mb342iQL4mx2D5JffsgZgCN55pO2TFB6t9OYuxE8FZvNNNa4a RnTOyCeFHM6AOhitiyVF/aHSXGmwJSApLK02rt30v3eS9/yvNeABa+9MJNcD0X5ouAXyk08ShJOin iYyCoqNvqDxul4wyEbWF6pwpKy/8AWrD6AhkJYDFMbQzuNLXeVtO1D/e3ChipZN0t8JyyKMMQAKOG 5ZdwdXYsMPOb6oyCbF8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qZF8s-003b4k-29; Thu, 24 Aug 2023 18:33:14 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qZF8k-003azj-1r for linux-arm-kernel@lists.infradead.org; Thu, 24 Aug 2023 18:33:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692901985; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=thxHPyqpXjBOV26mQw4932uoaf4t0NSsG4y7+rk0Hj4=; b=I2V7ZtaYenrtdPuPjrY6uasSdyevvxG9YVrV9lhJEyuUSxdzfB4LMRtMDpbFyZ9REzPpiA XP8baufP3zxFDXhvZbmv7d8BZ8AtLSc55dwLtGszKk95ktMj70RAzrphEkvMqTwOobj21F NwwLf8IvfYWHQrdxoGpclqc0L9zc9Ps= Received: from mail-oa1-f70.google.com (mail-oa1-f70.google.com [209.85.160.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-683-y9SvWCD2M-2vyNJcGxZNLg-1; Thu, 24 Aug 2023 14:33:03 -0400 X-MC-Unique: y9SvWCD2M-2vyNJcGxZNLg-1 Received: by mail-oa1-f70.google.com with SMTP id 586e51a60fabf-1c0ed186cf5so110035fac.1 for ; Thu, 24 Aug 2023 11:33:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692901983; x=1693506783; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=thxHPyqpXjBOV26mQw4932uoaf4t0NSsG4y7+rk0Hj4=; b=l/Ifmgw9q539QOlodaYc3l2Tq5FMYdIawiDzw0rGv8k5hvF2Yf8njDCY/RB7X8e+up rldYH4m2j2zKS6pB7aL4ojwpK7S8y4qoo1HA3NJOTU9wdIM/3SdoNHswVvovNaU7qjrL x8BwSE5/YE4k6x5FQtBH2iDubo4KSdzVeCt+Ptg2tCdo31hpGjSb7GJfsO3WtP/lALKI 2BBnByCbQoFN9jk97u6QWH2wMunFPynWu9L4CXnroQW1xPwZ8Nw4pJtB+7nE7mV6bUK+ Jw8z6zCnIRJQPiCE6Y2eB6BnHdzxoBizYhRAunNQ/T9CWN3bDDiVRkryOrY3mpj+ODfo Akzw== X-Gm-Message-State: AOJu0YwSFTFYiPcEiXjJaKt0xsXjWWlGRHwzd2ghHmix9aEVwJKavWgV +irhYx2VM5/o+zpgsVmfAbA+AduDLUYYDDb8YhakYiJKd3NFB/hWi1y1myZ9SgHhgYjxNe40uOw 3PGoWrLD6ZUx2upxbeNAflR/u/4NUXE2VKo8= X-Received: by 2002:a05:6870:b30e:b0:1c8:b870:4e62 with SMTP id a14-20020a056870b30e00b001c8b8704e62mr554127oao.52.1692901983111; Thu, 24 Aug 2023 11:33:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNSmaNfEZS7WL931iN10lI15Wz+1s4J2mbWyoGTTDkdpLqrEtuCwFnkDMpqeyKk0MWFoSBXQ== X-Received: by 2002:a05:6870:b30e:b0:1c8:b870:4e62 with SMTP id a14-20020a056870b30e00b001c8b8704e62mr553945oao.52.1692901979913; Thu, 24 Aug 2023 11:32:59 -0700 (PDT) Received: from [192.168.1.165] ([2600:1700:1ff0:d0e0::37]) by smtp.gmail.com with ESMTPSA id j17-20020a0ceb11000000b0064f77d37798sm4209qvp.5.2023.08.24.11.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 11:32:59 -0700 (PDT) From: Andrew Halaney Date: Thu, 24 Aug 2023 13:32:53 -0500 Subject: [PATCH net-next 2/7] net: stmmac: Use NSEC_PER_SEC for hwtstamp calculations MIME-Version: 1.0 Message-Id: <20230824-stmmac-subsecond-inc-cleanup-v1-2-e0b9f7c18b37@redhat.com> References: <20230824-stmmac-subsecond-inc-cleanup-v1-0-e0b9f7c18b37@redhat.com> In-Reply-To: <20230824-stmmac-subsecond-inc-cleanup-v1-0-e0b9f7c18b37@redhat.com> To: Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Richard Cochran Cc: netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Halaney X-Mailer: b4 0.12.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230824_113306_686466_112C3642 X-CRM114-Status: GOOD ( 11.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This makes it more clear what unit conversions are happening. Signed-off-by: Andrew Halaney --- drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c | 6 +++--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c index 6dcf8582a70e..29fd51bb853d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c @@ -36,12 +36,12 @@ static void config_sub_second_increment(void __iomem *ioaddr, * to mid-range = 2^31 when the remainder of this division is zero, * which will make the accumulator overflow once every 2 ptp_clock * cycles, adding twice the number of nanoseconds of a clock cycle : - * 2000000000ULL / ptp_clock. + * 2 * NSEC_PER_SEC / ptp_clock. */ if (value & PTP_TCR_TSCFUPDT) - data = (2000000000ULL / ptp_clock); + data = (2 * NSEC_PER_SEC / ptp_clock); else - data = (1000000000ULL / ptp_clock); + data = (NSEC_PER_SEC / ptp_clock); /* 0.465ns accuracy */ if (!(value & PTP_TCR_TSCTRLSSR)) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 67e4f65f0f68..ba38ca284e26 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -849,7 +849,7 @@ int stmmac_init_tstamp_counter(struct stmmac_priv *priv, u32 systime_flags) stmmac_config_sub_second_increment(priv, priv->ptpaddr, priv->plat->clk_ptp_rate, xmac, &sub_second_inc); - temp = div_u64(1000000000ULL, sub_second_inc); + temp = div_u64(NSEC_PER_SEC, sub_second_inc); /* Store sub second increment for later use */ priv->sub_second_inc = sub_second_inc;