[PATCH 07/10] i2c: st: Replace dev_err() with dev_err_probe() in probe function

Atharv Dubey
2026-03-24T18:28:25Z

drivers/i2c/busses/i2c-st.c | 34 ++++++++++++++--------------------
1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/drivers/i2c/busses/i2c-st.c b/drivers/i2c/busses/i2c-st.c
index 751ea421caaf..3f89c2145741 100644
--- a/drivers/i2c/busses/i2c-st.c
+++ b/drivers/i2c/busses/i2c-st.c
@@ -775,17 +775,15 @@ static int st_i2c_of_get_deglitch(struct device_node *np,

ret = of_property_read_u32(np, "st,i2c-min-scl-pulse-width-us",
&i2c_dev->scl_min_width_us);
- if ((ret == -ENODATA) || (ret == -EOVERFLOW)) {
- dev_err(i2c_dev->dev, "st,i2c-min-scl-pulse-width-us invalid\n");
- return ret;
- }
+ if ((ret == -ENODATA) || (ret == -EOVERFLOW))
+ return dev_err_probe(i2c_dev->dev, ret,
+ "st,i2c-min-scl-pulse-width-us invalid\n");

ret = of_property_read_u32(np, "st,i2c-min-sda-pulse-width-us",
&i2c_dev->sda_min_width_us);
- if ((ret == -ENODATA) || (ret == -EOVERFLOW)) {
- dev_err(i2c_dev->dev, "st,i2c-min-sda-pulse-width-us invalid\n");
- return ret;
- }
+ if ((ret == -ENODATA) || (ret == -EOVERFLOW))
+ return dev_err_probe(i2c_dev->dev, ret,
+ "st,i2c-min-sda-pulse-width-us invalid\n");

return 0;
}
@@ -808,16 +806,13 @@ static int st_i2c_probe(struct platform_device *pdev)
return PTR_ERR(i2c_dev->base);

i2c_dev->irq = irq_of_parse_and_map(np, 0);
- if (!i2c_dev->irq) {
- dev_err(&pdev->dev, "IRQ missing or invalid\n");
- return -EINVAL;
- }
+ if (!i2c_dev->irq)
+ return dev_err_probe(&pdev->dev, -EINVAL, "IRQ missing or invalid\n");

i2c_dev->clk = of_clk_get_by_name(np, "ssc");
- if (IS_ERR(i2c_dev->clk)) {
- dev_err(&pdev->dev, "Unable to request clock\n");
- return PTR_ERR(i2c_dev->clk);
- }
+ if (IS_ERR(i2c_dev->clk))
+ return dev_err_probe(&pdev->dev, PTR_ERR(i2c_dev->clk),
+ "Unable to request clock\n");

i2c_dev->mode = I2C_MODE_STANDARD;
ret = of_property_read_u32(np, "clock-frequency", &clk_rate);
@@ -829,10 +824,9 @@ static int st_i2c_probe(struct platform_device *pdev)
ret = devm_request_threaded_irq(&pdev->dev, i2c_dev->irq,
NULL, st_i2c_isr_thread,
IRQF_ONESHOT, pdev->name, i2c_dev);
- if (ret) {
- dev_err(&pdev->dev, "Failed to request irq %i\n", i2c_dev->irq);
- return ret;
- }
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret,
+ "Failed to request irq %i\n", i2c_dev->irq);

pinctrl_pm_select_default_state(i2c_dev->dev);
/* In case idle state available, select it */

--
2.43.0