Re: [RFC PATCH v7 13/16] net: dsa: qca8k: move page cache to driver priv
From: Ansuel Smith
Date: Tue Feb 01 2022 - 16:39:45 EST
On Tue, Jan 25, 2022 at 07:50:47PM -0800, Florian Fainelli wrote:
>
>
> 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@xxxxxxxxx>
> > ---
> > 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
I just checked this and no. The priv bus we have in qca8k_set_page,
points to the mdio ipq8064 priv struct. (or the gpio-bitbang driver I
assume)
> 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.
Should we change the function to provide qca8k_priv directly? Or I just
didn't understand your suggestion on how we can reduce the changes in
this patch.
> --
> Florian
--
Ansuel