Re: [PATCH v2] add MAX17040 Fuel Gauge driver

From: Minkyu Kang
Date: Thu Jun 04 2009 - 06:55:30 EST


Dear, Jean Delvare

>
> In case of error, this will wrap the error code into a u8 and the
> caller won't notice. So you'll return a random value, depending on the
> actual error which happened. No good.
>
> You should either return an int there, and have the caller check for
> errors, or if you don't want to care about errors, return an arbitrary
> value on error (e.g. 0.)
>

Yes, I missed it.

>> > +       ret = power_supply_register(&client->dev, &bat_ps);
>> > +       if (ret) {
>> > +               dev_err(&max17040->client->dev,
>> > +                               "failed: power supply register\n");
>> > +               cancel_delayed_work(&chip->work);
>> > +               i2c_set_clientdata(client, NULL);
>> > +               kfree(chip);
>> > +               max17040 = NULL;
>> > +               return -1;
>
> Please come up with a better error code.
>

Ok, many thanks :)

--
from. prom.
promsoft.net
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/