Skip to content

Commit

Permalink
i2c: rcar: clean up after refactoring i2c_timings
Browse files Browse the repository at this point in the history
The pointer is not really needed anymore since we have the timings
struct available in the function itself now. Remove the pointer and
access the struct directly.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
  • Loading branch information
Wolfram Sang authored and Wolfram Sang committed Mar 31, 2020
1 parent 624d1be commit df576be
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/i2c/busses/i2c-rcar.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,15 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv)
u32 scgd, cdf, round, ick, sum, scl, cdf_width;
unsigned long rate;
struct device *dev = rcar_i2c_priv_to_dev(priv);
struct i2c_timings i2c_t = {
struct i2c_timings t = {
.bus_freq_hz = I2C_MAX_STANDARD_MODE_FREQ,
.scl_fall_ns = 35,
.scl_rise_ns = 200,
.scl_int_delay_ns = 50,
}, *t = &i2c_t;
};

/* Fall back to previously used values if not supplied */
i2c_parse_fw_timings(dev, &i2c_t, false);
i2c_parse_fw_timings(dev, &t, false);

switch (priv->devtype) {
case I2C_RCAR_GEN1:
Expand Down Expand Up @@ -294,7 +294,7 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv)
* = F[sum * ick / 1000000000]
* = F[(ick / 1000000) * sum / 1000]
*/
sum = t->scl_fall_ns + t->scl_rise_ns + t->scl_int_delay_ns;
sum = t.scl_fall_ns + t.scl_rise_ns + t.scl_int_delay_ns;
round = (ick + 500000) / 1000000 * sum;
round = (round + 500) / 1000;

Expand All @@ -312,15 +312,15 @@ static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv)
*/
for (scgd = 0; scgd < 0x40; scgd++) {
scl = ick / (20 + (scgd * 8) + round);
if (scl <= t->bus_freq_hz)
if (scl <= t.bus_freq_hz)
goto scgd_find;
}
dev_err(dev, "it is impossible to calculate best SCL\n");
return -EIO;

scgd_find:
dev_dbg(dev, "clk %d/%d(%lu), round %u, CDF:0x%x, SCGD: 0x%x\n",
scl, t->bus_freq_hz, rate, round, cdf, scgd);
scl, t.bus_freq_hz, rate, round, cdf, scgd);

/* keep icccr value */
priv->icccr = scgd << cdf_width | cdf;
Expand Down

0 comments on commit df576be

Please sign in to comment.