[RFC v8 net-next 11/16] net: mscc: ocelot: expose regfield definition to be used by other drivers

Colin Foster colin.foster at in-advantage.com
Mon May 9 17:05:16 PDT 2022


On Mon, May 09, 2022 at 10:56:39AM +0000, Vladimir Oltean wrote:
> On Sun, May 08, 2022 at 11:53:08AM -0700, Colin Foster wrote:
> > The ocelot_regfields struct is common between several different chips, some
> > of which can only be controlled externally. Export this structure so it
> > doesn't have to be duplicated in these other drivers.
> > 
> > Rename the structure as well, to follow the conventions of other shared
> > resources.
> > 
> > Signed-off-by: Colin Foster <colin.foster at in-advantage.com>
> > ---
> 
> Doesn't the symbol need to be actually _exported_ (EXPORT_SYMBOL) to
> work when CONFIG_MSCC_OCELOT_SWITCH_LIB is a module?

Yes. I'll test the module configurations again before future rounds - I
admittedly haven't tested those cases in a while.

> 
> >  drivers/net/ethernet/mscc/ocelot_vsc7514.c | 60 +---------------------
> >  drivers/net/ethernet/mscc/vsc7514_regs.c   | 59 +++++++++++++++++++++
> >  include/soc/mscc/vsc7514_regs.h            |  2 +
> >  3 files changed, 62 insertions(+), 59 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
> > index 68d205088665..a13fec7247d6 100644
> > --- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c
> > +++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c
> > @@ -38,64 +38,6 @@ static const u32 *ocelot_regmap[TARGET_MAX] = {
> >  	[DEV_GMII] = vsc7514_dev_gmii_regmap,
> >  };
> >  
> > -static const struct reg_field ocelot_regfields[REGFIELD_MAX] = {
> > -};
> > -
> >  static const struct ocelot_stat_layout ocelot_stats_layout[] = {
> >  	{ .name = "rx_octets", .offset = 0x00, },
> >  	{ .name = "rx_unicast", .offset = 0x01, },
> > @@ -231,7 +173,7 @@ static int ocelot_chip_init(struct ocelot *ocelot, const struct ocelot_ops *ops)
> >  	ocelot->num_mact_rows = 1024;
> >  	ocelot->ops = ops;
> >  
> > -	ret = ocelot_regfields_init(ocelot, ocelot_regfields);
> > +	ret = ocelot_regfields_init(ocelot, vsc7514_regfields);
> >  	if (ret)
> >  		return ret;
> >  
> > diff --git a/drivers/net/ethernet/mscc/vsc7514_regs.c b/drivers/net/ethernet/mscc/vsc7514_regs.c
> > index c2af4eb8ca5d..847e64d11075 100644
> > --- a/drivers/net/ethernet/mscc/vsc7514_regs.c
> > +++ b/drivers/net/ethernet/mscc/vsc7514_regs.c
> > @@ -9,6 +9,65 @@
> >  #include <soc/mscc/vsc7514_regs.h>
> >  #include "ocelot.h"
> >  
> > +const struct reg_field vsc7514_regfields[REGFIELD_MAX] = {
> > +};
> > +
> >  const u32 vsc7514_ana_regmap[] = {
> >  	REG(ANA_ADVLEARN,				0x009000),
> >  	REG(ANA_VLANMASK,				0x009004),
> > diff --git a/include/soc/mscc/vsc7514_regs.h b/include/soc/mscc/vsc7514_regs.h
> > index ceee26c96959..9b40e7d00ec5 100644
> > --- a/include/soc/mscc/vsc7514_regs.h
> > +++ b/include/soc/mscc/vsc7514_regs.h
> > @@ -10,6 +10,8 @@
> >  
> >  #include <soc/mscc/ocelot_vcap.h>
> >  
> > +extern const struct reg_field vsc7514_regfields[REGFIELD_MAX];
> > +
> >  extern const u32 vsc7514_ana_regmap[];
> >  extern const u32 vsc7514_qs_regmap[];
> >  extern const u32 vsc7514_qsys_regmap[];
> > -- 
> > 2.25.1
> >



More information about the linux-arm-kernel mailing list