power: supply: lego_ev3: Simplify with dev_err_probe()

Common pattern of handling deferred probe can be simplified with
dev_err_probe().  Less code and also it prints the error value.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: David Lechner <david@lechnology.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
Krzysztof Kozlowski 2020-08-26 16:48:58 +02:00 committed by Sebastian Reichel
parent 31873dc23c
commit e03e3601fb
1 changed files with 9 additions and 15 deletions

View File

@ -166,27 +166,21 @@ static int lego_ev3_battery_probe(struct platform_device *pdev)
batt->iio_v = devm_iio_channel_get(dev, "voltage"); batt->iio_v = devm_iio_channel_get(dev, "voltage");
err = PTR_ERR_OR_ZERO(batt->iio_v); err = PTR_ERR_OR_ZERO(batt->iio_v);
if (err) { if (err)
if (err != -EPROBE_DEFER) return dev_err_probe(dev, err,
dev_err(dev, "Failed to get voltage iio channel\n"); "Failed to get voltage iio channel\n");
return err;
}
batt->iio_i = devm_iio_channel_get(dev, "current"); batt->iio_i = devm_iio_channel_get(dev, "current");
err = PTR_ERR_OR_ZERO(batt->iio_i); err = PTR_ERR_OR_ZERO(batt->iio_i);
if (err) { if (err)
if (err != -EPROBE_DEFER) return dev_err_probe(dev, err,
dev_err(dev, "Failed to get current iio channel\n"); "Failed to get current iio channel\n");
return err;
}
batt->rechargeable_gpio = devm_gpiod_get(dev, "rechargeable", GPIOD_IN); batt->rechargeable_gpio = devm_gpiod_get(dev, "rechargeable", GPIOD_IN);
err = PTR_ERR_OR_ZERO(batt->rechargeable_gpio); err = PTR_ERR_OR_ZERO(batt->rechargeable_gpio);
if (err) { if (err)
if (err != -EPROBE_DEFER) return dev_err_probe(dev, err,
dev_err(dev, "Failed to get rechargeable gpio\n"); "Failed to get rechargeable gpio\n");
return err;
}
/* /*
* The rechargeable battery indication switch cannot be changed without * The rechargeable battery indication switch cannot be changed without