Re: [PATCH v2 6/8] i2c: designware: Separate timing parameter setting from HW initalization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06/04/2018 03:48 PM, Andy Shevchenko wrote:
On Fri, 2018-06-01 at 16:47 +0300, Jarkko Nikula wrote:
Mixed timing parameter validation, calculation and their debug prints
with HW initialization in i2c_dw_init_master() and i2c_dw_init_slave()
has been bothering me some time.

It makes function a little bit unclear to follow, doesn't show what
steps
are needed to do only once during probe and what are needed whenever
HW
needs to be reinitialized. Also those debug prints show information
that
doesn't change runtime and thus are also needlessly printed multiple
times
whenever HW is reinitialized.

Thus let the i2c_dw_init_master() and i2c_dw_init_slave() to do only
HW
initialization and move out one time parameter setting and debug
prints
to separate functions which are called only during probe.

Signed-off-by: Jarkko Nikula <jarkko.nikula@xxxxxxxxxxxxxxx>
---
v2:
- SDA hold time configuration change moved to a new patch
- Indentation change around i2c_dw_scl_hcnt()/i2c_dw_scl_lcnt() and
   i2c_dw_clk_rate() cleanup moved to a new patch
- fp_str pointing to empty or " Plus" string for simpler fast
mode/fast
   mode plus debug prints in this and another patch in this series
---
  drivers/i2c/busses/i2c-designware-master.c | 128 +++++++++++++-------
-
  1 file changed, 77 insertions(+), 51 deletions(-)

diff --git a/drivers/i2c/busses/i2c-designware-master.c
b/drivers/i2c/busses/i2c-designware-master.c
index 6557e163065e..e3a56c8e33c7 100644
--- a/drivers/i2c/busses/i2c-designware-master.c
+++ b/drivers/i2c/busses/i2c-designware-master.c
@@ -46,85 +46,77 @@ static void i2c_dw_configure_fifo_master(struct
dw_i2c_dev *dev)
  }
static void i2c_dw_set_timings_master(struct dw_i2c_dev *dev)
-{
-	i2c_dw_set_sda_hold(dev);
-}
-
-/**
- * i2c_dw_init() - Initialize the designware I2C master hardware
- * @dev: device private data
- *
- * This functions configures and enables the I2C master.
- * This function is called during I2C init function, and in case of
timeout at
- * run time.
- */
-static int i2c_dw_init_master(struct dw_i2c_dev *dev)
  {
  	u32 ic_clk = i2c_dw_clk_rate(dev);
-	u32 hcnt, lcnt;
+	const char *fp_str = "";
  	u32 comp_param1;
  	u32 sda_falling_time, scl_falling_time;
  	int ret;
ret = i2c_dw_acquire_lock(dev);
  	if (ret)
-		return ret;
-
+		return;

Shouldn't we return an error code to the caller?
Previously we abort initialization IIUC and now silently skip the timing
settings completely. Feels like a regression.

Yes we should, thanks for spotting. I added locking while cooking the first version but failed to realize this regression in case we are not able to get the lock.

--
Jarkko



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux