From nobody Mon Feb 9 09:08:50 2026 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 D67382BCF4A for ; Thu, 22 Jan 2026 12:47:36 +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=1769086058; cv=none; b=uwOVrdttiwR99ftm65Y1Ol9bjHmBMHGD4XDAg/XHzcjqntXE0PLTL/YYSCgRriFuQ8hFBPYUGliT8dIVxIaCmWqJLSjeIxBMoKb+YpN4OyV665tg3+UPMWvmcsPnmRZ0Zd0U4Ltp2zxHSodGm8tq17Cbm2ksMyyyoKDElvImZGQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769086058; c=relaxed/simple; bh=f02GzYx48kesQ7jeGELEbs6RFs9qvuIFf9axfxA+iKc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=k4HCffYQfbrn/PgZ/4eKBjWNjujpwHV1fdk7noRFLHOLB9YNCfgEoS4H9tYL/YaqlQBu0goMyC4O7h11zbXtaRy+MmbW/tPJZXEPRlDI2cL+X4dV/8HPGNKGpv+oDPBVWkvBVkWZV87l/Ve1Kvv4z/LywdtKGFUbYMeayTHcxMY= 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=J6AKkjcN; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Ol+NvhPk; 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="J6AKkjcN"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ol+NvhPk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769086056; 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: content-transfer-encoding:content-transfer-encoding; bh=/p/2bC3+sbtEKV34RBkBnld1uYguVdDfDr4y5ubycHk=; b=J6AKkjcNODrOqNHrmPNRsIge5uRFfaStKAcSOQtxqZmZmgbQc3deNdlF3xnh4KTSokQELG eHAJ40UKWm6zJbSwnS0mdnUgxvWohWc6eGpD86xacwVOQQN5wGZXnXOif184xiEywPBq68 N5eQHbk/XKqob+lh7HNajEg52G7x8fk= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-159-lbBBbZ3_NBuaJJKsK-rSZA-1; Thu, 22 Jan 2026 07:47:34 -0500 X-MC-Unique: lbBBbZ3_NBuaJJKsK-rSZA-1 X-Mimecast-MFC-AGG-ID: lbBBbZ3_NBuaJJKsK-rSZA_1769086054 Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-88fcbe2e351so54280036d6.1 for ; Thu, 22 Jan 2026 04:47:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1769086054; x=1769690854; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=/p/2bC3+sbtEKV34RBkBnld1uYguVdDfDr4y5ubycHk=; b=Ol+NvhPkfAd5VxOl64kAJQopVvS6EBt++SPh73gQ7JlfoWSE30WCtAbETwJHFGdDOR 7iL/znHaSeInLtjt27IOtgGWLehDg3w8NTOi1xR+aLJz6UVlZPLZVtVc+VuYUw1/yucY KkG1uLhNk753Gkct/1j4N4PLF0z+5Wl5Z0DuXMQGVyfXTyTz2wD0BeGoc1kT71WL0GRm trM78VtcvInxDrC3dAH45bC9wDwngYLeaxAMtzFI5oy2MR6reUWk8RaqAXBjk9JyoSVr 2T7I1ktF8CDk1xdB+ke+D0xVUxQxiWg/LLfF2LMUz2TpRxYCTodXN4dS/LHS9NRtBnTy /VeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769086054; x=1769690854; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/p/2bC3+sbtEKV34RBkBnld1uYguVdDfDr4y5ubycHk=; b=rTQFwTCWX8SWYuJOh/0fHl3Wryv0YxY3EMeVATqch+9bUM8+zzMcgG3/h9E8P8cDnK d8vAmextj5jn7Lb02gNYmOU65CfVXojH/QPXaTLYZg8oejou97Eyqn+KYOTC7GBKEDIx 90abyP/Zm9OsTO2WPVJC2Ul43nPtvO4+KmfD5PVprTy2PgpYhGlaz64OqJhbShyyQ+mK q37q7r+QOHJjPzHDT/MAySlZMKAXDbIM5ZXaUloG/rC2ru3kmM3YxRr/MdH72FeyY7eT DLyb+fnn234PsDvdbySx+Jb/YvdGq6oSf7++A65T9ICoZC/ge2b4EKTbMEKtsG1TVg25 jDow== X-Forwarded-Encrypted: i=1; AJvYcCU43XrJKrCRN8dy7t84lWcPUjliMP9rVzcTRprgAQf4q9PIgpDa0MQhFJXlmsnItAjh5eC0QiYXHvju3fg=@vger.kernel.org X-Gm-Message-State: AOJu0Yw2W4NpNkux2XBmUNBzQfzI3lPnCGbKVSegtNSjl9aWr543y4z0 VQ/3nExC4YlNkj4d37QriTdN+Ykav5mdg92x1JxzQoaOcURcpdsX7kKaTYR25qI/9gcOwyndV+d zt7hCQmKt5f4aG3D8tVyU01oL3WmMsAgLxlAY41u0/XjsghlRNo/ImiUrsxRXJVTKYUVEn5uci8 dM5zOFsFYkqr6i6WeUjlDl/ThqN4fVxdvItiZkicA6ZlxQn8GC X-Gm-Gg: AZuq6aICBcl4JTWp+oYHZpr6TgXi0DmX4OKPtZ3auATdDTGQzvBjlWhdz991mARXheZ E8EKxYH4AJEU5i+PYSYmtyyaOnvuuUYI5/Zv7zgSUFTwACuHPU0DOjriJMsP7DDLdubdRVysLpO 3ytyV8XzeIImhawWpU3bEwJxYb39FD/blYr/5JgV9d3H8AoQN9A6xG7Iglt28hUdUkMR3xlegV7 4iulSfVOIffjhiYRAcKXO/yKZeSz4MSuEBktiiZsMNeCppsv1fe3Zcby83slRoOE7iw6/QElmy3 CD1ZyXrqqgqqMZOArqWdie1Nxly+WwV2Flk6tL5+o4uXvG/jRYOgqVCCo+2tBb4GU2A70JYkGk5 KiEB0IG3cYrK20lD0JwwdJCFSCMXPxhvjx2ZsZS77NexcNOwwiQ== X-Received: by 2002:a05:6214:2a87:b0:894:6531:d61c with SMTP id 6a1803df08f44-8947dfdc869mr37706456d6.19.1769086054233; Thu, 22 Jan 2026 04:47:34 -0800 (PST) X-Received: by 2002:a05:6214:2a87:b0:894:6531:d61c with SMTP id 6a1803df08f44-8947dfdc869mr37706116d6.19.1769086053745; Thu, 22 Jan 2026 04:47:33 -0800 (PST) Received: from [192.168.1.15] (c-73-183-52-120.hsd1.pa.comcast.net. [73.183.52.120]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8942e6d6ea3sm152362716d6.54.2026.01.22.04.47.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jan 2026 04:47:33 -0800 (PST) From: Brian Masney Date: Thu, 22 Jan 2026 07:47:16 -0500 Subject: [PATCH v2] rtc: ac100: convert from divider_round_rate() to divider_determine_rate() 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260122-rtc-ac100-divider-round-rate-v2-1-044f8b493c35@redhat.com> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/x3MOwqAMAwA0KtIZgM1glSvIg79RM1SJVURxLtbH N/yHsiswhmG6gHlS7JsqYDqCsLq0sIosRjIUGcaItQjoAuNMRjlksiKup0porqD0Qfy1s+9bVs LpdiVZ7n/fpze9wO1QfEcbgAAAA== X-Change-ID: 20260122-rtc-ac100-divider-round-rate-bc2b8bf98338 To: Alexandre Belloni Cc: Stephen Boyd , linux-clk@vger.kernel.org, linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, Brian Masney X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4044; i=bmasney@redhat.com; s=20250903; h=from:subject:message-id; bh=f02GzYx48kesQ7jeGELEbs6RFs9qvuIFf9axfxA+iKc=; b=owGbwMvMwCW2/dJd9di6A+2Mp9WSGDKLZFJiNTIOvcngcXj97XSFj8/WY98uuqkJWDQrrxJcN f/ouWNGHaUsDGJcDLJiiixLco0KIlJX2d67o8kCM4eVCWQIAxenAEzEi4nhf2CxP19gYw2LavO9 wgX7plhbbZ24+CPTWr7NwTVc74zbljAy7J6w6O8T8zNq4tbB/M+D+iOEdwun9j6bls+3LrftU4o 9CwA= X-Developer-Key: i=bmasney@redhat.com; a=openpgp; fpr=A46D32705865AA3DDEDC2904B7D2DD275D7EC087 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. Acked-by: Alexandre Belloni Signed-off-by: Brian Masney --- Changes since v1: - Fix two cases of brace inbalances around if/else Alexandre: Per v1 comments, I'll include this with my GIT PULL to Stephen. --- 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..bba7115ff3ad0f9a9b428784b49= ba3fde0d18484 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); } =20 -static long ac100_clkout_round_rate(struct clk_hw *hw, unsigned long rate, - unsigned long prate) -{ - unsigned long best_rate =3D 0, tmp_rate, tmp_prate; - int i; - - if (prate =3D=3D AC100_RTC_32K_RATE) - return divider_round_rate(hw, rate, &prate, NULL, - AC100_CLKOUT_DIV_WIDTH, - CLK_DIVIDER_POWER_OF_TWO); - - for (i =3D 0; ac100_clkout_prediv[i].div; i++) { - tmp_prate =3D DIV_ROUND_UP(prate, ac100_clkout_prediv[i].val); - tmp_rate =3D 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 =3D 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 =3D clk_hw_get_num_parents(hw); + struct clk_hw *best_parent =3D NULL; unsigned long best =3D 0; - int i, num_parents =3D clk_hw_get_num_parents(hw); =20 for (i =3D 0; i < num_parents; i++) { struct clk_hw *parent =3D clk_hw_get_parent_by_index(hw, i); - unsigned long tmp, prate; + unsigned long prate; =20 /* * 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, =20 prate =3D clk_hw_get_rate(parent); =20 - tmp =3D ac100_clkout_round_rate(hw, req->rate, prate); - - if (tmp > req->rate) - continue; - if (req->rate - tmp < req->rate - best) { - best =3D tmp; - best_parent =3D parent; + if (prate =3D=3D AC100_RTC_32K_RATE) { + struct clk_rate_request div_req =3D *req; + + div_req.best_parent_rate =3D prate; + + ret =3D divider_determine_rate(hw, &div_req, NULL, + AC100_CLKOUT_DIV_WIDTH, + CLK_DIVIDER_POWER_OF_TWO); + if (ret !=3D 0 || div_req.rate > req->rate) { + continue; + } else if (req->rate - div_req.rate < req->rate - best) { + best =3D div_req.rate; + best_parent =3D parent; + } + } else { + int j; + + for (j =3D 0; ac100_clkout_prediv[j].div; j++) { + struct clk_rate_request div_req =3D *req; + unsigned long tmp_prate; + + tmp_prate =3D DIV_ROUND_UP(prate, ac100_clkout_prediv[j].div); + div_req.best_parent_rate =3D tmp_prate; + + ret =3D divider_determine_rate(hw, &div_req, NULL, + AC100_CLKOUT_DIV_WIDTH, + CLK_DIVIDER_POWER_OF_TWO); + if (ret !=3D 0 || div_req.rate > req->rate) { + continue; + } else if (req->rate - div_req.rate < req->rate - best) { + best =3D div_req.rate; + best_parent =3D parent; + } + } } } =20 @@ -213,7 +214,7 @@ static int ac100_clkout_determine_rate(struct clk_hw *h= w, return -EINVAL; =20 req->best_parent_hw =3D best_parent; - req->best_parent_rate =3D best; + req->best_parent_rate =3D clk_hw_get_rate(best_parent); req->rate =3D best; =20 return 0; --- base-commit: e3b32dcb9f23e3c3927ef3eec6a5842a988fb574 change-id: 20260122-rtc-ac100-divider-round-rate-bc2b8bf98338 Best regards, --=20 Brian Masney