linux-stable/drivers/i2c
Geert Uytterhoeven de6b43798d i2c: riic: Always round-up when calculating bus period
Currently, the RIIC driver may run the I2C bus faster than requested,
which may cause subtle failures.  E.g. Biju reported a measured bus
speed of 450 kHz instead of the expected maximum of 400 kHz on RZ/G2L.

The initial calculation of the bus period uses DIV_ROUND_UP(), to make
sure the actual bus speed never becomes faster than the requested bus
speed.  However, the subsequent division-by-two steps do not use
round-up, which may lead to a too-small period, hence a too-fast and
possible out-of-spec bus speed.  E.g. on RZ/Five, requesting a bus speed
of 100 resp. 400 kHz will yield too-fast target bus speeds of 100806
resp. 403226 Hz instead of 97656 resp. 390625 Hz.

Fix this by using DIV_ROUND_UP() in the subsequent divisions, too.

Tested on RZ/A1H, RZ/A2M, and RZ/Five.

Fixes: d982d66514 ("i2c: riic: remove clock and frequency restrictions")
Reported-by: Biju Das <biju.das.jz@bp.renesas.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: <stable@vger.kernel.org> # v4.15+
Link: https://lore.kernel.org/r/c59aea77998dfea1b4456c4b33b55ab216fcbf5e.1732284746.git.geert+renesas@glider.be
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
2024-12-12 12:54:02 +01:00
..
algos i2c: algo: bit: allow getsda to be NULL 2023-01-23 23:15:49 +01:00
busses i2c: riic: Always round-up when calculating bus period 2024-12-12 12:54:02 +01:00
muxes i2c: Switch back to struct platform_driver::remove() 2024-11-17 11:58:14 +01:00
i2c-atr.c module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00
i2c-boardinfo.c i2c: Remove support for dangling device properties 2021-04-10 21:43:02 +02:00
i2c-core-acpi.c i2c: acpi: Unbind mux adapters before delete 2024-05-06 09:17:38 +02:00
i2c-core-base.c The DesignWare and the Renesas I2C drivers have received most of 2024-09-21 12:46:00 +02:00
i2c-core-of-prober.c module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00
i2c-core-of.c Char/Misc drivers for 6.4-rc1 2023-04-27 12:07:50 -07:00
i2c-core-slave.c i2c: simplify with scoped for each OF child loop 2024-09-03 12:01:52 +02:00
i2c-core-smbus.c i2c: Fix whitespace style issue 2024-11-27 12:23:43 +01:00
i2c-core.h i2c: core: Fix atomic xfer check for non-preempt config 2024-01-06 14:10:10 +01:00
i2c-dev.c i2c: dev: Fix memory leak when underlying adapter does not support I2C 2024-11-14 11:22:57 +01:00
i2c-mux.c i2c: mux: Remove class argument from i2c_mux_add_adapter() 2024-05-13 16:13:19 +02:00
i2c-slave-eeprom.c i2c: Convert drivers to new .probe() callback 2023-03-09 21:59:30 +01:00
i2c-slave-testunit.c i2c: testunit: improve error handling for GPIO 2024-10-08 10:15:42 +02:00
i2c-smbus.c i2c: support gpio-binding for SMBAlerts 2024-10-08 11:04:20 +02:00
i2c-stub.c i2c: stub: Don't let i2c adapters declare I2C_CLASS_SPD support if they support I2C_CLASS_HWMON 2024-01-18 21:10:41 +01:00
Kconfig i2c: Remove I2C_COMPAT config symbol and related code 2024-09-07 18:31:28 +02:00
Makefile i2c: Introduce OF component probe function 2024-11-27 12:04:10 +01:00