Messages in this thread | | | Subject | Re: [PATCH v3 3/3] power: supply: add CellWise cw2015 fuel gauge driver | From | Tobias Schramm <> | Date | Thu, 12 Mar 2020 00:51:28 +0100 |
| |
Hi Andy,
thanks for reviewing again.
>> + /* wait for gauge to become ready */ >> + for (i = 0; i < CW2015_READ_TRIES; i++) { >> + ret = regmap_read(cw_bat->regmap, CW2015_REG_SOC, ®_val); >> + if (ret) >> + return ret; >> + /* SoC must not be more than 100% */ >> + else if (reg_val <= 100) >> + break; >> + >> + msleep(100); >> + } > > Have you considered to use regmap_read_poll_timeout()?
Neat! That is a much cleaner solution. Will use that in v4.
> >> + >> + if (i >= CW2015_READ_TRIES) { >> + reg_val = CW2015_MODE_SLEEP; >> + regmap_write(cw_bat->regmap, CW2015_REG_MODE, reg_val); >> + dev_err(cw_bat->dev, >> + "Gauge did not become ready after profile upload"); >> + return -ETIMEDOUT; >> + } > > ... > >> + if (memcmp(bat_info, cw_bat->bat_profile, >> + CW2015_SIZE_BATINFO)) { > > I think it's pretty much okay to have this on one line, disregard 80 limit > (it's only 1 extra).
Ok, will probably do that in a few places.
Best Regards,
Tobias
| |