From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2C33606A334 for ; Thu, 3 Dec 2026 09:03:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=lAKe2MxT; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=hYiNNreV DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=xA49NAlbubeqty5blvyVl0OTcJM0rtsA0+MCsqCPayI=; b=lAKe2MxTRfmmM+ 0NmnMNfy81veQqJ5i/+m9RgL2G5HIRyh4YvRJ9sgjfXSYWcGzGUZbkVkXEjKB8G0EjztDbqwhRc3T iXIAHOksXgfVpXHe/hhVtdLt1jjcKZAnbMfjwPFVZfAlMBSyzxNI/rj+X9ymN5uU2iaDbmFXG0tuZ MKwVv7KlC4gmar0wRFaoY7bXRWVvCz2P0SRNwmUfgNcGGrO3taVCe00l4jvWGsKeiSs5VqHgq5J0c 9Y+MGUnzmWsJwS+ABOqMtuLXh1Cl5eOrEu4UqHIZk24GenFn9Dhbhiu70uKIKKdHJwPaoA6i9B01X yevDz0pj5I3vt4woJcRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ2iD-0000000Dvm9-1E0W; Thu, 03 Dec 2026 09:02:46 +0000 Received: from smtpout-04.galae.net ([185.171.202.116]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZ2i7-0000000Dvkh-26OI for linux-arm-kernel@lists.infradead.org; Thu, 03 Dec 2026 09:02:41 +0000 Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 59C05C2AC55; Thu, 3 Dec 2026 09:02:47 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 01527604ED; Thu, 3 Dec 2026 09:02:36 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id CCB3C11EA1D22; Thu, 03 Dec 2026 10:02:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1796288555; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=xA49NAlbubeqty5blvyVl0OTcJM0rtsA0+MCsqCPayI=; b=hYiNNreVSYo51iESGvQE3ddhyIMXxDuJ85xKsm9nDUKVqfMBki+FHQuNdNdWPSZ1mXroan zDMTYlHEnDyCIaaLbHCW3fwpuLDOVHQGwhF1HOYC3Pn7fTedJxin+F3tMWCIFHhDd6j8bC JjQD15UAovxW0bmK1ZraPxitHmSwoIrFdWdq71DlC5LhwNnKg2ZbkW4ZmIzjXHE8gj+LZF tnXf3EeAr1VpC/RZn8tC1ytTQl4Ct4RmoOZAtlnR3/C4v2+SCiIEiKNWytXb0PIiZjZckH gmtknKA+bAixiQy5NpiDEpbNpZJ0KOzoyPByLGqcRBD65wcezELriQU/wKwN1w== From: Paul Cercueil To: "Rafael J . Wysocki" , Len Brown , Russell King , Maciej Wieczor-Retman , Pawel Chmielewski Cc: linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, acpica-devel@lists.linux.dev, Thomas Petazzoni , Paul Cercueil Subject: [PATCH v8 2/2] clk: Search clocks of ACPI device with its companion device Date: Thu, 3 Dec 2026 10:02:21 +0100 Message-ID: <20261203090221.8601-2-paul.cercueil@bootlin.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261203090221.8601-1-paul.cercueil@bootlin.com> References: <20261203090221.8601-1-paul.cercueil@bootlin.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261203_010239_689583_5022CD01 X-CRM114-Status: GOOD ( 18.40 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 If the device passed as argument to clk_get() has a companion ACPI device, use it to search the clocks, if we can't find the clock using the regular path. The argument for this, is that ACPI clocks are registered to clkdev using the companion ACPI device's name, before the regular device object is created. Note that a wildcard clkdev entry with dev_id == NULL shadowing a clock registered for the ACPI companion device is not really a concern: those clocks are named "acpi-clkX" so if it happens it would be on purpose. Signed-off-by: Paul Cercueil --- v8: Reword commit message v7: - Search for the ACPI clock after the regular path. - Do not recurse with the ACPI device, as we want to create the clk with the regular device and not the ACPI companion device. - Only search clocks with the ACPI companion device if its name differs from the main device v6: New patch --- drivers/clk/clkdev.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 919fc680ae4d..8bd7cd9b25e0 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -6,6 +6,7 @@ * * Helper for the clk API to assist looking up a struct clk. */ +#include #include #include #include @@ -100,7 +101,10 @@ EXPORT_SYMBOL(clk_get_sys); struct clk *clk_get(struct device *dev, const char *con_id) { const char *dev_id = dev ? dev_name(dev) : NULL; + struct acpi_device *adev; + const char *acpi_dev_id; struct clk_hw *hw; + struct clk *clk; if (dev && dev->of_node) { hw = of_clk_get_hw(dev->of_node, 0, con_id); @@ -108,7 +112,17 @@ struct clk *clk_get(struct device *dev, const char *con_id) return clk_hw_create_clk(dev, hw, dev_id, con_id, NULL); } - return __clk_get_sys(dev, dev_id, con_id); + clk = __clk_get_sys(dev, dev_id, con_id); + + if (PTR_ERR(clk) == -ENOENT && dev && has_acpi_companion(dev)) { + adev = ACPI_COMPANION(dev); + acpi_dev_id = acpi_dev_name(adev); + + if (strcmp(dev_id, acpi_dev_id)) + clk = __clk_get_sys(dev, acpi_dev_id, con_id); + } + + return clk; } EXPORT_SYMBOL(clk_get); -- 2.47.3