From patchwork Wed Feb 14 13:43:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 10218891 X-Patchwork-Delegate: mturquette@baylibre.com 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 F119F602CB for ; Wed, 14 Feb 2018 13:44:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEC3528FAE for ; Wed, 14 Feb 2018 13:44:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D320328FE2; Wed, 14 Feb 2018 13:44:21 +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 A14E328FAE for ; Wed, 14 Feb 2018 13:44:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030202AbeBNNoG (ORCPT ); Wed, 14 Feb 2018 08:44:06 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34390 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030405AbeBNNny (ORCPT ); Wed, 14 Feb 2018 08:43:54 -0500 Received: by mail-wm0-f68.google.com with SMTP id j21so17865792wmh.1 for ; Wed, 14 Feb 2018 05:43:54 -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=bDLLco5S7iNPdRidSWRUB29Devrk8i84t9g+zhPMvLY=; b=pr2o+INelgXpqL6Bk3gT/HIgRHt/I6xw4pGAzkYIFizF1N6QwH4pO2+a4mpeoXL5Cw rlgQ+ecsIfe8f2yxXn+snhAI26HvdLGIcEXqMUbRnqS0YKrAJyyqQ7QCuEH8CPpw+qwW OHZEm60cAyyk8xfQ7wIaEeyz/l9+6ItXtAGpWXI6+alEm/9GxDH4P9odcvtoiNfrXpps nZB/xowk8q7TDeW3S9xvT1VIAOXOGo7RMYkZxE+JzTx9ElNA78lCewgXTH39hsZ0ivIs ahXEnfhQKizQ5VzLWWfgDgvbneH5aja6QsBUSwIE/qt0i2xiICJD5RE01fDul2gx/oE5 dwgw== 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=bDLLco5S7iNPdRidSWRUB29Devrk8i84t9g+zhPMvLY=; b=tOs/S2BJvSJpEx9J80U00XysHsCg58+ddjK0wum8vOWa21v+9rx1QseVXeTyTh2GB3 /ydY18m4J0toGQQu4sckKUi/C1L8WFaQOhrU+UhMFoGzUc+PUprAQE5kcfLilUKMYwnp /GwbWpiYHsHGcmaBwEfC35t+nUaZYUNgWKCFK+mt0XWDiXHbPVhXuq1WRe5KCK0H0vTT SZQnVvV3who4RMUFFH0kWM2Qi/EOFMHEbtIKKdcIdlwzSSUJSLsBxWaPZYpWJvQjC+iW tLegsdb7tDHBSdvYyjQJVW3x4rlfV/KuhY4hmTK9cdEzdIsfzpww9wNs05svu9mehMP5 84WA== X-Gm-Message-State: APf1xPCAVS+a7NJttyTieD8q0gtaGsDt8fsPLqy78zE/wApSjcc87yFU TiMZ34tUzoLTQrD2TfQ331/b7A== X-Google-Smtp-Source: AH8x226a8MunL9SKmigBAvIP/5MWSc3h5UUGXHjVF7zxYAHdwW4c8Px6CSJi/vXJhYDmZF6lqaXyXw== X-Received: by 10.28.206.6 with SMTP id e6mr2000200wmg.160.1518615833469; Wed, 14 Feb 2018 05:43:53 -0800 (PST) Received: from boomer.lan (cag06-3-82-243-161-21.fbx.proxad.net. [82.243.161.21]) by smtp.googlemail.com with ESMTPSA id k5sm6337694wmg.47.2018.02.14.05.43.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2018 05:43:53 -0800 (PST) From: Jerome Brunet To: Michael Turquette , Stephen Boyd Cc: Jerome Brunet , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 8/8] clk: qcom: use divider_ro_round_rate helper Date: Wed, 14 Feb 2018 14:43:40 +0100 Message-Id: <20180214134340.17242-9-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180214134340.17242-1-jbrunet@baylibre.com> References: <20180214134340.17242-1-jbrunet@baylibre.com> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@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 | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/clk/qcom/clk-regmap-divider.c b/drivers/clk/qcom/clk-regmap-divider.c index 4e9b8c2c8980..1ee75a5e93f4 100644 --- a/drivers/clk/qcom/clk-regmap-divider.c +++ b/drivers/clk/qcom/clk-regmap-divider.c @@ -28,22 +28,14 @@ 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; - 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; + u32 val; - *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,