From: Heiner Kallweit <hkallweit1@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Marek Behun <marek.behun@nic.cz>,
David Miller <davem@davemloft.net>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: [PATCH RFC 2/4] net: phy: allow to bind genphy driver at probe time
Date: Tue, 13 Aug 2019 23:25:31 +0200 [thread overview]
Message-ID: <b066560d-2cc3-2ea5-5233-e63a612c5aa1@gmail.com> (raw)
In-Reply-To: <ac3471d5-deb7-b711-6e74-23f59914758a@gmail.com>
In cases like a fixed phy that is never attached to a net_device we
may want to bind the genphy driver at probe time. Setting a PHY ID of
0xffffffff to bind the genphy driver would fail due to a check in
get_phy_device(). Therefore let's change the PHY ID the genphy driver
binds to to 0xfffffffe. This still shouldn't match any real PHY,
and it will pass the check in get_phy_devcie().
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/phy_device.c | 3 +--
include/linux/phy.h | 4 ++++
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 163295dbc..54f80af31 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -2388,8 +2388,7 @@ void phy_drivers_unregister(struct phy_driver *drv, int n)
EXPORT_SYMBOL(phy_drivers_unregister);
static struct phy_driver genphy_driver = {
- .phy_id = 0xffffffff,
- .phy_id_mask = 0xffffffff,
+ PHY_ID_MATCH_EXACT(GENPHY_ID),
.name = "Generic PHY",
.soft_reset = genphy_no_soft_reset,
.get_features = genphy_read_abilities,
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 5ac7d2137..3b07bce78 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -37,6 +37,10 @@
#define PHY_1000BT_FEATURES (SUPPORTED_1000baseT_Half | \
SUPPORTED_1000baseT_Full)
+#define GENPHY_ID_HIGH 0xffffU
+#define GENPHY_ID_LOW 0xfffeU
+#define GENPHY_ID ((GENPHY_ID_HIGH << 16) | GENPHY_ID_LOW)
+
extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_basic_features) __ro_after_init;
extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_basic_t1_features) __ro_after_init;
extern __ETHTOOL_DECLARE_LINK_MODE_MASK(phy_gbit_features) __ro_after_init;
--
2.22.0
next prev parent reply other threads:[~2019-08-13 21:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-13 21:23 [PATCH RFC 0/4] net: phy: improve fixed_phy / swphy handling Heiner Kallweit
2019-08-13 21:24 ` [PATCH RFC 1/4] net: phy: swphy: emulate register MII_ESTATUS Heiner Kallweit
2019-08-14 15:34 ` Andrew Lunn
2019-08-13 21:25 ` Heiner Kallweit [this message]
2019-08-13 22:53 ` [PATCH RFC 2/4] net: phy: allow to bind genphy driver at probe time Florian Fainelli
2019-08-13 23:02 ` Heiner Kallweit
2019-08-14 16:30 ` Florian Fainelli
2019-08-13 21:26 ` [PATCH RFC 3/4] net: phy: swphy: bind swphy to " Heiner Kallweit
2019-08-13 21:26 ` [PATCH RFC 4/4] net: phy: fixed_phy: let genphy driver set supported and advertised modes Heiner Kallweit
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=b066560d-2cc3-2ea5-5233-e63a612c5aa1@gmail.com \
--to=hkallweit1@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=marek.behun@nic.cz \
--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).