[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKxU2N8vW-b-=FpdZdBvakWzEYYhHJyhLDsEs-PJ4gapaxH0ow@mail.gmail.com>
Date: Mon, 21 Oct 2024 14:05:21 -0700
From: Rosen Penev <rosenp@...il.com>
To: Michael Chan <michael.chan@...adcom.com>
Cc: netdev@...r.kernel.org, Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net-next] net: bnxt: use ethtool string helpers
On Mon, Oct 21, 2024 at 1:26 PM Michael Chan <michael.chan@...adcom.com> wrote:
>
> On Sun, Oct 20, 2024 at 7:29 PM Rosen Penev <rosenp@...il.com> wrote:
> >
> > Avoids having to use manual pointer manipulation.
> >
> > Signed-off-by: Rosen Penev <rosenp@...il.com>
> > ---
> > .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 110 ++++++++----------
> > 1 file changed, 50 insertions(+), 60 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
> > index f71cc8188b4e..84d468ad3c8e 100644
> > --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
> > +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
> > @@ -713,18 +713,17 @@ static void bnxt_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
> > for (i = 0; i < bp->cp_nr_rings; i++) {
> > if (is_rx_ring(bp, i)) {
> > num_str = NUM_RING_RX_HW_STATS;
> > - for (j = 0; j < num_str; j++) {
> > - sprintf(buf, "[%d]: %s", i,
> > + for (j = 0; j < num_str; j++)
> > + ethtool_sprintf(
> > + &buf, "[%d]: %s", i,
>
> If you combine this line with the line above, I think it will look better:
>
> ethtool_sprintf(&buf, "[%d]: %s", i,
>
> checkpatch.pl may warn because the next line won't line up, but I
> think it will look better and it reduces the number of lines. The
> same comment applies to other similar spots in the patch. Thanks.
I use git-clang-format for this stuff.
The only real way to satisfy everything is to use a temporary variable like
for (i = 0; i < BNXT_NUM_PORT_STATS; i++) {
const char *str = bnxt_port_stats_arr[i].string;
ethtool_puts(&buf, str);
}
to make everything small.
>
> > bnxt_ring_rx_stats_str[j]);
> > - buf += ETH_GSTRING_LEN;
> > - }
Powered by blists - more mailing lists