netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nathaniel Case <ncase@xes-inc.com>
To: Andy Fleming <afleming@freescale.com>
Cc: netdev@vger.kernel.org, Jeff Garzik <jeff@garzik.org>,
	galak@kernel.crashing.org
Subject: [PATCH 1/2] PHYLIB: Add get_link ethtool helper function
Date: Mon, 05 Jun 2006 18:48:12 -0500	[thread overview]
Message-ID: <1149551292.10700.47.camel@localhost.localdomain> (raw)

This adds a phy_ethtool_get_link() function along the same lines as
phy_ethtool_gset().  This provides drivers utilizing PHYLIB an
alternative to using ethtool_op_get_link().  This is more desirable
since the "Link detected" field in ethtool would actually reflect the
state of the PHY register.

Patch depends on previous patch (0/2).

Signed-off-by: Nate Case <ncase@xes-inc.com>
Signed-off-by: Andy Fleming <afleming@freescale.com>

---

--- a/drivers/net/phy/phy.c	2006-06-04 16:01:59.000000000 -0500
+++ b/drivers/net/phy/phy.c	2006-06-05 10:55:31.000000000 -0500
@@ -301,6 +301,22 @@
 	return 0;
 }
 
+/* 
+ * phy_ethtool_get_link:
+ * A generic ethtool get_link function which is more accurate than
+ * the network interface carrier status since it queries the
+ * PHY directly.
+ */
+u32 phy_ethtool_get_link(struct phy_device *phydev)
+{
+	int err;
+
+	err = genphy_update_link(phydev);
+	if (err)
+		return 0;
+
+	return (u32) phydev->link;
+}
 
 /* Note that this function is currently incompatible with the
  * PHYCONTROL layer.  It changes registers without regard to
--- a/include/linux/phy.h	2006-06-05 11:33:59.000000000 -0500
+++ b/include/linux/phy.h	2006-06-04 19:31:51.000000000 -0500
@@ -374,6 +374,7 @@
 void phy_stop_machine(struct phy_device *phydev);
 int phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd);
 int phy_ethtool_gset(struct phy_device *phydev, struct ethtool_cmd *cmd);
+u32 phy_ethtool_get_link(struct phy_device *phydev);
 int phy_mii_ioctl(struct phy_device *phydev,
 		struct mii_ioctl_data *mii_data, int cmd);
 int phy_start_interrupts(struct phy_device *phydev);




             reply	other threads:[~2006-06-05 23:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-05 23:48 Nathaniel Case [this message]
2006-06-11 16:13 ` [PATCH 1/2] PHYLIB: Add get_link ethtool helper function Jeff Garzik
2006-06-12 16:12   ` Nathaniel Case

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=1149551292.10700.47.camel@localhost.localdomain \
    --to=ncase@xes-inc.com \
    --cc=afleming@freescale.com \
    --cc=galak@kernel.crashing.org \
    --cc=jeff@garzik.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).