Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753922AbeAAToF (ORCPT + 1 other); Mon, 1 Jan 2018 14:44:05 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:46554 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932234AbeAATnu (ORCPT ); Mon, 1 Jan 2018 14:43:50 -0500 X-Google-Smtp-Source: ACJfBotL6WGzLtLowMA9L3chMFb/ouUw+RcmR5diDiGGDoqdOhbta9AGrETRHjCw2CLtcR7T7hBpow== 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 v3 34/34] clk: change handling of round_rate() such that only zero is an error Date: Mon, 1 Jan 2018 19:43:13 +0000 Message-Id: <1514835793-1104-35-git-send-email-pure.logic@nexus-software.ie> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514835793-1104-1-git-send-email-pure.logic@nexus-software.ie> References: <1514835793-1104-1-git-send-email-pure.logic@nexus-software.ie> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Change the handling of clk_ops->round_rate() return values such that only zero is treated as an error. All implementations of clk_ops->round_rate() will have previously been updated to match this change. Using zero as the determinant for an error means its possible to pass an unsigned long as req->rate to a clk_ops->round_rate() function and return a rounded clock which is as high as the original req->rate. This allows us on 32 bit systems to return rounded rates of (2^32)-1 Hz or ULONG_MAX Hz - whereas without this change and the associated clk_ops->round_rate() change the maximum value that can be returned via clk_ops->round_rate() is LONG_MAX Hz - after which a higher-frequency clock looks like a negative error code - due to sign extension. 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.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 8a1860a..6af2ece 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -909,7 +909,6 @@ static int clk_core_round_rate_nolock(struct clk_core *core, struct clk_rate_request *req) { struct clk_core *parent; - long rate; lockdep_assert_held(&prepare_lock); @@ -928,12 +927,8 @@ static int clk_core_round_rate_nolock(struct clk_core *core, if (core->ops->determine_rate) { return core->ops->determine_rate(core->hw, req); } else if (core->ops->round_rate) { - rate = core->ops->round_rate(core->hw, req->rate, + req->rate = core->ops->round_rate(core->hw, req->rate, &req->best_parent_rate); - if (rate < 0) - return rate; - - req->rate = rate; } else if (core->flags & CLK_SET_RATE_PARENT) { return clk_core_round_rate_nolock(parent, req); } else { @@ -1454,12 +1449,8 @@ static struct clk_core *clk_calc_new_rates(struct clk_core *core, new_rate = req.rate; parent = req.best_parent_hw ? req.best_parent_hw->core : NULL; } else if (core->ops->round_rate) { - ret = core->ops->round_rate(core->hw, rate, - &best_parent_rate); - if (ret < 0) - return NULL; - - new_rate = ret; + new_rate = core->ops->round_rate(core->hw, rate, + &best_parent_rate); if (new_rate < min_rate || new_rate > max_rate) return NULL; } else if (!parent || !(core->flags & CLK_SET_RATE_PARENT)) { -- 2.7.4