[PATCH 7/7] smm911x: check if the device is ready before using it
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Wed Aug 29 04:35:07 EDT 2012
On 08:53 Wed 29 Aug , Sascha Hauer wrote:
> On Wed, Aug 29, 2012 at 07:06:18AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > poll the READY bit in PMT_CTRL. Any other access to the device is
> > forbidden while this bit isn't set. Try for 100ms
> >
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
> > ---
> > drivers/net/smc911x.c | 12 ++++++++++++
> > 1 file changed, 12 insertions(+)
> >
> > diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
> > index cfcd83f..3695d32 100644
> > --- a/drivers/net/smc911x.c
> > +++ b/drivers/net/smc911x.c
> > @@ -422,6 +422,7 @@ static int smc911x_probe(struct device_d *dev)
> > uint32_t val;
> > int is_32bit;
> > struct smc911x_plat *pdata = dev->platform_data;
> > + unsigned int to = 100;
> >
> > priv = xzalloc(sizeof(*priv));
> > is_32bit = dev->resource[0].flags & IORESOURCE_MEM_TYPE_MASK;
> > @@ -452,6 +453,17 @@ static int smc911x_probe(struct device_d *dev)
> > }
> > }
> >
> > + /*
> > + * poll the READY bit in PMT_CTRL. Any other access to the device is
> > + * forbidden while this bit isn't set. Try for 100ms
> > + */
> > + while (!(smc911x_reg_read(priv, PMT_CTRL) & PMT_CTRL_READY) && --to)
> > + udelay(1000);
>
> please use a regular timeout loop
code from the kernel I prefer to keep it as it
Best Regards,
J.
More information about the barebox
mailing list