From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 05A4920298C for ; Thu, 22 Jan 2026 00:48:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769042908; cv=none; b=qj1zGgohReLt45ooJT+xqbYteFiOta6LqKn73ROLAkhqM9+WIPsNSzpR2Ti963akglYZmHLRcnFLqDaBk+m44kezBeIXN7EWvWEbJpMbfQaHBTTerBmwlStododjcExoqRWsmAKcUKeS4HTma609pZxBcEuRowoFTC/Av3hprKU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769042908; c=relaxed/simple; bh=YgkbcXlmcga492MlvJ5hBRrRTRjG9AP55dNP5piMLys=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WN7dnzeU88RHGq7HozpLqXGTQKCJLITC8pdehe+BFKaGmfTrmLeT1pdVvgeMthgyXljNrmvmPXx92P/fbY7P+oO58Zo9qdSB6TRkzYXyDykphy8A8jNfASYcycZuxAHt1+C1sqn2HSr35LbqEYAH/4MTIDy6a2VhtL26gvII7kY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Ou3ovd+L; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=maRV4rBx; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ou3ovd+L"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="maRV4rBx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769042905; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XSYrCFJLTYE1vUJlazCK1VzEy0tKZI14lHyw9347PV8=; b=Ou3ovd+L4opHhC2AQGJEY+sT7WVffWICqFIOddvYteoS5kkgFWh7VsCx/TT9siTX2aOldx 6lO5gNtm3QRnpSJCgdMMD85J4tciNRbVpzdim925yeQASbCp1gGsrLlMRnZ7boItPSVaCL u8iIx1K6knpNE6NOOVZgKOCPlLw/7lo= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-39-3AR4LB3vMDitLpSV2GuiSg-1; Wed, 21 Jan 2026 19:48:22 -0500 X-MC-Unique: 3AR4LB3vMDitLpSV2GuiSg-1 X-Mimecast-MFC-AGG-ID: 3AR4LB3vMDitLpSV2GuiSg_1769042902 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-8947d47793fso22355366d6.2 for ; Wed, 21 Jan 2026 16:48:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1769042902; x=1769647702; darn=vger.kernel.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=XSYrCFJLTYE1vUJlazCK1VzEy0tKZI14lHyw9347PV8=; b=maRV4rBx9RgbqM11Eb2El7HGK6ckBV9Q4NYPtBGGnLw7HDDf2KY6Frqr1aTOqSs5gn KT3b1qYkly5iz1F2218UKP522+0PFSPddPwO9JGI1CaMsVxa5XvUCIS6KbuU9OX0w1PY 1vG22xKJoEeN8Tqr1GCLUWXOxSTE6E+R7gRZFtUPGFkawgRH59xH7wq3HrLLnIk+VBvp lrDpsQ9faTzHa7/NIu51KvzBUrShPmuJCJQh/10VYSerKWC6kfjhHTIKpnpzH08jxj3p 0aDwBk35zM1VQ/fwJM6dwHV5B8dBLddlGcsrLA+oxGybeE2ktkk3gig6xERVvhNbCEOc zTOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769042902; x=1769647702; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=XSYrCFJLTYE1vUJlazCK1VzEy0tKZI14lHyw9347PV8=; b=UfrVRWV/OlRw+N0b+69epdCcklhhyk13gI7+AFB8xUohbZsPSPQuKMq+SxnqPYtEEK 1hqr807hpf13Fc+rPc3qINhoG2wWZdffT51CePWERlXc9KN//zd1djOk5mnJw3LEZwg2 dBS76PerCOpaBbRHvO2HaMROA9BN0IujV8HLX/Ywzx2UvFZIRbSGMVOFs20YSu4wr3gt lBddVvaOgQ+2L2R4iNi1wkgp6jU9ySSU3WBXVjB1yvlU9ltW58RStbUWuE4JcUkLQyPu b6y9ckw58QlvAmR3aEukRIwkbwgTSANzU3J9604KC8uDRbmO3KKbUDlXny3AxKV4E75A SIRQ== X-Forwarded-Encrypted: i=1; AJvYcCWXmOE4DKZuCc1KgBh98bi48nx9RXvUn9U5MYK8oON2lWg13Yf6+9Bau21PzehTF3s6QDHEgNT69f01gTM=@vger.kernel.org X-Gm-Message-State: AOJu0YxeSK08NjbIoTmQ/4E2TLldfP8bwNfx7tbSCUh8aEsG/NOh0O8G F8LBB4OdkBP9RevOFqECFsXEczywYtmhCRaDvOjPbvoFHO3mDiNTnNuXP33cWspb9ZKY8WLk1j5 PWcjNTT48veOUEAec8sTnrC2NTHoEPbYAI4thOIROlWh7FmaBjYJu1yiHdVfTURFqGA== X-Gm-Gg: AZuq6aJT4w9SgZFoEeVZKaw/iJMAswOyTxFVXIpRjnlzuptXm1RMfr7agKcL4yTPcbo s/v1XRdckshYeoGmAAJ423rCVK1kLaPVK6R5Bf7Qee0igbZWAXjD15IQJOwZoCcmqnHqUfcnaH6 rQhF9+Z3x2hdc1/zdBzUbaTSycDINWf7NBh+QUkxK/0t3q7vfAzLs6oTZ3TGRN0hZzfbnEYuzgd sTO5GAVlymBoQ47TrHTcE1Ve6zWdMffa2efe+O69aq5C+vU5IikPRrCJcnQ44yniQTc+vRQUxdI Y774IpJVROCR5vhXWxmtTlWlv1Om62KZcLyqiCrhDThKj8ALYzxsmXb8Y5T2CNSq/kmoMe2B/pf PfKYsAUi6qi+iHr2oGoBCyVQazAM6ggpX4d5TWK6k3mm9 X-Received: by 2002:a05:6214:4001:b0:894:68f7:40f2 with SMTP id 6a1803df08f44-89468f7424cmr104557926d6.2.1769042901993; Wed, 21 Jan 2026 16:48:21 -0800 (PST) X-Received: by 2002:a05:6214:4001:b0:894:68f7:40f2 with SMTP id 6a1803df08f44-89468f7424cmr104557706d6.2.1769042901567; Wed, 21 Jan 2026 16:48:21 -0800 (PST) Received: from redhat.com (c-73-183-52-120.hsd1.pa.comcast.net. [73.183.52.120]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89468d65eebsm40483976d6.30.2026.01.21.16.48.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jan 2026 16:48:21 -0800 (PST) Date: Wed, 21 Jan 2026 19:48:19 -0500 From: Brian Masney To: Alexandre Belloni 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: 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: <202601220026092a75a45e@mail.local> User-Agent: Mutt/2.2.14 (2025-02-20) 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; } Brian