Commit 71dacb25 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Andi Shyti

i2c: riic: Simplify unsupported bus speed handling

Simplify checking for unsupported bus speeds and reporting errors by
factoring out the calculation of the maximum bus speed, and by using the
dev_err_probe() helper.

While at it, use "%u" for u32, and improve the error message.
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: default avatarClaudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Tested-by: default avatarClaudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: default avatarAndi Shyti <andi.shyti@kernel.org>
parent bc07fb41
...@@ -316,16 +316,13 @@ static int riic_init_hw(struct riic_dev *riic) ...@@ -316,16 +316,13 @@ static int riic_init_hw(struct riic_dev *riic)
struct i2c_timings *t = &riic->i2c_t; struct i2c_timings *t = &riic->i2c_t;
struct device *dev = riic->adapter.dev.parent; struct device *dev = riic->adapter.dev.parent;
bool fast_mode_plus = riic->info->fast_mode_plus; bool fast_mode_plus = riic->info->fast_mode_plus;
u32 max_freq = fast_mode_plus ? I2C_MAX_FAST_MODE_PLUS_FREQ
: I2C_MAX_FAST_MODE_FREQ;
if ((!fast_mode_plus && t->bus_freq_hz > I2C_MAX_FAST_MODE_FREQ) || if (t->bus_freq_hz > max_freq)
(fast_mode_plus && t->bus_freq_hz > I2C_MAX_FAST_MODE_PLUS_FREQ)) { return dev_err_probe(&riic->adapter.dev, -EINVAL,
dev_err(&riic->adapter.dev, "unsupported bus speed %uHz (%u max)\n",
"unsupported bus speed (%dHz). %d max\n", t->bus_freq_hz, max_freq);
t->bus_freq_hz,
fast_mode_plus ? I2C_MAX_FAST_MODE_PLUS_FREQ :
I2C_MAX_FAST_MODE_FREQ);
return -EINVAL;
}
rate = clk_get_rate(riic->clk); rate = clk_get_rate(riic->clk);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment