1 From 504bf65931824eda83494e5b5d75686e27ace03e Mon Sep 17 00:00:00 2001
2 From: Ansuel Smith <ansuelsmth@gmail.com>
3 Date: Fri, 14 May 2021 22:59:53 +0200
4 Subject: [PATCH] net: dsa: qca8k: improve qca8k read/write/rmw bus access
6 Put bus in local variable to improve faster access to the mdio bus.
8 Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
9 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
10 Signed-off-by: David S. Miller <davem@davemloft.net>
12 drivers/net/dsa/qca8k.c | 29 ++++++++++++++++-------------
13 1 file changed, 16 insertions(+), 13 deletions(-)
15 --- a/drivers/net/dsa/qca8k.c
16 +++ b/drivers/net/dsa/qca8k.c
17 @@ -142,17 +142,18 @@ qca8k_set_page(struct mii_bus *bus, u16
19 qca8k_read(struct qca8k_priv *priv, u32 reg)
21 + struct mii_bus *bus = priv->bus;
25 qca8k_split_addr(reg, &r1, &r2, &page);
27 - mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
28 + mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
30 - qca8k_set_page(priv->bus, page);
31 - val = qca8k_mii_read32(priv->bus, 0x10 | r2, r1);
32 + qca8k_set_page(bus, page);
33 + val = qca8k_mii_read32(bus, 0x10 | r2, r1);
35 - mutex_unlock(&priv->bus->mdio_lock);
36 + mutex_unlock(&bus->mdio_lock);
40 @@ -160,35 +161,37 @@ qca8k_read(struct qca8k_priv *priv, u32
42 qca8k_write(struct qca8k_priv *priv, u32 reg, u32 val)
44 + struct mii_bus *bus = priv->bus;
47 qca8k_split_addr(reg, &r1, &r2, &page);
49 - mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
50 + mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
52 - qca8k_set_page(priv->bus, page);
53 - qca8k_mii_write32(priv->bus, 0x10 | r2, r1, val);
54 + qca8k_set_page(bus, page);
55 + qca8k_mii_write32(bus, 0x10 | r2, r1, val);
57 - mutex_unlock(&priv->bus->mdio_lock);
58 + mutex_unlock(&bus->mdio_lock);
62 qca8k_rmw(struct qca8k_priv *priv, u32 reg, u32 mask, u32 val)
64 + struct mii_bus *bus = priv->bus;
68 qca8k_split_addr(reg, &r1, &r2, &page);
70 - mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
71 + mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
73 - qca8k_set_page(priv->bus, page);
74 - ret = qca8k_mii_read32(priv->bus, 0x10 | r2, r1);
75 + qca8k_set_page(bus, page);
76 + ret = qca8k_mii_read32(bus, 0x10 | r2, r1);
79 - qca8k_mii_write32(priv->bus, 0x10 | r2, r1, ret);
80 + qca8k_mii_write32(bus, 0x10 | r2, r1, ret);
82 - mutex_unlock(&priv->bus->mdio_lock);
83 + mutex_unlock(&bus->mdio_lock);