From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50DB636BCF7 for ; Thu, 22 Jan 2026 02:02:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769047337; cv=none; b=mHcXDO86xnCosSynZWT5Imc2JVTm61peDmi1X+jS9rHFwxGAYeEHHQbDW0MlKY1m7GIoA1rE2cxH3uu2ZZ4oZxdQAj7C94g6DDeftowkTvk/HxB6Lr3MsVpOeXOXmXxjVE1LCyp09nST8XvRgaVOABDsRbctT7FGBnO9E6iZDik= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769047337; c=relaxed/simple; bh=gqdjoSavvFU/Ljz9ZUNg7oKrF6AIY4V3UlVMG7lNwG0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ys5PpopRtmp0kfhxYJUUbWvhQ5Mhz3ruClJj2NWph4oXHtlNKcI9DfXGE9E9OK/ijLSPPl14VJnGTqXBKs5sAhYasTDIEMXlIc1dJBxQy3ySju7aGZTU+a7SKIIcrl58xktRPudcFs1qvIjBkmmEm9k1L58TXMiwIUgSqwmI2lM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=oZrd87Qd; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="oZrd87Qd" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id B2839C21A96; Thu, 22 Jan 2026 02:02:09 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id E621F60711; Thu, 22 Jan 2026 02:02:09 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1779D102F0B74; Thu, 22 Jan 2026 03:02:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1769047329; h=from:subject:date:message-id:to:cc:mime-version:content-type: in-reply-to:references; bh=U4VoT2uHHZbDUnK+cLuny/IQf7bwRywulijFTXxIp60=; b=oZrd87Qd43UalBkqoLJu0f8VoxvrC3lpujWJtOKE9uL0HUlC5cZKp0g6uH1UAyyIdAIiL7 dJQK6lUGIL1I4wHWkzH3VAmqZT0ucFgwrBMmiwAxBtj9iff3Z0f0p18OaOhf/VzuB/N0ri mU76fqjUY15op56HkmBFS1qfVQKNJpbb2ttXip9FxZCijHv2IXA21Jd/yoA7kNSdF9kfDH v0eplMU8MOwl+4MoLlWpjNU1WLpRfbD10nD5uJlPO24S24Uf4OP8VwXKnpvUzuLAQfaWyY sbstLHHSAlvAOl7H6h3zJ98yk+bP6g0oMI6bD+yQxzMZUyb6fuKYZKucP1zrsA== Date: Thu, 22 Jan 2026 03:02:07 +0100 From: Alexandre Belloni To: Brian Masney Cc: Michael Turquette , Stephen Boyd , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org Subject: Re: [PATCH 03/27] rtc: ac100: convert from divider_round_rate() to divider_determine_rate() Message-ID: <20260122020207de2216d9@mail.local> References: <20260108-clk-divider-round-rate-v1-0-535a3ed73bf3@redhat.com> <20260108-clk-divider-round-rate-v1-3-535a3ed73bf3@redhat.com> <202601220026092a75a45e@mail.local> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Last-TLS-Session-Version: TLSv1.3 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 > > > > > > --- > > > To: Alexandre Belloni > > > 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