Skip to content

Commit 9ce7610

Browse files
jhnikulaWolfram Sang
authored andcommitted
i2c: designware: Call i2c_dw_clk_rate() only when calculating timings
There are platforms which don't provide input clock rate but provide I2C timing parameters. Commit 3bd4f27 ("i2c: designware: Call i2c_dw_clk_rate() only once in i2c_dw_init_master()") causes needless warning during probe on those platforms since i2c_dw_clk_rate(), which causes the warning when input clock is unknown, is called even when there is no need to calculate timing parameters. Fixes: 3bd4f27 ("i2c: designware: Call i2c_dw_clk_rate() only once in i2c_dw_init_master()") Reported-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: <stable@vger.kernel.org> # 4.19 Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
1 parent 08d9db0 commit 9ce7610

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/i2c/busses/i2c-designware-master.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ static void i2c_dw_configure_fifo_master(struct dw_i2c_dev *dev)
3434

3535
static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev)
3636
{
37-
u32 ic_clk = i2c_dw_clk_rate(dev);
3837
const char *mode_str, *fp_str = "";
3938
u32 comp_param1;
4039
u32 sda_falling_time, scl_falling_time;
4140
struct i2c_timings *t = &dev->timings;
41+
u32 ic_clk;
4242
int ret;
4343

4444
ret = i2c_dw_acquire_lock(dev);
@@ -53,6 +53,7 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev)
5353

5454
/* Calculate SCL timing parameters for standard mode if not set */
5555
if (!dev->ss_hcnt || !dev->ss_lcnt) {
56+
ic_clk = i2c_dw_clk_rate(dev);
5657
dev->ss_hcnt =
5758
i2c_dw_scl_hcnt(ic_clk,
5859
4000, /* tHD;STA = tHIGH = 4.0 us */
@@ -89,6 +90,7 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev)
8990
* needed also in high speed mode.
9091
*/
9192
if (!dev->fs_hcnt || !dev->fs_lcnt) {
93+
ic_clk = i2c_dw_clk_rate(dev);
9294
dev->fs_hcnt =
9395
i2c_dw_scl_hcnt(ic_clk,
9496
600, /* tHD;STA = tHIGH = 0.6 us */

0 commit comments

Comments
 (0)