All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tobias Waldekranz <tobias@waldekranz.com>
To: netdev@vger.kernel.org
Subject: [PATCH 1/2] phylib: support reading the status of a fixed PHY
Date: Thu, 12 Feb 2015 15:12:55 +0100	[thread overview]
Message-ID: <20150212141255.GA12318@gmail.com> (raw)

This makes it possible to check if a PHY is fixed or physical.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
---
 drivers/net/phy/fixed_phy.c | 17 +++++++++++++++++
 include/linux/phy_fixed.h   |  9 +++++++++
 2 files changed, 26 insertions(+)

diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c
index a08a3c7..5575345 100644
--- a/drivers/net/phy/fixed_phy.c
+++ b/drivers/net/phy/fixed_phy.c
@@ -156,6 +156,23 @@ static int fixed_mdio_write(struct mii_bus *bus, int phy_addr, int reg_num,
 	return 0;
 }
 
+const struct fixed_phy_status *fixed_phy_get_status(struct phy_device *phydev)
+{
+	struct fixed_mdio_bus *fmb = &platform_fmb;
+	struct fixed_phy *fp;
+
+	if (!phydev || !phydev->bus || phydev->bus->priv != fmb)
+		return NULL;
+
+	list_for_each_entry(fp, &fmb->phys, node) {
+		if (fp->addr == phydev->addr)
+			return &fp->status;
+	}
+
+	return NULL;
+}
+EXPORT_SYMBOL(fixed_phy_get_status);
+
 /*
  * If something weird is required to be done with link/speed,
  * network driver is able to assign a function to implement this.
diff --git a/include/linux/phy_fixed.h b/include/linux/phy_fixed.h
index 7e75bfe..e783b8d 100644
--- a/include/linux/phy_fixed.h
+++ b/include/linux/phy_fixed.h
@@ -12,6 +12,9 @@ struct fixed_phy_status {
 struct device_node;
 
 #if IS_ENABLED(CONFIG_FIXED_PHY)
+extern const struct fixed_phy_status *fixed_phy_get_status(
+	struct phy_device *phydev);
+
 extern int fixed_phy_add(unsigned int irq, int phy_id,
 			 struct fixed_phy_status *status);
 extern struct phy_device *fixed_phy_register(unsigned int irq,
@@ -22,6 +25,12 @@ extern int fixed_phy_set_link_update(struct phy_device *phydev,
 			int (*link_update)(struct net_device *,
 					   struct fixed_phy_status *));
 #else
+static inline const struct fixed_phy_status *fixed_phy_get_status(
+	struct phy_device *phydev)
+{
+	return NULL;
+};
+
 static inline int fixed_phy_add(unsigned int irq, int phy_id,
 				struct fixed_phy_status *status)
 {
-- 
1.8.4.357.g8d83871.dirty

                 reply	other threads:[~2015-02-12 14:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20150212141255.GA12318@gmail.com \
    --to=tobias@waldekranz.com \
    --cc=netdev@vger.kernel.org \
    /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.