public inbox for linux-rtc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/27] clk: remove deprecated API divider_round_rate() and friends
@ 2026-01-08 21:16 Brian Masney
  2026-01-08 21:16 ` [PATCH 03/27] rtc: ac100: convert from divider_round_rate() to divider_determine_rate() Brian Masney
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Brian Masney @ 2026-01-08 21:16 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: linux-clk, linux-kernel, Brian Masney, Chen Wang, Inochi Amaoto,
	sophgo, Chen-Yu Tsai, Maxime Ripard, Jernej Skrabec,
	Samuel Holland, linux-arm-kernel, linux-sunxi, Alexandre Belloni,
	linux-rtc, Andreas Färber, Manivannan Sadhasivam,
	linux-actions, Keguang Zhang, linux-mips, Taichi Sugaya,
	Takao Orito, Jacky Huang, Shan-Chun Hung, Vladimir Zapolskiy,
	Piotr Wojtaszczyk, Bjorn Andersson, linux-arm-msm, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Maxime Coquelin, Alexandre Torgue,
	linux-stm32, Michal Simek, Rob Clark, Dmitry Baryshkov,
	David Airlie, Simona Vetter, Abhinav Kumar, Jessica Zhang,
	Sean Paul, Marijn Suijten, dri-devel, freedreno, Vinod Koul,
	Neil Armstrong, linux-phy

Here's a series that gets rid of the deprecated APIs
divider_round_rate(), divider_round_rate_parent(), and
divider_ro_round_rate_parent() since these functions are just wrappers
for the determine_rate variant.

Note that when I converted some of these drivers from round_rate to
determine_rate, this was mistakenly converted to the following in some
cases:

    req->rate = divider_round_rate(...)

This is invalid in the case when an error occurs since it can set the
rate to a negative value. So this series fixes those bugs and removes
the deprecated APIs all in one go.

Three of the patches ended up being a more complicated migration, and I
put them as the first three patches in this series (clk: sophgo:
cv18xx-ip), (clk: sunxi-ng), and (rtc: ac100). The remaining patches I
feel are all straight forward.

Merge strategy
==============

Only three of the patches are outside of drivers/clk (drm/msm, phy, and
rtc). For simplicity, I think it would be easiest if Stephen takes this
whole series through the clk tree. Subsystem maintainers please leave an
Acked-by for Stephen. Thanks!

Signed-off-by: Brian Masney <bmasney@redhat.com>
---
Brian Masney (27):
      clk: sophgo: cv18xx-ip: convert from divider_round_rate() to divider_determine_rate()
      clk: sunxi-ng: convert from divider_round_rate_parent() to divider_determine_rate()
      rtc: ac100: convert from divider_round_rate() to divider_determine_rate()
      clk: actions: owl-composite: convert from owl_divider_helper_round_rate() to divider_determine_rate()
      clk: actions: owl-divider: convert from divider_round_rate() to divider_determine_rate()
      clk: bm1880: convert from divider_ro_round_rate() to divider_ro_determine_rate()
      clk: bm1880: convert from divider_round_rate() to divider_determine_rate()
      clk: hisilicon: clkdivider-hi6220: convert from divider_round_rate() to divider_determine_rate()
      clk: loongson1: convert from divider_round_rate() to divider_determine_rate()
      clk: milbeaut: convert from divider_ro_round_rate() to divider_ro_determine_rate()
      clk: milbeaut: convert from divider_round_rate() to divider_determine_rate()
      clk: nuvoton: ma35d1-divider: convert from divider_round_rate() to divider_determine_rate()
      clk: nxp: lpc32xx: convert from divider_round_rate() to divider_determine_rate()
      clk: qcom: alpha-pll: convert from divider_round_rate() to divider_determine_rate()
      clk: qcom: regmap-divider: convert from divider_ro_round_rate() to divider_ro_determine_rate()
      clk: qcom: regmap-divider: convert from divider_round_rate() to divider_determine_rate()
      clk: sophgo: sg2042-clkgen: convert from divider_round_rate() to divider_determine_rate()
      clk: sprd: div: convert from divider_round_rate() to divider_determine_rate()
      clk: stm32: stm32-core: convert from divider_ro_round_rate() to divider_ro_determine_rate()
      clk: stm32: stm32-core: convert from divider_round_rate_parent() to divider_determine_rate()
      clk: versaclock3: convert from divider_round_rate() to divider_determine_rate()
      clk: x86: cgu: convert from divider_round_rate() to divider_determine_rate()
      clk: zynqmp: divider: convert from divider_round_rate() to divider_determine_rate()
      drm/msm/dsi_phy_14nm: convert from divider_round_rate() to divider_determine_rate()
      phy: ti: phy-j721e-wiz: convert from divider_round_rate() to divider_determine_rate()
      clk: divider: remove divider_ro_round_rate_parent()
      clk: divider: remove divider_round_rate() and divider_round_rate_parent()

 drivers/clk/actions/owl-composite.c        |  11 +--
 drivers/clk/actions/owl-divider.c          |  17 +---
 drivers/clk/actions/owl-divider.h          |   5 -
 drivers/clk/clk-bm1880.c                   |  13 +--
 drivers/clk/clk-divider.c                  |  44 ---------
 drivers/clk/clk-loongson1.c                |   5 +-
 drivers/clk/clk-milbeaut.c                 |  15 +--
 drivers/clk/clk-versaclock3.c              |   7 +-
 drivers/clk/hisilicon/clkdivider-hi6220.c  |   6 +-
 drivers/clk/nuvoton/clk-ma35d1-divider.c   |   7 +-
 drivers/clk/nxp/clk-lpc32xx.c              |   6 +-
 drivers/clk/qcom/clk-alpha-pll.c           |  21 ++--
 drivers/clk/qcom/clk-regmap-divider.c      |  16 +--
 drivers/clk/sophgo/clk-cv18xx-ip.c         | 154 ++++++++++++++++-------------
 drivers/clk/sophgo/clk-sg2042-clkgen.c     |  15 +--
 drivers/clk/sprd/div.c                     |   6 +-
 drivers/clk/stm32/clk-stm32-core.c         |  42 +++-----
 drivers/clk/sunxi-ng/ccu_div.c             |  25 +++--
 drivers/clk/sunxi-ng/ccu_mp.c              |  26 ++---
 drivers/clk/sunxi-ng/ccu_mult.c            |  16 +--
 drivers/clk/sunxi-ng/ccu_mux.c             |  49 +++++----
 drivers/clk/sunxi-ng/ccu_mux.h             |   8 +-
 drivers/clk/sunxi-ng/ccu_nkm.c             |  25 ++---
 drivers/clk/x86/clk-cgu.c                  |   6 +-
 drivers/clk/zynqmp/divider.c               |   5 +-
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_14nm.c |   7 +-
 drivers/phy/ti/phy-j721e-wiz.c             |   5 +-
 drivers/rtc/rtc-ac100.c                    |  75 +++++++-------
 include/linux/clk-provider.h               |  28 ------
 29 files changed, 257 insertions(+), 408 deletions(-)
---
base-commit: f8f97927abf7c12382dddc93a144fc9df7919b77
change-id: 20260107-clk-divider-round-rate-1cfd117b0670

Best regards,
-- 
Brian Masney <bmasney@redhat.com>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 03/27] rtc: ac100: convert from divider_round_rate() to divider_determine_rate()
  2026-01-08 21:16 [PATCH 00/27] clk: remove deprecated API divider_round_rate() and friends Brian Masney
@ 2026-01-08 21:16 ` Brian Masney
  2026-01-22  0:26   ` Alexandre Belloni
  2026-01-10 19:11 ` (subset) [PATCH 00/27] clk: remove deprecated API divider_round_rate() and friends Bjorn Andersson
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Brian Masney @ 2026-01-08 21:16 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: linux-clk, linux-kernel, Brian Masney, Alexandre Belloni,
	linux-rtc

