From: yuan linyu <cugyly@163.com>
To: Florian Fainelli <f.fainelli@gmail.com>,
"David S . Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
Subject: [PATCH] net: add regs attribute to phy device for user diagnose
Date: Sat, 14 Jan 2017 10:46:31 +0800 [thread overview]
Message-ID: <1484361992-30591-1-git-send-email-cugyly@163.com> (raw)
From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
if phy device have register(s) configuration problem,
user can use this attribute to diagnose.
this feature need phy driver maintainer implement.
Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
---
drivers/net/phy/phy_device.c | 26 ++++++++++++++++++++++++++
include/linux/phy.h | 4 ++++
2 files changed, 30 insertions(+)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 92b0838..a400748 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -617,10 +617,36 @@ phy_has_fixups_show(struct device *dev, struct device_attribute *attr,
}
static DEVICE_ATTR_RO(phy_has_fixups);
+static ssize_t
+phy_regs_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct phy_device *phydev = to_phy_device(dev);
+
+ if (!phydev->drv || !phydev->drv->read_regs)
+ return 0;
+
+ return phydev->drv->read_regs(phydev, buf, PAGE_SIZE);
+}
+
+static ssize_t
+phy_regs_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct phy_device *phydev = to_phy_device(dev);
+
+ if (!phydev->drv || !phydev->drv->write_regs)
+ return 0;
+
+ return phydev->drv->write_regs(phydev, buf, count);
+}
+static DEVICE_ATTR_RW(phy_regs);
+
static struct attribute *phy_dev_attrs[] = {
&dev_attr_phy_id.attr,
&dev_attr_phy_interface.attr,
&dev_attr_phy_has_fixups.attr,
+ &dev_attr_phy_regs.attr,
NULL,
};
ATTRIBUTE_GROUPS(phy_dev);
diff --git a/include/linux/phy.h b/include/linux/phy.h
index f7d95f6..c9c4ab3 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -622,6 +622,10 @@ struct phy_driver {
int (*set_tunable)(struct phy_device *dev,
struct ethtool_tunable *tuna,
const void *data);
+
+ /* Diagnose PHY register configuration issue from user space */
+ ssize_t (*read_regs)(struct phy_device *dev, char *buf, size_t size);
+ int (*write_regs)(struct phy_device *dev, const char *buf, size_t size);
};
#define to_phy_driver(d) container_of(to_mdio_common_driver(d), \
struct phy_driver, mdiodrv)
--
2.7.4
next reply other threads:[~2017-01-14 2:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-14 2:46 yuan linyu [this message]
2017-01-14 16:24 ` [PATCH] net: add regs attribute to phy device for user diagnose Andrew Lunn
2017-01-14 18:35 ` Florian Fainelli
2017-01-15 1:51 ` yuan linyu
2017-01-15 1:57 ` Florian Fainelli
2017-01-15 10:40 ` yuan linyu
2017-01-15 17:21 ` Andrew Lunn
2017-01-16 12:59 ` yuan linyu
2017-01-16 20:22 ` Florian Fainelli
2017-01-16 21:54 ` David Miller
2017-01-17 0:11 ` YUAN Linyu
2017-01-18 12:37 ` Zefir Kurtisi
2017-01-19 0:45 ` YUAN Linyu
2017-01-19 1:01 ` Andrew Lunn
2017-02-11 3:48 ` yuan linyu
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=1484361992-30591-1-git-send-email-cugyly@163.com \
--to=cugyly@163.com \
--cc=Linyu.Yuan@alcatel-sbell.com.cn \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.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 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).