Re: [RFC PATCH v7 13/16] net: dsa: qca8k: move page cache to driver priv

Florian Fainelli
2022-01-26T03:50:51Z

On 1/22/2022 5:33 PM, Ansuel Smith wrote:
> There can be multiple qca8k switch on the same system. Move the static
> qca8k_current_page to qca8k_priv and make it specific for each switch.
>
> Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
> ---
> drivers/net/dsa/qca8k.c | 47 +++++++++++++++++++++++------------------
> drivers/net/dsa/qca8k.h | 9 ++++++++
> 2 files changed, 36 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
> index e7bc0770bae9..c2f5414033d8 100644
> --- a/drivers/net/dsa/qca8k.c
> +++ b/drivers/net/dsa/qca8k.c
> @@ -75,12 +75,6 @@ static const struct qca8k_mib_desc ar8327_mib[] = {
> MIB_DESC(1, 0xac, "TXUnicast"),
> };
>
> -/* The 32bit switch registers are accessed indirectly. To achieve this we need
> - * to set the page of the register. Track the last page that was set to reduce
> - * mdio writes
> - */
> -static u16 qca8k_current_page = 0xffff;
> -
> static void
> qca8k_split_addr(u32 regaddr, u16 *r1, u16 *r2, u16 *page)
> {
> @@ -134,11 +128,11 @@ qca8k_mii_write32(struct mii_bus *bus, int phy_id, u32 regnum, u32 val)
> }
>
> static int
> -qca8k_set_page(struct mii_bus *bus, u16 page)
> +qca8k_set_page(struct mii_bus *bus, u16 page, u16 *cached_page)
> {

bus->priv is assigned a qca8k_priv pointer, so we can just de-reference
it here from bus->priv and avoid changing a whole bunch of function
signatures that are now getting both a qca8k_priv *and* a
qca8k_mdio_cache set of pointers when you can just use back pointers to
those.
--
Florian