* [PATCH] power: bq25890: add return values to error messages
@ 2021-10-14 9:45 Martin Kepplinger
2021-10-18 16:35 ` Sebastian Reichel
0 siblings, 1 reply; 2+ messages in thread
From: Martin Kepplinger @ 2021-10-14 9:45 UTC (permalink / raw)
To: sre, linux-pm; +Cc: kernel, linux-kernel, Martin Kepplinger
Add more details to the error messages that indicate what went wrong
and use dev_err_probe() at a few places in the probe() path in order
to avoid error messages for deferred probe after which the driver probes
correctly.
Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
---
drivers/power/supply/bq25890_charger.c | 34 ++++++++++++--------------
1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c
index 0e23d2db0fc4..ec81653e58c0 100644
--- a/drivers/power/supply/bq25890_charger.c
+++ b/drivers/power/supply/bq25890_charger.c
@@ -979,13 +979,13 @@ static int bq25890_get_chip_version(struct bq25890_device *bq)
id = bq25890_field_read(bq, F_PN);
if (id < 0) {
- dev_err(bq->dev, "Cannot read chip ID.\n");
+ dev_err(bq->dev, "Cannot read chip ID: %d\n", id);
return id;
}
rev = bq25890_field_read(bq, F_DEV_REV);
if (rev < 0) {
- dev_err(bq->dev, "Cannot read chip revision.\n");
+ dev_err(bq->dev, "Cannot read chip revision: %d\n", rev);
return rev;
}
@@ -1028,10 +1028,9 @@ static int bq25890_irq_probe(struct bq25890_device *bq)
struct gpio_desc *irq;
irq = devm_gpiod_get(bq->dev, BQ25890_IRQ_PIN, GPIOD_IN);
- if (IS_ERR(irq)) {
- dev_err(bq->dev, "Could not probe irq pin.\n");
- return PTR_ERR(irq);
- }
+ if (IS_ERR(irq))
+ return dev_err_probe(bq->dev, PTR_ERR(irq),
+ "Could not probe irq pin.\n");
return gpiod_to_irq(irq);
}
@@ -1153,34 +1152,33 @@ static int bq25890_probe(struct i2c_client *client,
mutex_init(&bq->lock);
bq->rmap = devm_regmap_init_i2c(client, &bq25890_regmap_config);
- if (IS_ERR(bq->rmap)) {
- dev_err(dev, "failed to allocate register map\n");
- return PTR_ERR(bq->rmap);
- }
+ if (IS_ERR(bq->rmap))
+ return dev_err_probe(dev, PTR_ERR(bq->rmap),
+ "failed to allocate register map\n");
for (i = 0; i < ARRAY_SIZE(bq25890_reg_fields); i++) {
const struct reg_field *reg_fields = bq25890_reg_fields;
bq->rmap_fields[i] = devm_regmap_field_alloc(dev, bq->rmap,
reg_fields[i]);
- if (IS_ERR(bq->rmap_fields[i])) {
- dev_err(dev, "cannot allocate regmap field\n");
- return PTR_ERR(bq->rmap_fields[i]);
- }
+ if (IS_ERR(bq->rmap_fields[i]))
+ return dev_err_probe(dev, PTR_ERR(bq->rmap_fields[i]),
+ "cannot allocate regmap field\n");
}
i2c_set_clientdata(client, bq);
ret = bq25890_get_chip_version(bq);
if (ret) {
- dev_err(dev, "Cannot read chip ID or unknown chip.\n");
+ dev_err(dev, "Cannot read chip ID or unknown chip: %d\n", ret);
return ret;
}
if (!dev->platform_data) {
ret = bq25890_fw_probe(bq);
if (ret < 0) {
- dev_err(dev, "Cannot read device properties.\n");
+ dev_err(dev, "Cannot read device properties: %d\n",
+ ret);
return ret;
}
} else {
@@ -1189,7 +1187,7 @@ static int bq25890_probe(struct i2c_client *client,
ret = bq25890_hw_init(bq);
if (ret < 0) {
- dev_err(dev, "Cannot initialize the chip.\n");
+ dev_err(dev, "Cannot initialize the chip: %d\n", ret);
return ret;
}
@@ -1225,7 +1223,7 @@ static int bq25890_probe(struct i2c_client *client,
ret = bq25890_power_supply_init(bq);
if (ret < 0) {
- dev_err(dev, "Failed to register power supply\n");
+ dev_err_probe(dev, ret, "Failed to register power supply.\n");
goto irq_fail;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] power: bq25890: add return values to error messages
2021-10-14 9:45 [PATCH] power: bq25890: add return values to error messages Martin Kepplinger
@ 2021-10-18 16:35 ` Sebastian Reichel
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2021-10-18 16:35 UTC (permalink / raw)
To: Martin Kepplinger; +Cc: linux-pm, kernel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 3836 bytes --]
Hi,
On Thu, Oct 14, 2021 at 11:45:33AM +0200, Martin Kepplinger wrote:
> Add more details to the error messages that indicate what went wrong
> and use dev_err_probe() at a few places in the probe() path in order
> to avoid error messages for deferred probe after which the driver probes
> correctly.
>
> Signed-off-by: Martin Kepplinger <martin.kepplinger@puri.sm>
> ---
Thanks, queued.
-- Sebastian
> drivers/power/supply/bq25890_charger.c | 34 ++++++++++++--------------
> 1 file changed, 16 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/power/supply/bq25890_charger.c b/drivers/power/supply/bq25890_charger.c
> index 0e23d2db0fc4..ec81653e58c0 100644
> --- a/drivers/power/supply/bq25890_charger.c
> +++ b/drivers/power/supply/bq25890_charger.c
> @@ -979,13 +979,13 @@ static int bq25890_get_chip_version(struct bq25890_device *bq)
>
> id = bq25890_field_read(bq, F_PN);
> if (id < 0) {
> - dev_err(bq->dev, "Cannot read chip ID.\n");
> + dev_err(bq->dev, "Cannot read chip ID: %d\n", id);
> return id;
> }
>
> rev = bq25890_field_read(bq, F_DEV_REV);
> if (rev < 0) {
> - dev_err(bq->dev, "Cannot read chip revision.\n");
> + dev_err(bq->dev, "Cannot read chip revision: %d\n", rev);
> return rev;
> }
>
> @@ -1028,10 +1028,9 @@ static int bq25890_irq_probe(struct bq25890_device *bq)
> struct gpio_desc *irq;
>
> irq = devm_gpiod_get(bq->dev, BQ25890_IRQ_PIN, GPIOD_IN);
> - if (IS_ERR(irq)) {
> - dev_err(bq->dev, "Could not probe irq pin.\n");
> - return PTR_ERR(irq);
> - }
> + if (IS_ERR(irq))
> + return dev_err_probe(bq->dev, PTR_ERR(irq),
> + "Could not probe irq pin.\n");
>
> return gpiod_to_irq(irq);
> }
> @@ -1153,34 +1152,33 @@ static int bq25890_probe(struct i2c_client *client,
> mutex_init(&bq->lock);
>
> bq->rmap = devm_regmap_init_i2c(client, &bq25890_regmap_config);
> - if (IS_ERR(bq->rmap)) {
> - dev_err(dev, "failed to allocate register map\n");
> - return PTR_ERR(bq->rmap);
> - }
> + if (IS_ERR(bq->rmap))
> + return dev_err_probe(dev, PTR_ERR(bq->rmap),
> + "failed to allocate register map\n");
>
> for (i = 0; i < ARRAY_SIZE(bq25890_reg_fields); i++) {
> const struct reg_field *reg_fields = bq25890_reg_fields;
>
> bq->rmap_fields[i] = devm_regmap_field_alloc(dev, bq->rmap,
> reg_fields[i]);
> - if (IS_ERR(bq->rmap_fields[i])) {
> - dev_err(dev, "cannot allocate regmap field\n");
> - return PTR_ERR(bq->rmap_fields[i]);
> - }
> + if (IS_ERR(bq->rmap_fields[i]))
> + return dev_err_probe(dev, PTR_ERR(bq->rmap_fields[i]),
> + "cannot allocate regmap field\n");
> }
>
> i2c_set_clientdata(client, bq);
>
> ret = bq25890_get_chip_version(bq);
> if (ret) {
> - dev_err(dev, "Cannot read chip ID or unknown chip.\n");
> + dev_err(dev, "Cannot read chip ID or unknown chip: %d\n", ret);
> return ret;
> }
>
> if (!dev->platform_data) {
> ret = bq25890_fw_probe(bq);
> if (ret < 0) {
> - dev_err(dev, "Cannot read device properties.\n");
> + dev_err(dev, "Cannot read device properties: %d\n",
> + ret);
> return ret;
> }
> } else {
> @@ -1189,7 +1187,7 @@ static int bq25890_probe(struct i2c_client *client,
>
> ret = bq25890_hw_init(bq);
> if (ret < 0) {
> - dev_err(dev, "Cannot initialize the chip.\n");
> + dev_err(dev, "Cannot initialize the chip: %d\n", ret);
> return ret;
> }
>
> @@ -1225,7 +1223,7 @@ static int bq25890_probe(struct i2c_client *client,
>
> ret = bq25890_power_supply_init(bq);
> if (ret < 0) {
> - dev_err(dev, "Failed to register power supply\n");
> + dev_err_probe(dev, ret, "Failed to register power supply.\n");
> goto irq_fail;
> }
>
> --
> 2.30.2
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-18 16:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-14 9:45 [PATCH] power: bq25890: add return values to error messages Martin Kepplinger
2021-10-18 16:35 ` Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).