summaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorSebastian Reichel <sebastian.reichel@collabora.com>2021-03-09 19:04:01 +0100
committerSebastian Reichel <sebastian.reichel@collabora.com>2021-04-02 14:19:25 +0200
commit166767ab913dbf79129cf5f36b15b581513b501a (patch)
tree49d60d60bb9a14b66601eaa2ce6ebf579dd700ca /drivers/power
parentpower: supply: 88pm860x_battery: Remove unnecessary int for long long (diff)
downloadlinux-166767ab913dbf79129cf5f36b15b581513b501a.tar.xz
linux-166767ab913dbf79129cf5f36b15b581513b501a.zip
power: supply: sbs-battery: use dev_err_probe
Introduce usage of dev_err_probe in probe routine, which makes the code slightly more readable and removes some lines of code. It also removes PROBE_DEFER errors being logged by default, which are common when the battery is waiting for the charger driver to be registered. This also cleans up a useless goto and instead returns directly. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/supply/sbs-battery.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/drivers/power/supply/sbs-battery.c b/drivers/power/supply/sbs-battery.c
index b6a538ebb378..4bf92831cb06 100644
--- a/drivers/power/supply/sbs-battery.c
+++ b/drivers/power/supply/sbs-battery.c
@@ -1123,11 +1123,9 @@ static int sbs_probe(struct i2c_client *client)
chip->gpio_detect = devm_gpiod_get_optional(&client->dev,
"sbs,battery-detect", GPIOD_IN);
- if (IS_ERR(chip->gpio_detect)) {
- dev_err(&client->dev, "Failed to get gpio: %ld\n",
- PTR_ERR(chip->gpio_detect));
- return PTR_ERR(chip->gpio_detect);
- }
+ if (IS_ERR(chip->gpio_detect))
+ return dev_err_probe(&client->dev, PTR_ERR(chip->gpio_detect),
+ "Failed to get gpio\n");
i2c_set_clientdata(client, chip);
@@ -1158,31 +1156,23 @@ skip_gpio:
rc = sbs_get_battery_presence_and_health(
client, POWER_SUPPLY_PROP_PRESENT, &val);
- if (rc < 0 || !val.intval) {
- dev_err(&client->dev, "Failed to get present status\n");
- rc = -ENODEV;
- goto exit_psupply;
- }
+ if (rc < 0 || !val.intval)
+ return dev_err_probe(&client->dev, -ENODEV,
+ "Failed to get present status\n");
}
INIT_DELAYED_WORK(&chip->work, sbs_delayed_work);
chip->power_supply = devm_power_supply_register(&client->dev, sbs_desc,
&psy_cfg);
- if (IS_ERR(chip->power_supply)) {
- dev_err(&client->dev,
- "%s: Failed to register power supply\n", __func__);
- rc = PTR_ERR(chip->power_supply);
- goto exit_psupply;
- }
+ if (IS_ERR(chip->power_supply))
+ return dev_err_probe(&client->dev, PTR_ERR(chip->power_supply),
+ "Failed to register power supply\n");
dev_info(&client->dev,
"%s: battery gas gauge device registered\n", client->name);
return 0;
-
-exit_psupply:
- return rc;
}
static int sbs_remove(struct i2c_client *client)