forked from Openwrt/openwrt
d40756563c
Let's pick a bunch of useful phylink changes which allow us to keep drivers in sync with mainline Linux. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
72 lines
2.6 KiB
Diff
72 lines
2.6 KiB
Diff
From 441e1e44301fc5762a06737f8ec04bf1ce3fb039 Mon Sep 17 00:00:00 2001
|
|
From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
|
|
Date: Sat, 20 May 2023 11:41:42 +0100
|
|
Subject: [PATCH 16/21] net: phylink: require supported_interfaces to be filled
|
|
|
|
We have been requiring the supported_interfaces bitmap to be filled in
|
|
by MAC drivers that have a mac_select_pcs() method. Now that all MAC
|
|
drivers fill in the supported_interfaces bitmap, it is time to enforce
|
|
this. We have already required supported_interfaces to be set in order
|
|
for optical SFPs to be configured in commit f81fa96d8a6c ("net: phylink:
|
|
use phy_interface_t bitmaps for optical modules").
|
|
|
|
Refuse phylink creation if supported_interfaces is empty, and remove
|
|
code to deal with cases where this mask is empty.
|
|
|
|
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
|
|
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
|
Link: https://lore.kernel.org/r/E1q0K1u-006EIP-ET@rmk-PC.armlinux.org.uk
|
|
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
|
---
|
|
drivers/net/phy/phylink.c | 26 +++++++++++---------------
|
|
1 file changed, 11 insertions(+), 15 deletions(-)
|
|
|
|
--- a/drivers/net/phy/phylink.c
|
|
+++ b/drivers/net/phy/phylink.c
|
|
@@ -710,14 +710,11 @@ static int phylink_validate(struct phyli
|
|
{
|
|
const unsigned long *interfaces = pl->config->supported_interfaces;
|
|
|
|
- if (!phy_interface_empty(interfaces)) {
|
|
- if (state->interface == PHY_INTERFACE_MODE_NA)
|
|
- return phylink_validate_mask(pl, supported, state,
|
|
- interfaces);
|
|
+ if (state->interface == PHY_INTERFACE_MODE_NA)
|
|
+ return phylink_validate_mask(pl, supported, state, interfaces);
|
|
|
|
- if (!test_bit(state->interface, interfaces))
|
|
- return -EINVAL;
|
|
- }
|
|
+ if (!test_bit(state->interface, interfaces))
|
|
+ return -EINVAL;
|
|
|
|
return phylink_validate_mac_and_pcs(pl, supported, state);
|
|
}
|
|
@@ -1512,19 +1509,18 @@ struct phylink *phylink_create(struct ph
|
|
struct phylink *pl;
|
|
int ret;
|
|
|
|
- if (mac_ops->mac_select_pcs &&
|
|
- mac_ops->mac_select_pcs(config, PHY_INTERFACE_MODE_NA) !=
|
|
- ERR_PTR(-EOPNOTSUPP))
|
|
- using_mac_select_pcs = true;
|
|
-
|
|
/* Validate the supplied configuration */
|
|
- if (using_mac_select_pcs &&
|
|
- phy_interface_empty(config->supported_interfaces)) {
|
|
+ if (phy_interface_empty(config->supported_interfaces)) {
|
|
dev_err(config->dev,
|
|
- "phylink: error: empty supported_interfaces but mac_select_pcs() method present\n");
|
|
+ "phylink: error: empty supported_interfaces\n");
|
|
return ERR_PTR(-EINVAL);
|
|
}
|
|
|
|
+ if (mac_ops->mac_select_pcs &&
|
|
+ mac_ops->mac_select_pcs(config, PHY_INTERFACE_MODE_NA) !=
|
|
+ ERR_PTR(-EOPNOTSUPP))
|
|
+ using_mac_select_pcs = true;
|
|
+
|
|
pl = kzalloc(sizeof(*pl), GFP_KERNEL);
|
|
if (!pl)
|
|
return ERR_PTR(-ENOMEM);
|