Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4766190imm; Mon, 30 Jul 2018 22:58:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfdICGveAnWVV3oodOWvRHf2UP3aUf/2Sa0HFKVV2QMO+p9KbP/8RFLYog3L2+p2OSWtu0S X-Received: by 2002:a63:f002:: with SMTP id k2-v6mr18802028pgh.8.1533016723981; Mon, 30 Jul 2018 22:58:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533016723; cv=none; d=google.com; s=arc-20160816; b=BCZkCBaBmlTp2Vtp8rKyZS5X95C/QEaG270xAL+1QfsfWZyaM8Pyr54Y9MYDycitCw Yrx4yFmyr/RKQkoA1Zy9PRcA26CWne/8Cs27I/g1uqy2NvM+aryJzVxL8TaOu8LuAPf/ wyH39V9E8Nth4p3qJpQqMKxWHTf6IP1UMl8AuhgnKCm1UHi+y7QmdrPXZJ3+Tj07rwKQ sFyTVh7V/MYQTehgldLWQcND7YNuxbdkDym7FakgS9aivJZoq+bFt4RHQF/QoW/7xo+i 3olIb2SLpD8CAMhL0Bhod8ax4FJKyL+j/BQNTawO0aYTgU3NweEx6wQmGAybAebTaynI iuXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=AxAufD6GejaukOhxUPzo5d+h7hP5SE/5sOntgZZdS68=; b=m4zr55D1EigEWMltmqNN7y0/JmGYb5pqTeAhPpWBLKBFtAlMXjwMqM6bXYLmOto0VY rY400w+kPj0F5wg/pDm8jNvgEfhSkkHnl5nUqzg61JV7cpqtv5c4G3aN9dcnyV8Dv5UH r4SD4U8HMfNipNq9e2Fxotvj+t22GhYr+bXTBvNVBLb77eXiYgGQ7l9SdFN5WGzwkqhk aqzdkKMVasDo9ylJvzjFgZav7G8qTr/NJbNyXT4OMfvW0eA4Cdx4GYkL6T3idFEO8SGv 2aYmJZW4H8XiFwzMsg11YNlglzQhltYBR2xFfaDcdPMpA8xOWwXVEEt5bRKDcqjTcFpo wh+Q== 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 d5-v6si11406928plo.3.2018.07.30.22.58.29; Mon, 30 Jul 2018 22:58:43 -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 S1729622AbeGaHen (ORCPT + 99 others); Tue, 31 Jul 2018 03:34:43 -0400 Received: from foss.arm.com ([217.140.101.70]:48048 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726070AbeGaHem (ORCPT ); Tue, 31 Jul 2018 03:34:42 -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 CBF3680D; Mon, 30 Jul 2018 22:56:09 -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 79B993F5D0; Mon, 30 Jul 2018 22:56:07 -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: Tue, 31 Jul 2018 11:25:55 +0530 Message-Id: <1533016555-3731-1-git-send-email-amit.kachhap@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <153296797329.17365.14490424418553594815@swboyd.mtv.corp.google.com> References: <153296797329.17365.14490424418553594815@swboyd.mtv.corp.google.com> 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. Fixes: 6d6a1d82eaef7 ("clk: add support for clocks provided by SCMI") Acked-by: Sudeep Holla 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