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 8D43D606A322 for ; Fri, 4 Dec 2026 09:03:02 +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=BVYB4pLU; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=vnNdbfAL 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=LlQkuKKnnVBETduj0l5KlKXjKV9f7RdMedZipNK4CJM=; b=BVYB4pLU22DfR5 5vlpaBGqeWzncdxGjG3PtiCLDHB9MlCjNQbXm/wx2DMFYTET2PYJY0cf1ye+qSy33BKa4do1ZeQvE fXMmgSEnv1s1QqKGRu6q3IjaC59HEDOLzmHH49gS2QdeAi8Naw5YE/QIOSC3UeZgmUG6ebKDoWeCa 5JIuNQ8PvfQ4IsgUCzFHPM8TpxOGWyUli/NUdYQX/SZR+L0RmHPrQHGQ1XaRWf8cXiSbWcxSthmIu vLESFqisPlJP2jcJutxooFTamosOV91HOnfUXTvUkgWlaa42duM2aNI/9dQPgvel/5WQ5O3cpLfJs r7NiJlJ4UskvhfuuNw4Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZPBk-0000000HH4u-0SIv; Fri, 04 Dec 2026 09:02:44 +0000 Received: from smtpout-03.galae.net ([185.246.85.4]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZPBe-0000000HGwV-0tO1 for linux-arm-kernel@lists.infradead.org; Fri, 04 Dec 2026 09:02:40 +0000 Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 8A9784E41883; Fri, 4 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 592CE603C4; Fri, 4 Dec 2026 09:02:36 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 435F911EA187F; Fri, 04 Dec 2026 10:02:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1796374955; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=LlQkuKKnnVBETduj0l5KlKXjKV9f7RdMedZipNK4CJM=; b=vnNdbfALGetLyKDB5IDknxa3TBA5pGVE/4lMpBCnsEgN4L/lYDExY07D2SSEUr8MtZ9vYg 496w9tU6QpXaPFITfN/WvGK/oHVRUfbegbxCCXU3cRmTSZc/F6sJe5JoyPiUvf2DQj4Ip6 7fKbkiwRNvKGcVT/xYNlTtQw04KMWsAE9MgodP54ge7b0R6UmfjeS8y0S7UDYh/IaOvoZG nO5w7QuTDoWYnHIiqfTXsNNKMFNzhTufRd8VSEA2/kFYPR9e72lk5Oy42YlrPdsrpHjU96 dRosFR3kyErkYeBjEcXld1RbqVt1g7zhg0R01qGJI/EZBXb99pjHxQIklaz6Nw== 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 , gregory.clement@bootlin.com, maxime.chevallier@bootlin.com, thomas.richard@bootlin.com, Paul Cercueil Subject: [PATCH v9 2/2] clk: Search clocks of ACPI device with its companion device Date: Fri, 4 Dec 2026 10:02:10 +0100 Message-ID: <20261204090210.8950-2-paul.cercueil@bootlin.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261204090210.8950-1-paul.cercueil@bootlin.com> References: <20261204090210.8950-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-20261204_010238_405389_6284002F X-CRM114-Status: GOOD ( 18.42 ) 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=-19.3 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 --- v9: - Search for the ACPI clock *before* the regular path. As we now search the clock with the ACPI companion device only if its name differs, we won't be shadowing an entry with the same con_id provided elsewhere. This makes sure that we respect the precedence of an entry's dev_id over con_id. - Only use the ACPI companion's name to find the hw_clk, then create the clock using the regular device name. 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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 919fc680ae4d..23cf7396db72 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,6 +101,8 @@ 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; if (dev && dev->of_node) { @@ -108,6 +111,17 @@ 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); + acpi_dev_id = acpi_dev_name(adev); + + if (strcmp(dev_id, acpi_dev_id)) { + hw = clk_find_hw(acpi_dev_id, con_id); + if (!IS_ERR(hw)) + return clk_hw_create_clk(dev, hw, dev_id, con_id, NULL); + } + } + return __clk_get_sys(dev, dev_id, con_id); } EXPORT_SYMBOL(clk_get); -- 2.47.3