All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: designware: Call i2c_dw_clk_rate() only when calculating timings
@ 2018-10-01 11:49 Jarkko Nikula
  2018-10-01 13:10 ` Ard Biesheuvel
  2018-10-05 11:41 ` Wolfram Sang
  0 siblings, 2 replies; 3+ messages in thread
From: Jarkko Nikula @ 2018-10-01 11:49 UTC (permalink / raw)
  To: linux-i2c
  Cc: Wolfram Sang, Ard Biesheuvel, Andy Shevchenko, Mika Westerberg,
	Jarkko Nikula, stable

There are platforms which don't provide input clock rate but provide
I2C timing parameters. Commit 3bd4f277274b ("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: 3bd4f277274b ("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>
---
for current 4.19-rc6. I Cc'ed stable just in case this doesn't hit the
v4.19.
---
 drivers/i2c/busses/i2c-designware-master.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
index 94d94b4a9a0d..18cc324f3ca9 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -34,11 +34,11 @@ static void i2c_dw_configure_fifo_master(struct dw_i2c_dev *dev)
 
 static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev)
 {
-	u32 ic_clk = i2c_dw_clk_rate(dev);
 	const char *mode_str, *fp_str = "";
 	u32 comp_param1;
 	u32 sda_falling_time, scl_falling_time;
 	struct i2c_timings *t = &dev->timings;
+	u32 ic_clk;
 	int ret;
 
 	ret = i2c_dw_acquire_lock(dev);
@@ -53,6 +53,7 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev)
 
 	/* Calculate SCL timing parameters for standard mode if not set */
 	if (!dev->ss_hcnt || !dev->ss_lcnt) {
+		ic_clk = i2c_dw_clk_rate(dev);
 		dev->ss_hcnt =
 			i2c_dw_scl_hcnt(ic_clk,
 					4000,	/* tHD;STA = tHIGH = 4.0 us */
@@ -89,6 +90,7 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev)
 	 * needed also in high speed mode.
 	 */
 	if (!dev->fs_hcnt || !dev->fs_lcnt) {
+		ic_clk = i2c_dw_clk_rate(dev);
 		dev->fs_hcnt =
 			i2c_dw_scl_hcnt(ic_clk,
 					600,	/* tHD;STA = tHIGH = 0.6 us */
-- 
2.19.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] i2c: designware: Call i2c_dw_clk_rate() only when calculating timings
  2018-10-01 11:49 [PATCH] i2c: designware: Call i2c_dw_clk_rate() only when calculating timings Jarkko Nikula
@ 2018-10-01 13:10 ` Ard Biesheuvel
  2018-10-05 11:41 ` Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2018-10-01 13:10 UTC (permalink / raw)
  To: Jarkko Nikula
  Cc: linux-i2c, Wolfram Sang, Andy Shevchenko, Mika Westerberg, stable

On 1 October 2018 at 13:49, Jarkko Nikula <jarkko.nikula@linux.intel.com> wrote:
> There are platforms which don't provide input clock rate but provide
> I2C timing parameters. Commit 3bd4f277274b ("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: 3bd4f277274b ("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>

Thanks!

> ---
> for current 4.19-rc6. I Cc'ed stable just in case this doesn't hit the
> v4.19.
> ---
>  drivers/i2c/busses/i2c-designware-master.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
> index 94d94b4a9a0d..18cc324f3ca9 100644
> --- a/drivers/i2c/busses/i2c-designware-master.c
> +++ b/drivers/i2c/busses/i2c-designware-master.c
> @@ -34,11 +34,11 @@ static void i2c_dw_configure_fifo_master(struct dw_i2c_dev *dev)
>
>  static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev)
>  {
> -       u32 ic_clk = i2c_dw_clk_rate(dev);
>         const char *mode_str, *fp_str = "";
>         u32 comp_param1;
>         u32 sda_falling_time, scl_falling_time;
>         struct i2c_timings *t = &dev->timings;
> +       u32 ic_clk;
>         int ret;
>
>         ret = i2c_dw_acquire_lock(dev);
> @@ -53,6 +53,7 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev)
>
>         /* Calculate SCL timing parameters for standard mode if not set */
>         if (!dev->ss_hcnt || !dev->ss_lcnt) {
> +               ic_clk = i2c_dw_clk_rate(dev);
>                 dev->ss_hcnt =
>                         i2c_dw_scl_hcnt(ic_clk,
>                                         4000,   /* tHD;STA = tHIGH = 4.0 us */
> @@ -89,6 +90,7 @@ static int i2c_dw_set_timings_master(struct dw_i2c_dev *dev)
>          * needed also in high speed mode.
>          */
>         if (!dev->fs_hcnt || !dev->fs_lcnt) {
> +               ic_clk = i2c_dw_clk_rate(dev);
>                 dev->fs_hcnt =
>                         i2c_dw_scl_hcnt(ic_clk,
>                                         600,    /* tHD;STA = tHIGH = 0.6 us */
> --
> 2.19.0
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] i2c: designware: Call i2c_dw_clk_rate() only when calculating timings
  2018-10-01 11:49 [PATCH] i2c: designware: Call i2c_dw_clk_rate() only when calculating timings Jarkko Nikula
  2018-10-01 13:10 ` Ard Biesheuvel
@ 2018-10-05 11:41 ` Wolfram Sang
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2018-10-05 11:41 UTC (permalink / raw)
  To: Jarkko Nikula
  Cc: linux-i2c, Ard Biesheuvel, Andy Shevchenko, Mika Westerberg, stable

[-- Attachment #1: Type: text/plain, Size: 780 bytes --]

On Mon, Oct 01, 2018 at 02:49:05PM +0300, Jarkko Nikula wrote:
> There are platforms which don't provide input clock rate but provide
> I2C timing parameters. Commit 3bd4f277274b ("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: 3bd4f277274b ("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>

Applied to for-current, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-05 11:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-01 11:49 [PATCH] i2c: designware: Call i2c_dw_clk_rate() only when calculating timings Jarkko Nikula
2018-10-01 13:10 ` Ard Biesheuvel
2018-10-05 11:41 ` Wolfram Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.