diff options
Diffstat (limited to 'drivers/power/supply/max17040_battery.c')
-rw-r--r-- | drivers/power/supply/max17040_battery.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/power/supply/max17040_battery.c b/drivers/power/supply/max17040_battery.c index d956c67d5155..1aab868adabf 100644 --- a/drivers/power/supply/max17040_battery.c +++ b/drivers/power/supply/max17040_battery.c @@ -268,11 +268,10 @@ static int max17040_get_of_data(struct max17040_chip *chip) rcomp_len = device_property_count_u8(dev, "maxim,rcomp"); chip->rcomp = MAX17040_RCOMP_DEFAULT; if (rcomp_len == data->rcomp_bytes) { - device_property_read_u8_array(dev, "maxim,rcomp", - rcomp, rcomp_len); - chip->rcomp = rcomp_len == 2 ? - rcomp[0] << 8 | rcomp[1] : - rcomp[0] << 8; + if (!device_property_read_u8_array(dev, "maxim,rcomp", + rcomp, rcomp_len)) + chip->rcomp = rcomp_len == 2 ? rcomp[0] << 8 | rcomp[1] : + rcomp[0] << 8; } else if (rcomp_len > 0) { dev_err(dev, "maxim,rcomp has incorrect length\n"); return -EINVAL; @@ -487,8 +486,7 @@ static int max17040_probe(struct i2c_client *client, ret = max17040_get_of_data(chip); if (ret) return ret; - chip_id = (enum chip_id) (uintptr_t) - of_device_get_match_data(&client->dev); + chip_id = (uintptr_t)of_device_get_match_data(&client->dev); } chip->data = max17040_family[chip_id]; |