[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <02874ECE860811409154E81DA85FBB5882DD21E8@ORSMSX115.amr.corp.intel.com>
Date: Tue, 8 May 2018 17:40:46 +0000
From: "Keller, Jacob E" <jacob.e.keller@...el.com>
To: Joe Perches <joe@...ches.com>,
"Kirsher, Jeffrey T" <jeffrey.t.kirsher@...el.com>,
"davem@...emloft.net" <davem@...emloft.net>
CC: "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"nhorman@...hat.com" <nhorman@...hat.com>,
"sassmann@...hat.com" <sassmann@...hat.com>,
"jogreene@...hat.com" <jogreene@...hat.com>
Subject: RE: [net-next 2/6] fm10k: reduce duplicate fm10k_stat macro code
> -----Original Message-----
> From: netdev-owner@...r.kernel.org [mailto:netdev-owner@...r.kernel.org]
> On Behalf Of Joe Perches
> Sent: Tuesday, May 08, 2018 10:00 AM
> To: Kirsher, Jeffrey T <jeffrey.t.kirsher@...el.com>; davem@...emloft.net
> Cc: Keller, Jacob E <jacob.e.keller@...el.com>; netdev@...r.kernel.org;
> nhorman@...hat.com; sassmann@...hat.com; jogreene@...hat.com
> Subject: Re: [net-next 2/6] fm10k: reduce duplicate fm10k_stat macro code
>
> On Mon, 2018-05-07 at 07:45 -0700, Jeff Kirsher wrote:
> > Share some of the code for setting up fm10k_stat macros by implementing
> > an FM10K_STAT_FIELDS macro which we can use when setting up the type
> > specific macros.
> []
> > diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
> b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
> []
> > @@ -11,12 +11,16 @@ struct fm10k_stats {
> > int stat_offset;
> > };o
> >
> > -#define FM10K_NETDEV_STAT(_net_stat) { \
> > - .stat_string = #_net_stat, \
> > - .sizeof_stat = FIELD_SIZEOF(struct net_device_stats, _net_stat), \
> > - .stat_offset = offsetof(struct net_device_stats, _net_stat) \
> > +#define FM10K_STAT_FIELDS(_type, _name, _stat) { \
> > + .stat_string = _name, \
> > + .sizeof_stat = FIELD_SIZEOF(_type, _stat), \
> > + .stat_offset = offsetof(_type, _stat) \
> > }
> >
> > +/* netdevice statistics */
> > +#define FM10K_NETDEV_STAT(_net_stat) \
> > + FM10K_STAT_FIELDS(struct net_device_stats, #_net_stat, _net_stat)
>
> trivia:
>
> It's somewhat unusual to use # in a macro argument.
> Perhaps this would be slightly easier to understand using __stringify
>
> #define FM10K_NETDEV_STAT(_net_stat) \
> FM10K_STAT_FIELDS(struct net_device_stats, __stringify(_net_stat),
> _net_stat)
Makes sense. Will change.
Thanks,
Jake
Powered by blists - more mailing lists