From mboxrd@z Thu Jan 1 00:00:00 1970 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 47FD7CCF9E6 for ; Thu, 23 Oct 2025 19:52:51 +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=g4TAwkb6TAa103GDrj4e9w9FmjJdfgk98b2TmeVWNfI=; b=LBMRw39dR2vBp4 OCY4d/zMLAfYx3OQHJOVNU3DnIs7REoRiqrqCydtY29iA9yrOXMOYAsJ8ffoLyzzpFaWaYJqtotaq sDF8H9lQC5706Xqs2QCYiNO/tL6DVNRw50nMfmfwcs8rTXVviJVNEkoK4UgofteyxXl5C4wkggyzl jB1BEc5qTlMCSX6zxUVVGCH4XstWO5oGj3u8yTu6ms93VzHsHo//E9qJ8aGk5BCuAXNk49Ljxos++ sKbj+QDcbTViF0urJ8hedoRX1ArzGfCFkvuqU3wI/s7D9spnE+LwTUedM3dlfOhqiNVsK4DLbLilG T9Bm8DIpyf5IHGym84rg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vC1Mg-00000007RbC-1sVw; Thu, 23 Oct 2025 19:52:50 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vC1Me-00000007RXO-06UI; Thu, 23 Oct 2025 19:52:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=jOfAQy6zSU9ALbpL1BWUFEG7xOjI+5Wynrtljel5J2E=; b=nn1xb3dOk9hdw8KYMX6PmOHOKm JOX4S3a5Y+SNTssqK6vCsBfy6/zCx255ANJK2Oidb1x35UKHA9ebP3Ttr17TMiz9kgd0WcSz1aKwx L+LhpjTI7cdpkndthCCngPr8XBMJFhxLKxoPQ945NNZxzlg0GvanvOxh1FPwRU5cSfwK49ECi1quP ts4iw7cH1QoIKeiMMZsdJ9KIE71fZEih+zyCpD5Nc61AMqrh2LFNtVU3swtUHKTuwRZkDc/X12cn4 71eH6u+ecdjPkxz4+A24vPMsd1InOsj/yv8xSz7oW+x0V8kaCXdRN6xol97d7xpOpGvHXbuCRcwN7 oylmSMPA==; Received: from sender4-pp-f112.zoho.com ([136.143.188.112]) by desiato.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vC0Uu-00000001gOK-49Q5; Thu, 23 Oct 2025 18:57:20 +0000 ARC-Seal: i=1; a=rsa-sha256; t=1761249150; cv=none; d=zohomail.com; s=zohoarc; b=OvSSNLHStUlrCORQ9PchBe6O40+m7u6B/rckCMgFy0eHwNA27p/khkj3ToOxtAqHZUx9NNYAvts7gMz+13f0zbYP/vaA7VwiqFhY9KJS/VO4YaQLWGrD915tRZp8CZL/dkWD5E+GHBFNzE3CK1lZJIEEE2mAi9JReGqV5472tWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761249150; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=jOfAQy6zSU9ALbpL1BWUFEG7xOjI+5Wynrtljel5J2E=; b=f44fxNE2GKwvoB360EzCyCi8e3JJTg0V5MnAFe2XrfasWO0mWqCg8D4OOX3VDf0en7GstPozmmwbuii86Wu81nzA5SX+uJ4jQBg5wMOkmCTtsehPuL0J/+cx5o6pyJdmladw8LjffqNU+Ykz2Ug65BlUPcfVkXcp4M8tpLKum9E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1761249150; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=jOfAQy6zSU9ALbpL1BWUFEG7xOjI+5Wynrtljel5J2E=; b=SSWhn1m5RDIPEWeXMnuakcnTctbnXu6PjKtibIJBDa2adzOH0oDZBaG2hFICID5q 8VpMhqflL7gBeijxRiKoLr1mpEf+SaIPzo0SRHQScjs6PjB5T1XxpchDcDAzke5DEDb lxKk/HQRx0mYz63SgVMsOcy2Cp8tCs1XA797Up0g= Received: by mx.zohomail.com with SMTPS id 1761249149624289.98114903850785; Thu, 23 Oct 2025 12:52:29 -0700 (PDT) From: Nicolas Frattaroli Date: Thu, 23 Oct 2025 21:49:40 +0200 Subject: [PATCH v3 22/24] scsi: ufs: mediatek: Make scale_us in setup_clk_gating const MIME-Version: 1.0 Message-Id: <20251023-mt8196-ufs-v3-22-0f04b4a795ff@collabora.com> References: <20251023-mt8196-ufs-v3-0-0f04b4a795ff@collabora.com> In-Reply-To: <20251023-mt8196-ufs-v3-0-0f04b4a795ff@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown Cc: Louis-Alexis Eyraud , kernel@collabora.com, linux-scsi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-phy@lists.infradead.org, Nicolas Frattaroli X-Mailer: b4 0.14.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251023_195717_463981_0541D61C X-CRM114-Status: GOOD ( 12.38 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org The scale_us values are constant, and should be declared as such. Do this, and use ARRAY_SIZE instead of a fixed <= comparison before accessing members of the array, to avoid possible future mistakes. This results in the same assembly with clang, so there is no functional change, but it makes me feel better. Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c index 38698fbbd228..5f5ebaf61ae0 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -940,10 +940,10 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba) static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba) { + const u32 scale_us[] = {1, 10, 100, 1000, 10000, 100000}; unsigned long flags; u32 ah_ms = 10; u32 ah_scale, ah_timer; - u32 scale_us[] = {1, 10, 100, 1000, 10000, 100000}; if (ufshcd_is_clkgating_allowed(hba)) { if (ufshcd_is_auto_hibern8_supported(hba) && hba->ahit) { @@ -951,7 +951,7 @@ static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba) hba->ahit); ah_timer = FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK, hba->ahit); - if (ah_scale <= 5) + if (ah_scale < ARRAY_SIZE(scale_us)) ah_ms = ah_timer * scale_us[ah_scale] / 1000; } -- 2.51.1.dirty -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy