Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.246.84.56 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796288559; b=a4PWAuwDNuXTkhKxd2LAJwu1OaFywiK86+f6knn0cPh4gA3hCoDHCRxgFFBxtRcOc7sX jPKknsqAK+G+Zej5XdyTnAStjTijKUNsiEdTZ4hWdS+ez1LLq5FADGRNsW8zdzdzgbrVj /BB9TO/jMgmB4Vu6Z3XnbhkvNxiNn/yeJrCSN4dchp/anD5ICW68dixBmEyMT+UlgM+YN yWIeZyUfdQAGyw4IL0x+4x2XnqWZOC86g2DUh7pC1RjVaiHW8xFPj+8dLf7gzDOUjAb1T c3xbD/hB273ZGhGX4UrTzSVTHC2wAMZ4zxiqwxa+j31zoU1k2diSARXPTAAq1nrFJtw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796288559; h=DMARC-Filter:Received:Received:Received:DKIM-Signature:From:To:Cc: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Last-TLS-Session-Version; bh=xA49NAlbubeqty5blvyVl0OTcJM0rtsA0+MCsqCPayI=; b=ITb3wdidDB4Woi0gm1xXMN//BUT5cH4nwzpBg7lLYY5CIHL9n3fkSlZvqkBYk/0ybvmh W7SRVt/0SSNW2Bs01cWjeHoXx+VOh8BBLgVpJz6ZeJVunIC7dBms76nBlEq7NGvPbI/Vy 990GJRKwcFiN3Ps1q4aGdXvl4N9ConOFB7Fo60WuFrgLQ9De1Hp1PNbL88JKbizs6N/Tt OjnqTP6UzD3w0WAXZqyIN1zd4qioBFws4HtAWSqYSpRvSoxLVrDt59aXvSLB8BlnNiIYf SAPs/pOOwNHNK9K4Nln89shANJnD4GTWOivp6vb6lSy2EWNHVEfKfecFvQ0FIjTpkig== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=hYiNNreV; arc=none smtp.remote-ip=185.246.84.56 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 EA86A606A32D for ; Thu, 3 Dec 2026 09:02:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EA86A606A32D 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.a=rsa-sha256 header.s=dkim header.b=hYiNNreV Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 314DD1A190F; Thu, 3 Dec 2026 09:02:36 +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-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 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