From patchwork Mon Jan 1 19:43:13 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: 10139403 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 A0DEF60362 for ; Mon, 1 Jan 2018 19:44:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92CAD28649 for ; Mon, 1 Jan 2018 19:44:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87164286B7; Mon, 1 Jan 2018 19:44:18 +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=unavailable 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 15FED28649 for ; Mon, 1 Jan 2018 19:44:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753905AbeAAToF (ORCPT ); Mon, 1 Jan 2018 14:44:05 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:44151 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932232AbeAATnu (ORCPT ); Mon, 1 Jan 2018 14:43:50 -0500 Received: by mail-wm0-f66.google.com with SMTP id t8so58263588wmc.3 for ; Mon, 01 Jan 2018 11:43:49 -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=znCjTq0O6SlC0UnpZlIkn9udFjoYXDRq80g0vtAT4Tc=; b=P1KIqhywrGKmQEyszeHVx7Q7ZlAU/TZ4lVSmJnay0K7WM94axcS5GMpmlwY35Xi+u0 SbH6FD8ceRj/Hpvna8d0WUz7FQBAvJ//ApbXH/dzYI4flEWn61eGaJ0cBj4ogNz4/uGg CoGjbVk606nVkPYP57kBoyvdJOV0UWm/DRVNNOOqqqbk4eRiBD3E4qz/EQqUNgTq0Yrb 05+ln6XWbKRItAxPKtmcIz+IWefVAzZcnNytiktS4eSu90PCi3pzxCz0k1htj1RaUZXE X7zdVkcHwZ1krtGkeFe4s8gQ87waCVyAUfDcnNyc97WlltZHw/T6PkEOS/Nl8ZPZJWQb pS+A== 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=znCjTq0O6SlC0UnpZlIkn9udFjoYXDRq80g0vtAT4Tc=; b=WkdRVgKYDbIdSjNBcfnU8lGpH9WS9ZZaVr2KQazwGef4kXy+hGnSsppYFB1f0Fncet 6IhxTUTUv6aeraGgGp55/TO+GmNBgXETzbbKU/ptSiowIQJHFn+b9Vde2biwzymldSvZ NdeMDPaJ6svmDIAoo5IFtk2ZuTPu2khaXje6LgRV+IhcVo8IoG1ux2Gfcid0mXGx1jVz 3rvMbY5wr9+kbDe/FtTux8XOsWooVVocdT+k+qt2xXnHD//PUbmSODR6UHc+KTGDI9tb 07deakJJdG48zQBhEPD1VkWmvqv47/pXx/d60odF8wgXYnQ7prA0X6emIwdxeb4kTZef wGZw== X-Gm-Message-State: AKGB3mI58piFYDXwtB/HTdxk4V7jQH9T9rTrtYfuIc0Ho+XTcp/1jWWV AM2CYc6CM4AXayvA56v3qFgUHOzw X-Google-Smtp-Source: ACJfBotL6WGzLtLowMA9L3chMFb/ouUw+RcmR5diDiGGDoqdOhbta9AGrETRHjCw2CLtcR7T7hBpow== X-Received: by 10.80.215.89 with SMTP id i25mr60244321edj.274.1514835829115; Mon, 01 Jan 2018 11:43:49 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id w2sm39361075edb.4.2018.01.01.11.43.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jan 2018 11:43:48 -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 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-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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)) {