From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Wolfram Sang <wsa@the-dreams.de>, linux-i2c@vger.kernel.org
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v5 3/6] i2c: rcar: Consolidate timings calls in rcar_i2c_clock_calculate()
Date: Tue, 24 Mar 2020 14:32:13 +0200 [thread overview]
Message-ID: <20200324123216.78113-3-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20200324123216.78113-1-andriy.shevchenko@linux.intel.com>
Move i2c_parse_fw_timings() to rcar_i2c_clock_calculate() to consolidate
timings calls in one place.
While here, replace hard coded values with standard bus frequency definitions.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v5: switched to timings definition on stack (Wolfram)
drivers/i2c/busses/i2c-rcar.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index c8b57ded0e7b..25013641a85d 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -235,17 +235,20 @@ static int rcar_i2c_bus_barrier(struct rcar_i2c_priv *priv)
return i2c_recover_bus(&priv->adap);
}
-static int rcar_i2c_clock_calculate(struct rcar_i2c_priv *priv, struct i2c_timings *t)
+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 = {
+ .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 */
- t->bus_freq_hz = t->bus_freq_hz ?: 100000;
- t->scl_fall_ns = t->scl_fall_ns ?: 35;
- t->scl_rise_ns = t->scl_rise_ns ?: 200;
- t->scl_int_delay_ns = t->scl_int_delay_ns ?: 50;
+ i2c_parse_fw_timings(dev, &i2c_t, false);
switch (priv->devtype) {
case I2C_RCAR_GEN1:
@@ -920,7 +923,6 @@ static int rcar_i2c_probe(struct platform_device *pdev)
struct rcar_i2c_priv *priv;
struct i2c_adapter *adap;
struct device *dev = &pdev->dev;
- struct i2c_timings i2c_t = { 0 };
int ret;
/* Otherwise logic will break because some bytes must always use PIO */
@@ -957,8 +959,6 @@ static int rcar_i2c_probe(struct platform_device *pdev)
i2c_set_adapdata(adap, priv);
strlcpy(adap->name, pdev->name, sizeof(adap->name));
- i2c_parse_fw_timings(dev, &i2c_t, false);
-
/* Init DMA */
sg_init_table(&priv->sg, 1);
priv->dma_direction = DMA_NONE;
@@ -967,7 +967,7 @@ static int rcar_i2c_probe(struct platform_device *pdev)
/* Activate device for clock calculation */
pm_runtime_enable(dev);
pm_runtime_get_sync(dev);
- ret = rcar_i2c_clock_calculate(priv, &i2c_t);
+ ret = rcar_i2c_clock_calculate(priv);
if (ret < 0)
goto out_pm_put;
--
2.25.1
next prev parent reply other threads:[~2020-03-24 12:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-24 12:32 [PATCH v5 1/6] i2c: core: Provide generic definitions for bus frequencies Andy Shevchenko
2020-03-24 12:32 ` [PATCH v5 2/6] i2c: core: Allow override timing properties with 0 Andy Shevchenko
2020-03-24 21:09 ` Wolfram Sang
2020-03-24 12:32 ` Andy Shevchenko [this message]
2020-03-24 21:09 ` [PATCH v5 3/6] i2c: rcar: Consolidate timings calls in rcar_i2c_clock_calculate() Wolfram Sang
2020-03-24 12:32 ` [PATCH v5 4/6] i2c: stm32f7: switch to I²C generic property parsing Andy Shevchenko
2020-03-24 21:09 ` Wolfram Sang
2020-03-24 12:32 ` [PATCH v5 5/6] i2c: algo: Use generic definitions for bus frequencies Andy Shevchenko
2020-03-24 21:09 ` Wolfram Sang
2020-03-24 21:09 ` [PATCH v5 1/6] i2c: core: Provide " Wolfram Sang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200324123216.78113-3-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=linux-i2c@vger.kernel.org \
--cc=wsa@the-dreams.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.