Skip to content

Commit e2aa250

Browse files
prabhakarladWolfram Sang
authored andcommitted
i2c: riic: Use dev_err_probe in probe and riic_init_hw functions
Refactor error handling in the riic_i2c_probe() and riic_init_hw() functions by replacing multiple dev_err() calls with dev_err_probe(). Additionally, update the riic_init_hw() function to use a local `dev` pointer instead of `riic->adapter.dev` for dev_err_probe(), as the I2C adapter is not initialized at this stage. Drop the cast to (unsigned long) in the riic_init_hw() function when printing the bus frequency, and update the error message to display the frequency in Hz, improving clarity. Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Tested-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> Reviewed-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
1 parent 76dc162 commit e2aa250

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

drivers/i2c/busses/i2c-riic.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,9 @@ static int riic_init_hw(struct riic_dev *riic)
356356
rate /= 2;
357357
}
358358

359-
if (brl > (0x1F + 3)) {
360-
dev_err(&riic->adapter.dev, "invalid speed (%lu). Too slow.\n",
361-
(unsigned long)t->bus_freq_hz);
362-
return -EINVAL;
363-
}
359+
if (brl > (0x1F + 3))
360+
return dev_err_probe(dev, -EINVAL, "invalid speed (%uHz). Too slow.\n",
361+
t->bus_freq_hz);
364362

365363
brh = total_ticks - brl;
366364

@@ -445,10 +443,9 @@ static int riic_i2c_probe(struct platform_device *pdev)
445443
return PTR_ERR(riic->base);
446444

447445
riic->clk = devm_clk_get(dev, NULL);
448-
if (IS_ERR(riic->clk)) {
449-
dev_err(dev, "missing controller clock");
450-
return PTR_ERR(riic->clk);
451-
}
446+
if (IS_ERR(riic->clk))
447+
return dev_err_probe(dev, PTR_ERR(riic->clk),
448+
"missing controller clock");
452449

453450
riic->rstc = devm_reset_control_get_optional_exclusive(dev, NULL);
454451
if (IS_ERR(riic->rstc))
@@ -472,10 +469,9 @@ static int riic_i2c_probe(struct platform_device *pdev)
472469

473470
ret = devm_request_irq(dev, irq, riic_irqs[i].isr,
474471
0, riic_irqs[i].name, riic);
475-
if (ret) {
476-
dev_err(dev, "failed to request irq %s\n", riic_irqs[i].name);
477-
return ret;
478-
}
472+
if (ret)
473+
return dev_err_probe(dev, ret, "failed to request irq %s\n",
474+
riic_irqs[i].name);
479475
}
480476

481477
riic->info = of_device_get_match_data(dev);

0 commit comments

Comments
 (0)