Message ID | 20210917120642.8993-9-claudiu.beznea@microchip.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <SRS0=Xah1=OH=lists.infradead.org=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B95B2C433EF for <linux-arm-kernel@archiver.kernel.org>; Fri, 17 Sep 2021 12:11:23 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 7F9EB60F9C for <linux-arm-kernel@archiver.kernel.org>; Fri, 17 Sep 2021 12:11:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7F9EB60F9C Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uQEbBOWniIhK7xtb4V1M/S2OFvOzZ2O9BTdQj2toznc=; b=GQeerSwQE6dCKV usOSmKDiUC11ewWFDk/jA0S3MW/YDyEXcnHCeLH4MutHetwyvxh2FBILsKT71xkA5bST0D6o9OfsC G+jCLHNZPgsRZqhpDlSl7J6R/fv6n3dv7KGpe94uw7uZTlgRxOXLL/oAiHdw0/ZaPE6U8vXV0CC1l qS8mJwRSYZ/NG5U9lM0n1bwc++aQWHfHQI95+zl4035MTza95upXqPtkQws0DSk8UOrbuzj1foY9B CY4h3wLtOv/4zV40moHT/3wN1NZkPVbHFYf+rU979br4oDU5JuH2xmx4Ai3V6R7PFwG/AKVl8jYJQ n/VT71WYX/0+tuXRwYmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mRCgG-00Dwwy-3c; Fri, 17 Sep 2021 12:09:24 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mRCe2-00Dw2V-5s for linux-arm-kernel@lists.infradead.org; Fri, 17 Sep 2021 12:07:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1631880426; x=1663416426; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=S2pBzduVdLBand+IYegWgUWMNB29c7JB6jeWuWWNdV0=; b=uo1Xp1j0ncAbNorSk/+O/hHlR6m4OAduRGAUkd1PsS2ud03p0zgRtFHj DKg43D5cjQPlxjdnPcIRU62SxSFqOQbsrWlefYdxNQ8MwtcRDKaWSMlvu G5gtMMhx+5iTSxAwzNucgA2ZGNBLJhX7ok/3YQDATKNQAsfRhjcK7tgHT s02GS9RIunx0ItPOkwCqFuoUUHD8ep6DOgpo6QTrxv90PqXDHbriA4krv 16KH2sCDQrHSz0Q78mKJJv62/Tz1nY7mojMYFg9bp8zhjAxefVF8F7nEX 4FF+q4qfUb4RL3b2qpqFGiOeOYz43lcNvc/qfe+8/Lw25kqU9tQU5y4J0 g==; IronPort-SDR: 1nNifu9LJLOxWKnyepGqqWC2u2ISxYQrmCXq41NexwlaETXPjGt24xVL+h4OEhYxbnqcDjr6VS 7Y7/r+V16meT07/vwPx0Eo/Pm111jkO2bh4XMNq9Gxr31X4O8aJX71xVbJSiDzdINR6D0O6EXL hUC6iE5rCjPPKjHxsu5j4+IHZov3zjuR0lrxuCq873MqfkWSWcGgqXjkJsCeVC+DoLU+eXyTl2 FtWEeUrJ1rFhzDV8ikdAnBbyidwEtVveHN59xxieA1yULBu3njXWmz+kssuUbtWiY+wyZbE+1x T+2RZFd722MKesdeB0zmr3nk X-IronPort-AV: E=Sophos;i="5.85,301,1624345200"; d="scan'208";a="136356768" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 Sep 2021 05:07:06 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Fri, 17 Sep 2021 05:07:05 -0700 Received: from rob-dk-mpu01.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Fri, 17 Sep 2021 05:07:03 -0700 From: Claudiu Beznea <claudiu.beznea@microchip.com> To: <mturquette@baylibre.com>, <sboyd@kernel.org>, <nicolas.ferre@microchip.com>, <alexandre.belloni@bootlin.com>, <ludovic.desroches@microchip.com> CC: <linux-clk@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org>, Claudiu Beznea <claudiu.beznea@microchip.com> Subject: [PATCH v3 08/17] clk: at91: clk-master: check if div or pres is zero Date: Fri, 17 Sep 2021 15:06:33 +0300 Message-ID: <20210917120642.8993-9-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20210917120642.8993-1-claudiu.beznea@microchip.com> References: <20210917120642.8993-1-claudiu.beznea@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210917_050706_298742_F569EB48 X-CRM114-Status: GOOD ( 11.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
clk: at91: updates for power management and dvfs
|
expand
|
diff --git a/drivers/clk/at91/clk-master.c b/drivers/clk/at91/clk-master.c index 9a2c8e64cacf..2093e13b5068 100644 --- a/drivers/clk/at91/clk-master.c +++ b/drivers/clk/at91/clk-master.c @@ -344,7 +344,7 @@ static int clk_master_pres_set_rate(struct clk_hw *hw, unsigned long rate, else if (pres == 3) pres = MASTER_PRES_MAX; - else + else if (pres) pres = ffs(pres) - 1; spin_lock_irqsave(master->lock, flags); @@ -757,7 +757,7 @@ static int clk_sama7g5_master_set_rate(struct clk_hw *hw, unsigned long rate, if (div == 3) div = MASTER_PRES_MAX; - else + else if (div) div = ffs(div) - 1; spin_lock_irqsave(master->lock, flags);
Check if div or pres is zero before using it as argument for ffs(). In case div is zero ffs() will return 0 and thus substracting from zero will lead to invalid values to be setup in registers. Fixes: 7a110b9107ed8 ("clk: at91: clk-master: re-factor master clock") Fixes: 75c88143f3b87 ("clk: at91: clk-master: add master clock support for SAMA7G5") Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com> --- drivers/clk/at91/clk-master.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)