Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp838142imm; Fri, 27 Jul 2018 07:03:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdv2ADFFRby25xU12hWUW1yFm6j6b8vdR3rTa9VPPvhIqE3/LKc5zLOifCSGVyD5Q9tCCRO X-Received: by 2002:a63:5922:: with SMTP id n34-v6mr6273914pgb.113.1532700199350; Fri, 27 Jul 2018 07:03:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532700199; cv=none; d=google.com; s=arc-20160816; b=bFFT51pwg+sgfRJbnKKfNCcoO4SxOY0Fp59sRoR+8/386xbR2n6SfkSqP78wUwzvYR 2IRZtdRuH9CZ2jMPRXeZhCk7s3suU1Ujf4b8tA40+MaWj1Qfno3UoIRZLZBjNIEf6xS1 9KgmdAzKq4jNCzyr2utFU1xdv5bZegZpmHnFEE+/cBkBHw9D30MDkx3rhDbfF2DTYiUS mZXamU3IKtAqiqsBcC7QxSiXELbiJpqNcvseeullxkTt6Js0Zk+YRzC4LaNynAcHs8vo dbZ/VTWuhkmRRO4bly/Ghdjqq1fiKhucZYDfiGzGOZk/ao0V+zXawmJMJwKEyUG0kgfY okSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=uwYch3+74k88jX6jVaA+6DryWjmpVJyiEI2+62ZmhJY=; b=CfxBW8NvpjIXm46bbQi7pkWN8GvyiKfnZS0StepYQF7lC2rZELlLx/bkldS2awJs94 e3XQScpTBC8xR7/YofEXcfXV/KTQRHITfhL1P4owupC0jRvDMhGNHxhAqL3uZ/fLxi5W GhgZ5j7zcI1uT4cO90dw/R+VhD2D0WkOewcA00Prs6Fr2HZkCs38mYLlLaAg2qA67NMX kRoD9qSLQ7fNbgCR3om1Bw0ToMf6DIfaNG8ER91sLYfZTZ7s6k6UdRbtwpEs6Xfp/ocY EOcXJWiI/TEEC1+/9Ye/HdyFqiwRelgMz15EeVEn/4dj2cxgqxDb/op0QnV8bDNz6AKO L63w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r24-v6si3681411pgo.295.2018.07.27.07.03.04; Fri, 27 Jul 2018 07:03:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388571AbeG0PYI (ORCPT + 99 others); Fri, 27 Jul 2018 11:24:08 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:44006 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730475AbeG0PYI (ORCPT ); Fri, 27 Jul 2018 11:24:08 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CACE3ED1; Fri, 27 Jul 2018 07:02:03 -0700 (PDT) Received: from usa.arm.com (a75553-lin.blr.arm.com [10.162.0.175]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7872A3F6A8; Fri, 27 Jul 2018 07:02:01 -0700 (PDT) From: Amit Daniel Kachhap To: linux-arm-kernel@lists.infradead.org Cc: Sudeep Holla , Michael Turquette , Stephen Boyd , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Daniel Kachhap Subject: [PATCH] clk: scmi: Fix the rounding of clock rate Date: Fri, 27 Jul 2018 19:31:52 +0530 Message-Id: <1532700112-11852-1-git-send-email-amit.kachhap@arm.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This fix rounds the clock rate properly by using quotient and not remainder in the calculation. This issue was found while testing HDMI in the Juno platform. Signed-off-by: Amit Daniel Kachhap --- drivers/clk/clk-scmi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/clk/clk-scmi.c b/drivers/clk/clk-scmi.c index bb2a6f2..a985bf5 100644 --- a/drivers/clk/clk-scmi.c +++ b/drivers/clk/clk-scmi.c @@ -38,7 +38,6 @@ static unsigned long scmi_clk_recalc_rate(struct clk_hw *hw, static long scmi_clk_round_rate(struct clk_hw *hw, unsigned long rate, unsigned long *parent_rate) { - int step; u64 fmin, fmax, ftmp; struct scmi_clk *clk = to_scmi_clk(hw); @@ -60,9 +59,9 @@ static long scmi_clk_round_rate(struct clk_hw *hw, unsigned long rate, ftmp = rate - fmin; ftmp += clk->info->range.step_size - 1; /* to round up */ - step = do_div(ftmp, clk->info->range.step_size); + do_div(ftmp, clk->info->range.step_size); - return step * clk->info->range.step_size + fmin; + return ftmp * clk->info->range.step_size + fmin; } static int scmi_clk_set_rate(struct clk_hw *hw, unsigned long rate, -- 2.7.4