[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221129085009.GC25526@pengutronix.de>
Date: Tue, 29 Nov 2022 09:50:09 +0100
From: Oleksij Rempel <o.rempel@...gutronix.de>
To: Arun.Ramadoss@...rochip.com
Cc: olteanv@...il.com, UNGLinuxDriver@...rochip.com,
vivien.didelot@...il.com, andrew@...n.ch, f.fainelli@...il.com,
kuba@...nel.org, edumazet@...gle.com, pabeni@...hat.com,
Woojung.Huh@...rochip.com, davem@...emloft.net,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
kernel@...gutronix.de
Subject: Re: [PATCH v1 10/26] net: dsa: microchip: ksz8: refactor
ksz8_fdb_dump()
On Tue, Nov 29, 2022 at 08:29:47AM +0000, Arun.Ramadoss@...rochip.com wrote:
> Hi Oleksij,
>
> On Mon, 2022-11-28 at 12:59 +0100, Oleksij Rempel wrote:
> > EXTERNAL EMAIL: Do not click links or open attachments unless you
> > know the content is safe
> >
> > After fixing different bugs we can refactor this function:
> > - be paranoid - read only max possibly amount of entries supported by
> > the HW.
> > - pass error values returned by regmap
> >
> > Signed-off-by: Oleksij Rempel <o.rempel@...gutronix.de>
> > ---
> > drivers/net/dsa/microchip/ksz8795.c | 41 ++++++++++++++---------
> > --
> > drivers/net/dsa/microchip/ksz8795_reg.h | 1 +
> > 2 files changed, 24 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/net/dsa/microchip/ksz8795.c
> > b/drivers/net/dsa/microchip/ksz8795.c
> > index 736cf4e54333..308b46bb2ce5 100644
> > --- a/drivers/net/dsa/microchip/ksz8795.c
> > +++ b/drivers/net/dsa/microchip/ksz8795.c
> > @@ -949,26 +949,31 @@ void ksz8_flush_dyn_mac_table(struct ksz_device
> > *dev, int port)
> > int ksz8_fdb_dump(struct ksz_device *dev, int port,
> > dsa_fdb_dump_cb_t *cb, void *data)
> > {
> > - int ret = 0;
> > - u16 i = 0;
> > - u16 entries = 0;
> > - u8 src_port;
> > - u8 mac[ETH_ALEN];
> > + u16 i, entries = 0;
> > + int ret;
> >
> > - do {
> > - ret = ksz8_r_dyn_mac_table(dev, i, mac, &src_port,
> > - &entries);
> > - if (!ret && port == src_port) {
> > - ret = cb(mac, 0, false, data);
> > - if (ret)
> > - break;
> > - }
> > - i++;
> > - } while (i < entries);
> > - if (i >= entries)
> > - ret = 0;
> > + for (i = 0; i < KSZ8_DYN_MAC_ENTRIES; i++) {
> > + u8 mac[ETH_ALEN];
> > + u8 src_port;
>
> Any specific reason for declaring variable within for loop instead of
> outside.
No. It is personal preference to declare variables within the scope where
variable is used.
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Powered by blists - more mailing lists