lkml.org 
[lkml]   [2020]   [Mar]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v4 3/3] power: supply: add CellWise cw2015 fuel gauge driver
From
Date
Hi Andy,

thanks for your feedback. Please find my comments inline.

>
>> + dev_err(cw_bat->dev,
>> + "Failed to upload battery info\n");
>
> Indentation of the second line.
>
I've seen quite a few different indentation styles used in kernel
source. Personally I'd indent like this:

dev_warn(cw_bat->dev,
"some long error message");

However coding-style.rst specifies that spaces are never to be used for
indentation. May I assume they are ok for alignment though?


> And I'm thinking that we may refactor this function. So,
>
> length = ..._count_u8(...);
> if (length < 0) {
> dev_warn(...);
> } else if (length != ...) {
> dev_err(...);
> ...
> } else {
> ...
> }
>
>
>
>> + if (length != CW2015_SIZE_BATINFO) {
>> + dev_err(cw_bat->dev, "battery-profile must be %d bytes",
>> + CW2015_SIZE_BATINFO);
>> + return -EINVAL;
>> + }
>> +
>> + cw_bat->bat_profile = devm_kzalloc(dev, length, GFP_KERNEL);
>> + if (!cw_bat->bat_profile) {
>> + dev_err(cw_bat->dev,
>> + "Failed to allocate memory for battery config info");
>> + return -ENOMEM;
>> + }
>> +
>> + ret = device_property_read_u8_array(dev,
>> + "cellwise,battery-profile",
>> + cw_bat->bat_profile,
>> + length);
>> + if (ret)
>> + return ret;
>> + } else {
>> + dev_warn(cw_bat->dev,
>> + "No battery-profile found, rolling with current flash contents");
>> + }
>> +
>
> ...and here...
>
>> + cw_bat->poll_interval_ms = CW2015_DEFAULT_POLL_INTERVAL_MS;
>> + ret = device_property_read_u32(dev, "cellwise,monitor-interval-ms", &value);
>> + if (ret >= 0) {
>> + dev_dbg(cw_bat->dev, "Overriding default monitor-interval with %u ms",
>> + value);
>> + cw_bat->poll_interval_ms = value;
>> + }
>
> ret = device_property_read_u32(dev, "cellwise,monitor-interval-ms", &cw_bat->poll_interval_ms);
> if (ret) {
> dev_dbg(cw_bat->dev, "Use default\n");
> cw_bat->poll_interval_ms = CW2015_DEFAULT_POLL_INTERVAL_MS;
> }
>
> What do you think?
>
Looks good to me. I'll use it just like that.

>
>> + int ret;
>> + struct cw_battery *cw_bat;
>
>> + struct power_supply_config psy_cfg = { };
>
> Don't you need 0 here?
>
Yeah, that would be better. Think empty initializers are a GNU extension.


Best Regards,

Tobias

\
 
 \ /
  Last update: 2020-03-15 12:00    [W:0.053 / U:31.976 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site