[U-Boot] [PATCH] smc911x driver: cleanup smc911x_initialize()

Ben Warren biggerbadderben at gmail.com
Fri Jan 22 08:36:41 CET 2010


Hi Matthias,

On Thu, Jan 21, 2010 at 10:18 PM, Matthias Kaehlcke
<matthias at kaehlcke.net>wrote:

> hi mike,
>
> El Thu, Jan 21, 2010 at 06:01:47PM -0500 Mike Frysinger ha dit:
>
> > On Thursday 21 January 2010 16:29:24 Matthias Kaehlcke wrote:
> > > smc911x_initialize(): remove unecessary call to free() and
> > > return 0 in case of failure instead of -1
> > >
> > > Signed-off-by: Matthias Kaehlcke <matthias at kaehlcke.net>
> > > ---
> > >  drivers/net/smc911x.c |    3 +--
> > >  1 files changed, 1 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
> > > index 5d51406..f2b5895 100644
> > > --- a/drivers/net/smc911x.c
> > > +++ b/drivers/net/smc911x.c
> > > @@ -242,8 +242,7 @@ int smc911x_initialize(u8 dev_num, int base_addr)
> > >
> > >     dev = malloc(sizeof(*dev));
> > >     if (!dev) {
> > > -           free(dev);
> >
> > OK
> >
> > > -           return -1;
> > > +           return 0;
> >
> > this is an error path, so i think -1 is correct.  if you're out of
> memory,
> > increase your malloc region.
>
> that's what I thought in the first place, but Ben Warren told me that
> in the initialize function the return value indicates the number of
> devices that were initialized (see
> http://lists.denx.de/pipermail/u-boot/2010-January/066859.html)
>
> I agree that this is confusing.  If the following xxx_eth_initialize()
return codes seem reasonable, I'll send a patch tomorrow that applies it to
the logic in net/eth.c:

-2: reserved (magic value, used to return from __def_eth_init())
-1: error
0: no devices added, no error
1+: number of devices added

best regards
>
> --
> Matthias Kaehlcke
> Embedded Linux Developer
> Barcelona
>
> regards,
Ben


More information about the U-Boot mailing list