From patchwork Sat Dec 30 01:13:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 10137471 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 C06CF6037D for ; Sat, 30 Dec 2017 01:14:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B06712D23A for ; Sat, 30 Dec 2017 01:14:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A30AE2D245; Sat, 30 Dec 2017 01:14:39 +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 4A6372D23A for ; Sat, 30 Dec 2017 01:14:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751305AbdL3BNq (ORCPT ); Fri, 29 Dec 2017 20:13:46 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34544 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751087AbdL3BNp (ORCPT ); Fri, 29 Dec 2017 20:13:45 -0500 Received: by mail-wm0-f68.google.com with SMTP id y82so6993928wmg.1 for ; Fri, 29 Dec 2017 17:13:44 -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=iO2PHmCt/WA6hfJ0SBW+DRgKvcbmtp94L+Q9RWmt9wTNcz+yN76o7Kxh/+dS38VBZ0 VTXh2K2o0Ifv+zsxPEB+DypreuND6C8jo+R2PDfxOPJmLLL+dk6SstxyYq/PudCmXYv/ UivsPXdfkUP5Zlsro8DaXX/pxff/laZ+Euw0estLzNm/AToR7OrKyxNaGZ8/FNo8qjWe Y4C/VJepSMPZiBqcbmsZr+HPm+fgL6bbkDPa1oPk8uZl31AU+W9p5L3PKrPjSWlyxpb8 a4/q+B6Ghy9f2NilGrvGdw0uJp5cqDp0Q/e+CIxBMaCsCFtaDe0seFvNpB5Ar7y/dxtl G3BQ== 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=DeHddJJFtdOnrRYR7AI06M8QdzQ01WgAF56Zg6CuGitmqYxl3WBPuqu4JjvzplXWf5 76Wj6N204vqYIMq30txRzpUwU/yBCsk2MInvSmOYT2TznU7dOq4KBMMBEI4ddOzrrQY4 vaZt25Pyn0RhBon5t/X8ofSLCRRqKYir9JxiYRqq4/uZwpVZj3ijM2oLWtUkG7A1pz42 Qd5BI+eK6WwlTdSWNBfcBXraIhYLZAS56cjCiq+qbUrfkzN9Rca9+0u+j4tAvf2YVG8y gv352v/WFao/YtGHxIjthTOesmcsQ4PYoryPy5uFGm4a/kvHNOV4SMVcetffZdO30aES 4Jew== X-Gm-Message-State: AKGB3mIRbPYOcNoMrFlM75anVcLKU5Fbvh8mpXihUlqwgmEcQmSGQAy2 85jy+dYArdOyvyw6IQE44VIO1Q== X-Google-Smtp-Source: ACJfBosEPbYjT6oUR3bWXCt5MVmBx/fyAJnh6ZSwytUnOZC76m7C9v2mwbfSEkkOb9Vy5RlBeeqDfA== X-Received: by 10.80.216.141 with SMTP id p13mr47564183edj.24.1514596424246; Fri, 29 Dec 2017 17:13:44 -0800 (PST) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id h4sm29818268edb.16.2017.12.29.17.13.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Dec 2017 17:13:43 -0800 (PST) From: Bryan O'Donoghue To: mturquette@baylibre.com, sboyd@codeaurora.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org Cc: pure.logic@nexus-software.ie Subject: [PATCH 33/33] clk: change handling of round_rate() such that only zero is an error Date: Sat, 30 Dec 2017 01:13:12 +0000 Message-Id: <1514596392-22270-34-git-send-email-pure.logic@nexus-software.ie> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514596392-22270-1-git-send-email-pure.logic@nexus-software.ie> References: <1514596392-22270-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)) {