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

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

drivers/i2c/busses/i2c-stm32f4.c | 53 ++++++++++++++++------------------------
1 file changed, 21 insertions(+), 32 deletions(-)

diff --git a/drivers/i2c/busses/i2c-stm32f4.c b/drivers/i2c/busses/i2c-stm32f4.c
index b3d56d0aa9d0..44e8b04962bb 100644
--- a/drivers/i2c/busses/i2c-stm32f4.c
+++ b/drivers/i2c/busses/i2c-stm32f4.c
@@ -163,11 +163,9 @@ static int stm32f4_i2c_set_periph_clk_freq(struct stm32f4_i2c_dev *i2c_dev)
* to hardware limitation
*/
if (freq < STM32F4_I2C_MIN_STANDARD_FREQ ||
- freq > STM32F4_I2C_MAX_FREQ) {
- dev_err(i2c_dev->dev,
- "bad parent clk freq for standard mode\n");
- return -EINVAL;
- }
+ freq > STM32F4_I2C_MAX_FREQ)
+ return dev_err_probe(i2c_dev->dev, -EINVAL,
+ "bad parent clk freq for standard mode\n");
} else {
/*
* To be as close as possible to 400 kHz, the parent clk
@@ -175,11 +173,9 @@ static int stm32f4_i2c_set_periph_clk_freq(struct stm32f4_i2c_dev *i2c_dev)
* maximum value of 46 MHz due to hardware limitation
*/
if (freq < STM32F4_I2C_MIN_FAST_FREQ ||
- freq > STM32F4_I2C_MAX_FREQ) {
- dev_err(i2c_dev->dev,
- "bad parent clk freq for fast mode\n");
- return -EINVAL;
- }
+ freq > STM32F4_I2C_MAX_FREQ)
+ return dev_err_probe(i2c_dev->dev, -EINVAL,
+ "bad parent clk freq for fast mode\n");
}

cr2 |= STM32F4_I2C_CR2_FREQ(freq);
@@ -772,22 +768,19 @@ static int stm32f4_i2c_probe(struct platform_device *pdev)
return PTR_ERR(i2c_dev->base);

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

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

i2c_dev->clk = devm_clk_get_enabled(&pdev->dev, NULL);
- if (IS_ERR(i2c_dev->clk)) {
- dev_err(&pdev->dev, "Failed to enable 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),
+ "Failed to enable clock\n");

rst = devm_reset_control_get_exclusive(&pdev->dev, NULL);
if (IS_ERR(rst))
@@ -807,19 +800,15 @@ static int stm32f4_i2c_probe(struct platform_device *pdev)

ret = devm_request_irq(&pdev->dev, irq_event, stm32f4_i2c_isr_event, 0,
pdev->name, i2c_dev);
- if (ret) {
- dev_err(&pdev->dev, "Failed to request irq event %i\n",
- irq_event);
- return ret;
- }
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret,
+ "Failed to request irq event %i\n", irq_event);

ret = devm_request_irq(&pdev->dev, irq_error, stm32f4_i2c_isr_error, 0,
pdev->name, i2c_dev);
- if (ret) {
- dev_err(&pdev->dev, "Failed to request irq error %i\n",
- irq_error);
- return ret;
- }
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret,
+ "Failed to request irq error %i\n", irq_error);

ret = stm32f4_i2c_hw_config(i2c_dev);
if (ret)

--
2.43.0