diff mbox series

[v2,9/9] iio: adis16460: Make use of __adis_initial_startup

Message ID 20200210132606.9315-9-alexandru.ardelean@analog.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/9] iio: imu: adis16480: initialize adis_data statically | expand

Commit Message

Alexandru Ardelean Feb. 10, 2020, 1:26 p.m. UTC
From: Nuno Sá <nuno.sa@analog.com>

All of the actions done in `adis16460_initial_setup()` are now done in
`__adis_initial_startup()` so, there's no need for code duplication.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
---
 drivers/iio/imu/adis16460.c | 38 +++----------------------------------
 1 file changed, 3 insertions(+), 35 deletions(-)

Comments

Jonathan Cameron Feb. 14, 2020, 2:45 p.m. UTC | #1
On Mon, 10 Feb 2020 15:26:06 +0200
Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:

> From: Nuno Sá <nuno.sa@analog.com>
> 
> All of the actions done in `adis16460_initial_setup()` are now done in
> `__adis_initial_startup()` so, there's no need for code duplication.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>

Applied.

Thanks,

Jonathan

> ---
>  drivers/iio/imu/adis16460.c | 38 +++----------------------------------
>  1 file changed, 3 insertions(+), 35 deletions(-)
> 
> diff --git a/drivers/iio/imu/adis16460.c b/drivers/iio/imu/adis16460.c
> index 42fa473c6d81..0027683d0256 100644
> --- a/drivers/iio/imu/adis16460.c
> +++ b/drivers/iio/imu/adis16460.c
> @@ -333,40 +333,6 @@ static int adis16460_enable_irq(struct adis *adis, bool enable)
>  	return 0;
>  }
>  
> -static int adis16460_initial_setup(struct iio_dev *indio_dev)
> -{
> -	struct adis16460 *st = iio_priv(indio_dev);
> -	uint16_t prod_id;
> -	unsigned int device_id;
> -	int ret;
> -
> -	adis_reset(&st->adis);
> -	msleep(222);
> -
> -	ret = adis_write_reg_16(&st->adis, ADIS16460_REG_GLOB_CMD, BIT(1));
> -	if (ret)
> -		return ret;
> -	msleep(75);
> -
> -	ret = adis_check_status(&st->adis);
> -	if (ret)
> -		return ret;
> -
> -	ret = adis_read_reg_16(&st->adis, ADIS16460_REG_PROD_ID, &prod_id);
> -	if (ret)
> -		return ret;
> -
> -	ret = sscanf(indio_dev->name, "adis%u\n", &device_id);
> -	if (ret != 1)
> -		return -EINVAL;
> -
> -	if (prod_id != device_id)
> -		dev_warn(&indio_dev->dev, "Device ID(%u) and product ID(%u) do not match.",
> -				device_id, prod_id);
> -
> -	return 0;
> -}
> -
>  #define ADIS16460_DIAG_STAT_IN_CLK_OOS	7
>  #define ADIS16460_DIAG_STAT_FLASH_MEM	6
>  #define ADIS16460_DIAG_STAT_SELF_TEST	5
> @@ -392,6 +358,8 @@ static const struct adis_timeout adis16460_timeouts = {
>  static const struct adis_data adis16460_data = {
>  	.diag_stat_reg = ADIS16460_REG_DIAG_STAT,
>  	.glob_cmd_reg = ADIS16460_REG_GLOB_CMD,
> +	.prod_id_reg = ADIS16460_REG_PROD_ID,
> +	.prod_id = 16460,
>  	.self_test_mask = BIT(2),
>  	.self_test_reg = ADIS16460_REG_GLOB_CMD,
>  	.has_paging = false,
> @@ -441,7 +409,7 @@ static int adis16460_probe(struct spi_device *spi)
>  
>  	adis16460_enable_irq(&st->adis, 0);
>  
> -	ret = adis16460_initial_setup(indio_dev);
> +	ret = __adis_initial_startup(&st->adis);
>  	if (ret)
>  		goto error_cleanup_buffer;
>
diff mbox series

Patch

diff --git a/drivers/iio/imu/adis16460.c b/drivers/iio/imu/adis16460.c
index 42fa473c6d81..0027683d0256 100644
--- a/drivers/iio/imu/adis16460.c
+++ b/drivers/iio/imu/adis16460.c
@@ -333,40 +333,6 @@  static int adis16460_enable_irq(struct adis *adis, bool enable)
 	return 0;
 }
 
-static int adis16460_initial_setup(struct iio_dev *indio_dev)
-{
-	struct adis16460 *st = iio_priv(indio_dev);
-	uint16_t prod_id;
-	unsigned int device_id;
-	int ret;
-
-	adis_reset(&st->adis);
-	msleep(222);
-
-	ret = adis_write_reg_16(&st->adis, ADIS16460_REG_GLOB_CMD, BIT(1));
-	if (ret)
-		return ret;
-	msleep(75);
-
-	ret = adis_check_status(&st->adis);
-	if (ret)
-		return ret;
-
-	ret = adis_read_reg_16(&st->adis, ADIS16460_REG_PROD_ID, &prod_id);
-	if (ret)
-		return ret;
-
-	ret = sscanf(indio_dev->name, "adis%u\n", &device_id);
-	if (ret != 1)
-		return -EINVAL;
-
-	if (prod_id != device_id)
-		dev_warn(&indio_dev->dev, "Device ID(%u) and product ID(%u) do not match.",
-				device_id, prod_id);
-
-	return 0;
-}
-
 #define ADIS16460_DIAG_STAT_IN_CLK_OOS	7
 #define ADIS16460_DIAG_STAT_FLASH_MEM	6
 #define ADIS16460_DIAG_STAT_SELF_TEST	5
@@ -392,6 +358,8 @@  static const struct adis_timeout adis16460_timeouts = {
 static const struct adis_data adis16460_data = {
 	.diag_stat_reg = ADIS16460_REG_DIAG_STAT,
 	.glob_cmd_reg = ADIS16460_REG_GLOB_CMD,
+	.prod_id_reg = ADIS16460_REG_PROD_ID,
+	.prod_id = 16460,
 	.self_test_mask = BIT(2),
 	.self_test_reg = ADIS16460_REG_GLOB_CMD,
 	.has_paging = false,
@@ -441,7 +409,7 @@  static int adis16460_probe(struct spi_device *spi)
 
 	adis16460_enable_irq(&st->adis, 0);
 
-	ret = adis16460_initial_setup(indio_dev);
+	ret = __adis_initial_startup(&st->adis);
 	if (ret)
 		goto error_cleanup_buffer;