From patchwork Mon Jan 1 19:07:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 10139249 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 7794060596 for ; Mon, 1 Jan 2018 19:09:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6ABC7286AB for ; Mon, 1 Jan 2018 19:09:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F96A28765; Mon, 1 Jan 2018 19:09:41 +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 7F4B12875C for ; Mon, 1 Jan 2018 19:09:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752562AbeAATJi (ORCPT ); Mon, 1 Jan 2018 14:09:38 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35060 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752549AbeAATIH (ORCPT ); Mon, 1 Jan 2018 14:08:07 -0500 Received: by mail-wm0-f66.google.com with SMTP id a79so19001139wma.0 for ; Mon, 01 Jan 2018 11:08:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexus-software-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=quYEV7WVBM557n8sBg+B64GNpgz2/9llWnkNitw5Who=; b=DRHXP7SPtH5ZxkzHa5oAAK8JqlMFQ4kaMy4H4qM9m2WzAS9bIIyVwXZauXZDOhiV/e N1me7pBmcnqhUzjgEDkFGrgrJBP3lUJyYOivX7ymaDfWbky9IZlb5yITjlHyT1FAXVZs W4ED1rLbAMaMBofAsP2xmmetbnFnkYIzC5SqYt1wZTAyyD+QJyX4jB/MBJZkjcxZyoQW Q9FWBhFfg3NctBl6qhJiuji7i6fi2sxfy2gA+A2T6Fk8pBSGiJTxrH0b8GFXuEOB8XzJ IkgTgK15rt4c6gNtq1g4bPAYK5d+NksDtwfR1XA7MGBPFjvoxUHxyVxQGlxdPsWboQGP NFbw== 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=quYEV7WVBM557n8sBg+B64GNpgz2/9llWnkNitw5Who=; b=Wt0wA6k5unoGPSRQFVSpc1eZITQLRA71gHu69bmSe3ACu5eoGx1Fm2t8NPrKdcAEuW 60IcbX/FKVd2n3na0k5pJyIXU1mdZfJ/XYMtrXCyBj4WfezsLcxQT0W+p8Ey3tU7qfHR SwWPqR4/pwsJC2izzXKmXxRjZr3ChYuWWxUHSPAINz1pXt5uDr/GrJfSlNpTcta1cANB 5f9WpXc3TVbcXQQCUmvh5uTekMgabZ4VmCR43pGplaeFlUU6SRbUiAWNe+Ga9K+zmA8N 1DwsXRDlVjNDul+M42mEJ8EndBWAqkc4WeO4wnXlMPPaS8B1h7EVwKB1yYcue4HofwFU eQrA== X-Gm-Message-State: AKGB3mIR1RSuf+WQBKy/kRXlqj+qNVV/Kggmxq49njPAkT6G6wjX6062 Smw/yGgsW6rEglRwi288DVU74t1h X-Google-Smtp-Source: ACJfBouJG/9TaLeuyRuJ1w/euzbx4AXjpClYC/sJNKKQE5Wk6by+sNjJohJTVD8NtDm6/ECNqR/6rg== X-Received: by 10.80.153.125 with SMTP id l58mr59011287edb.183.1514833686518; Mon, 01 Jan 2018 11:08:06 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id v15sm33236633edb.41.2018.01.01.11.08.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jan 2018 11:08:05 -0800 (PST) From: Bryan O'Donoghue To: mturquette@baylibre.com, sboyd@codeaurora.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org Cc: Bryan O'Donoghue Subject: [PATCH v2 02/34] clk: core: update divider_round_rate functions to return unsigned long Date: Mon, 1 Jan 2018 19:07:29 +0000 Message-Id: <1514833681-30737-3-git-send-email-pure.logic@nexus-software.ie> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514833681-30737-1-git-send-email-pure.logic@nexus-software.ie> References: <1514833681-30737-1-git-send-email-pure.logic@nexus-software.ie> 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 Returning a long from round_rate() class functions is rooted in the notion that we will propagate a negative number on some class of failure to round a clock rate; however this approach does not scale to 32 bit systems which legitimately round a clock over LONG_MAX as the returned clock rate is indistinguishable from an error number. A better approach is to return zero when we cannot round a clock and non-zero when we can - thus supporting the full range of the unsigned long rate input value to round_rate() functions. Update the signature of divider_round_rate functions to do this now. Signed-off-by: Bryan O'Donoghue Cc: Michael Turquette Cc: Stephen Boyd Cc: linux-clk@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/clk/clk-divider.c | 10 ++++++---- include/linux/clk-provider.h | 19 +++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c index a26ec7c..e827304 100644 --- a/drivers/clk/clk-divider.c +++ b/drivers/clk/clk-divider.c @@ -332,10 +332,12 @@ static int clk_divider_bestdiv(struct clk_hw *hw, struct clk_hw *parent, return bestdiv; } -long divider_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent, - unsigned long rate, unsigned long *prate, - const struct clk_div_table *table, - u8 width, unsigned long flags) +unsigned long divider_round_rate_parent(struct clk_hw *hw, + struct clk_hw *parent, + unsigned long rate, + unsigned long *prate, + const struct clk_div_table *table, + u8 width, unsigned long flags) { int div; diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 79b1d6e..e763d94 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -413,10 +413,12 @@ extern const struct clk_ops clk_divider_ro_ops; unsigned long divider_recalc_rate(struct clk_hw *hw, unsigned long parent_rate, unsigned int val, const struct clk_div_table *table, unsigned long flags); -long divider_round_rate_parent(struct clk_hw *hw, struct clk_hw *parent, - unsigned long rate, unsigned long *prate, - const struct clk_div_table *table, - u8 width, unsigned long flags); +unsigned long divider_round_rate_parent(struct clk_hw *hw, + struct clk_hw *parent, + unsigned long rate, + unsigned long *prate, + const struct clk_div_table *table, + u8 width, unsigned long flags); int divider_get_val(unsigned long rate, unsigned long parent_rate, const struct clk_div_table *table, u8 width, unsigned long flags); @@ -762,10 +764,11 @@ static inline void __clk_hw_set_clk(struct clk_hw *dst, struct clk_hw *src) dst->core = src->core; } -static inline long divider_round_rate(struct clk_hw *hw, unsigned long rate, - unsigned long *prate, - const struct clk_div_table *table, - u8 width, unsigned long flags) +static inline unsigned long divider_round_rate(struct clk_hw *hw, + unsigned long rate, + unsigned long *prate, + const struct clk_div_table *table, + u8 width, unsigned long flags) { return divider_round_rate_parent(hw, clk_hw_get_parent(hw), rate, prate, table, width, flags);