Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1723762rwd; Tue, 13 Jun 2023 13:13:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6aJtVKB+fZYjrOEeq05kEjKk7wU7IzXeyvp8ATqv5BrPLgKZsBnDRgT4m51xsJGHJWargm X-Received: by 2002:a17:906:5d09:b0:978:af9d:c004 with SMTP id g9-20020a1709065d0900b00978af9dc004mr12556698ejt.4.1686687202207; Tue, 13 Jun 2023 13:13:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686687202; cv=none; d=google.com; s=arc-20160816; b=nBlLzUmJ7iXFF67LrqA8E0JAA4b6viSdKeXRkN98KJhvTTNIy09bYJMpNqBOmagnvE Bw78G2HZND2kFhKbrysIZaOqZLP8hsGVqUSF9Wp2898iwu0nrIbnoGw6KM28NPo6pnWR guE/XzSjFBDQQMuiSsY5pl/HkiTRJenZEcokhW6DcGccclMOEKNXqOLbLkO/dh1nBVzw MNuHoXZXDLO92xzpm+nsLJvQrz4K102hz3PneXOY+/1F9KqMpzkHgxHaWhU7dKXpPrBU 8dz+vD00kl2vqhVPfse9DW3VdZdMa2+Zpv2sOl3YwZcmb2an3NcvTvuyk/8emKaTca1n RyGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=xvbDQ2+GwwiYdKL8ghJi7W0JA/DVyE4DjHj8Fj72HF0=; b=OVrVV8lOB7uloaOl04Z+JJ5UogTtiibn8SZcRmwFtG+rHDn1U6NGr00sIWUXCXnP99 5cEYqY8t2ikX+9KWkyhoP2ZPR9hqqy8e3PeCY1m1D/I6KVtZXQJYkpHnbSlP4EH24x6r HLXo6vww+SLP5akhDEXyhqJ8/BiIMajxF71pJaW99nn+fpD3leQMViYbuYFbYGGGIK/u HDpgNdFQKRZVawmyjTVKw6+NWBGEZc6bn4bjG7/BAvtI0jtCrbeWADOkeWKsnksmpuO2 5rlY5XoZEMmHAEvg2ZtqEEPLRLNh0D0RQBh9s2thABTUHMw6DKs4ndFZfyJ7yohIMlp9 CRCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="l5Rn/F83"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p8-20020a170906838800b00965bc999a84si7480280ejx.872.2023.06.13.13.12.56; Tue, 13 Jun 2023 13:13:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="l5Rn/F83"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239077AbjFMTzO (ORCPT + 99 others); Tue, 13 Jun 2023 15:55:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbjFMTyr (ORCPT ); Tue, 13 Jun 2023 15:54:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44F50170E; Tue, 13 Jun 2023 12:54:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CE82261800; Tue, 13 Jun 2023 19:54:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 070A1C433F0; Tue, 13 Jun 2023 19:54:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686686084; bh=01Gy2b0SAp8++a2vjuQkj4/e/l8budPgWfPPBbejKNM=; h=From:To:Cc:Subject:Date:From; b=l5Rn/F83C70fysAwoHA+9nJdR8eCqM0WUQWwkLnPgY5m84IO+ApRXZdcpGi7JOzsL dEkZl60e5ywxRY2ZSTbNiEplcxNVlyZAmAk623GdTTwOShmUCxhUAFFP77h4Ie3iGo 1JoDZXPVhJIYNV7HoGiafU6vkZU1z8xtTnE+ZOk6BjwsyALCJCSNu2JA86mJlu9Ufa rIYa53660HdtMjHwvWGA2EHZlGDMkVmSFtt65wwxrBmwK5hqjvXSNbMDHULEiZz8RF /c7Np2W/RvaFuKeO8ULIzI48uwCrYN3Il/H8ipvp5SzTI6DlOuL+AEPZvEqtWclwKL 0CXEsvPNc8mkg== From: Stephen Boyd To: Michael Turquette , Stephen Boyd Cc: linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, patches@lists.linux.dev, Harshit Mogalapalli , Maxime Ripard Subject: [PATCH] clk: sprd: composite: Simplify determine_rate implementation Date: Tue, 13 Jun 2023 12:54:42 -0700 Message-ID: <20230613195443.1555132-1-sboyd@kernel.org> X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The sprd_div_helper_round_rate() function calls divider_round_rate() which calls divider_round_rate_parent() which calls divider_determine_rate(). This call chain converts back and forth from the rate request structure to make a determine_rate clk_op fit with a round_rate clk_op. Simplify the code here by directly calling divider_determine_rate() instead. This fixes a smatch warning where an unsigned long is compared to less than zero, which is impossible. This makes sprd_div_helper_round_rate() unnecessary as well so simply remove it and fold it into the only caller left. Reported-by: Harshit Mogalapalli Closes: https://lore.kernel.org/r/45fdc54e-7ab6-edd6-d55a-473485608473@oracle.com Cc: Maxime Ripard Fixes: 302d2f836d78 ("clk: sprd: composite: Switch to determine_rate") Signed-off-by: Stephen Boyd --- drivers/clk/sprd/composite.c | 9 +-------- drivers/clk/sprd/div.c | 14 ++------------ drivers/clk/sprd/div.h | 5 ----- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/drivers/clk/sprd/composite.c b/drivers/clk/sprd/composite.c index d3a852720c07..ad6b6383e21f 100644 --- a/drivers/clk/sprd/composite.c +++ b/drivers/clk/sprd/composite.c @@ -13,15 +13,8 @@ static int sprd_comp_determine_rate(struct clk_hw *hw, struct clk_rate_request *req) { struct sprd_comp *cc = hw_to_sprd_comp(hw); - unsigned long rate; - rate = sprd_div_helper_round_rate(&cc->common, &cc->div, - req->rate, &req->best_parent_rate); - if (rate < 0) - return rate; - - req->rate = rate; - return 0; + return divider_determine_rate(hw, req, NULL, cc->div.width, 0); } static unsigned long sprd_comp_recalc_rate(struct clk_hw *hw, diff --git a/drivers/clk/sprd/div.c b/drivers/clk/sprd/div.c index 7621a1d1ab9c..c7261630cab4 100644 --- a/drivers/clk/sprd/div.c +++ b/drivers/clk/sprd/div.c @@ -9,23 +9,13 @@ #include "div.h" -long sprd_div_helper_round_rate(struct sprd_clk_common *common, - const struct sprd_div_internal *div, - unsigned long rate, - unsigned long *parent_rate) -{ - return divider_round_rate(&common->hw, rate, parent_rate, - NULL, div->width, 0); -} -EXPORT_SYMBOL_GPL(sprd_div_helper_round_rate); - static long sprd_div_round_rate(struct clk_hw *hw, unsigned long rate, unsigned long *parent_rate) { struct sprd_div *cd = hw_to_sprd_div(hw); - return sprd_div_helper_round_rate(&cd->common, &cd->div, - rate, parent_rate); + return divider_round_rate(&cd->common.hw, rate, parent_rate, NULL, + cd->div.width, 0); } unsigned long sprd_div_helper_recalc_rate(struct sprd_clk_common *common, diff --git a/drivers/clk/sprd/div.h b/drivers/clk/sprd/div.h index 6acfe6b179fc..f5d614b3dcf1 100644 --- a/drivers/clk/sprd/div.h +++ b/drivers/clk/sprd/div.h @@ -64,11 +64,6 @@ static inline struct sprd_div *hw_to_sprd_div(const struct clk_hw *hw) return container_of(common, struct sprd_div, common); } -long sprd_div_helper_round_rate(struct sprd_clk_common *common, - const struct sprd_div_internal *div, - unsigned long rate, - unsigned long *parent_rate); - unsigned long sprd_div_helper_recalc_rate(struct sprd_clk_common *common, const struct sprd_div_internal *div, unsigned long parent_rate); -- https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/ https://git.kernel.org/pub/scm/linux/kernel/git/sboyd/spmi.git