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: 10146805 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A7A03601A1 for ; Fri, 5 Jan 2018 17:10:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C3542846F for ; Fri, 5 Jan 2018 17:10:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81196286FF; Fri, 5 Jan 2018 17:10:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3853D2846F for ; Fri, 5 Jan 2018 17:10:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752492AbeAERK0 (ORCPT ); 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-Google-Smtp-Source: ACJfBouSljtBfrzWgMio51l6NUKQyTvBgJX2+HZn9G2bm3v6c+gJ9+fSv5VLGFpSsws8OPxkD0woxw== 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 X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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,