715-18-v6.5-net-phylink-require-supported_interfaces-to-be-fille.patch 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. From 441e1e44301fc5762a06737f8ec04bf1ce3fb039 Mon Sep 17 00:00:00 2001
  2. From: "Russell King (Oracle)" <[email protected]>
  3. Date: Sat, 20 May 2023 11:41:42 +0100
  4. Subject: [PATCH 16/21] net: phylink: require supported_interfaces to be filled
  5. We have been requiring the supported_interfaces bitmap to be filled in
  6. by MAC drivers that have a mac_select_pcs() method. Now that all MAC
  7. drivers fill in the supported_interfaces bitmap, it is time to enforce
  8. this. We have already required supported_interfaces to be set in order
  9. for optical SFPs to be configured in commit f81fa96d8a6c ("net: phylink:
  10. use phy_interface_t bitmaps for optical modules").
  11. Refuse phylink creation if supported_interfaces is empty, and remove
  12. code to deal with cases where this mask is empty.
  13. Signed-off-by: Russell King (Oracle) <[email protected]>
  14. Reviewed-by: Andrew Lunn <[email protected]>
  15. Link: https://lore.kernel.org/r/[email protected]
  16. Signed-off-by: Jakub Kicinski <[email protected]>
  17. ---
  18. drivers/net/phy/phylink.c | 26 +++++++++++---------------
  19. 1 file changed, 11 insertions(+), 15 deletions(-)
  20. --- a/drivers/net/phy/phylink.c
  21. +++ b/drivers/net/phy/phylink.c
  22. @@ -710,14 +710,11 @@ static int phylink_validate(struct phyli
  23. {
  24. const unsigned long *interfaces = pl->config->supported_interfaces;
  25. - if (!phy_interface_empty(interfaces)) {
  26. - if (state->interface == PHY_INTERFACE_MODE_NA)
  27. - return phylink_validate_mask(pl, supported, state,
  28. - interfaces);
  29. + if (state->interface == PHY_INTERFACE_MODE_NA)
  30. + return phylink_validate_mask(pl, supported, state, interfaces);
  31. - if (!test_bit(state->interface, interfaces))
  32. - return -EINVAL;
  33. - }
  34. + if (!test_bit(state->interface, interfaces))
  35. + return -EINVAL;
  36. return phylink_validate_mac_and_pcs(pl, supported, state);
  37. }
  38. @@ -1512,19 +1509,18 @@ struct phylink *phylink_create(struct ph
  39. struct phylink *pl;
  40. int ret;
  41. - if (mac_ops->mac_select_pcs &&
  42. - mac_ops->mac_select_pcs(config, PHY_INTERFACE_MODE_NA) !=
  43. - ERR_PTR(-EOPNOTSUPP))
  44. - using_mac_select_pcs = true;
  45. -
  46. /* Validate the supplied configuration */
  47. - if (using_mac_select_pcs &&
  48. - phy_interface_empty(config->supported_interfaces)) {
  49. + if (phy_interface_empty(config->supported_interfaces)) {
  50. dev_err(config->dev,
  51. - "phylink: error: empty supported_interfaces but mac_select_pcs() method present\n");
  52. + "phylink: error: empty supported_interfaces\n");
  53. return ERR_PTR(-EINVAL);
  54. }
  55. + if (mac_ops->mac_select_pcs &&
  56. + mac_ops->mac_select_pcs(config, PHY_INTERFACE_MODE_NA) !=
  57. + ERR_PTR(-EOPNOTSUPP))
  58. + using_mac_select_pcs = true;
  59. +
  60. pl = kzalloc(sizeof(*pl), GFP_KERNEL);
  61. if (!pl)
  62. return ERR_PTR(-ENOMEM);