From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>,
mgr@pengutronix.de, rcz@pengutronix.de
Subject: [PATCH 4/6] phy: introduce phy_get_by_index
Date: Thu, 20 Feb 2020 11:01:09 +0100 [thread overview]
Message-ID: <20200220100109.18147-5-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20200220100109.18147-1-a.fatoum@pengutronix.de>
The upstream (v5.6-rc1) device tree node of the stm32mp157c-dk2's OHCI
has a phys property, but not phy-names. We have no API to reference
such a phy easily (passing NULL isn't allowed). Add one.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
drivers/phy/phy-core.c | 14 ++++++++++++++
include/linux/phy/phy.h | 6 ++++++
2 files changed, 20 insertions(+)
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index ad1e8147881b..ff6e35d16060 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -371,3 +371,17 @@ struct phy *phy_optional_get(struct device_d *dev, const char *string)
return phy;
}
+/**
+ * phy_get_by_index() - lookup and obtain a reference to a phy by index.
+ * @dev: device with node that references this phy
+ * @index: index of the phy
+ *
+ * Gets the phy using _of_phy_get()
+ */
+struct phy *phy_get_by_index(struct device_d *dev, int index)
+{
+ if (!dev->device_node)
+ return ERR_PTR(-ENODEV);
+
+ return _of_phy_get(dev->device_node, index);
+}
diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h
index df480d4634ac..8a28b8e068b1 100644
--- a/include/linux/phy/phy.h
+++ b/include/linux/phy/phy.h
@@ -149,6 +149,7 @@ struct phy_provider *__of_phy_provider_register(struct device_d *dev,
struct of_phandle_args *args));
void of_phy_provider_unregister(struct phy_provider *phy_provider);
struct usb_phy *phy_to_usbphy(struct phy *phy);
+struct phy *phy_get_by_index(struct device_d *dev, int index);
#else
static inline int phy_init(struct phy *phy)
{
@@ -247,6 +248,11 @@ static inline struct usb_phy *phy_to_usbphy(struct phy *phy)
return NULL;
}
+static struct phy *phy_get_by_index(struct device_d *dev, int index)
+{
+ return ERR_PTR(-ENODEV);
+}
+
#endif
#endif /* __DRIVERS_PHY_H */
--
2.25.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2020-02-20 10:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-20 10:01 [PATCH 0/6] phy: usb: add support for STM32 usbphyc Ahmad Fatoum
2020-02-20 10:01 ` [PATCH 1/6] regulator: import Linux regulator_bulk API Ahmad Fatoum
2020-02-20 10:01 ` [PATCH 2/6] phy: remove unused init_data parameter Ahmad Fatoum
2020-02-20 10:01 ` [PATCH 3/6] phy: populate existing ->pwr member with phy-supply Ahmad Fatoum
2020-02-20 10:01 ` Ahmad Fatoum [this message]
2020-02-20 10:01 ` [PATCH 5/6] regulator: port over Linux stm32 PWR regulator driver Ahmad Fatoum
2020-02-20 10:01 ` [PATCH 6/6] phy: port over Linux stm32 usbphyc driver Ahmad Fatoum
2020-02-25 8:11 ` [PATCH 0/6] phy: usb: add support for STM32 usbphyc Sascha Hauer
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=20200220100109.18147-5-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=mgr@pengutronix.de \
--cc=rcz@pengutronix.de \
/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