[PATCH] net/fsl_pq_mdio: fix handling of TBIPA register

Scott Wood scottwood at freescale.com
Wed Aug 7 09:55:00 EST 2013


On Tue, 2013-08-06 at 18:10 -0500, Scott Wood wrote:
> On Thu, 2013-08-01 at 19:49 +0200, Lutz Jaenicke wrote:
> > The TBIPA register is part of gianfar's full register set. When starting
> > from the MII registers, the start address of struct gfar needs to
> > be determined via container_of().
> > Experienced with mpc8313 and "fsl,gianfar-mdio" device tree entries.
> > 
> > Signed-off-by: Lutz Jaenicke <ljaenicke at innominate.com>
> > ---
> >  drivers/net/ethernet/freescale/fsl_pq_mdio.c |    3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/ethernet/freescale/fsl_pq_mdio.c b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
> > index c93a056..9485fdb 100644
> > --- a/drivers/net/ethernet/freescale/fsl_pq_mdio.c
> > +++ b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
> > @@ -193,7 +193,8 @@ static int fsl_pq_mdio_reset(struct mii_bus *bus)
> >   */
> >  static uint32_t __iomem *get_gfar_tbipa(void __iomem *p)
> >  {
> > -	struct gfar __iomem *enet_regs = p;
> > +	struct gfar __iomem *enet_regs = 
> > +		container_of(p, struct gfar, gfar_mii_regs);
> >  
> >  	return &enet_regs->tbipa;
> >  }
> 
> Please send this to the netdev list/maintainer.

Though, do we have any guarantee that p is contained by a "struct gfar"?
It looks like the code of_iomap()s the reg of the mdio node, which is
just the MDIO registers.  Don't access outside that area.

Of course, this register probably *should* be described in the MDIO node
(see http://patchwork.ozlabs.org/patch/250766/), but since it isn't,
we'll need to either find the associated full gianfar device and ask it
to set tbipa, or look up the physical address of tbipa and do a separate
ioremap.  I know that in practice we'll have at least 4K-granular
mappings and thus tbipa will be there, but it's best to avoid such
hacks.

-Scott





More information about the Linuxppc-dev mailing list