From patchwork Mon Jan 1 19:42:42 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: 10139535 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 259A2601A1 for ; Mon, 1 Jan 2018 19:51:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16C4328701 for ; Mon, 1 Jan 2018 19:51:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0AC0428706; Mon, 1 Jan 2018 19:51:13 +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 97AA128701 for ; Mon, 1 Jan 2018 19:51:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751575AbeAATvL (ORCPT ); Mon, 1 Jan 2018 14:51:11 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34108 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752821AbeAATnV (ORCPT ); Mon, 1 Jan 2018 14:43:21 -0500 Received: by mail-wm0-f66.google.com with SMTP id y82so13974757wmg.1 for ; Mon, 01 Jan 2018 11:43:20 -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=Ymh91Crh0tbJ1LpwPqDBGzvIqc/HGYl7tsejvkPjtaWgnygUcXYiaN8dBYmuejvwES XZ5VtmPQPJNAwsq5tatiwQdvfK8cmT5GPpNC/yV1jmgj+1Nl7Wk7r0QApCQaXOEIslIg QbIC40RFgGn6JdEU9eEOE9721GNoTZjttB94knXGtDMd45iDDC3DaoP7i6QT+B7nmyTd f5li1Lc8i7rP0u7CQLq7a3sUp/S8TyESF9xr7dTEvw+1aa8w35pYcKYcSKn2AIj7nxL/ AAqKybR2emPX2CpCkqhpehPxYRl+71PX6Y8MuTarNQUldpysLMCnHItIJKg/pnQxHABB +sCw== 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=UQI5jeMlRn8QfYAKmSfOeWjbxN0F9Lj1QA94cFX2vv6Mm7GVjjZQS7dNouziXeNZd8 FLGQ8Do/OHNN92AFivOLHYKlfhzelBHRu+SICHm3hg1UNKwl4NeW/FQXAK9CSDY0ytNt 172Z+hNAQM1MSC1inMYDVCAkmvpFQvEnxv1AVezF9OI7L8+i8Z2GemXUf8uqfaZo2UrO oM9aTyUeCOzePZZlMtDYLjoWLPCOv/p2cBdhHMWgBapcA7mHueJwuSSYSJqZQwAgpkoW qvEAogH6Q9eOjjsDjZCXxWSSr0R5L+yydWFkbbHELzvjv7h9VOZ4wuhQs7fD87tq0n07 91gQ== X-Gm-Message-State: AKGB3mI+WKcmfgAILrFNPgDGj15K6241a1ZR2FtdNe+ZdZQQIBQuRnRX Fo+AfxOS0t0cgD71nzSf+4sGYg== X-Google-Smtp-Source: ACJfBosd6KBDM895GpftFB9u80bKD/loJdYbLMNKLJOqRHXBb86I81hub54zvj2hl/LEXovgRVY9xQ== X-Received: by 10.80.204.7 with SMTP id m7mr58080044edi.73.1514835800308; Mon, 01 Jan 2018 11:43:20 -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.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jan 2018 11:43:19 -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 03/34] clk: composite: allow round_rate to scale past LONG_MAX on 32 bit systems Date: Mon, 1 Jan 2018 19:42:42 +0000 Message-Id: <1514835793-1104-4-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 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);