From patchwork Fri Jan 5 17:09:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 123552 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1058243qgn; Fri, 5 Jan 2018 09:10:28 -0800 (PST) X-Google-Smtp-Source: ACJfBoslWCXewYwjkLh8yF1sDmC4zWGAsDBy0Nzmp1R1+0vQq+4unW2DvAVOYtDR1XHM6hOnJZlm X-Received: by 10.84.131.162 with SMTP id d31mr3731575pld.193.1515172228482; Fri, 05 Jan 2018 09:10:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515172228; cv=none; d=google.com; s=arc-20160816; b=symiqm92SZ4SD0GkWasc/J2fr8wdS+0GC8u7AAaBS6vaNBH5MvkD8YLwfx66dx2/xJ E3SyR91uOzFm5+1uRppvM7pKlRYDX0LZKy3oCly6T4slnIu8gbKI8lKqZ5tIZSzLasMv Ed7vbTHgeFa+Y8v3hRXSC52kJuU01ukH8Iihcejtk8H0VWlOF2/mBKTW1drRmnDo35gi fz45sPXNSVCTYNaQWIKsPvTwEFtgFI50Wa5dg2bvUZxuMZMlcZR1fgm+5wmflFBKLj5D GvdyVcqvjAg3E0Uz+3H/RmaQEOs+nMpF74/7YjBudXZ7owX3f7xo1N1MpLcx5LUI2tPK KKrQ== 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:dkim-signature:arc-authentication-results; bh=zrlG7d7mr1NAqysmO1+4qBVU4M3eJai7kH+FTAvhMD0=; b=H/KLRNjB0Oe2FpYrhlz2BnGVsOr4X/LQ76mfIGIUgM1EtTSEQoNV23JLRURqNX4l/A 9aM/NFLCP33FydPbfFpwL1gO5KMBvgp2aiYtnoEy2H5eOj2mNP/H7ZKQ+ejoPacEKM6d PmiJHB38IsNHtdmZCG5YEKppGh+AYw6f5tVgKkuNpfh1gxdRL9eJFliwjXT4AgyYDUNp ZFvJD+zZzj3uuu5AFQ9Q1nMEw/5At0FGvXijSYgeWzv5KXl03NH7ydQ9zDT4SGK4HHFZ fyVwVFyXeNRDGmGI5zoLC5LP9tYjy4HSUdFHJF5wQ4MbdTG4HyLI0Y07P7+va1BjoWFa 5lHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=VOeopaMA; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 o5si4213934plh.477.2018.01.05.09.10.28; Fri, 05 Jan 2018 09:10:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=VOeopaMA; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752492AbeAERK0 (ORCPT + 10 others); Fri, 5 Jan 2018 12:10:26 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:39282 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752434AbeAERKJ (ORCPT ); Fri, 5 Jan 2018 12:10:09 -0500 Received: by mail-wr0-f196.google.com with SMTP id s10so1962656wrb.6 for ; Fri, 05 Jan 2018 09:10:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=K0KrHqJBo0bGCzzug0ZPhoG+FjAD5rkjcE9+waAJNss=; b=VOeopaMAhkUK4SCipjJ38Zlkz3zuZxk6SzmpYH7l/PpXvPe9ApBkhvEtKtToX15KxQ emsb4Ptx+v+Cj43t5QLTMykD1b+pyMUOG5qgTwZ+HP7BwYXEIGltiFxOabYfjnriJmCs e7uENwd+Cb1UoFAF/vTWfsQyOUnJWgKAclWPyBWEnmNOuN2/TxQH639tqcf0Dy0XbRPP ijT/Ss5/ua0z6V5qE5KTXATJUAjILONiZNf+HwTtjTx2tqLedPzXat2l4haXQu/hQqKi tx6ekNkynHYvXxPINoJJP1GiXcJ71OyT7VIUiXk5ZAwEZ7SRL/RWQAuK30scrkJXa2Dd bvhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=K0KrHqJBo0bGCzzug0ZPhoG+FjAD5rkjcE9+waAJNss=; b=NP8kvUNLz1PwNbE1vha9qYT4uQzOd+utfZTxxek6j2Vu1SEqVvZVydOMRcNYgiDqNM SA9NPVceVojixiy3ncRWwq9J4ASJXiv+XyVXUeHMRE0jDTQ241eUqutWe+1LpXADvXC/ vxeyQzpwNrl1NHuy+B0D1bPqbyIzw5zY7qwtWFwvO5jYc7yyO9kBwvG+qEBlyHtARZWM sTvy0NwxTgtRiZnl51RgyduL/ZjZxOPi0Zc5y2/qCe9hGcwnN34JBCE/CV89RnBn889+ NFp3nxaazRhUMul9Ub54VDY5W/M7Qq87vYkmX0H1cgBR8wdDheyjRxt7iz1EiPCUtZzv jyHw== X-Gm-Message-State: AKGB3mLSJHLWuHUMnjiFddTU9gvW+HIx1nuTN1bD1+YHRA/TygMwXOiS p3A6mViJoHF6jpZeUIR1mrEIRg== X-Received: by 10.223.138.210 with SMTP id z18mr3298459wrz.230.1515172208576; Fri, 05 Jan 2018 09:10:08 -0800 (PST) Received: from boomer.baylibre.local ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id g17sm3263661wra.6.2018.01.05.09.10.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jan 2018 09:10:08 -0800 (PST) From: Jerome Brunet To: Stephen Boyd , Michael Turquette , linux-clk@vger.kernel.org Cc: Jerome Brunet , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Vladimir Zapolskiy , Sylvain Lemieux , Andy Gross , David Brown Subject: [PATCH 5/5] clk: qcom: use divider_ro_round_rate helper Date: Fri, 5 Jan 2018 18:09:59 +0100 Message-Id: <20180105170959.17266-6-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180105170959.17266-1-jbrunet@baylibre.com> References: <20180105170959.17266-1-jbrunet@baylibre.com> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org There is now an helper function to round the rate when the divider is read-only. Let's use it Signed-off-by: Jerome Brunet --- drivers/clk/qcom/clk-regmap-divider.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/clk/qcom/clk-regmap-divider.c b/drivers/clk/qcom/clk-regmap-divider.c index 4e9b8c2c8980..114e36b97255 100644 --- a/drivers/clk/qcom/clk-regmap-divider.c +++ b/drivers/clk/qcom/clk-regmap-divider.c @@ -28,22 +28,15 @@ static long div_round_ro_rate(struct clk_hw *hw, unsigned long rate, { struct clk_regmap_div *divider = to_clk_regmap_div(hw); struct clk_regmap *clkr = ÷r->clkr; - u32 div; + u32 val; struct clk_hw *hw_parent = clk_hw_get_parent(hw); - regmap_read(clkr->regmap, divider->reg, &div); - div >>= divider->shift; - div &= BIT(divider->width) - 1; - div += 1; - - if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) { - if (!hw_parent) - return -EINVAL; - - *prate = clk_hw_round_rate(hw_parent, rate * div); - } + regmap_read(clkr->regmap, divider->reg, &val); + val >>= divider->shift; + val &= BIT(divider->width) - 1; - return DIV_ROUND_UP_ULL((u64)*prate, div); + return divider_ro_round_rate(hw, rate, prate, NULL, divider->width, + CLK_DIVIDER_ROUND_CLOSEST, val); } static long div_round_rate(struct clk_hw *hw, unsigned long rate,