790-05-v6.4-net-dsa-mt7530-use-unlocked-regmap-accessors.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. From efb41b8e9b7bbb08ace1930373bff63d4f5cc6e2 Mon Sep 17 00:00:00 2001
  2. From: Daniel Golle <[email protected]>
  3. Date: Mon, 3 Apr 2023 02:17:40 +0100
  4. Subject: [PATCH 05/48] net: dsa: mt7530: use unlocked regmap accessors
  5. Instead of wrapping the locked register accessor functions, use the
  6. unlocked variants and add locking wrapper functions to let regmap
  7. handle the locking.
  8. This is a preparation towards being able to always use regmap to
  9. access switch registers instead of open-coded accessor functions.
  10. Signed-off-by: Daniel Golle <[email protected]>
  11. Reviewed-by: Andrew Lunn <[email protected]>
  12. Signed-off-by: David S. Miller <[email protected]>
  13. ---
  14. drivers/net/dsa/mt7530.c | 23 ++++++++++++++---------
  15. 1 file changed, 14 insertions(+), 9 deletions(-)
  16. --- a/drivers/net/dsa/mt7530.c
  17. +++ b/drivers/net/dsa/mt7530.c
  18. @@ -2974,7 +2974,7 @@ static int mt7530_regmap_read(void *cont
  19. {
  20. struct mt7530_priv *priv = context;
  21. - *val = mt7530_read(priv, reg);
  22. + *val = mt7530_mii_read(priv, reg);
  23. return 0;
  24. };
  25. @@ -2982,23 +2982,25 @@ static int mt7530_regmap_write(void *con
  26. {
  27. struct mt7530_priv *priv = context;
  28. - mt7530_write(priv, reg, val);
  29. + mt7530_mii_write(priv, reg, val);
  30. return 0;
  31. };
  32. -static int mt7530_regmap_update_bits(void *context, unsigned int reg,
  33. - unsigned int mask, unsigned int val)
  34. +static void
  35. +mt7530_mdio_regmap_lock(void *mdio_lock)
  36. {
  37. - struct mt7530_priv *priv = context;
  38. + mutex_lock_nested(mdio_lock, MDIO_MUTEX_NESTED);
  39. +}
  40. - mt7530_rmw(priv, reg, mask, val);
  41. - return 0;
  42. -};
  43. +static void
  44. +mt7530_mdio_regmap_unlock(void *mdio_lock)
  45. +{
  46. + mutex_unlock(mdio_lock);
  47. +}
  48. static const struct regmap_bus mt7531_regmap_bus = {
  49. .reg_write = mt7530_regmap_write,
  50. .reg_read = mt7530_regmap_read,
  51. - .reg_update_bits = mt7530_regmap_update_bits,
  52. };
  53. static int
  54. @@ -3024,6 +3026,9 @@ mt7531_create_sgmii(struct mt7530_priv *
  55. mt7531_pcs_config[i]->reg_stride = 4;
  56. mt7531_pcs_config[i]->reg_base = MT7531_SGMII_REG_BASE(5 + i);
  57. mt7531_pcs_config[i]->max_register = 0x17c;
  58. + mt7531_pcs_config[i]->lock = mt7530_mdio_regmap_lock;
  59. + mt7531_pcs_config[i]->unlock = mt7530_mdio_regmap_unlock;
  60. + mt7531_pcs_config[i]->lock_arg = &priv->bus->mdio_lock;
  61. regmap = devm_regmap_init(priv->dev,
  62. &mt7531_regmap_bus, priv,