From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BD60FC88E72 for ; Thu, 17 Sep 2026 12:29:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:Reply-To:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:References:Cc:To:Subject: From:MIME-Version:Date:Message-ID:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GP+EnTxumdQhuCXoKxpELYnBEcTZV9wEocoMo8rBUyw=; b=RD+fmtaHP2fiKnWErsFxP3e6wX szuirDHcuH9CBAljVEO6IH7m968t8Tnl2jW9JafOX+rXz70cxc7CNolPA2NHqAizoVaqzhz5WHxzi w92kUFau5tiX7qo3QkWhFiY+p+s2uiZSGtssZq80IKCa5hOMjDdo/Rhn3wnGDcp/tTJUjHEAaskP/ Phoi/gh4s6GabcMPHN0O6tMu1LjUzVMTVssbIFTP3d9JuG3aWzQfZLhNG5K4FDtbqTqxXXgPJi9Fq 076SAdU5phXFdQiYZg4YqaaWldC9OFz033vY6cx6mfMiWSjELZwprYLUyzylsFS5nGSemLNJMzMP5 D7ygV56A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x7BFU-0000000BIHK-1woY; Thu, 17 Sep 2026 12:29:56 +0000 Received: from mail-wm2-x10.google.com ([2a00:1450:4864:31::10]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x7BFS-0000000BIGb-2gYW for linux-phy@lists.infradead.org; Thu, 17 Sep 2026 12:29:55 +0000 Received: by mail-wm2-x10.google.com with SMTP id 5b1f17b1804b1-49e6598dd44so4293275e9.1 for ; Thu, 17 Sep 2026 05:29:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1789648192; x=1790252992; darn=lists.infradead.org; h=content-transfer-encoding:content-type:in-reply-to:organization :autocrypt:content-language:references:cc:to:subject:reply-to:from :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to:content-type; bh=gC/Ov+71qXFh+qBimBh+DCQrBkKyOWQ85VQeOxH4dWo=; b=l6ohTXPn+w9agVvUNYWPlyC2yYc4MhyLU1rorIk08OgKHd6pBNdgyljYtNiAIi3qZg 76sX13kZ4wfspLkHLpZfiTd3qzJKejdZkcnNUk4aKCR+yguZNd8lwjl7ko0GxtcfJ2YQ yri3f0E18WEC4rDAmgqETJInhPmV+sIebsTUCs0gSAY6O5iFe7ZBw9L6VTkz7v2Twwwl EtXguMEYnvKWPFtnQLPl3P/d0fZKTK5m/eRzndeUMtHG0Wcb7xSG3sl3GC32lQE6waDP DOMMNO2uLhCACCT56dcElvrJ5m7djpxm5oBuu1sdnw6h2nZCn3IGbSfzdqJyXkKy3jTx Z+PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789648192; x=1790252992; h=content-transfer-encoding:content-type:in-reply-to:organization :autocrypt:content-language:references:cc:to:subject:reply-to:from :user-agent:mime-version:date:message-id:x-gm-gg:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to:content-type; bh=gC/Ov+71qXFh+qBimBh+DCQrBkKyOWQ85VQeOxH4dWo=; b=o1SKHa3z6hQ5IiBsoiieIhaTXXmDFwkfjRvJuWg+pkQTmf3fJQSnF91vHI4xjx/oMU YWfigJZVYlxeKhsUrXl91Sft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wsyHjvTOcEbXSAMzzTgJGkg== X-Received: by 2002:a05:600c:19c6:b0:49e:645e:2616 with SMTP id 5b1f17b1804b1-49eac463955mr74481465e9.5.1789648191941; Thu, 17 Sep 2026 05:29:51 -0700 (PDT) Received: from ?IPV6:2a01:e0a:106d:1080:b5f0:971e:8fd2:f1c9? ([2a01:e0a:106d:1080:b5f0:971e:8fd2:f1c9]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49fbd2563ccsm89340375e9.13.2026.09.17.05.29.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Sep 2026 05:29:51 -0700 (PDT) Message-ID: Date: Thu, 17 Sep 2026 14:29:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Neil Armstrong Subject: Re: [PATCH v18 2/5] phy: core: Add phy_get_by_of_node() To: Bryan O'Donoghue , Bjorn Andersson , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Robert Foss , Todor Tomov , Mauro Carvalho Chehab , Konrad Dybcio , Vladimir Zapolskiy , Bryan O'Donoghue , Loic Poulain , Vinod Koul , Greg Kroah-Hartman , Kishon Vijay Abraham I , Felipe Balbi , Manivannan Sadhasivam Cc: linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-phy@lists.infradead.org, Krzysztof Kozlowski References: <20260917-b4-linux-next-25-03-13-dtsi-x1e80100-camss-v18-0-f85c9103177e@linaro.org> <20260917-b4-linux-next-25-03-13-dtsi-x1e80100-camss-v18-2-f85c9103177e@linaro.org> Content-Language: en-US, fr Autocrypt: addr=neil.armstrong@linaro.org; keydata= xsBNBE1ZBs8BCAD78xVLsXPwV/2qQx2FaO/7mhWL0Qodw8UcQJnkrWmgTFRobtTWxuRx8WWP GTjuhvbleoQ5Cxjr+v+1ARGCH46MxFP5DwauzPekwJUD5QKZlaw/bURTLmS2id5wW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iL4oHcsGtUX oUk33HEAEQEAAcLAXwQYAQIACQUCTVkGzwIbDAAKCRAWmrexpM/4rrXiB/sGbkQ6itMrAIfn M7IbRuiSZS1unlySUVYu3SD6YBYnNi3G5EpbwfBNuT3H8//rVvtOFK4OD8cRYkxXRQmTvqa3 3eDIHu/zr1HMKErm+2SD6PO9umRef8V82o2oaCLvf4WeIssFjwB0b6a12opuRP7yo3E3gTCS KmbUuLv1CtxKQF+fUV1cVaTPMyT25Od+RC1K+iOR0F54oUJvJeq7fUzbn/KdlhA8XPGzwGRy 4zcsPWvwnXgfe5tk680fEKZVwOZKIEuJC3v+/yZpQzDvGYJvbyix0lHnrCzq43WefRHI5XTT QbM0WUIBIcGmq38+OgUsMYu4NzLu7uZFAcmp6h8g Organization: Linaro In-Reply-To: <20260917-b4-linux-next-25-03-13-dtsi-x1e80100-camss-v18-2-f85c9103177e@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260917_052954_751270_FB770DFB X-CRM114-Status: GOOD ( 27.34 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Neil Armstrong Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org On 9/17/26 13:07, Bryan O'Donoghue wrote: > Add new function phy_get_by_of_node() allowing lookup of a phy by > device_node. Separates existing logic in _of_phy_get() into an internal > helper method _of_phy_get_with_args() to allow for reuse in new method. > > Signed-off-by: Bryan O'Donoghue > --- > drivers/phy/phy-core.c | 95 +++++++++++++++++++++++++++++++++++++------------ > include/linux/phy/phy.h | 6 ++++ > 2 files changed, 78 insertions(+), 23 deletions(-) > > diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c > index 89addd732bff3..490a7cde6d40a 100644 > --- a/drivers/phy/phy-core.c > +++ b/drivers/phy/phy-core.c > @@ -606,22 +606,51 @@ int phy_validate(struct phy *phy, enum phy_mode mode, int submode, > } > EXPORT_SYMBOL_GPL(phy_validate); > > +/** > + * _of_phy_get_with_args() - lookup and obtain a reference to a phy by of_phandle_args > + * @args: of_phandle_args to the phy > + * > + * Returns the phy from the provider's of_xlate, -ENODEV if disabled, > + * -EPROBE_DEFER if the provider is not yet registered. > + */ > +static struct phy *_of_phy_get_with_args(struct of_phandle_args *args) > +{ > + struct phy *phy; > + struct phy_provider *phy_provider; > + > + lockdep_assert_held(&phy_provider_mutex); > + > + phy_provider = of_phy_provider_lookup(args->np); > + if (IS_ERR(phy_provider) || !try_module_get(phy_provider->owner)) > + return ERR_PTR(-EPROBE_DEFER); > + > + if (!of_device_is_available(args->np)) { > + dev_warn(phy_provider->dev, "Requested PHY is disabled\n"); > + phy = ERR_PTR(-ENODEV); > + goto out_put_module; > + } > + > + phy = phy_provider->of_xlate(phy_provider->dev, args); > + > +out_put_module: > + module_put(phy_provider->owner); > + > + return phy; > +} > + > /** > * _of_phy_get() - lookup and obtain a reference to a phy by phandle > * @np: device_node for which to get the phy > * @index: the index of the phy > * > - * Returns the phy associated with the given phandle value, > - * after getting a refcount to it or -ENODEV if there is no such phy or > - * -EPROBE_DEFER if there is a phandle to the phy, but the device is > - * not yet loaded. This function uses of_xlate call back function provided > - * while registering the phy_provider to find the phy instance. > + * Returns the phy associated with the given phandle value after getting > + * a refcount to it; -ENODEV if there is no such phy or the phy is > + * disabled; -EPROBE_DEFER if the phy provider is not yet available. > */ Why changing the comment here ? You're not supposed to changes the _of_phy_get() behaviour. > static struct phy *_of_phy_get(struct device_node *np, int index) > { > int ret; > - struct phy_provider *phy_provider; > - struct phy *phy = NULL; > + struct phy *phy; > struct of_phandle_args args; > > lockdep_assert_held(&phy_provider_mutex); > @@ -637,22 +666,7 @@ static struct phy *_of_phy_get(struct device_node *np, int index) > goto out_put_node; > } > > - phy_provider = of_phy_provider_lookup(args.np); > - if (IS_ERR(phy_provider) || !try_module_get(phy_provider->owner)) { > - phy = ERR_PTR(-EPROBE_DEFER); > - goto out_put_node; > - } > - > - if (!of_device_is_available(args.np)) { > - dev_warn(phy_provider->dev, "Requested PHY is disabled\n"); > - phy = ERR_PTR(-ENODEV); > - goto out_put_module; > - } > - > - phy = phy_provider->of_xlate(phy_provider->dev, &args); > - > -out_put_module: > - module_put(phy_provider->owner); > + phy = _of_phy_get_with_args(&args); > > out_put_node: > of_node_put(args.np); > @@ -1001,6 +1015,41 @@ struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np, > } > EXPORT_SYMBOL_GPL(devm_of_phy_get_by_index); > > +/** > + * phy_get_by_of_node() - lookup and obtain a reference to a phy by device_node > + * @np: node containing the phy > + * > + * Returns the phy associated with the device node or ERR_PTR. > + */ > +struct phy *phy_get_by_of_node(struct device_node *np) > +{ > + struct of_phandle_args args = { .np = np, .args_count = 0 }; > + struct phy *phy; > + > + if (!np) > + return ERR_PTR(-EINVAL); > + > + mutex_lock(&phy_provider_mutex); > + > + phy = _of_phy_get_with_args(&args); > + > + if (IS_ERR(phy)) > + goto out_unlock; > + > + if (!try_module_get(phy->ops->owner)) { > + phy = ERR_PTR(-EPROBE_DEFER); > + goto out_unlock; > + } > + > + get_device(&phy->dev); > + > +out_unlock: > + mutex_unlock(&phy_provider_mutex); > + > + return phy; > +} > +EXPORT_SYMBOL_GPL(phy_get_by_of_node); > + > /** > * phy_create() - create a new phy > * @dev: device that is creating the new phy > diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h > index ea47975e288ae..71c2e16397130 100644 > --- a/include/linux/phy/phy.h > +++ b/include/linux/phy/phy.h > @@ -284,6 +284,7 @@ struct phy *devm_of_phy_optional_get(struct device *dev, struct device_node *np, > const char *con_id); > struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np, > int index); > +struct phy *phy_get_by_of_node(struct device_node *np); > void of_phy_put(struct phy *phy); > void phy_put(struct device *dev, struct phy *phy); > void devm_phy_put(struct device *dev, struct phy *phy); > @@ -493,6 +494,11 @@ static inline struct phy *devm_of_phy_get_by_index(struct device *dev, > return ERR_PTR(-ENOSYS); > } > > +static inline struct phy *phy_get_by_of_node(struct device_node *np) > +{ > + return ERR_PTR(-ENOSYS); > +} > + > static inline void of_phy_put(struct phy *phy) > { > } > Apart that, looks good: Reviewed-by: Neil Armstrong Thanks, Neil -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy