From: Inochi Amaoto <inochiama@gmail.com>
To: "Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Damien Le Moal" <dlemoal@kernel.org>,
"Niklas Cassel" <cassel@kernel.org>,
"Frank Li" <Frank.Li@nxp.com>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
"Aksh Garg" <a-garg7@ti.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Vinod Koul" <vkoul@kernel.org>,
"Neil Armstrong" <neil.armstrong@linaro.org>,
"Inochi Amaoto" <inochiama@gmail.com>,
"Rhys Tumelty" <rhys@tumelty.co.uk>,
"Manikandan K Pillai" <mpillai@cadence.com>,
"vladimir.oltean@nxp.com" <vladimir.oltean@nxp.com>,
"Qiang Yu" <qiang.yu@oss.qualcomm.com>,
"Hans Zhang" <18255117159@163.com>, "Yao Zi" <me@ziyao.cc>
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-ide@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org,
linux-phy@lists.infradead.org, Yixun Lan <dlan@gentoo.org>,
Longbin Li <looong.bin@gmail.com>
Subject: [PATCH v5 1/8] phy: core: Add common helper to add phy phandle device link
Date: Wed, 25 Nov 2026 12:36:32 +0800 [thread overview]
Message-ID: <20261125043639.249525-2-inochiama@gmail.com> (raw)
In-Reply-To: <20261125043639.249525-1-inochiama@gmail.com>
It is very common for adding a device link for phy phandle
for device managed phy helper functions. So add a common
helper for future reuse.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/phy/phy-core.c | 46 ++++++++++++++++++++++++------------------
1 file changed, 26 insertions(+), 20 deletions(-)
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 597e6b234f5e..b7550ca37e66 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -606,6 +606,27 @@ int phy_validate(struct phy *phy, enum phy_mode mode, int submode,
}
EXPORT_SYMBOL_GPL(phy_validate);
+/**
+ * phy_add_device_link() - Associate the phy with the device
+ * @dev: the device consuming the PHY
+ * @phy: the PHY supplied to @dev
+ *
+ * Add a device link with @dev as the consumer and @phy as the
+ * PHY supplier.
+ */
+static void phy_add_device_link(struct device *dev, struct phy *phy)
+{
+ struct device_link *link;
+
+ if (!phy)
+ return;
+
+ link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS);
+ if (!link)
+ dev_dbg(dev, "failed to create device link to %s\n",
+ dev_name(phy->dev.parent));
+}
+
/**
* _of_phy_get_with_args() - lookup and obtain a reference to a phy by of_phandle_args
* @args: of_phandle_args to the phy
@@ -805,7 +826,6 @@ struct phy *phy_get(struct device *dev, const char *string)
{
int index = 0;
struct phy *phy;
- struct device_link *link;
mutex_lock(&phy_provider_mutex);
if (dev->of_node) {
@@ -833,10 +853,7 @@ struct phy *phy_get(struct device *dev, const char *string)
get_device(&phy->dev);
- link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS);
- if (!link)
- dev_dbg(dev, "failed to create device link to %s\n",
- dev_name(phy->dev.parent));
+ phy_add_device_link(dev, phy);
out_unlock:
mutex_unlock(&phy_provider_mutex);
@@ -912,7 +929,6 @@ struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
const char *con_id)
{
struct phy **ptr, *phy;
- struct device_link *link;
ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
@@ -927,10 +943,7 @@ struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
return phy;
}
- link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS);
- if (!link)
- dev_dbg(dev, "failed to create device link to %s\n",
- dev_name(phy->dev.parent));
+ phy_add_device_link(dev, phy);
return phy;
}
@@ -982,7 +995,6 @@ struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
int index)
{
struct phy **ptr, *phy;
- struct device_link *link;
ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
@@ -1006,10 +1018,7 @@ struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
*ptr = phy;
devres_add(dev, ptr);
- link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS);
- if (!link)
- dev_dbg(dev, "failed to create device link to %s\n",
- dev_name(phy->dev.parent));
+ phy_add_device_link(dev, phy);
out_unlock:
mutex_unlock(&phy_provider_mutex);
@@ -1059,7 +1068,6 @@ EXPORT_SYMBOL_GPL(phy_get_by_of_node);
struct phy *devm_phy_get_by_of_node(struct device *dev, struct device_node *np)
{
struct phy **ptr, *phy;
- struct device_link *link;
ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
@@ -1073,10 +1081,8 @@ struct phy *devm_phy_get_by_of_node(struct device *dev, struct device_node *np)
*ptr = phy;
devres_add(dev, ptr);
- link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS);
- if (!link)
- dev_dbg(dev, "failed to create device link to %s\n",
- dev_name(phy->dev.parent));
+
+ phy_add_device_link(dev, phy);
return phy;
}
--
2.56.1
WARNING: multiple messages have this Message-ID (diff)
From: Inochi Amaoto <inochiama@gmail.com>
To: "Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Damien Le Moal" <dlemoal@kernel.org>,
"Niklas Cassel" <cassel@kernel.org>,
"Frank Li" <Frank.Li@nxp.com>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
"Aksh Garg" <a-garg7@ti.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Krzysztof Wilczyński" <kwilczynski@kernel.org>,
"Manivannan Sadhasivam" <mani@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Vinod Koul" <vkoul@kernel.org>,
"Neil Armstrong" <neil.armstrong@linaro.org>,
"Inochi Amaoto" <inochiama@gmail.com>,
"Rhys Tumelty" <rhys@tumelty.co.uk>,
"Manikandan K Pillai" <mpillai@cadence.com>,
"vladimir.oltean@nxp.com" <vladimir.oltean@nxp.com>,
"Qiang Yu" <qiang.yu@oss.qualcomm.com>,
"Hans Zhang" <18255117159@163.com>, "Yao Zi" <me@ziyao.cc>
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-ide@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org,
linux-phy@lists.infradead.org, Yixun Lan <dlan@gentoo.org>,
Longbin Li <looong.bin@gmail.com>
Subject: [PATCH v5 1/8] phy: core: Add common helper to add phy phandle device link
Date: Wed, 25 Nov 2026 12:36:32 +0800 [thread overview]
Message-ID: <20261125043639.249525-2-inochiama@gmail.com> (raw)
In-Reply-To: <20261125043639.249525-1-inochiama@gmail.com>
It is very common for adding a device link for phy phandle
for device managed phy helper functions. So add a common
helper for future reuse.
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/phy/phy-core.c | 46 ++++++++++++++++++++++++------------------
1 file changed, 26 insertions(+), 20 deletions(-)
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index 597e6b234f5e..b7550ca37e66 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -606,6 +606,27 @@ int phy_validate(struct phy *phy, enum phy_mode mode, int submode,
}
EXPORT_SYMBOL_GPL(phy_validate);
+/**
+ * phy_add_device_link() - Associate the phy with the device
+ * @dev: the device consuming the PHY
+ * @phy: the PHY supplied to @dev
+ *
+ * Add a device link with @dev as the consumer and @phy as the
+ * PHY supplier.
+ */
+static void phy_add_device_link(struct device *dev, struct phy *phy)
+{
+ struct device_link *link;
+
+ if (!phy)
+ return;
+
+ link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS);
+ if (!link)
+ dev_dbg(dev, "failed to create device link to %s\n",
+ dev_name(phy->dev.parent));
+}
+
/**
* _of_phy_get_with_args() - lookup and obtain a reference to a phy by of_phandle_args
* @args: of_phandle_args to the phy
@@ -805,7 +826,6 @@ struct phy *phy_get(struct device *dev, const char *string)
{
int index = 0;
struct phy *phy;
- struct device_link *link;
mutex_lock(&phy_provider_mutex);
if (dev->of_node) {
@@ -833,10 +853,7 @@ struct phy *phy_get(struct device *dev, const char *string)
get_device(&phy->dev);
- link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS);
- if (!link)
- dev_dbg(dev, "failed to create device link to %s\n",
- dev_name(phy->dev.parent));
+ phy_add_device_link(dev, phy);
out_unlock:
mutex_unlock(&phy_provider_mutex);
@@ -912,7 +929,6 @@ struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
const char *con_id)
{
struct phy **ptr, *phy;
- struct device_link *link;
ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
@@ -927,10 +943,7 @@ struct phy *devm_of_phy_get(struct device *dev, struct device_node *np,
return phy;
}
- link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS);
- if (!link)
- dev_dbg(dev, "failed to create device link to %s\n",
- dev_name(phy->dev.parent));
+ phy_add_device_link(dev, phy);
return phy;
}
@@ -982,7 +995,6 @@ struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
int index)
{
struct phy **ptr, *phy;
- struct device_link *link;
ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
@@ -1006,10 +1018,7 @@ struct phy *devm_of_phy_get_by_index(struct device *dev, struct device_node *np,
*ptr = phy;
devres_add(dev, ptr);
- link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS);
- if (!link)
- dev_dbg(dev, "failed to create device link to %s\n",
- dev_name(phy->dev.parent));
+ phy_add_device_link(dev, phy);
out_unlock:
mutex_unlock(&phy_provider_mutex);
@@ -1059,7 +1068,6 @@ EXPORT_SYMBOL_GPL(phy_get_by_of_node);
struct phy *devm_phy_get_by_of_node(struct device *dev, struct device_node *np)
{
struct phy **ptr, *phy;
- struct device_link *link;
ptr = devres_alloc(devm_phy_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
@@ -1073,10 +1081,8 @@ struct phy *devm_phy_get_by_of_node(struct device *dev, struct device_node *np)
*ptr = phy;
devres_add(dev, ptr);
- link = device_link_add(dev, &phy->dev, DL_FLAG_STATELESS);
- if (!link)
- dev_dbg(dev, "failed to create device link to %s\n",
- dev_name(phy->dev.parent));
+
+ phy_add_device_link(dev, phy);
return phy;
}
--
2.56.1
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-11-25 4:37 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 4:36 [PATCH v5 0/8] phy: core: Add phy bulk helpers support Inochi Amaoto
2026-11-25 4:36 ` Inochi Amaoto
2026-11-25 4:36 ` Inochi Amaoto [this message]
2026-11-25 4:36 ` [PATCH v5 1/8] phy: core: Add common helper to add phy phandle device link Inochi Amaoto
2026-11-25 4:36 ` [PATCH v5 2/8] phy: core: Add common helper for get phy phandle by index Inochi Amaoto
2026-11-25 4:36 ` Inochi Amaoto
2026-11-25 4:36 ` [PATCH v5 3/8] phy: core: Make phy_put() ignore NULL and error pointers Inochi Amaoto
2026-11-25 4:36 ` Inochi Amaoto
2026-11-25 4:36 ` [PATCH v5 4/8] phy: core: Add phy bulk data helper functions Inochi Amaoto
2026-11-25 4:36 ` Inochi Amaoto
2026-11-25 15:20 ` Vladimir Oltean
2026-11-25 15:20 ` Vladimir Oltean
2026-11-25 4:36 ` [PATCH v5 5/8] phy: core: Add managed " Inochi Amaoto
2026-11-25 4:36 ` Inochi Amaoto
2026-11-25 4:36 ` [PATCH v5 6/8] doc: phy: Document some bulk " Inochi Amaoto
2026-11-25 4:36 ` Inochi Amaoto
2026-11-25 15:28 ` Vladimir Oltean
2026-11-25 15:28 ` Vladimir Oltean
2026-11-25 4:36 ` [PATCH v5 7/8] PCI: cadence: Use phy bulk data api to simplifiy the logic Inochi Amaoto
2026-11-25 4:36 ` Inochi Amaoto
2026-11-25 15:23 ` Vladimir Oltean
2026-11-25 15:23 ` Vladimir Oltean
2026-11-25 4:36 ` [PATCH v5 8/8] ata: ahci_imx: Use bulk PHY APIs for calibration PHYs Inochi Amaoto
2026-11-25 4:36 ` Inochi Amaoto
2026-11-25 15:39 ` Vladimir Oltean
2026-11-25 15:39 ` Vladimir Oltean
2026-11-25 15:56 ` Niklas Cassel
2026-11-25 15:56 ` Niklas Cassel
2026-11-25 22:48 ` Inochi Amaoto
2026-11-25 22:48 ` Inochi Amaoto
2026-11-25 4:50 ` [PATCH v5 0/8] phy: core: Add phy bulk helpers support sashiko-bot
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=20261125043639.249525-2-inochiama@gmail.com \
--to=inochiama@gmail.com \
--cc=18255117159@163.com \
--cc=Frank.Li@nxp.com \
--cc=a-garg7@ti.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bhelgaas@google.com \
--cc=cassel@kernel.org \
--cc=corbet@lwn.net \
--cc=dlan@gentoo.org \
--cc=dlemoal@kernel.org \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=kwilczynski@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=looong.bin@gmail.com \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=me@ziyao.cc \
--cc=mpillai@cadence.com \
--cc=neil.armstrong@linaro.org \
--cc=qiang.yu@oss.qualcomm.com \
--cc=rdunlap@infradead.org \
--cc=rhys@tumelty.co.uk \
--cc=robh@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=skhan@linuxfoundation.org \
--cc=vkoul@kernel.org \
--cc=vladimir.oltean@nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.