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: 10146835 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 2E988601A1 for ; Fri, 5 Jan 2018 17:13:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1087128779 for ; Fri, 5 Jan 2018 17:13:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0503028783; Fri, 5 Jan 2018 17:13:10 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A59CC28779 for ; Fri, 5 Jan 2018 17:13:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=MnwEE/1A0jMOOWKHpBcUxm4AkkBUYKa7PGXrAxD3ikI=; b=gpeUo8rsF+sudWm3qmSq5bLCcj fLS5xQ2DTwydEAQhSHwPP84wrfDqlmyn7REGPxRmLsLrvlnzjnnWZPoXlulYqbaAZUjDCZerNNYX0 iIsoel0aCQUGlfB6Ag8LtbUzDz2KQdYEy7PGO1ZSd0DOrKL77w2/sZEN6Onk0ppPHas9z95DvP7Vj 3nv3KdslnIvDIi0f6YtPG95/KWF3kJG1dQUW9luVWRGnls3GmojLh8EfxA/XynSAamuIH08W6JIgG Ixw1mTQ6II72Im/lMPO7tasZRek+blr0PF34LRtY1VB7fyZUgMrH2HeVpOnuTHsEgqQVqjzp5uXD6 Hbi16UjA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eXVYH-00056m-3q; Fri, 05 Jan 2018 17:13:05 +0000 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eXVVX-0002CN-Jt for linux-arm-kernel@lists.infradead.org; Fri, 05 Jan 2018 17:10:21 +0000 Received: by mail-wr0-x243.google.com with SMTP id p6so4896660wrd.0 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=Djd04PTlXOgK/YFIOLy0/bRaQjV5qFo8FWGU/aaZdd0xeq6k/c49wYfInSRr/s84UN i9r1gYAbDG+JWnPBG1lyCLOnPNMWPUGBgw3MutkFDxie1rZrdXvzsAHqSBL0IPUUFVcf TurgFpjZye/KCWNi6q/gwVZMGBZ5c1BqXJ2C1OCCipmEZKHzItQyQibIu1Znaj5XbuVq RDzH7aV8T/rgXzP/hdl7zTTtiflbL6ZNaenXshhDLfTJx9LddzHNIIP3PAHK5A+kPhWs w1ldjla7GiywZM1+QcYQX9i798+Fg93F/9Xeyzv35OSLsGeBVZo4W/a+12O8CtwJEpwI aDKA== X-Gm-Message-State: AKGB3mIKzB6vlDOd+cszqoeD97lbVIAE5YBgHIW+fRkKkSZ83SUIRmZU jiW0Psm2Aqygb0KtNSl93riVzw== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180105_091015_788568_E55249A3 X-CRM114-Status: UNSURE ( 9.40 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Vladimir Zapolskiy , David Brown , Sylvain Lemieux , Andy Gross , linux-arm-kernel@lists.infradead.org, Jerome Brunet MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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,