From 380b107bbf9449ddea0637cefe65a6cbf7b6ca84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20S=C3=A1?= Date: Tue, 7 Jan 2020 13:17:04 +0200 Subject: iio: adis: Introduce timeouts structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The adis library only allows to define a `startup_delay` which for some devices is enough. However, other devices define different timeouts with significantly different timings which could lead to devices to not wait enough time or to wait a lot more than necessary (which is not efficient). This patch introduces a new timeout struct that must be passed into `adis_init()`. There are mainly, for now, three timeouts used. This is also an introductory patch with the goal of refactoring `adis_initial_startup()`. New driver's (eg: adis16480, adis16460) are replicating code for the device initial setup. With some changes (being this the first one) we can pass this to `adis_initial_startup()`. Signed-off-by: Nuno Sá Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16203.c | 7 +++++++ drivers/staging/iio/accel/adis16240.c | 7 +++++++ 2 files changed, 14 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c index 39687139a7d3..3d706ee02df0 100644 --- a/drivers/staging/iio/accel/adis16203.c +++ b/drivers/staging/iio/accel/adis16203.c @@ -237,6 +237,12 @@ static const char * const adis16203_status_error_msgs[] = { [ADIS16203_DIAG_STAT_POWER_LOW_BIT] = "Power supply below 2.975V", }; +static const struct adis_timeout adis16203_timeouts = { + .reset_ms = ADIS16203_STARTUP_DELAY, + .sw_reset_ms = ADIS16203_STARTUP_DELAY, + .self_test_ms = ADIS16203_STARTUP_DELAY +}; + static const struct adis_data adis16203_data = { .read_delay = 20, .msc_ctrl_reg = ADIS16203_MSC_CTRL, @@ -246,6 +252,7 @@ static const struct adis_data adis16203_data = { .self_test_mask = ADIS16203_MSC_CTRL_SELF_TEST_EN, .self_test_no_autoclear = true, .startup_delay = ADIS16203_STARTUP_DELAY, + .timeouts = &adis16203_timeouts, .status_error_msgs = adis16203_status_error_msgs, .status_error_mask = BIT(ADIS16203_DIAG_STAT_SELFTEST_FAIL_BIT) | diff --git a/drivers/staging/iio/accel/adis16240.c b/drivers/staging/iio/accel/adis16240.c index 794f063e6c86..d4848ef78c75 100644 --- a/drivers/staging/iio/accel/adis16240.c +++ b/drivers/staging/iio/accel/adis16240.c @@ -359,6 +359,12 @@ static const char * const adis16240_status_error_msgs[] = { [ADIS16240_DIAG_STAT_POWER_LOW_BIT] = "Power supply below 2.225V", }; +static const struct adis_timeout adis16240_timeouts = { + .reset_ms = ADIS16240_STARTUP_DELAY, + .sw_reset_ms = ADIS16240_STARTUP_DELAY, + .self_test_ms = ADIS16240_STARTUP_DELAY, +}; + static const struct adis_data adis16240_data = { .write_delay = 35, .read_delay = 35, @@ -369,6 +375,7 @@ static const struct adis_data adis16240_data = { .self_test_mask = ADIS16240_MSC_CTRL_SELF_TEST_EN, .self_test_no_autoclear = true, .startup_delay = ADIS16240_STARTUP_DELAY, + .timeouts = &adis16240_timeouts, .status_error_msgs = adis16240_status_error_msgs, .status_error_mask = BIT(ADIS16240_DIAG_STAT_PWRON_FAIL_BIT) | -- cgit v1.2.3 From 77038bd01ce66ae65bcb66266c9747b670b5facd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20S=C3=A1?= Date: Tue, 7 Jan 2020 13:17:05 +0200 Subject: iio: adis: Remove startup_delay MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All timeouts are now handled by a dedicated timeout struct. This variable is no longer needed. Signed-off-by: Nuno Sá Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16203.c | 1 - drivers/staging/iio/accel/adis16240.c | 1 - 2 files changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c index 3d706ee02df0..39dfe3f7f254 100644 --- a/drivers/staging/iio/accel/adis16203.c +++ b/drivers/staging/iio/accel/adis16203.c @@ -251,7 +251,6 @@ static const struct adis_data adis16203_data = { .self_test_mask = ADIS16203_MSC_CTRL_SELF_TEST_EN, .self_test_no_autoclear = true, - .startup_delay = ADIS16203_STARTUP_DELAY, .timeouts = &adis16203_timeouts, .status_error_msgs = adis16203_status_error_msgs, diff --git a/drivers/staging/iio/accel/adis16240.c b/drivers/staging/iio/accel/adis16240.c index d4848ef78c75..39eb8364aa95 100644 --- a/drivers/staging/iio/accel/adis16240.c +++ b/drivers/staging/iio/accel/adis16240.c @@ -374,7 +374,6 @@ static const struct adis_data adis16240_data = { .self_test_mask = ADIS16240_MSC_CTRL_SELF_TEST_EN, .self_test_no_autoclear = true, - .startup_delay = ADIS16240_STARTUP_DELAY, .timeouts = &adis16240_timeouts, .status_error_msgs = adis16240_status_error_msgs, -- cgit v1.2.3