From patchwork Mon Jan 1 19:07:33 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: 10139267 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 C15386035E for ; Mon, 1 Jan 2018 19:10:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3CFD285C5 for ; Mon, 1 Jan 2018 19:10:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7B6C285D2; Mon, 1 Jan 2018 19:10:32 +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 5361F285C5 for ; Mon, 1 Jan 2018 19:10:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752573AbeAATJe (ORCPT ); Mon, 1 Jan 2018 14:09:34 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36570 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752572AbeAATIM (ORCPT ); Mon, 1 Jan 2018 14:08:12 -0500 Received: by mail-wm0-f66.google.com with SMTP id b76so58169530wmg.1 for ; Mon, 01 Jan 2018 11:08:12 -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=vfT3c0CQ3OuIO2+UqaI9pEwSVGMAlOMAx7ZOdaN3MlE=; b=L+wIa2aoM+Ra3ZeMQpdsA8O42XV+ESUd01yuyyfuKQK+DDM/mxBSqrtsZzuS5H7/Hy bwV3SUokVWwAgfuW9lEKieROtSAY4p8VLzD1YjTGsZji91OVs48eB58IIC4DZmdVkMbI ZHvrWN9COUiC7SJUAEjy0bcJ+4ZCvgol6CQVBJXsmcgMZwyQSWn2TtLBi/s8tDIeno86 TcZn8D8pKahX/P1bP1Eat3hmkxIyj8utU30CatfIApfsHPEV7JforyUeM/fS8h3cAfzj jAseD3tP4pIVtbm4zj9smO0OEHPUx4B6pX3HjWP99hVQlpOLCGsL6UzGpqR8iOU9MQ/v flYg== 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=vfT3c0CQ3OuIO2+UqaI9pEwSVGMAlOMAx7ZOdaN3MlE=; b=TKv5WyRPOO7iUyJr765xnNqi39Ud9/1nhecfYI+CrXQbJBEBWnkdy7CGXJVlwCSzaq udhW/Fo8uN67MgWwOXJyEdfnYG4SlO/rkM1m+2r/hGqTN4fOFmiK1XK2KfAnQN6Ir/zL dqK5Bzjr9rXqPeY8WqyndTHu7HKzp1DVT5jjX7nfmDP4bLJYX/+j5191XVz71XiV72r7 /rRSWsr2j9ybztdXIFv4XPqrVJgTzAsf0gGaSlM6iAdwUq9BqirMJZRMnBjS8RQQlGc5 mZJkJPlsVaSeIydKl1U/27kYxKxVllxCSXo8F2CIEMLVVrBF3dB+pkIle5BNRUBpThLL BHIA== X-Gm-Message-State: AKGB3mKy6Q7rP3c9Hv38O1Uy712wYv1GUps9AZ8Qiund/f9LL8xc9daz awcstK66ZxlCSvxD5un9NBBjLQ== X-Google-Smtp-Source: ACJfBotqcluu2KSTbhJ0IKAwkcrKHCRG1qewtcWbD2AiWCSorAapgsBRPFRZsCfthh5UXunnUsDjSw== X-Received: by 10.80.178.35 with SMTP id o32mr49959939edd.293.1514833691469; Mon, 01 Jan 2018 11:08:11 -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.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jan 2018 11:08:10 -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 , Boris Brezillon Subject: [PATCH v2 06/34] clk: at91: change clk_pll_get_best_div_mul() return logic Date: Mon, 1 Jan 2018 19:07:33 +0000 Message-Id: <1514833681-30737-7-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 This patch updates the round_rate() logic here to return zero instead of a negative number on error. In conjunction with higher-level changes associated with acting on the return value of clk_ops->round_rate() it is then possible to have clk_ops->round_rate() return values from 1 Hz to ULONG_MAX Hz instead of the current limitation of 1 Hz to LONG_MAX Hz. Signed-off-by: Bryan O'Donoghue Cc: Boris Brezillon Cc: Michael Turquette Cc: Stephen Boyd Cc: linux-clk@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/clk/at91/clk-pll.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/clk/at91/clk-pll.c b/drivers/clk/at91/clk-pll.c index 630203e..1c90ae7 100644 --- a/drivers/clk/at91/clk-pll.c +++ b/drivers/clk/at91/clk-pll.c @@ -157,14 +157,14 @@ static unsigned long clk_pll_get_best_div_mul(struct clk_pll *pll, pll->characteristics; unsigned long bestremainder = ULONG_MAX; unsigned long maxdiv, mindiv, tmpdiv; - long bestrate = -ERANGE; + unsigned long bestrate = 0; unsigned long bestdiv; unsigned long bestmul; int i = 0; /* Check if parent_rate is a valid input rate */ if (parent_rate < characteristics->input.min) - return -ERANGE; + return 0; /* * Calculate minimum divider based on the minimum multiplier, the @@ -179,7 +179,7 @@ static unsigned long clk_pll_get_best_div_mul(struct clk_pll *pll, if (parent_rate > characteristics->input.max) { tmpdiv = DIV_ROUND_UP(parent_rate, characteristics->input.max); if (tmpdiv > PLL_DIV_MAX) - return -ERANGE; + return 0; if (tmpdiv > mindiv) mindiv = tmpdiv; @@ -234,8 +234,8 @@ static unsigned long clk_pll_get_best_div_mul(struct clk_pll *pll, break; } - /* We haven't found any multiplier/divider pair => return -ERANGE */ - if (bestrate < 0) + /* We haven't found any multiplier/divider pair => return 0 */ + if (bestrate == 0) return bestrate; /* Check if bestrate is a valid output rate */ @@ -246,7 +246,7 @@ static unsigned long clk_pll_get_best_div_mul(struct clk_pll *pll, } if (i >= characteristics->num_output) - return -ERANGE; + return 0; if (div) *div = bestdiv; @@ -271,15 +271,15 @@ static int clk_pll_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) { struct clk_pll *pll = to_clk_pll(hw); - long ret; + unsigned long ret; u32 div; u32 mul; u32 index; ret = clk_pll_get_best_div_mul(pll, rate, parent_rate, &div, &mul, &index); - if (ret < 0) - return ret; + if (ret == 0) + return -ERANGE; pll->range = index; pll->div = div;