From patchwork Sat Dec 30 01:12:42 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: 10137573 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 11CF26037D for ; Sat, 30 Dec 2017 01:19:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04F362B551 for ; Sat, 30 Dec 2017 01:19:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE0AB2B55D; Sat, 30 Dec 2017 01:19:06 +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 5C6012B551 for ; Sat, 30 Dec 2017 01:19:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751029AbdL3BNY (ORCPT ); Fri, 29 Dec 2017 20:13:24 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:45490 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750924AbdL3BNR (ORCPT ); Fri, 29 Dec 2017 20:13:17 -0500 Received: by mail-wm0-f68.google.com with SMTP id 9so50432270wme.4 for ; Fri, 29 Dec 2017 17:13:16 -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=0wqDADc1Ejd0EVUC5UThDzyu1gTsxbIMNm+mXrKx+4AMgWb62LowZOPeUmgQ/V8kua Ard3EpSSmUwGELjDwADQ8s7JF1gH+S9eu5nFm+zYaOQqquSKYNye8ZxPclrccGpiBpD6 FSweJ66FE10f/VvKQxWeGgm9IcBdVmw554eouArm++ISW4tYvfzVNZFH3j4xLwI6U5+t sLJUJy99AAN3y2s0B5XLb9AS66oIhEtm+4b9+YYD0c7C5ciuEFxMBKCY74wTl8P7KXev hHPITXfWPa+2YKs00l3yIQFV1f34t4WpEOLSkfRVMAQ2cEyVrntO8p4YXJGYpM1dbmCl rVXg== 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=k71XnvP+tCJNRZYgOyTUyJzm3kcw7gR4nNhCKc0YaxOXUPS+JBHas+/iLItZ9gSXSw ohnx74NGRArVkJ7eOk6ocYpcy+KzSDBL68J75uL8NKXlhpQhK1xj7E3UqhyQ4zuPPk0R dSt1STaIsqT1MsULzIWgDdXNPIwoayh6ixqtzrBr+2m71IgdWlPvNTNV/AUq47eo4+u8 d6JWsLlo7S2fWAXfYdZwt5BU4VewBjVlwuYJoa4VX/KUUT/xxm6zr5cplOcrwOErBPCo l1HR5pfPehzSDFS6WQcntSmZqR0Tgh4NwpvaWTKjK3cWBvLHH2XeLClVEkJ1W5W68SIB yTcg== X-Gm-Message-State: AKGB3mJ/aAqHGRVHwLIH/1tOT8dyfKjWmDEfRIxuiMPd0AijArv1wx82 rFHJyxBUb4EG1zUQP029pbWD0g== X-Google-Smtp-Source: ACJfBov4KwNoVbaz0/lwBhWeRFp+b//pYIbk1yG8c/kxWMcqBQ+S38VVQXM0TEtI554Z/7cC6c709w== X-Received: by 10.80.186.97 with SMTP id 30mr47381303eds.275.1514596395965; Fri, 29 Dec 2017 17:13:15 -0800 (PST) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id h4sm29818268edb.16.2017.12.29.17.13.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Dec 2017 17:13:15 -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 03/33] clk: composite: allow round_rate to scale past LONG_MAX on 32 bit systems Date: Sat, 30 Dec 2017 01:12:42 +0000 Message-Id: <1514596392-22270-4-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 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);