Commit 436ff8c9 authored by Sebastian Reichel's avatar Sebastian Reichel

power: supply: sbs-manager: 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.
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent 814ddbd9
...@@ -294,10 +294,8 @@ static int sbsm_gpio_setup(struct sbsm_data *data) ...@@ -294,10 +294,8 @@ static int sbsm_gpio_setup(struct sbsm_data *data)
gc->owner = THIS_MODULE; gc->owner = THIS_MODULE;
ret = devm_gpiochip_add_data(dev, gc, data); ret = devm_gpiochip_add_data(dev, gc, data);
if (ret) { if (ret)
dev_err(dev, "devm_gpiochip_add_data failed: %d\n", ret); return dev_err_probe(dev, ret, "devm_gpiochip_add_data failed\n");
return ret;
}
return ret; return ret;
} }
...@@ -349,11 +347,8 @@ static int sbsm_probe(struct i2c_client *client, ...@@ -349,11 +347,8 @@ static int sbsm_probe(struct i2c_client *client,
data->supported_bats = ret & SBSM_MASK_BAT_SUPPORTED; data->supported_bats = ret & SBSM_MASK_BAT_SUPPORTED;
data->muxc = i2c_mux_alloc(adapter, dev, SBSM_MAX_BATS, 0, data->muxc = i2c_mux_alloc(adapter, dev, SBSM_MAX_BATS, 0,
I2C_MUX_LOCKED, &sbsm_select, NULL); I2C_MUX_LOCKED, &sbsm_select, NULL);
if (!data->muxc) { if (!data->muxc)
dev_err(dev, "failed to alloc i2c mux\n"); return dev_err_probe(dev, -ENOMEM, "failed to alloc i2c mux\n");
ret = -ENOMEM;
goto err_mux_alloc;
}
data->muxc->priv = data; data->muxc->priv = data;
ret = devm_add_action_or_reset(dev, sbsm_del_mux_adapter, data); ret = devm_add_action_or_reset(dev, sbsm_del_mux_adapter, data);
...@@ -368,45 +363,29 @@ static int sbsm_probe(struct i2c_client *client, ...@@ -368,45 +363,29 @@ static int sbsm_probe(struct i2c_client *client,
break; break;
} }
} }
if (ret) { if (ret)
dev_err(dev, "failed to register i2c mux channel %d\n", i + 1); return dev_err_probe(dev, ret, "failed to register i2c mux channel %d\n", i + 1);
goto err_mux_register;
}
psy_desc = devm_kmemdup(dev, &sbsm_default_psy_desc, psy_desc = devm_kmemdup(dev, &sbsm_default_psy_desc, sizeof(*psy_desc), GFP_KERNEL);
sizeof(struct power_supply_desc), if (!psy_desc)
GFP_KERNEL); return -ENOMEM;
if (!psy_desc) {
ret = -ENOMEM; psy_desc->name = devm_kasprintf(dev, GFP_KERNEL, "sbsm-%s", dev_name(&client->dev));
goto err_psy; if (!psy_desc->name)
} return -ENOMEM;
psy_desc->name = devm_kasprintf(dev, GFP_KERNEL, "sbsm-%s",
dev_name(&client->dev));
if (!psy_desc->name) {
ret = -ENOMEM;
goto err_psy;
}
ret = sbsm_gpio_setup(data); ret = sbsm_gpio_setup(data);
if (ret < 0) if (ret < 0)
goto err_psy; return ret;
psy_cfg.drv_data = data; psy_cfg.drv_data = data;
psy_cfg.of_node = dev->of_node; psy_cfg.of_node = dev->of_node;
data->psy = devm_power_supply_register(dev, psy_desc, &psy_cfg); data->psy = devm_power_supply_register(dev, psy_desc, &psy_cfg);
if (IS_ERR(data->psy)) { if (IS_ERR(data->psy))
ret = PTR_ERR(data->psy); return dev_err_probe(dev, PTR_ERR(data->psy),
dev_err(dev, "failed to register power supply %s\n", "failed to register power supply %s\n", psy_desc->name);
psy_desc->name);
goto err_psy;
}
return 0; return 0;
err_psy:
err_mux_register:
err_mux_alloc:
return ret;
} }
static const struct i2c_device_id sbsm_ids[] = { static const struct i2c_device_id sbsm_ids[] = {
......
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