mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
regulator: mcp16502: Convert to dev_err_probe() in mcp16502_probe()
The mcp16502_probe() currently uses dev_err() for logging errors. However, functions like devm_regmap_init_i2c, devm_gpiod_get_optional and devm_regulator_register can return -EPROBE_DEFER. Using dev_err() in these situations can cause unnecessary error spam in dmesg. As a result, convert to dev_err_probe(). It also simplifies the print and return operations into single statement. The 'ret' variable is no longer required and has been removed. Originally detected by Coccinelle with this warning "Consider using %pe to print PTR_ERR()" Compile-tested only. Signed-off-by: Ninad Naik <ninadnaik07@gmail.com> Link: https://patch.msgid.link/20260714192228.1639768-1-ninadnaik07@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
@@ -508,7 +508,7 @@ static int mcp16502_probe(struct i2c_client *client)
|
||||
struct device *dev;
|
||||
struct mcp16502 *mcp;
|
||||
struct regmap *rmap;
|
||||
int i, ret;
|
||||
int i;
|
||||
|
||||
dev = &client->dev;
|
||||
config.dev = dev;
|
||||
@@ -518,30 +518,23 @@ static int mcp16502_probe(struct i2c_client *client)
|
||||
return -ENOMEM;
|
||||
|
||||
rmap = devm_regmap_init_i2c(client, &mcp16502_regmap_config);
|
||||
if (IS_ERR(rmap)) {
|
||||
ret = PTR_ERR(rmap);
|
||||
dev_err(dev, "regmap init failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
if (IS_ERR(rmap))
|
||||
return dev_err_probe(dev, PTR_ERR(rmap), "regmap init failed\n");
|
||||
|
||||
i2c_set_clientdata(client, mcp);
|
||||
config.regmap = rmap;
|
||||
config.driver_data = mcp;
|
||||
|
||||
mcp->lpm = devm_gpiod_get_optional(dev, "lpm", GPIOD_OUT_LOW);
|
||||
if (IS_ERR(mcp->lpm)) {
|
||||
dev_err(dev, "failed to get lpm pin: %ld\n", PTR_ERR(mcp->lpm));
|
||||
return PTR_ERR(mcp->lpm);
|
||||
}
|
||||
if (IS_ERR(mcp->lpm))
|
||||
return dev_err_probe(dev, PTR_ERR(mcp->lpm), "failed to get lpm pin\n");
|
||||
|
||||
for (i = 0; i < NUM_REGULATORS; i++) {
|
||||
rdev = devm_regulator_register(dev, &mcp16502_desc[i], &config);
|
||||
if (IS_ERR(rdev)) {
|
||||
dev_err(dev,
|
||||
"failed to register %s regulator %ld\n",
|
||||
mcp16502_desc[i].name, PTR_ERR(rdev));
|
||||
return PTR_ERR(rdev);
|
||||
}
|
||||
if (IS_ERR(rdev))
|
||||
return dev_err_probe(dev, PTR_ERR(rdev),
|
||||
"failed to register %s regulator\n",
|
||||
mcp16502_desc[i].name);
|
||||
}
|
||||
|
||||
mcp16502_gpio_set_mode(mcp, MCP16502_OPMODE_ACTIVE);
|
||||
|
||||
Reference in New Issue
Block a user