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: 123554 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1058962qgn; Fri, 5 Jan 2018 09:11:08 -0800 (PST) X-Google-Smtp-Source: ACJfBotVhpnj6W224T61FKjzP/ZnAkNQKpRdACzf83ELBh/F369O6o+bPxdGjWx3yjBVOQmwC9vC X-Received: by 10.84.233.138 with SMTP id l10mr3797371plk.315.1515172268612; Fri, 05 Jan 2018 09:11:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515172268; cv=none; d=google.com; s=arc-20160816; b=kVPKaDrsA5f1+kH+DRYYAi0AhNl7pqq9U5pAz8ZMjpIr02PlCNGCLwMCGNALf9PlLa agLyRIxlfxMo6UYO0Y598YnWyldqCmaURrcs+pGHomd4y6dnZQh5SvEIfzhCkl62oFxP cpwtwFDl/HfUUmcrNN/3Qvqv8H58O2XrRP0StXu/NhtQ0zvDDu38gaUjl8uENkRXr4Vz LHrPIrjG5z0f191CY/gUm++S/wjGngltHRI633C5A9vDTKpjDTPjaMW78l56HOg5OrjL 3dSfPa1e9avvweIdfxkAsnTUzPmUrU3wqB0HGfjUVyL2ZMTnd4MivV72c1M5kSHP9PIt at7g== 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=kKqHP/OhLAtZQRV2WWwNEmRqSXv/6Q23knaThbrShq0=; b=YMC2rGewPF6sS4KV2sGXODe60jDLJhDiTrvzh8J5cfh/+b/wieN4L1CiJuQn8vVnwp cg1RoQDgfB15YnGeEx9IHwwYDHsQGnxsy5Y0ZhaKaRfQGwJt37uA3CTYl4RtczpFnYc/ 02inZPTGFerNWlpBVMiKLA4sEOlbnXDHv+PhG7gdf6xCANKNITO4+YEmGFe3eBf9ZrEl Gtpi2+HFgdubHEDJqxrIcwdNVkHFTKn8o5R7FvaPL+KCp80QtqotJk9PVNN5OxPHGslA Pgvb2ggAAWf3gG/DzkV+wStxULo6IO8iyQgqfppYf9NskcZbB1Gw1lZ1rborNhErPleu aQrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=iOAT5wYY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 f4si2126658pgt.238.2018.01.05.09.11.08; Fri, 05 Jan 2018 09:11:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=iOAT5wYY; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752540AbeAERK3 (ORCPT + 26 others); Fri, 5 Jan 2018 12:10:29 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:39279 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752427AbeAERKJ (ORCPT ); Fri, 5 Jan 2018 12:10:09 -0500 Received: by mail-wr0-f194.google.com with SMTP id s10so1962617wrb.6 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=ZUhov+lEYZAAux4XCbhf8X8NCxFf5wSMCwJW6JBgIBUZOQ+K36ShMyZ59FoQUauUk7 qKWFKDXiXV7Yw3xAM+QMLBDRqBrnMnvSwCY/vwiHO5n6R5yD0RATBFBWMAFkFxetACMp ka83/xRARbLetuqzZaUkzqGD8cCAclSmPC6JRdOulVhRnVDj0ncrwWphF/gvww+HLwnj 898P6+g1YFQlpNmtpEch727tsGHqS1Ag01KStFPOlodC0QY+1a7nNOu0783DN3soKGsj SQMC34kvIIM15TRWMnvURR456LmZvL/+pf/cxIiTQ3gR+liFpWiSH2LKg0ZHgHhRUlPg Gjjw== X-Gm-Message-State: AKGB3mLIrcuoKy7DfP2f7WoNMwwxY7jhcf3PqDNuRp5yClPsLXMX4L/c A/E7j3ke4/RQ1w2r1ROzAzAadQ== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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/nxp/clk-lpc32xx.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) -- 2.14.3 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,