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: 10146833 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 B32A3601A1 for ; Fri, 5 Jan 2018 17:12:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95BA728537 for ; Fri, 5 Jan 2018 17:12:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A60028779; Fri, 5 Jan 2018 17:12:27 +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 01D0B28537 for ; Fri, 5 Jan 2018 17:12:27 +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=N3+Qv42quSHPRuJiY7hkmDrcLUM5c6xzar7Y6kJgjCk=; b=Jt57PonSdg4gP5Nd/DDJ2mth9s KKYSHOBVFhzTgcKN39iYA2Yo9+7FzJkad0QBJVT6ux0ELlZcU2GNX4LFoomKnziGjmRI8E63/z2Ck wpnbCePER+lAoecm/JKWdC+lb5XjwndNXyRu/FjAPRsCEzOciU9uypZoAcn1h11tZAxYd/gtQHaVy MX4ZfV6qPx+SzqGMUqkxE085//uCYWln0G44aYTflB6YIYgeULaVyyM2BguCUoeRpH4bvLThT01xc t/iEiZQzVs7sFwq+MR9S4Q24B8MHYMFHzYbnwvoU9G/1RiK6qU8OBsEpwpm0mUbsMp6GtL42k76EC d6Nomc8w==; 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 1eXVXb-0004TM-3P; Fri, 05 Jan 2018 17:12:23 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eXVVa-00025p-Kf for linux-arm-kernel@lists.infradead.org; Fri, 05 Jan 2018 17:10:22 +0000 Received: by mail-wr0-x242.google.com with SMTP id l19so4887234wrc.2 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=kG2ukV0NgHAjLF/JWHJ3w2vY8qSbqnBIAoXaq/r97toibQ1MHwQIYdThgIVPCiOJ76 bt3jKiDtKkciYW4KWIhfSWSmBvQy+P0PcJ1iYshIb8qb130ls1CJwOdI4Mmn+qkC2+N+ nzjDugSUQzmOuOwXeoIyH8hdFkSXOgjuMAkWvSuurk30ZSWo9e7MOUcTnSFj9m0HQCh/ 0MeGk3ZgEWSLiryTqKEsVdcvZZewyLMwZ5z8kMyG+42lQDl8LFK1bd7YMR1+N5TKW10o JQd61VYEwLR5lwlFUand6hAlufepZjFOR0bIrwrHu+CvUffyDUPYikxb//UFluSmMTlW GI1A== X-Gm-Message-State: AKGB3mIRlt0O+nTDRMfeKMiRvp9HiZKyQNVAGMUtObLamLTAM+wYRR03 H9Uuv8CjGnw6Q3EYAHabVUT0fA== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180105_091018_935392_C6003BC1 X-CRM114-Status: UNSURE ( 9.68 ) 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/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,