mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jianhui Zhao <zhaojh329@gmail.com>
To: andrew@lunn.ch
Cc: hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jianhui Zhao <zhaojh329@gmail.com>
Subject: [PATCH] net: phy: Add sysfs attribute for PHY c45 identifiers.
Date: Sun, 11 Jun 2023 23:27:43 +0800	[thread overview]
Message-ID: <20230611152743.2158-1-zhaojh329@gmail.com> (raw)

If a phydevice use c45, its phy_id property is always 0, so
this adds a phy_c45_ids sysfs attribute to MDIO devices. This
attribute can be useful when debugging problems related to
phy drivers.

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
---
 drivers/net/phy/phy_device.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 17d0d0555a79..521228792840 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -560,6 +560,29 @@ phy_id_show(struct device *dev, struct device_attribute *attr, char *buf)
 }
 static DEVICE_ATTR_RO(phy_id);
 
+static ssize_t
+phy_c45_ids_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct phy_device *phydev = to_phy_device(dev);
+	const int num_ids = ARRAY_SIZE(phydev->c45_ids.device_ids);
+	int ret = 0;
+	int i;
+
+	if (!phydev->is_c45)
+		return 0;
+
+	for (i = 1; i < num_ids; i++) {
+		if (phydev->c45_ids.device_ids[i] == 0xffffffff)
+			continue;
+
+		ret += sprintf(buf + ret, "%d: 0x%.8lx\n", i,
+			(unsigned long)phydev->c45_ids.device_ids[i]);
+	}
+
+	return ret;
+}
+static DEVICE_ATTR_RO(phy_c45_ids);
+
 static ssize_t
 phy_interface_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
@@ -597,6 +620,7 @@ static DEVICE_ATTR_RO(phy_dev_flags);
 
 static struct attribute *phy_dev_attrs[] = {
 	&dev_attr_phy_id.attr,
+	&dev_attr_phy_c45_ids.attr,
 	&dev_attr_phy_interface.attr,
 	&dev_attr_phy_has_fixups.attr,
 	&dev_attr_phy_dev_flags.attr,
-- 
2.34.1


             reply	other threads:[~2023-06-11 15:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-11 15:27 Jianhui Zhao [this message]
2023-06-11 15:40 ` Andrew Lunn
2023-06-12 14:04 ` Jianhui Zhao
2023-06-12 14:10   ` Andrew Lunn
2023-06-12 15:06   ` Russell King (Oracle)
2023-06-12 15:10     ` Russell King (Oracle)

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=20230611152743.2158-1-zhaojh329@gmail.com \
    --to=zhaojh329@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®