Re: [PATCH v2] add MAX17040 Fuel Gauge driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux