lkml.org 
[lkml]   [2009]   [Jun]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2] add MAX17040 Fuel Gauge driver
From
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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2009-06-04 12:57    [W:0.055 / U:0.264 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site