mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Cercueil <paul.cercueil@bootlin.com>
To: "Rafael J . Wysocki" <rafael@kernel.org>,
	Len Brown <lenb@kernel.org>, Russell King <linux@armlinux.org.uk>,
	Maciej Wieczor-Retman <maciej.wieczor-retman@intel.com>,
	Pawel Chmielewski <pawel.chmielewski@intel.com>
Cc: linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	acpica-devel@lists.linux.dev, linux-kernel@vger.kernel.org,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Paul Cercueil <paul.cercueil@bootlin.com>
Subject: [PATCH v6 2/2] clk: Search clocks of ACPI device with its companion device
Date: Mon, 30 Nov 2026 13:28:27 +0100	[thread overview]
Message-ID: <20261130122827.157946-3-paul.cercueil@bootlin.com> (raw)
In-Reply-To: <20261130122827.157946-1-paul.cercueil@bootlin.com>

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 our clock there,
fall back to 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.

Signed-off-by: Paul Cercueil <paul.cercueil@bootlin.com>
---

v6: New patch
---
 drivers/clk/clkdev.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 919fc680ae4d..396715f30ff0 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 <linux/acpi.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
@@ -100,7 +101,9 @@ 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;
 	struct clk_hw *hw;
+	struct clk *clk;
 
 	if (dev && dev->of_node) {
 		hw = of_clk_get_hw(dev->of_node, 0, con_id);
@@ -108,6 +111,13 @@ struct clk *clk_get(struct device *dev, const char *con_id)
 			return clk_hw_create_clk(dev, hw, dev_id, con_id, NULL);
 	}
 
+	if (dev && has_acpi_companion(dev)) {
+		adev = ACPI_COMPANION(dev);
+		clk = clk_get(&adev->dev, con_id);
+		if (!IS_ERR(clk) || PTR_ERR(clk) != -ENOENT)
+			return clk;
+	}
+
 	return __clk_get_sys(dev, dev_id, con_id);
 }
 EXPORT_SYMBOL(clk_get);
-- 
2.47.3


      parent reply	other threads:[~2026-11-30 12:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 12:28 [PATCH v6 0/2] ACPI: Add ACPI 6.5 fixed clock support Paul Cercueil
2026-11-30 12:28 ` [PATCH v6 1/2] ACPI: Add basic support for ACPI 6.5 fixed clock resources Paul Cercueil
2026-11-30 12:28 ` Paul Cercueil [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130122827.157946-3-paul.cercueil@bootlin.com \
    --to=paul.cercueil@bootlin.com \
    --cc=acpica-devel@lists.linux.dev \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=maciej.wieczor-retman@intel.com \
    --cc=pawel.chmielewski@intel.com \
    --cc=rafael@kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®