From patchwork Mon Jan 1 19:35:00 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: 10139301 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 7946560596 for ; Mon, 1 Jan 2018 19:35:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 539392674B for ; Mon, 1 Jan 2018 19:35:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4877426E49; Mon, 1 Jan 2018 19:35:31 +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 DE8642674B for ; Mon, 1 Jan 2018 19:35:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753087AbeAATf2 (ORCPT ); Mon, 1 Jan 2018 14:35:28 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:33009 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753198AbeAATfW (ORCPT ); Mon, 1 Jan 2018 14:35:22 -0500 Received: by mail-wm0-f67.google.com with SMTP id g130so14001940wme.0 for ; Mon, 01 Jan 2018 11:35:21 -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=E20txSFxuNwmLuWOZXyqs/8OrYT4AXVjmBx4Oj4BVRCniN55qJaxr7jIERaL2RXKeI TR1wPrBAxY648qLuSz8LMa1GKz39Gf3roN80u2sGvZDqYhAau1JpzXEY/uE37p0fmKSq khIXFQOsKCJ25gmlkKJ+xXFgHWIHqkMuog1CGjMdBmytZaCxRWxMOapacvsXQb8p6XYh XyZoLxM7vj3u3aebkZYwUH0hwWx6/uZK5t1nSxJQEkjCdEVd4DUp7/7F7TfZGy9P1daD 9vtBLH3bm9UfEzJTvPuGDLOKhlatWUUqrqVddRCrdtlqIuSa9JYOpqA8OERP38m0cER+ BJyg== 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=pd4K57caz3ACXizmgePNYADxdlcxHZkcVYaCzl41yE4hQkNSJuuzred6mVykHb12zw vf9dVYVUErbvyE8hlZgIsrNrVSng/b7GNqhTUeBXlBjbAzVnVvjglwOc0ixYutxbZwoo l0F7aDiKuyhTDPvrBNe8xv7oM9VweVT3kmpzToXvJFqlpuqdLJsvbtTdV+jmYuIeXnrm TU6occNzu0LHjfa149mMXlokNSmSG1GTaJQ18iRsMe48XnoftB8Zzpeqdp6Abb1T8b6h MwOGiUelshtGy/eNkVYMLnwkJLKM4Vd0hv0Xldk+Mlo+CZtkp4hPcNbOiOrWuwEnIUzj j8ZA== X-Gm-Message-State: AKGB3mJQowfcC9L3lermzdmcTu3mrbUa2QhpY8PxCF4WAYCej+6wkKJt hFfVoQjecGZVOORt9kMrrpBQ4EmO25M= X-Google-Smtp-Source: ACJfBosoHQCGcILGYOGl6dT8GV5ivob7HRpAlwsCtLWv4XmWCIOyuRk44PTjt+03V/u5u0/MW+KhCA== X-Received: by 10.80.202.200 with SMTP id f8mr58134409edi.54.1514835320880; Mon, 01 Jan 2018 11:35:20 -0800 (PST) Received: from localhost.localdomain (D4CCACC7.cm-2.dynamic.ziggo.nl. [212.204.172.199]) by smtp.gmail.com with ESMTPSA id r8sm29086992edm.22.2018.01.01.11.35.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jan 2018 11:35:20 -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 34/34] clk: change handling of round_rate() such that only zero is an error Date: Mon, 1 Jan 2018 19:35:00 +0000 Message-Id: <1514835300-381-20-git-send-email-pure.logic@nexus-software.ie> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514835300-381-1-git-send-email-pure.logic@nexus-software.ie> References: <1514835300-381-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)) {