Commit 513e3b53 authored by Michał Mirosław's avatar Michał Mirosław Committed by Sebastian Reichel

power: supply: ltc2941: clean up error messages

Replace dev_err() with dev_err_probe() in probe() and extend register
access failure messages. dev_err()s in _reset() are removed as they
are redundant: register access wrappers already log the error.
Signed-off-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent cf215c37
...@@ -112,7 +112,8 @@ static int ltc294x_read_regs(struct i2c_client *client, ...@@ -112,7 +112,8 @@ static int ltc294x_read_regs(struct i2c_client *client,
ret = i2c_transfer(client->adapter, &msgs[0], 2); ret = i2c_transfer(client->adapter, &msgs[0], 2);
if (ret < 0) { if (ret < 0) {
dev_err(&client->dev, "ltc2941 read_reg failed!\n"); dev_err(&client->dev, "ltc2941 read_reg(0x%x[%d]) failed: %pe\n",
reg, num_regs, ERR_PTR(ret));
return ret; return ret;
} }
...@@ -130,7 +131,8 @@ static int ltc294x_write_regs(struct i2c_client *client, ...@@ -130,7 +131,8 @@ static int ltc294x_write_regs(struct i2c_client *client,
ret = i2c_smbus_write_i2c_block_data(client, reg_start, num_regs, buf); ret = i2c_smbus_write_i2c_block_data(client, reg_start, num_regs, buf);
if (ret < 0) { if (ret < 0) {
dev_err(&client->dev, "ltc2941 write_reg failed!\n"); dev_err(&client->dev, "ltc2941 write_reg(0x%x[%d]) failed: %pe\n",
reg, num_regs, ERR_PTR(ret));
return ret; return ret;
} }
...@@ -148,11 +150,8 @@ static int ltc294x_reset(const struct ltc294x_info *info, int prescaler_exp) ...@@ -148,11 +150,8 @@ static int ltc294x_reset(const struct ltc294x_info *info, int prescaler_exp)
/* Read status and control registers */ /* Read status and control registers */
ret = ltc294x_read_regs(info->client, LTC294X_REG_CONTROL, &value, 1); ret = ltc294x_read_regs(info->client, LTC294X_REG_CONTROL, &value, 1);
if (ret < 0) { if (ret < 0)
dev_err(&info->client->dev, return ret;
"Could not read registers from device\n");
goto error_exit;
}
control = LTC294X_REG_CONTROL_PRESCALER_SET(prescaler_exp) | control = LTC294X_REG_CONTROL_PRESCALER_SET(prescaler_exp) |
LTC294X_REG_CONTROL_ALCC_CONFIG_DISABLED; LTC294X_REG_CONTROL_ALCC_CONFIG_DISABLED;
...@@ -172,17 +171,11 @@ static int ltc294x_reset(const struct ltc294x_info *info, int prescaler_exp) ...@@ -172,17 +171,11 @@ static int ltc294x_reset(const struct ltc294x_info *info, int prescaler_exp)
if (value != control) { if (value != control) {
ret = ltc294x_write_regs(info->client, ret = ltc294x_write_regs(info->client,
LTC294X_REG_CONTROL, &control, 1); LTC294X_REG_CONTROL, &control, 1);
if (ret < 0) { if (ret < 0)
dev_err(&info->client->dev, return ret;
"Could not write register\n");
goto error_exit;
}
} }
return 0; return 0;
error_exit:
return ret;
} }
static int ltc294x_read_charge_register(const struct ltc294x_info *info, static int ltc294x_read_charge_register(const struct ltc294x_info *info,
...@@ -472,11 +465,9 @@ static int ltc294x_i2c_probe(struct i2c_client *client, ...@@ -472,11 +465,9 @@ static int ltc294x_i2c_probe(struct i2c_client *client,
/* r_sense can be negative, when sense+ is connected to the battery /* r_sense can be negative, when sense+ is connected to the battery
* instead of the sense-. This results in reversed measurements. */ * instead of the sense-. This results in reversed measurements. */
ret = of_property_read_u32(np, "lltc,resistor-sense", &r_sense); ret = of_property_read_u32(np, "lltc,resistor-sense", &r_sense);
if (ret < 0) { if (ret < 0)
dev_err(&client->dev, return dev_err_probe(&client->dev, ret,
"Could not find lltc,resistor-sense in devicetree\n"); "Could not find lltc,resistor-sense in devicetree\n");
return ret;
}
info->r_sense = r_sense; info->r_sense = r_sense;
ret = of_property_read_u32(np, "lltc,prescaler-exponent", ret = of_property_read_u32(np, "lltc,prescaler-exponent",
...@@ -502,11 +493,9 @@ static int ltc294x_i2c_probe(struct i2c_client *client, ...@@ -502,11 +493,9 @@ static int ltc294x_i2c_probe(struct i2c_client *client,
/* Read status register to check for LTC2942 */ /* Read status register to check for LTC2942 */
if (info->id == LTC2941_ID || info->id == LTC2942_ID) { if (info->id == LTC2941_ID || info->id == LTC2942_ID) {
ret = ltc294x_read_regs(client, LTC294X_REG_STATUS, &status, 1); ret = ltc294x_read_regs(client, LTC294X_REG_STATUS, &status, 1);
if (ret < 0) { if (ret < 0)
dev_err(&client->dev, return dev_err_probe(&client->dev, ret,
"Could not read status register\n"); "Could not read status register\n");
return ret;
}
if (status & LTC2941_REG_STATUS_CHIP_ID) if (status & LTC2941_REG_STATUS_CHIP_ID)
info->id = LTC2941_ID; info->id = LTC2941_ID;
else else
...@@ -545,19 +534,17 @@ static int ltc294x_i2c_probe(struct i2c_client *client, ...@@ -545,19 +534,17 @@ static int ltc294x_i2c_probe(struct i2c_client *client,
return ret; return ret;
ret = ltc294x_reset(info, prescaler_exp); ret = ltc294x_reset(info, prescaler_exp);
if (ret < 0) { if (ret < 0)
dev_err(&client->dev, "Communication with chip failed\n"); return dev_err_probe(&client->dev, ret,
return ret; "Communication with chip failed\n");
}
info->supply = devm_power_supply_register(&client->dev, info->supply = devm_power_supply_register(&client->dev,
&info->supply_desc, &psy_cfg); &info->supply_desc, &psy_cfg);
if (IS_ERR(info->supply)) { if (IS_ERR(info->supply))
dev_err(&client->dev, "failed to register ltc2941\n"); return dev_err_probe(&client->dev, PTR_ERR(info->supply),
return PTR_ERR(info->supply); "failed to register ltc2941\n");
} else {
schedule_delayed_work(&info->work, LTC294X_WORK_DELAY * HZ); schedule_delayed_work(&info->work, LTC294X_WORK_DELAY * HZ);
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment