Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal/drivers/brcmstb_thermal: Simplify with dev_err_probe()

dev_err_probe() is used to log an error message during the probe process
of a device.

It can simplify the error path and unify a message template.

Using this helper is totally fine even if err is known to never
be -EPROBE_DEFER.

The benefit compared to a normal dev_err() is the standardized format
of the error code, it being emitted symbolically and the fact that
the error code is returned which allows more compact error paths.

Signed-off-by: Yan Zhen <yanzhen@vivo.com>
Link: https://lore.kernel.org/r/20240830103918.501234-1-yanzhen@vivo.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

authored by

Yan Zhen and committed by
Daniel Lezcano
b779bbb9 8e12f1f8

+6 -9
+6 -9
drivers/thermal/broadcom/brcmstb_thermal.c
··· 338 338 339 339 thermal = devm_thermal_of_zone_register(&pdev->dev, 0, priv, 340 340 of_ops); 341 - if (IS_ERR(thermal)) { 342 - ret = PTR_ERR(thermal); 343 - dev_err(&pdev->dev, "could not register sensor: %d\n", ret); 344 - return ret; 345 - } 341 + if (IS_ERR(thermal)) 342 + return dev_err_probe(&pdev->dev, PTR_ERR(thermal), 343 + "could not register sensor\n"); 346 344 347 345 priv->thermal = thermal; 348 346 ··· 350 352 brcmstb_tmon_irq_thread, 351 353 IRQF_ONESHOT, 352 354 DRV_NAME, priv); 353 - if (ret < 0) { 354 - dev_err(&pdev->dev, "could not request IRQ: %d\n", ret); 355 - return ret; 356 - } 355 + if (ret < 0) 356 + return dev_err_probe(&pdev->dev, ret, 357 + "could not request IRQ\n"); 357 358 } 358 359 359 360 dev_info(&pdev->dev, "registered AVS TMON of-sensor driver\n");