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=1796374958; b=GejqMDzcgt3oaRQccsUr+nZtqmVuHH8xaUNXVS+Q0RbGzTWQqqAj7D3m5hPFuuW25+pc IwPjJtuDOtW6lc8yzh982YK1LGMRtfqa2kd/jXT6wUUS5nzhLSC+1LaXaO+JMejvPTXPz hwfP+eBoMA7NW1etU9z3Td0tf3WbspdHurbPZgkbcriV73QXmDUQHjx2pHJGi4vPYsHv9 ZGc8xhLLXM444ntjYzg8NLrons2u8/DXgxD32RlZoXZ83eRNqIU8aUpRdPKABF2zyIVWJ D0Var6xY0OCM9WkH8iDop6Ud1KK8SDel4sEquLkFOlOBFWog2X6hfNqvYx0Zn9pM/iQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796374958; 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=LlQkuKKnnVBETduj0l5KlKXjKV9f7RdMedZipNK4CJM=; b=fP5R8gxtAGO+kwyWnpvRVuyc3S/T+IMte9kGoOtuMlSbXzTMH6/wuix/JcSgkQWyRVXA Kx5ap06Y/cNiCZyA+IxDhkZ//LSIURmn3bkklzvfytF5QPiNw2+c95kqLYj5VVVgFpftv DO5bJ7ZNhTFB3kg2Ce25VhBaV1V1su+AFikBVUpbAbw6m7/h27yZP5qoA9BXDASwf9wQK hct3K45UH1V2RS9/SC0NyySFgAoezbRK+n+zveIHbrUxn5VK1+frx2ice9lsXibf2jOe2 UdwrADhBu4SpLyokDTLiDFcZ9krR451S26+QSliLBWEF4aAGyobFQ4Yg6vl6OikMKfg== 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=vnNdbfAL; 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 63C9E606A322 for ; Fri, 4 Dec 2026 09:02:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 63C9E606A322 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=vnNdbfAL Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 854CA1A1948; 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-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 --- 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