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,
ret = i2c_transfer(client->adapter, &msgs[0], 2);
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;
}
......@@ -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);
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;
}
......@@ -148,11 +150,8 @@ static int ltc294x_reset(const struct ltc294x_info *info, int prescaler_exp)
/* Read status and control registers */
ret = ltc294x_read_regs(info->client, LTC294X_REG_CONTROL, &value, 1);
if (ret < 0) {
dev_err(&info->client->dev,
"Could not read registers from device\n");
goto error_exit;
}
if (ret < 0)
return ret;
control = LTC294X_REG_CONTROL_PRESCALER_SET(prescaler_exp) |
LTC294X_REG_CONTROL_ALCC_CONFIG_DISABLED;
......@@ -172,17 +171,11 @@ static int ltc294x_reset(const struct ltc294x_info *info, int prescaler_exp)
if (value != control) {
ret = ltc294x_write_regs(info->client,
LTC294X_REG_CONTROL, &control, 1);
if (ret < 0) {
dev_err(&info->client->dev,
"Could not write register\n");
goto error_exit;
}
if (ret < 0)
return ret;
}
return 0;
error_exit:
return ret;
}
static int ltc294x_read_charge_register(const struct ltc294x_info *info,
......@@ -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
* instead of the sense-. This results in reversed measurements. */
ret = of_property_read_u32(np, "lltc,resistor-sense", &r_sense);
if (ret < 0) {
dev_err(&client->dev,
if (ret < 0)
return dev_err_probe(&client->dev, ret,
"Could not find lltc,resistor-sense in devicetree\n");
return ret;
}
info->r_sense = r_sense;
ret = of_property_read_u32(np, "lltc,prescaler-exponent",
......@@ -502,11 +493,9 @@ static int ltc294x_i2c_probe(struct i2c_client *client,
/* Read status register to check for LTC2942 */
if (info->id == LTC2941_ID || info->id == LTC2942_ID) {
ret = ltc294x_read_regs(client, LTC294X_REG_STATUS, &status, 1);
if (ret < 0) {
dev_err(&client->dev,
if (ret < 0)
return dev_err_probe(&client->dev, ret,
"Could not read status register\n");
return ret;
}
if (status & LTC2941_REG_STATUS_CHIP_ID)
info->id = LTC2941_ID;
else
......@@ -545,19 +534,17 @@ static int ltc294x_i2c_probe(struct i2c_client *client,
return ret;
ret = ltc294x_reset(info, prescaler_exp);
if (ret < 0) {
dev_err(&client->dev, "Communication with chip failed\n");
return ret;
}
if (ret < 0)
return dev_err_probe(&client->dev, ret,
"Communication with chip failed\n");
info->supply = devm_power_supply_register(&client->dev,
&info->supply_desc, &psy_cfg);
if (IS_ERR(info->supply)) {
dev_err(&client->dev, "failed to register ltc2941\n");
return PTR_ERR(info->supply);
} else {
schedule_delayed_work(&info->work, LTC294X_WORK_DELAY * HZ);
}
if (IS_ERR(info->supply))
return dev_err_probe(&client->dev, PTR_ERR(info->supply),
"failed to register ltc2941\n");
schedule_delayed_work(&info->work, LTC294X_WORK_DELAY * HZ);
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