gpio-nct5104d: fix compilation with kernel 6.6
[openwrt/openwrt.git] / target / linux / generic / backport-6.1 / 790-v6.4-0003-net-dsa-mt7530-use-unlocked-regmap-accessors.patch
1 From 33396408776385f3d2f6069646169a6b5b28e3b3 Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Mon, 3 Apr 2023 02:17:40 +0100
4 Subject: [PATCH 03/13] net: dsa: mt7530: use unlocked regmap accessors
5
6 Instead of wrapping the locked register accessor functions, use the
7 unlocked variants and add locking wrapper functions to let regmap
8 handle the locking.
9
10 This is a preparation towards being able to always use regmap to
11 access switch registers instead of open-coded accessor functions.
12
13 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
14 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
15 Signed-off-by: David S. Miller <davem@davemloft.net>
16 ---
17 drivers/net/dsa/mt7530.c | 23 ++++++++++++++---------
18 1 file changed, 14 insertions(+), 9 deletions(-)
19
20 --- a/drivers/net/dsa/mt7530.c
21 +++ b/drivers/net/dsa/mt7530.c
22 @@ -2941,7 +2941,7 @@ static int mt7530_regmap_read(void *cont
23 {
24 struct mt7530_priv *priv = context;
25
26 - *val = mt7530_read(priv, reg);
27 + *val = mt7530_mii_read(priv, reg);
28 return 0;
29 };
30
31 @@ -2949,23 +2949,25 @@ static int mt7530_regmap_write(void *con
32 {
33 struct mt7530_priv *priv = context;
34
35 - mt7530_write(priv, reg, val);
36 + mt7530_mii_write(priv, reg, val);
37 return 0;
38 };
39
40 -static int mt7530_regmap_update_bits(void *context, unsigned int reg,
41 - unsigned int mask, unsigned int val)
42 +static void
43 +mt7530_mdio_regmap_lock(void *mdio_lock)
44 {
45 - struct mt7530_priv *priv = context;
46 + mutex_lock_nested(mdio_lock, MDIO_MUTEX_NESTED);
47 +}
48
49 - mt7530_rmw(priv, reg, mask, val);
50 - return 0;
51 -};
52 +static void
53 +mt7530_mdio_regmap_unlock(void *mdio_lock)
54 +{
55 + mutex_unlock(mdio_lock);
56 +}
57
58 static const struct regmap_bus mt7531_regmap_bus = {
59 .reg_write = mt7530_regmap_write,
60 .reg_read = mt7530_regmap_read,
61 - .reg_update_bits = mt7530_regmap_update_bits,
62 };
63
64 static int
65 @@ -2991,6 +2993,9 @@ mt7531_create_sgmii(struct mt7530_priv *
66 mt7531_pcs_config[i]->reg_stride = 4;
67 mt7531_pcs_config[i]->reg_base = MT7531_SGMII_REG_BASE(5 + i);
68 mt7531_pcs_config[i]->max_register = 0x17c;
69 + mt7531_pcs_config[i]->lock = mt7530_mdio_regmap_lock;
70 + mt7531_pcs_config[i]->unlock = mt7530_mdio_regmap_unlock;
71 + mt7531_pcs_config[i]->lock_arg = &priv->bus->mdio_lock;
72
73 regmap = devm_regmap_init(priv->dev,
74 &mt7531_regmap_bus, priv,