Re: [PATCH net-next] net: intel: use ethtool string helpers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 24, 2024 at 9:06 PM Przemek Kitszel
<przemyslaw.kitszel@xxxxxxxxx> wrote:
>
> On 10/24/24 21:56, Rosen Penev wrote:
> > The latter is the preferred way to copy ethtool strings.
> >
> > Avoids manually incrementing the pointer. Cleans up the code quite well.
>
> Indeed, thanks a lot!
>
> Could you please tag next version as [iwl-next], so it will be easier to
> via Tony's tree first?
message awaits moderator approval.
>
> Codewise it's good, just one nitpick from me.
>
> >
> > Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
> > ---
> >   .../net/ethernet/intel/e1000/e1000_ethtool.c  | 10 ++---
> >   drivers/net/ethernet/intel/e1000e/ethtool.c   | 14 +++----
> >   .../net/ethernet/intel/fm10k/fm10k_ethtool.c  | 12 +++---
> >   .../net/ethernet/intel/i40e/i40e_ethtool.c    |  8 ++--
> >   drivers/net/ethernet/intel/ice/ice_ethtool.c  | 37 +++++++++++--------
> >   drivers/net/ethernet/intel/igb/igb_ethtool.c  | 35 ++++++++++--------
> >   drivers/net/ethernet/intel/igbvf/ethtool.c    | 10 ++---
> >   drivers/net/ethernet/intel/igc/igc_ethtool.c  | 36 +++++++++---------
> >   .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c  | 32 ++++++++--------
> >   drivers/net/ethernet/intel/ixgbevf/ethtool.c  | 36 +++++++-----------
> >   10 files changed, 119 insertions(+), 111 deletions(-)
> >
>
> [..]
>
> > --- a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
> > +++ b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
> > @@ -122,7 +122,7 @@ static const char fm10k_gstrings_test[][ETH_GSTRING_LEN] = {
> >       "Mailbox test (on/offline)"
> >   };
> >
> > -#define FM10K_TEST_LEN (sizeof(fm10k_gstrings_test) / ETH_GSTRING_LEN)
> > +#define FM10K_TEST_LEN ARRAY_SIZE(fm10k_gstrings_test)
>
> this line is not strictly related to the stated goal of the commit,
> fine anyway for me
I use grep ETH_GSTRING_LEN to find opportunities for these changes,
hence why I changed.
>
> >
> >   enum fm10k_self_test_types {
> >       FM10K_TEST_MBX,
> > @@ -180,17 +180,19 @@ static void fm10k_get_stat_strings(struct net_device *dev, u8 *data)
> >   static void fm10k_get_strings(struct net_device *dev,
> >                             u32 stringset, u8 *data)
> >   {
> > +     int i;
> > +
> >       switch (stringset) {
> >       case ETH_SS_TEST:
> > -             memcpy(data, fm10k_gstrings_test,
> > -                    FM10K_TEST_LEN * ETH_GSTRING_LEN);
> > +             for (i = 0; i < FM10K_TEST_LEN; i++)
>
> for new code we put the iterator declaration into the loop, do:
>                 for (int i = 0; ...
>
> ditto other places/drivers
I changed the places where I had + int i;

I kept every other place as is.
>
> > +                     ethtool_puts(&data, fm10k_gstrings_test[i]);
> >               break;
> >       case ETH_SS_STATS:
> >               fm10k_get_stat_strings(dev, data);
> >               break;
> >       case ETH_SS_PRIV_FLAGS:
> > -             memcpy(data, fm10k_prv_flags,
> > -                    FM10K_PRV_FLAG_LEN * ETH_GSTRING_LEN);
> > +             for (i = 0; i < FM10K_PRV_FLAG_LEN; i++)
> > +                     ethtool_puts(&data, fm10k_prv_flags[i]);
> >               break;
> >       }
> >   }
>





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux