Hi, On 2/24/22 11:55, Andy Shevchenko wrote: > On Thu, Feb 24, 2022 at 12:19 PM Hans de Goede <hdegoede@xxxxxxxxxx> wrote: >> >> The battery on the 2nd hand Surface 3 which I recently bought appears to >> not have a serial no programmed in. This results in any I2C reads from >> the registers containing the serial no failing with an I2C NACK. >> >> This was causing mshw0011_bix() to fail causing the battery readings to >> not work at all. >> >> Ignore EREMOTEIO (I2C NACK) errors when retrieving the serial no and >> continue with an empty serial no to fix this. > > Maybe in all cases > > serial no --> Serial Number > > ? This "no" requires to re-read again. Ack, will fix before merging. >> Fixes: b1f81b496b0d ("platform/x86: surface3_power: MSHW0011 rev-eng implementation") >> Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx> >> --- >> drivers/platform/surface/surface3_power.c | 13 ++++++++++--- >> 1 file changed, 10 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/platform/surface/surface3_power.c b/drivers/platform/surface/surface3_power.c >> index abac3eec565e..b283bc9bb5fd 100644 >> --- a/drivers/platform/surface/surface3_power.c >> +++ b/drivers/platform/surface/surface3_power.c >> @@ -232,14 +232,21 @@ static int mshw0011_bix(struct mshw0011_data *cdata, struct bix *bix) >> } >> bix->last_full_charg_capacity = ret; >> >> - /* get serial number */ >> + /* >> + * get serial number, on some devices (with unofficial replacement > > Get Ack. > >> + * battery?) reading any of the serial no range addresses gets nacked >> + * in this case just leave the serial no empty. >> + */ >> ret = i2c_smbus_read_i2c_block_data(client, MSHW0011_BAT0_REG_SERIAL_NO, >> sizeof(buf), buf); >> - if (ret != sizeof(buf)) { >> + if (ret == -EREMOTEIO) { >> + /* no serial number available */ >> + } else if (ret != sizeof(buf)) { >> dev_err(&client->dev, "Error reading serial no: %d\n", ret); >> return ret; >> + } else { >> + snprintf(bix->serial, ARRAY_SIZE(bix->serial), "%3pE%6pE", buf + 7, buf); >> } >> - snprintf(bix->serial, ARRAY_SIZE(bix->serial), "%3pE%6pE", buf + 7, buf); >> >> /* get cycle count */ >> ret = i2c_smbus_read_word_data(client, MSHW0011_BAT0_REG_CYCLE_CNT); >> -- >> 2.35.1 >> > > Regards, Hans