The divider_round_rate() function is now deprecated, so let's migrate
to divider_determine_rate() instead so that this deprecated API can be
removed.

Signed-off-by: Brian Masney <bmasney@redhat.com>

---
To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: linux-rtc@vger.kernel.org
---
 drivers/rtc/rtc-ac100.c | 75 +++++++++++++++++++++++++------------------------
 1 file changed, 38 insertions(+), 37 deletions(-)

diff --git a/drivers/rtc/rtc-ac100.c b/drivers/rtc/rtc-ac100.c
index 33626311fa781b5ce90dcc472f948dc933bbc897..16aca4431da8c029e6195d8a3c9fe75fa95d0bc0 100644
--- a/drivers/rtc/rtc-ac100.c
+++ b/drivers/rtc/rtc-ac100.c
@@ -140,42 +140,16 @@ static unsigned long ac100_clkout_recalc_rate(struct clk_hw *hw,
 				   AC100_CLKOUT_DIV_WIDTH);
 }
 
-static long ac100_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
-				    unsigned long prate)
-{
-	unsigned long best_rate = 0, tmp_rate, tmp_prate;
-	int i;
-
-	if (prate == AC100_RTC_32K_RATE)
-		return divider_round_rate(hw, rate, &prate, NULL,
-					  AC100_CLKOUT_DIV_WIDTH,
-					  CLK_DIVIDER_POWER_OF_TWO);
-
-	for (i = 0; ac100_clkout_prediv[i].div; i++) {
-		tmp_prate = DIV_ROUND_UP(prate, ac100_clkout_prediv[i].val);
-		tmp_rate = divider_round_rate(hw, rate, &tmp_prate, NULL,
-					      AC100_CLKOUT_DIV_WIDTH,
-					      CLK_DIVIDER_POWER_OF_TWO);
-
-		if (tmp_rate > rate)
-			continue;
-		if (rate - tmp_rate < best_rate - tmp_rate)
-			best_rate = tmp_rate;
-	}
-
-	return best_rate;
-}
-
 static int ac100_clkout_determine_rate(struct clk_hw *hw,
 				       struct clk_rate_request *req)
 {
-	struct clk_hw *best_parent;
+	int i, ret, num_parents = clk_hw_get_num_parents(hw);
+	struct clk_hw *best_parent = NULL;
 	unsigned long best = 0;
-	int i, num_parents = clk_hw_get_num_parents(hw);
 
 	for (i = 0; i < num_parents; i++) {
 		struct clk_hw *parent = clk_hw_get_parent_by_index(hw, i);
-		unsigned long tmp, prate;
+		unsigned long prate;
 
 		/*
 		 * The clock has two parents, one is a fixed clock which is
@@ -199,13 +173,40 @@ static int ac100_clkout_determine_rate(struct clk_hw *hw,
 
 		prate = clk_hw_get_rate(parent);
 
-		tmp = ac100_clkout_round_rate(hw, req->rate, prate);
-
-		if (tmp > req->rate)
-			continue;
-		if (req->rate - tmp < req->rate - best) {
-			best = tmp;
-			best_parent = parent;
+		if (prate == AC100_RTC_32K_RATE) {
+			struct clk_rate_request div_req = *req;
+
+			div_req.best_parent_rate = prate;
+
+			ret = divider_determine_rate(hw, &div_req, NULL,
+						     AC100_CLKOUT_DIV_WIDTH,
+						     CLK_DIVIDER_POWER_OF_TWO);
+			if (ret != 0 || div_req.rate > req->rate)
+				continue;
+			else if (req->rate - div_req.rate < req->rate - best) {
+				best = div_req.rate;
+				best_parent = parent;
+			}
+		} else {
+			int j;
+
+			for (j = 0; ac100_clkout_prediv[j].div; j++) {
+				struct clk_rate_request div_req = *req;
+				unsigned long tmp_prate;
+
+				tmp_prate = DIV_ROUND_UP(prate, ac100_clkout_prediv[j].div);
+				div_req.best_parent_rate = tmp_prate;
+
+				ret = divider_determine_rate(hw, &div_req, NULL,
+							     AC100_CLKOUT_DIV_WIDTH,
+							     CLK_DIVIDER_POWER_OF_TWO);
+				if (ret != 0 || div_req.rate > req->rate)
+					continue;
+				else if (req->rate - div_req.rate < req->rate - best) {
+					best = div_req.rate;
+					best_parent = parent;
+				}
+			}
 		}
 	}
 
@@ -213,7 +214,7 @@ static int ac100_clkout_determine_rate(struct clk_hw *hw,
 		return -EINVAL;
 
 	req->best_parent_hw = best_parent;
-	req->best_parent_rate = best;
+	req->best_parent_rate = clk_hw_get_rate(best_parent);
 	req->rate = best;
 
 	return 0;

-- 
2.52.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: (subset) [PATCH 00/27] clk: remove deprecated API divider_round_rate() and friends
  2026-01-08 21:16 [PATCH 00/27] clk: remove deprecated API divider_round_rate() and friends Brian Masney
  2026-01-08 21:16 ` [PATCH 03/27] rtc: ac100: convert from divider_round_rate() to divider_determine_rate() Brian Masney
@ 2026-01-10 19:11 ` Bjorn Andersson
  2026-01-15 21:05 ` Dmitry Baryshkov
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Bjorn Andersson @ 2026-01-10 19:11 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Brian Masney
  Cc: linux-clk, linux-kernel, Chen Wang, Inochi Amaoto, sophgo,
	Chen-Yu Tsai, Maxime Ripard, Jernej Skrabec, Samuel Holland,
	linux-arm-kernel, linux-sunxi, Alexandre Belloni, linux-rtc,
	Andreas Färber, Manivannan Sadhasivam, linux-actions,
	Keguang Zhang, linux-mips, Taichi Sugaya, Takao Orito,
	Jacky Huang, Shan-Chun Hung, Vladimir Zapolskiy,
	Piotr Wojtaszczyk, linux-arm-msm, Orson Zhai, Baolin Wang,
	Chunyan Zhang, Maxime Coquelin, Alexandre Torgue, linux-stm32,
	Michal Simek, Rob Clark, Dmitry Baryshkov, David Airlie,
	Simona Vetter, Abhinav Kumar, Jessica Zhang, Sean Paul,
	Marijn Suijten, dri-devel, freedreno, Vinod Koul, Neil Armstrong,
	linux-phy


On Thu, 08 Jan 2026 16:16:18 -0500, Brian Masney wrote:
> Here's a series that gets rid of the deprecated APIs
> divider_round_rate(), divider_round_rate_parent(), and
> divider_ro_round_rate_parent() since these functions are just wrappers
> for the determine_rate variant.
> 
> Note that when I converted some of these drivers from round_rate to
> determine_rate, this was mistakenly converted to the following in some
> cases:
> 
> [...]

Applied, thanks!

[14/27] clk: qcom: alpha-pll: convert from divider_round_rate() to divider_determine_rate()
        commit: e1f08613e113f02a3ec18c9a7964de97f940acbf
[15/27] clk: qcom: regmap-divider: convert from divider_ro_round_rate() to divider_ro_determine_rate()
        commit: 35a48f41b63f67c490f3a2a89b042536be67cf0f
[16/27] clk: qcom: regmap-divider: convert from divider_round_rate() to divider_determine_rate()
        commit: b2f36d675e09299d9aee395c6f83d8a95d4c9441

Best regards,
-- 
Bjorn Andersson <andersson@kernel.org>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 00/27] clk: remove deprecated API divider_round_rate() and friends
  2026-01-08 21:16 [PATCH 00/27] clk: remove deprecated API divider_round_rate() and friends Brian Masney
  2026-01-08 21:16 ` [PATCH 03/27] rtc: ac100: convert from divider_round_rate() to divider_determine_rate() Brian Masney
  2026-01-10 19:11 ` (subset) [PATCH 00/27] clk: remove deprecated API divider_round_rate() and friends Bjorn Andersson
@ 2026-01-15 21:05 ` Dmitry Baryshkov
  2026-01-21 22:53 ` Brian Masney
  2026-02-04 15:44 ` (subset) " Vinod Koul
  4 siblings, 0 replies; 9+ messages in thread
From: Dmitry Baryshkov @ 2026-01-15 21:05 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Brian Masney
  Cc: linux-clk, linux-kernel, Chen Wang, Inochi Amaoto, sophgo,
	Chen-Yu Tsai, Maxime Ripard, Jernej Skrabec, Samuel Holland,
	linux-arm-kernel, linux-sunxi, Alexandre Belloni, linux-rtc,
	Andreas Färber, Manivannan Sadhasivam, linux-actions,
	Keguang Zhang, linux-mips, Taichi Sugaya, Takao Orito,
	Jacky Huang, Shan-Chun Hung, Vladimir Zapolskiy,
	Piotr Wojtaszczyk, Bjorn Andersson, linux-arm-msm, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Maxime Coquelin, Alexandre Torgue,
	linux-stm32, Michal Simek, Rob Clark, Dmitry Baryshkov,
	David Airlie, Simona Vetter, Abhinav Kumar, Jessica Zhang,
	Sean Paul, Marijn Suijten, dri-devel, freedreno, Vinod Koul,
	Neil Armstrong, linux-phy

On Thu, 08 Jan 2026 16:16:18 -0500, Brian Masney wrote:
> Here's a series that gets rid of the deprecated APIs
> divider_round_rate(), divider_round_rate_parent(), and
> divider_ro_round_rate_parent() since these functions are just wrappers
> for the determine_rate variant.
> 
> Note that when I converted some of these drivers from round_rate to
> determine_rate, this was mistakenly converted to the following in some
> cases:
> 
> [...]

Applied to msm-next, thanks!

[24/27] drm/msm/dsi_phy_14nm: convert from divider_round_rate() to divider_determine_rate()
        https://gitlab.freedesktop.org/lumag/msm/-/commit/1d232f793d4d

Best regards,
-- 
With best wishes
Dmitry



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 00/27] clk: remove deprecated API divider_round_rate() and friends
  2026-01-08 21:16 [PATCH 00/27] clk: remove deprecated API divider_round_rate() and friends Brian Masney
                   ` (2 preceding siblings ...)
  2026-01-15 21:05 ` Dmitry Baryshkov
@ 2026-01-21 22:53 ` Brian Masney
  2026-02-04 15:44 ` (subset) " Vinod Koul
  4 siblings, 0 replies; 9+ messages in thread
From: Brian Masney @ 2026-01-21 22:53 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd
  Cc: linux-clk, linux-kernel, Chen Wang, Inochi Amaoto, sophgo,
	Chen-Yu Tsai, Maxime Ripard, Jernej Skrabec, Samuel Holland,
	linux-arm-kernel, linux-sunxi, Alexandre Belloni, linux-rtc,
	Andreas Färber, Manivannan Sadhasivam, linux-actions,
	Keguang Zhang, linux-mips, Taichi Sugaya, Takao Orito,
	Jacky Huang, Shan-Chun Hung, Vladimir Zapolskiy,
	Piotr Wojtaszczyk, Bjorn Andersson, linux-arm-msm, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Maxime Coquelin, Alexandre Torgue,
	linux-stm32, Michal Simek, Rob Clark, Dmitry Baryshkov,
	David Airlie, Simona Vetter, Abhinav Kumar, Jessica Zhang,
	Sean Paul, Marijn Suijten, dri-devel, freedreno, Vinod Koul,
	Neil Armstrong, linux-phy

Hi Stephen,

On Thu, Jan 08, 2026 at 04:16:18PM -0500, Brian Masney wrote:
> Here's a series that gets rid of the deprecated APIs
> divider_round_rate(), divider_round_rate_parent(), and
> divider_ro_round_rate_parent() since these functions are just wrappers
> for the determine_rate variant.

I sent you a GIT PULL for what can go to Linus for the upcoming merge
window from this series:

https://lore.kernel.org/linux-clk/aXFYU324yQ6uBmk0@redhat.com/T/#u

Thanks,

Brian


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 03/27] rtc: ac100: convert from divider_round_rate() to divider_determine_rate()
  2026-01-08 21:16 ` [PATCH 03/27] rtc: ac100: convert from divider_round_rate() to divider_determine_rate() Brian Masney
@ 2026-01-22  0:26   ` Alexandre Belloni
  2026-01-22  0:48     ` Brian Masney
  0 siblings, 1 reply; 9+ messages in thread
From: Alexandre Belloni @ 2026-01-22  0:26 UTC (permalink / raw)
  To: Brian Masney
  Cc: Michael Turquette, Stephen Boyd, linux-clk, linux-kernel,
	linux-rtc

Hello,

On 08/01/2026 16:16:21-0500, Brian Masney wrote:
> The divider_round_rate() function is now deprecated, so let's migrate
> to divider_determine_rate() instead so that this deprecated API can be
> removed.
> 
> Signed-off-by: Brian Masney <bmasney@redhat.com>
> 
> ---
> To: Alexandre Belloni <alexandre.belloni@bootlin.com>
> Cc: linux-rtc@vger.kernel.org
> ---
>  drivers/rtc/rtc-ac100.c | 75 +++++++++++++++++++++++++------------------------
>  1 file changed, 38 insertions(+), 37 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-ac100.c b/drivers/rtc/rtc-ac100.c
> index 33626311fa781b5ce90dcc472f948dc933bbc897..16aca4431da8c029e6195d8a3c9fe75fa95d0bc0 100644
> --- a/drivers/rtc/rtc-ac100.c
> +++ b/drivers/rtc/rtc-ac100.c
> @@ -140,42 +140,16 @@ static unsigned long ac100_clkout_recalc_rate(struct clk_hw *hw,
>  				   AC100_CLKOUT_DIV_WIDTH);
>  }
>  
> -static long ac100_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
> -				    unsigned long prate)
> -{
> -	unsigned long best_rate = 0, tmp_rate, tmp_prate;
> -	int i;
> -
> -	if (prate == AC100_RTC_32K_RATE)
> -		return divider_round_rate(hw, rate, &prate, NULL,
> -					  AC100_CLKOUT_DIV_WIDTH,
> -					  CLK_DIVIDER_POWER_OF_TWO);
> -
> -	for (i = 0; ac100_clkout_prediv[i].div; i++) {
> -		tmp_prate = DIV_ROUND_UP(prate, ac100_clkout_prediv[i].val);
> -		tmp_rate = divider_round_rate(hw, rate, &tmp_prate, NULL,
> -					      AC100_CLKOUT_DIV_WIDTH,
> -					      CLK_DIVIDER_POWER_OF_TWO);
> -
> -		if (tmp_rate > rate)
> -			continue;
> -		if (rate - tmp_rate < best_rate - tmp_rate)
> -			best_rate = tmp_rate;
> -	}
> -
> -	return best_rate;
> -}
> -
>  static int ac100_clkout_determine_rate(struct clk_hw *hw,
>  				       struct clk_rate_request *req)
>  {
> -	struct clk_hw *best_parent;
> +	int i, ret, num_parents = clk_hw_get_num_parents(hw);
> +	struct clk_hw *best_parent = NULL;
>  	unsigned long best = 0;
> -	int i, num_parents = clk_hw_get_num_parents(hw);
>  
>  	for (i = 0; i < num_parents; i++) {
>  		struct clk_hw *parent = clk_hw_get_parent_by_index(hw, i);
> -		unsigned long tmp, prate;
> +		unsigned long prate;
>  
>  		/*
>  		 * The clock has two parents, one is a fixed clock which is
> @@ -199,13 +173,40 @@ static int ac100_clkout_determine_rate(struct clk_hw *hw,
>  
>  		prate = clk_hw_get_rate(parent);
>  
> -		tmp = ac100_clkout_round_rate(hw, req->rate, prate);
> -
> -		if (tmp > req->rate)
> -			continue;
> -		if (req->rate - tmp < req->rate - best) {
> -			best = tmp;
> -			best_parent = parent;
> +		if (prate == AC100_RTC_32K_RATE) {
> +			struct clk_rate_request div_req = *req;
> +
> +			div_req.best_parent_rate = prate;
> +
> +			ret = divider_determine_rate(hw, &div_req, NULL,
> +						     AC100_CLKOUT_DIV_WIDTH,
> +						     CLK_DIVIDER_POWER_OF_TWO);
> +			if (ret != 0 || div_req.rate > req->rate)
> +				continue;

This leaves a braces inbalance

> +			else if (req->rate - div_req.rate < req->rate - best) {
> +				best = div_req.rate;
> +				best_parent = parent;
> +			}
> +		} else {
> +			int j;
> +
> +			for (j = 0; ac100_clkout_prediv[j].div; j++) {
> +				struct clk_rate_request div_req = *req;
> +				unsigned long tmp_prate;
> +
> +				tmp_prate = DIV_ROUND_UP(prate, ac100_clkout_prediv[j].div);
> +				div_req.best_parent_rate = tmp_prate;
> +
> +				ret = divider_determine_rate(hw, &div_req, NULL,
> +							     AC100_CLKOUT_DIV_WIDTH,
> +							     CLK_DIVIDER_POWER_OF_TWO);
> +				if (ret != 0 || div_req.rate > req->rate)
> +					continue;

Ditto.

> +				else if (req->rate - div_req.rate < req->rate - best) {
> +					best = div_req.rate;
> +					best_parent = parent;
> +				}
> +			}
>  		}
>  	}


-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 03/27] rtc: ac100: convert from divider_round_rate() to divider_determine_rate()
  2026-01-22  0:26   ` Alexandre Belloni
@ 2026-01-22  0:48     ` Brian Masney
  2026-01-22  2:02       ` Alexandre Belloni
  0 siblings, 1 reply; 9+ messages in thread
From: Brian Masney @ 2026-01-22  0:48 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Michael Turquette, Stephen Boyd, linux-clk, linux-kernel,
	linux-rtc

Hi Alexandre,

On Thu, Jan 22, 2026 at 01:26:09AM +0100, Alexandre Belloni wrote:
> On 08/01/2026 16:16:21-0500, Brian Masney wrote:
> > The divider_round_rate() function is now deprecated, so let's migrate
> > to divider_determine_rate() instead so that this deprecated API can be
> > removed.
> > 
> > Signed-off-by: Brian Masney <bmasney@redhat.com>
> > 
> > ---
> > To: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > Cc: linux-rtc@vger.kernel.org
> > ---
> >  drivers/rtc/rtc-ac100.c | 75 +++++++++++++++++++++++++------------------------
> >  1 file changed, 38 insertions(+), 37 deletions(-)
> > 
> > diff --git a/drivers/rtc/rtc-ac100.c b/drivers/rtc/rtc-ac100.c
> > index 33626311fa781b5ce90dcc472f948dc933bbc897..16aca4431da8c029e6195d8a3c9fe75fa95d0bc0 100644
> > --- a/drivers/rtc/rtc-ac100.c
> > +++ b/drivers/rtc/rtc-ac100.c
> > @@ -140,42 +140,16 @@ static unsigned long ac100_clkout_recalc_rate(struct clk_hw *hw,
> >  				   AC100_CLKOUT_DIV_WIDTH);
> >  }
> >  
> > -static long ac100_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
> > -				    unsigned long prate)
> > -{
> > -	unsigned long best_rate = 0, tmp_rate, tmp_prate;
> > -	int i;
> > -
> > -	if (prate == AC100_RTC_32K_RATE)
> > -		return divider_round_rate(hw, rate, &prate, NULL,
> > -					  AC100_CLKOUT_DIV_WIDTH,
> > -					  CLK_DIVIDER_POWER_OF_TWO);
> > -
> > -	for (i = 0; ac100_clkout_prediv[i].div; i++) {
> > -		tmp_prate = DIV_ROUND_UP(prate, ac100_clkout_prediv[i].val);
> > -		tmp_rate = divider_round_rate(hw, rate, &tmp_prate, NULL,
> > -					      AC100_CLKOUT_DIV_WIDTH,
> > -					      CLK_DIVIDER_POWER_OF_TWO);
> > -
> > -		if (tmp_rate > rate)
> > -			continue;
> > -		if (rate - tmp_rate < best_rate - tmp_rate)
> > -			best_rate = tmp_rate;
> > -	}
> > -
> > -	return best_rate;
> > -}
> > -
> >  static int ac100_clkout_determine_rate(struct clk_hw *hw,
> >  				       struct clk_rate_request *req)
> >  {
> > -	struct clk_hw *best_parent;
> > +	int i, ret, num_parents = clk_hw_get_num_parents(hw);
> > +	struct clk_hw *best_parent = NULL;
> >  	unsigned long best = 0;
> > -	int i, num_parents = clk_hw_get_num_parents(hw);
> >  
> >  	for (i = 0; i < num_parents; i++) {
> >  		struct clk_hw *parent = clk_hw_get_parent_by_index(hw, i);
> > -		unsigned long tmp, prate;
> > +		unsigned long prate;
> >  
> >  		/*
> >  		 * The clock has two parents, one is a fixed clock which is
> > @@ -199,13 +173,40 @@ static int ac100_clkout_determine_rate(struct clk_hw *hw,
> >  
> >  		prate = clk_hw_get_rate(parent);
> >  
> > -		tmp = ac100_clkout_round_rate(hw, req->rate, prate);
> > -
> > -		if (tmp > req->rate)
> > -			continue;
> > -		if (req->rate - tmp < req->rate - best) {
> > -			best = tmp;
> > -			best_parent = parent;
> > +		if (prate == AC100_RTC_32K_RATE) {
> > +			struct clk_rate_request div_req = *req;
> > +
> > +			div_req.best_parent_rate = prate;
> > +
> > +			ret = divider_determine_rate(hw, &div_req, NULL,
> > +						     AC100_CLKOUT_DIV_WIDTH,
> > +						     CLK_DIVIDER_POWER_OF_TWO);
> > +			if (ret != 0 || div_req.rate > req->rate)
> > +				continue;
> 
> This leaves a braces inbalance

To be clear, you also want the braces around the if like this:

if (ret != 0 || div_req.rate > req->rate) {
	continue;
} else if (req->rate - div_req.rate < req->rate - best) {
	best = div_req.rate;
	best_parent = parent;
}

Brian


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 03/27] rtc: ac100: convert from divider_round_rate() to divider_determine_rate()
  2026-01-22  0:48     ` Brian Masney
@ 2026-01-22  2:02       ` Alexandre Belloni
  0 siblings, 0 replies; 9+ messages in thread
From: Alexandre Belloni @ 2026-01-22  2:02 UTC (permalink / raw)
  To: Brian Masney
  Cc: Michael Turquette, Stephen Boyd, linux-clk, linux-kernel,
	linux-rtc

On 21/01/2026 19:48:19-0500, Brian Masney wrote:
> Hi Alexandre,
> 
> On Thu, Jan 22, 2026 at 01:26:09AM +0100, Alexandre Belloni wrote:
> > On 08/01/2026 16:16:21-0500, Brian Masney wrote:
> > > The divider_round_rate() function is now deprecated, so let's migrate
> > > to divider_determine_rate() instead so that this deprecated API can be
> > > removed.
> > > 
> > > Signed-off-by: Brian Masney <bmasney@redhat.com>
> > > 
> > > ---
> > > To: Alexandre Belloni <alexandre.belloni@bootlin.com>
> > > Cc: linux-rtc@vger.kernel.org
> > > ---
> > >  drivers/rtc/rtc-ac100.c | 75 +++++++++++++++++++++++++------------------------
> > >  1 file changed, 38 insertions(+), 37 deletions(-)
> > > 
> > > diff --git a/drivers/rtc/rtc-ac100.c b/drivers/rtc/rtc-ac100.c
> > > index 33626311fa781b5ce90dcc472f948dc933bbc897..16aca4431da8c029e6195d8a3c9fe75fa95d0bc0 100644
> > > --- a/drivers/rtc/rtc-ac100.c
> > > +++ b/drivers/rtc/rtc-ac100.c
> > > @@ -140,42 +140,16 @@ static unsigned long ac100_clkout_recalc_rate(struct clk_hw *hw,
> > >  				   AC100_CLKOUT_DIV_WIDTH);
> > >  }
> > >  
> > > -static long ac100_clkout_round_rate(struct clk_hw *hw, unsigned long rate,
> > > -				    unsigned long prate)
> > > -{
> > > -	unsigned long best_rate = 0, tmp_rate, tmp_prate;
> > > -	int i;
> > > -
> > > -	if (prate == AC100_RTC_32K_RATE)
> > > -		return divider_round_rate(hw, rate, &prate, NULL,
> > > -					  AC100_CLKOUT_DIV_WIDTH,
> > > -					  CLK_DIVIDER_POWER_OF_TWO);
> > > -
> > > -	for (i = 0; ac100_clkout_prediv[i].div; i++) {
> > > -		tmp_prate = DIV_ROUND_UP(prate, ac100_clkout_prediv[i].val);
> > > -		tmp_rate = divider_round_rate(hw, rate, &tmp_prate, NULL,
> > > -					      AC100_CLKOUT_DIV_WIDTH,
> > > -					      CLK_DIVIDER_POWER_OF_TWO);
> > > -
> > > -		if (tmp_rate > rate)
> > > -			continue;
> > > -		if (rate - tmp_rate < best_rate - tmp_rate)
> > > -			best_rate = tmp_rate;
> > > -	}
> > > -
> > > -	return best_rate;
> > > -}
> > > -
> > >  static int ac100_clkout_determine_rate(struct clk_hw *hw,
> > >  				       struct clk_rate_request *req)
> > >  {
> > > -	struct clk_hw *best_parent;
> > > +	int i, ret, num_parents = clk_hw_get_num_parents(hw);
> > > +	struct clk_hw *best_parent = NULL;
> > >  	unsigned long best = 0;
> > > -	int i, num_parents = clk_hw_get_num_parents(hw);
> > >  
> > >  	for (i = 0; i < num_parents; i++) {
> > >  		struct clk_hw *parent = clk_hw_get_parent_by_index(hw, i);
> > > -		unsigned long tmp, prate;
> > > +		unsigned long prate;
> > >  
> > >  		/*
> > >  		 * The clock has two parents, one is a fixed clock which is
> > > @@ -199,13 +173,40 @@ static int ac100_clkout_determine_rate(struct clk_hw *hw,
> > >  
> > >  		prate = clk_hw_get_rate(parent);
> > >  
> > > -		tmp = ac100_clkout_round_rate(hw, req->rate, prate);
> > > -
> > > -		if (tmp > req->rate)
> > > -			continue;
> > > -		if (req->rate - tmp < req->rate - best) {
> > > -			best = tmp;
> > > -			best_parent = parent;
> > > +		if (prate == AC100_RTC_32K_RATE) {
> > > +			struct clk_rate_request div_req = *req;
> > > +
> > > +			div_req.best_parent_rate = prate;
> > > +
> > > +			ret = divider_determine_rate(hw, &div_req, NULL,
> > > +						     AC100_CLKOUT_DIV_WIDTH,
> > > +						     CLK_DIVIDER_POWER_OF_TWO);
> > > +			if (ret != 0 || div_req.rate > req->rate)
> > > +				continue;
> > 
> > This leaves a braces inbalance
> 
> To be clear, you also want the braces around the if like this:
> 
> if (ret != 0 || div_req.rate > req->rate) {
> 	continue;
> } else if (req->rate - div_req.rate < req->rate - best) {
> 	best = div_req.rate;
> 	best_parent = parent;
> }
> 

Yes, you can change that and add my ack on v2, I'm fine with this going
through clk.


-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: (subset) [PATCH 00/27] clk: remove deprecated API divider_round_rate() and friends
  2026-01-08 21:16 [PATCH 00/27] clk: remove deprecated API divider_round_rate() and friends Brian Masney
                   ` (3 preceding siblings ...)
  2026-01-21 22:53 ` Brian Masney
@ 2026-02-04 15:44 ` Vinod Koul
  4 siblings, 0 replies; 9+ messages in thread
From: Vinod Koul @ 2026-02-04 15:44 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd, Brian Masney
  Cc: linux-clk, linux-kernel, Chen Wang, Inochi Amaoto, sophgo,
	Chen-Yu Tsai, Maxime Ripard, Jernej Skrabec, Samuel Holland,
	linux-arm-kernel, linux-sunxi, Alexandre Belloni, linux-rtc,
	Andreas Färber, Manivannan Sadhasivam, linux-actions,
	Keguang Zhang, linux-mips, Taichi Sugaya, Takao Orito,
	Jacky Huang, Shan-Chun Hung, Vladimir Zapolskiy,
	Piotr Wojtaszczyk, Bjorn Andersson, linux-arm-msm, Orson Zhai,
	Baolin Wang, Chunyan Zhang, Maxime Coquelin, Alexandre Torgue,
	linux-stm32, Michal Simek, Rob Clark, Dmitry Baryshkov,
	David Airlie, Simona Vetter, Abhinav Kumar, Jessica Zhang,
	Sean Paul, Marijn Suijten, dri-devel, freedreno, Neil Armstrong,
	linux-phy


On Thu, 08 Jan 2026 16:16:18 -0500, Brian Masney wrote:
> Here's a series that gets rid of the deprecated APIs
> divider_round_rate(), divider_round_rate_parent(), and
> divider_ro_round_rate_parent() since these functions are just wrappers
> for the determine_rate variant.
> 
> Note that when I converted some of these drivers from round_rate to
> determine_rate, this was mistakenly converted to the following in some
> cases:
> 
> [...]

Applied, thanks!

[25/27] phy: ti: phy-j721e-wiz: convert from divider_round_rate() to divider_determine_rate()
        commit: dbeea86fecef7cf2b93aded4525d74f6277376ef

Best regards,
-- 
~Vinod



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-02-04 15:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-08 21:16 [PATCH 00/27] clk: remove deprecated API divider_round_rate() and friends Brian Masney
2026-01-08 21:16 ` [PATCH 03/27] rtc: ac100: convert from divider_round_rate() to divider_determine_rate() Brian Masney
2026-01-22  0:26   ` Alexandre Belloni
2026-01-22  0:48     ` Brian Masney
2026-01-22  2:02       ` Alexandre Belloni
2026-01-10 19:11 ` (subset) [PATCH 00/27] clk: remove deprecated API divider_round_rate() and friends Bjorn Andersson
2026-01-15 21:05 ` Dmitry Baryshkov
2026-01-21 22:53 ` Brian Masney
2026-02-04 15:44 ` (subset) " Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox