From patchwork Mon Jan 1 19:07:30 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: 10139245 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 719B26035E for ; Mon, 1 Jan 2018 19:09:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63B0F286AB for ; Mon, 1 Jan 2018 19:09:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57D7E28797; Mon, 1 Jan 2018 19:09:40 +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 43427286AB for ; Mon, 1 Jan 2018 19:09:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752771AbeAATJh (ORCPT ); Mon, 1 Jan 2018 14:09:37 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33086 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752562AbeAATII (ORCPT ); Mon, 1 Jan 2018 14:08:08 -0500 Received: by mail-wm0-f66.google.com with SMTP id g130so13948128wme.0 for ; Mon, 01 Jan 2018 11:08:08 -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=ZgQZkk8fMlsZMgCkhDM0Go1uRnU2cDsvjdDVgG4N3jI=; b=J082i3d/qdPx5kFtStNLy6133rYu26DocIUCg+MXWmjOc74kLKWJtHY+8f2697kSyV zGYirAJU5lKoA+FFl4JrcRK4tnQok6QsSDzeu5VLL8ecaMl674WNlKqmeJ+hyuQC5Yvs HE0tgR19GFayYrqFTnL4GeEaai0zi+js2lVBcswBecfdEmEE4Gf/Ailjw5bH0TeXl/L2 6wzFesVSerybQ12bgFjz3iJik0/55JWcsKtQ5CE4bUAp5ah/BqwzSkgvu8irzC+y0OrC TRYlzg9jbjU6G9qGINGuzTjBLgDaa90H/nNjIj92xKJjwx/U8dDObuQSqI976ZwRVqf8 lCxw== 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=ZgQZkk8fMlsZMgCkhDM0Go1uRnU2cDsvjdDVgG4N3jI=; b=ku4MwY7mORwj/X/B8j1zaaj29gpPnwbTb0wy3VZ/SSiry6/+BqrHvOKCWV2DVXDjOz YnKyXugQDIJDynzp/HNhQQlIpf38cgq4paV3uSuT2FrPtE8o3Aj0xhQJAjjmrAnmUnzF 4lcHR0ljmZHVfYlbCAdoM06cBhMyeQd+VixMdNtuMORXq/wkYjNWDuk/q6IVCpjoikf/ GFRaKzymBIpmu1WnsfHDvnk2VRJLn7wdhv37qwWdnOwVI0eLLr/+PYI+UAi/ebjjywfN F16INtFjAJPeFlfLLUE9Lopoa4rh3NX0LzDCzDo3pHDGi6O5IPhZEm+QFmzCHVYDfp7F 45/w== X-Gm-Message-State: AKGB3mJAnuvBEk1LZgdmyPQlPsO3tttKD7j7CMA+czp/NCyBYwHVADeX CNCMPwUCdnmeVx+qZw7PaKMsqQ== X-Google-Smtp-Source: ACJfBosH78YV9FyKRXdhfGSjR2W8gpSJz3nAFK2NHvXVAzspOi63wcMgHVdOQMJGL2XBOV2cQuVYZg== X-Received: by 10.80.212.158 with SMTP id s30mr59526080edi.286.1514833687834; Mon, 01 Jan 2018 11:08:07 -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.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jan 2018 11:08:06 -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 03/34] clk: composite: allow round_rate to scale past LONG_MAX on 32 bit systems Date: Mon, 1 Jan 2018 19:07:30 +0000 Message-Id: <1514833681-30737-4-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 Defining the return value of round_rate as a long and returning error codes as well as the rounded-clock value in the return value of a clk_ops->round_rate callback means that its not possible to return a clock greater than LONG_MAX Hz on a 32 bit system. This patch changes the handling of the return value from round_rate() such that zero indicates an unusable clock and non-zero indicates a successfully rounded clock giving us a full range of 1 Hz to ULONG_MAX Hz on 32 bit systems. Implementations of round_rate() must either return a rounded-clock or zero to indicate error. 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-composite.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c index f3707c3..2090b74 100644 --- a/drivers/clk/clk-composite.c +++ b/drivers/clk/clk-composite.c @@ -66,7 +66,7 @@ static int clk_composite_determine_rate(struct clk_hw *hw, long tmp_rate, best_rate = 0; unsigned long rate_diff; unsigned long best_rate_diff = ULONG_MAX; - long rate; + unsigned long rate; int i; if (rate_hw && rate_ops && rate_ops->determine_rate) { @@ -83,8 +83,8 @@ static int clk_composite_determine_rate(struct clk_hw *hw, rate = rate_ops->round_rate(rate_hw, req->rate, &req->best_parent_rate); - if (rate < 0) - return rate; + if (!rate) + return -EINVAL; req->rate = rate; return 0; @@ -99,7 +99,7 @@ static int clk_composite_determine_rate(struct clk_hw *hw, tmp_rate = rate_ops->round_rate(rate_hw, req->rate, &parent_rate); - if (tmp_rate < 0) + if (tmp_rate == 0) continue; rate_diff = abs(req->rate - tmp_rate);