regulator: mcp16502: Convert to dev_err_probe() in mcp16502_probe()
PATCH 1/1 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.
--- drivers/regulator/mcp16502.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
drivers/regulator/mcp16502.c +9 -16
@@ -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 );
Signature · 1 line
2.55.0
Mark Brown
maintainerQuoted 1 line · Ninad Naik
regulator: mcp16502: Convert to
dev_err_probe()inmcp16502_probe()
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-7.3
Thanks!
[1/1] regulator: mcp16502: Convert to dev_err_probe() in mcp16502_probe()
https://git.kernel.org/broonie/regulator/c/25706f1ab9fb
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark