Commit 166767ab authored by Sebastian Reichel's avatar Sebastian Reichel

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: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent 33ae8b03
...@@ -1123,11 +1123,9 @@ static int sbs_probe(struct i2c_client *client) ...@@ -1123,11 +1123,9 @@ static int sbs_probe(struct i2c_client *client)
chip->gpio_detect = devm_gpiod_get_optional(&client->dev, chip->gpio_detect = devm_gpiod_get_optional(&client->dev,
"sbs,battery-detect", GPIOD_IN); "sbs,battery-detect", GPIOD_IN);
if (IS_ERR(chip->gpio_detect)) { if (IS_ERR(chip->gpio_detect))
dev_err(&client->dev, "Failed to get gpio: %ld\n", return dev_err_probe(&client->dev, PTR_ERR(chip->gpio_detect),
PTR_ERR(chip->gpio_detect)); "Failed to get gpio\n");
return PTR_ERR(chip->gpio_detect);
}
i2c_set_clientdata(client, chip); i2c_set_clientdata(client, chip);
...@@ -1158,31 +1156,23 @@ static int sbs_probe(struct i2c_client *client) ...@@ -1158,31 +1156,23 @@ static int sbs_probe(struct i2c_client *client)
rc = sbs_get_battery_presence_and_health( rc = sbs_get_battery_presence_and_health(
client, POWER_SUPPLY_PROP_PRESENT, &val); client, POWER_SUPPLY_PROP_PRESENT, &val);
if (rc < 0 || !val.intval) { if (rc < 0 || !val.intval)
dev_err(&client->dev, "Failed to get present status\n"); return dev_err_probe(&client->dev, -ENODEV,
rc = -ENODEV; "Failed to get present status\n");
goto exit_psupply;
}
} }
INIT_DELAYED_WORK(&chip->work, sbs_delayed_work); INIT_DELAYED_WORK(&chip->work, sbs_delayed_work);
chip->power_supply = devm_power_supply_register(&client->dev, sbs_desc, chip->power_supply = devm_power_supply_register(&client->dev, sbs_desc,
&psy_cfg); &psy_cfg);
if (IS_ERR(chip->power_supply)) { if (IS_ERR(chip->power_supply))
dev_err(&client->dev, return dev_err_probe(&client->dev, PTR_ERR(chip->power_supply),
"%s: Failed to register power supply\n", __func__); "Failed to register power supply\n");
rc = PTR_ERR(chip->power_supply);
goto exit_psupply;
}
dev_info(&client->dev, dev_info(&client->dev,
"%s: battery gas gauge device registered\n", client->name); "%s: battery gas gauge device registered\n", client->name);
return 0; return 0;
exit_psupply:
return rc;
} }
static int sbs_remove(struct i2c_client *client) static int sbs_remove(struct i2c_client *client)
......
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