Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp880762pxk; Thu, 17 Sep 2020 20:12:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnzIQmb2srP/VKJQB2G35X6AqJAL1VTZgdEopDGlpubdwuk9/8XWHW49xvEzFq2OOrd5Hs X-Received: by 2002:a50:fc83:: with SMTP id f3mr37407189edq.102.1600398728691; Thu, 17 Sep 2020 20:12:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398728; cv=none; d=google.com; s=arc-20160816; b=KECHr5KfCVWF8fr+xPx3Zj4EDxX2rFekXTMBbhXkKTELMgONnDIzKHbrUz/1MRHj5z E5wD6O///LA1PpQjGhdmilOBcBH5BxhQZp1o1cyVvEyxYuyQvAOSa53VobrnYEGI5IQi D8vx5RFZ0rmLs5SnDV/Vrw5hKre7Wl4q/qMKiZgs+ME/P2tWXvDI609u3ItGr9O+v9wS 7bHpWLdN0qOd1BUZ/STTDdTJWV5mMIc5WZ0iUj5lnHH20LS0q1TSD/tgiGGFh+rTyngI 63sCnx4e0E45+6cZv6bsz/yjdzytCwbZFM165GTK/u74FJ0cED7uDeV4BMx95AhE/YOb UM4g== 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=zZxPplcDiUOpvyQX4J9WBmc74SXEikLEQesIRpemqOo=; b=j9RUnxccd9imdvEQOHAQ8wb1emj+hH1QzJb0XB3ULJ/qSD6ky71iFeJSQ8XHUKqdb8 YqQ9RKgo5p72SKhnIe/GvyuhEg3d/vue9Ls32t2Q74X5nY0lTBl2sWHNR6QT62LGdvUD G3NuO4sbOfcybpFMM7wyyft5gAfRqyJ8F02HwbYsGJu74Ln+oAvoOIwz2h3pD/G4+ggS He8diUa/P7pG+HuwaXdlq+ulyupcQr57HLfg34AGiR5QDrHh9sLQ4pUsMLQACJYqXF9k WKfV+FzxvS7486JZ5mp5cEoTdtHwlyfzlh9Cj6Rf2apqzJxU2boEyl5U4BC00EJVcLNY pQWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k8rcC15x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c24si1162535edw.144.2020.09.17.20.11.45; Thu, 17 Sep 2020 20:12:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=k8rcC15x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728515AbgIRDHj (ORCPT + 99 others); Thu, 17 Sep 2020 23:07:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:50458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727154AbgIRCDr (ORCPT ); Thu, 17 Sep 2020 22:03:47 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 109D72344C; Fri, 18 Sep 2020 02:03:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394626; bh=9B85iJUhVDSboa+F3wPLvnpFiPXBa38iJOK81UXFYgQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k8rcC15xkga+N+/8z0uttaYQSnBcbLs5Picv1AkZfW3XCO5v3FtAA5Vls7sU02xkS GW+Jxs46MXYBbss48tJhnhQ2eYdNzAFsbbDGNFsenOdscDHitLHG2cSK/dRJsbGUGD BuhHg9sKlTpsJltO9gj/fqPox4Gv5V2a+vWSkrNU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dinh Nguyen , Stephen Boyd , Sasha Levin , linux-clk@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 127/330] clk: stratix10: use do_div() for 64-bit calculation Date: Thu, 17 Sep 2020 21:57:47 -0400 Message-Id: <20200918020110.2063155-127-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dinh Nguyen [ Upstream commit cc26ed7be46c5f5fa45f3df8161ed7ca3c4d318c ] do_div() macro to perform u64 division and guards against overflow if the result is too large for the unsigned long return type. Signed-off-by: Dinh Nguyen Link: https://lkml.kernel.org/r/20200114160726.19771-1-dinguyen@kernel.org Signed-off-by: Stephen Boyd Signed-off-by: Sasha Levin --- drivers/clk/socfpga/clk-pll-s10.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/clk/socfpga/clk-pll-s10.c b/drivers/clk/socfpga/clk-pll-s10.c index 4705eb544f01b..8d7b1d0c46643 100644 --- a/drivers/clk/socfpga/clk-pll-s10.c +++ b/drivers/clk/socfpga/clk-pll-s10.c @@ -39,7 +39,9 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hwclk, /* read VCO1 reg for numerator and denominator */ reg = readl(socfpgaclk->hw.reg); refdiv = (reg & SOCFPGA_PLL_REFDIV_MASK) >> SOCFPGA_PLL_REFDIV_SHIFT; - vco_freq = (unsigned long long)parent_rate / refdiv; + + vco_freq = parent_rate; + do_div(vco_freq, refdiv); /* Read mdiv and fdiv from the fdbck register */ reg = readl(socfpgaclk->hw.reg + 0x4); -- 2.25.1