From patchwork Fri Jan 5 17:09:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 10146823 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 4DC6D604D3 for ; Fri, 5 Jan 2018 17:11:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31D9E28537 for ; Fri, 5 Jan 2018 17:11:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 268DD28779; Fri, 5 Jan 2018 17:11:40 +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 C6AEA2871F for ; Fri, 5 Jan 2018 17:11:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752518AbeAERK0 (ORCPT ); Fri, 5 Jan 2018 12:10:26 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:42390 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752425AbeAERKJ (ORCPT ); Fri, 5 Jan 2018 12:10:09 -0500 Received: by mail-wr0-f193.google.com with SMTP id w107so4878873wrb.9 for ; Fri, 05 Jan 2018 09:10:08 -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=kKqHP/OhLAtZQRV2WWwNEmRqSXv/6Q23knaThbrShq0=; b=iOAT5wYY3B6LLyD4Q8akP8Qp2f3MCJD3lP4hMGirgRfMRbXhSNU1L/U48pAEj2/Wnv xi1K5x8ivJyG8MBhrsHCzqvz8e05ZiEScSCFjMO/ndZj+SsZU9NmVRlPp2iiUQZYsXTK 3Yd2Zbxdwn//eunZt46uzq+UZZYThtXcHYaugdBAjkYyog0w8ml/m5wko8bhV4mojG7L CRUkebt0sQPkHS53DeaUW7pvMbbjDPUWCrkwQCzsOjBCqN5CvOFyH3SL/pGYloruOxoX evrwibqZeeHMIsU3rS5ExYygdgubnVBr+QbpdmkebcDJPas/MtafCdceazWzHyj4iXFO CL2Q== 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=kKqHP/OhLAtZQRV2WWwNEmRqSXv/6Q23knaThbrShq0=; b=pK1sM0n8AZzJIWPgoRynuXbMzG2pomUOSEFw31kOIbBBroCGf+StYHJPc++ZKl81aP vzf++NiSDzBkPB4J4JGzcnNYEkwDfzIRrz5ffRJRvNzM4TwXSOYeNBx3P9uX3d9k8F5m RCIm1BKnvBDCvx+dbP1ea2Vw7Hx4KRX+Di/L7K3NfhDrS38YQzX+Lc8nVHCUSLPjqMEi Isbbh+Ke9BaYoOPUYaEFxMxHJrUAG8bK4p12zn7TrqU1E7AhfoS9mKzLNbfgz/VRPG2z 1EDrNH2/gst1ka0JkmGNtshqTYe0ILXtOhJc2VncBt5MronKid9Ml3+iKSc4tsNlQxCM +TBw== X-Gm-Message-State: AKGB3mLuXU0FYM0cLEcsmqE3Sv/zKeClRfK+B4P9e9XD0KAqjegfI215 QcKQ4zIV79l5330RSSeXhKUbsg== X-Google-Smtp-Source: ACJfBoswhSBLj9IZDcxX4tf1wIbtTVBBnprPlqb8NjToL9zuna9OFuK+5ImV8DFfjDSArH9UEz/lAA== X-Received: by 10.223.186.1 with SMTP id o1mr3348741wrg.95.1515172207534; Fri, 05 Jan 2018 09:10:07 -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.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jan 2018 09:10:07 -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 4/5] clk: lpc32xx: use divider_ro_round_rate helper Date: Fri, 5 Jan 2018 18:09:58 +0100 Message-Id: <20180105170959.17266-5-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/nxp/clk-lpc32xx.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/drivers/clk/nxp/clk-lpc32xx.c b/drivers/clk/nxp/clk-lpc32xx.c index 729333766f97..c20285e74b8e 100644 --- a/drivers/clk/nxp/clk-lpc32xx.c +++ b/drivers/clk/nxp/clk-lpc32xx.c @@ -963,26 +963,17 @@ static long clk_divider_round_rate(struct clk_hw *hw, unsigned long rate, unsigned long *prate) { struct lpc32xx_clk_div *divider = to_lpc32xx_div(hw); - struct clk_hw *hw_parent = clk_hw_get_parent(hw); - unsigned int bestdiv; + unsigned int val; /* if read only, just return current value */ if (divider->flags & CLK_DIVIDER_READ_ONLY) { - regmap_read(clk_regmap, divider->reg, &bestdiv); - bestdiv >>= divider->shift; - bestdiv &= div_mask(divider->width); - bestdiv = _get_div(divider->table, bestdiv, divider->flags, - divider->width); - - /* Even a read-only clock can propagate a rate change */ - if (clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT) { - if (!hw_parent) - return -EINVAL; - - *prate = clk_hw_round_rate(hw_parent, rate * bestdiv); - } + regmap_read(clk_regmap, divider->reg, &val); + val >>= divider->shift; + val &= div_mask(divider->width); - return DIV_ROUND_UP(*prate, bestdiv); + return divider_ro_round_rate(hw, rate, prate, divider->table, + divider->width, divider->flags, + bestdiv); } return divider_round_rate(hw, rate, prate, divider->table,