All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<nuno.sa@analog.com>
Subject: Re: [PATCH v2 2/9] iio: imu: adis16400: initialize adis_data statically
Date: Fri, 14 Feb 2020 14:29:23 +0000	[thread overview]
Message-ID: <20200214142923.7838cdf7@archlinux> (raw)
In-Reply-To: <20200210132606.9315-2-alexandru.ardelean@analog.com>

On Mon, 10 Feb 2020 15:25:59 +0200
Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:

> This change overrides commit 380b107bbf944 ("iio: adis: Introduce timeouts
> structure"). It removes the memory allocation and moves the 'adis_data'
> information to be static on the chip_info struct.
> 
> This also adds a timeout structure to ADIS16334, since it was initially
> omitted. This was omitted (by accident) when the change was done.
> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Applied.  Thanks,

Jonathan

> ---
>  drivers/iio/imu/adis16400.c | 139 ++++++++++++++++--------------------
>  1 file changed, 63 insertions(+), 76 deletions(-)
> 
> diff --git a/drivers/iio/imu/adis16400.c b/drivers/iio/imu/adis16400.c
> index cfb1c19eb930..1c0770e03ec9 100644
> --- a/drivers/iio/imu/adis16400.c
> +++ b/drivers/iio/imu/adis16400.c
> @@ -156,7 +156,7 @@ struct adis16400_state;
>  
>  struct adis16400_chip_info {
>  	const struct iio_chan_spec *channels;
> -	const struct adis_timeout *timeouts;
> +	const struct adis_data adis_data;
>  	const int num_channels;
>  	const long flags;
>  	unsigned int gyro_scale_micro;
> @@ -930,12 +930,63 @@ static const struct iio_chan_spec adis16334_channels[] = {
>  	IIO_CHAN_SOFT_TIMESTAMP(ADIS16400_SCAN_TIMESTAMP),
>  };
>  
> +static const char * const adis16400_status_error_msgs[] = {
> +	[ADIS16400_DIAG_STAT_ZACCL_FAIL] = "Z-axis accelerometer self-test failure",
> +	[ADIS16400_DIAG_STAT_YACCL_FAIL] = "Y-axis accelerometer self-test failure",
> +	[ADIS16400_DIAG_STAT_XACCL_FAIL] = "X-axis accelerometer self-test failure",
> +	[ADIS16400_DIAG_STAT_XGYRO_FAIL] = "X-axis gyroscope self-test failure",
> +	[ADIS16400_DIAG_STAT_YGYRO_FAIL] = "Y-axis gyroscope self-test failure",
> +	[ADIS16400_DIAG_STAT_ZGYRO_FAIL] = "Z-axis gyroscope self-test failure",
> +	[ADIS16400_DIAG_STAT_ALARM2] = "Alarm 2 active",
> +	[ADIS16400_DIAG_STAT_ALARM1] = "Alarm 1 active",
> +	[ADIS16400_DIAG_STAT_FLASH_CHK] = "Flash checksum error",
> +	[ADIS16400_DIAG_STAT_SELF_TEST] = "Self test error",
> +	[ADIS16400_DIAG_STAT_OVERFLOW] = "Sensor overrange",
> +	[ADIS16400_DIAG_STAT_SPI_FAIL] = "SPI failure",
> +	[ADIS16400_DIAG_STAT_FLASH_UPT] = "Flash update failed",
> +	[ADIS16400_DIAG_STAT_POWER_HIGH] = "Power supply above 5.25V",
> +	[ADIS16400_DIAG_STAT_POWER_LOW] = "Power supply below 4.75V",
> +};
> +
> +#define ADIS16400_DATA(_timeouts)					\
> +{									\
> +	.msc_ctrl_reg = ADIS16400_MSC_CTRL,				\
> +	.glob_cmd_reg = ADIS16400_GLOB_CMD,				\
> +	.diag_stat_reg = ADIS16400_DIAG_STAT,				\
> +	.read_delay = 50,						\
> +	.write_delay = 50,						\
> +	.self_test_mask = ADIS16400_MSC_CTRL_MEM_TEST,			\
> +	.status_error_msgs = adis16400_status_error_msgs,		\
> +	.status_error_mask = BIT(ADIS16400_DIAG_STAT_ZACCL_FAIL) |	\
> +		BIT(ADIS16400_DIAG_STAT_YACCL_FAIL) |			\
> +		BIT(ADIS16400_DIAG_STAT_XACCL_FAIL) |			\
> +		BIT(ADIS16400_DIAG_STAT_XGYRO_FAIL) |			\
> +		BIT(ADIS16400_DIAG_STAT_YGYRO_FAIL) |			\
> +		BIT(ADIS16400_DIAG_STAT_ZGYRO_FAIL) |			\
> +		BIT(ADIS16400_DIAG_STAT_ALARM2) |			\
> +		BIT(ADIS16400_DIAG_STAT_ALARM1) |			\
> +		BIT(ADIS16400_DIAG_STAT_FLASH_CHK) |			\
> +		BIT(ADIS16400_DIAG_STAT_SELF_TEST) |			\
> +		BIT(ADIS16400_DIAG_STAT_OVERFLOW) |			\
> +		BIT(ADIS16400_DIAG_STAT_SPI_FAIL) |			\
> +		BIT(ADIS16400_DIAG_STAT_FLASH_UPT) |			\
> +		BIT(ADIS16400_DIAG_STAT_POWER_HIGH) |			\
> +		BIT(ADIS16400_DIAG_STAT_POWER_LOW),			\
> +	.timeouts = (_timeouts),					\
> +}
> +
>  static const struct adis_timeout adis16300_timeouts = {
>  	.reset_ms = ADIS16400_STARTUP_DELAY,
>  	.sw_reset_ms = ADIS16400_STARTUP_DELAY,
>  	.self_test_ms = ADIS16400_STARTUP_DELAY,
>  };
>  
> +static const struct adis_timeout adis16334_timeouts = {
> +	.reset_ms = 60,
> +	.sw_reset_ms = 60,
> +	.self_test_ms = 14,
> +};
> +
>  static const struct adis_timeout adis16362_timeouts = {
>  	.reset_ms = 130,
>  	.sw_reset_ms = 130,
> @@ -972,7 +1023,7 @@ static struct adis16400_chip_info adis16400_chips[] = {
>  		.temp_offset = 25000000 / 140000, /* 25 C = 0x00 */
>  		.set_freq = adis16400_set_freq,
>  		.get_freq = adis16400_get_freq,
> -		.timeouts = &adis16300_timeouts,
> +		.adis_data = ADIS16400_DATA(&adis16300_timeouts),
>  	},
>  	[ADIS16334] = {
>  		.channels = adis16334_channels,
> @@ -985,6 +1036,7 @@ static struct adis16400_chip_info adis16400_chips[] = {
>  		.temp_offset = 25000000 / 67850, /* 25 C = 0x00 */
>  		.set_freq = adis16334_set_freq,
>  		.get_freq = adis16334_get_freq,
> +		.adis_data = ADIS16400_DATA(&adis16334_timeouts),
>  	},
>  	[ADIS16350] = {
>  		.channels = adis16350_channels,
> @@ -996,7 +1048,7 @@ static struct adis16400_chip_info adis16400_chips[] = {
>  		.flags = ADIS16400_NO_BURST | ADIS16400_HAS_SLOW_MODE,
>  		.set_freq = adis16400_set_freq,
>  		.get_freq = adis16400_get_freq,
> -		.timeouts = &adis16300_timeouts,
> +		.adis_data = ADIS16400_DATA(&adis16300_timeouts),
>  	},
>  	[ADIS16360] = {
>  		.channels = adis16350_channels,
> @@ -1009,7 +1061,7 @@ static struct adis16400_chip_info adis16400_chips[] = {
>  		.temp_offset = 25000000 / 136000, /* 25 C = 0x00 */
>  		.set_freq = adis16400_set_freq,
>  		.get_freq = adis16400_get_freq,
> -		.timeouts = &adis16300_timeouts,
> +		.adis_data = ADIS16400_DATA(&adis16300_timeouts),
>  	},
>  	[ADIS16362] = {
>  		.channels = adis16350_channels,
> @@ -1022,7 +1074,7 @@ static struct adis16400_chip_info adis16400_chips[] = {
>  		.temp_offset = 25000000 / 136000, /* 25 C = 0x00 */
>  		.set_freq = adis16400_set_freq,
>  		.get_freq = adis16400_get_freq,
> -		.timeouts = &adis16362_timeouts,
> +		.adis_data = ADIS16400_DATA(&adis16362_timeouts),
>  	},
>  	[ADIS16364] = {
>  		.channels = adis16350_channels,
> @@ -1035,7 +1087,7 @@ static struct adis16400_chip_info adis16400_chips[] = {
>  		.temp_offset = 25000000 / 136000, /* 25 C = 0x00 */
>  		.set_freq = adis16400_set_freq,
>  		.get_freq = adis16400_get_freq,
> -		.timeouts = &adis16362_timeouts,
> +		.adis_data = ADIS16400_DATA(&adis16362_timeouts),
>  	},
>  	[ADIS16367] = {
>  		.channels = adis16350_channels,
> @@ -1048,7 +1100,7 @@ static struct adis16400_chip_info adis16400_chips[] = {
>  		.temp_offset = 25000000 / 136000, /* 25 C = 0x00 */
>  		.set_freq = adis16400_set_freq,
>  		.get_freq = adis16400_get_freq,
> -		.timeouts = &adis16300_timeouts,
> +		.adis_data = ADIS16400_DATA(&adis16300_timeouts),
>  	},
>  	[ADIS16400] = {
>  		.channels = adis16400_channels,
> @@ -1060,7 +1112,7 @@ static struct adis16400_chip_info adis16400_chips[] = {
>  		.temp_offset = 25000000 / 140000, /* 25 C = 0x00 */
>  		.set_freq = adis16400_set_freq,
>  		.get_freq = adis16400_get_freq,
> -		.timeouts = &adis16400_timeouts,
> +		.adis_data = ADIS16400_DATA(&adis16400_timeouts),
>  	},
>  	[ADIS16445] = {
>  		.channels = adis16445_channels,
> @@ -1074,7 +1126,7 @@ static struct adis16400_chip_info adis16400_chips[] = {
>  		.temp_offset = 31000000 / 73860, /* 31 C = 0x00 */
>  		.set_freq = adis16334_set_freq,
>  		.get_freq = adis16334_get_freq,
> -		.timeouts = &adis16445_timeouts,
> +		.adis_data = ADIS16400_DATA(&adis16445_timeouts),
>  	},
>  	[ADIS16448] = {
>  		.channels = adis16448_channels,
> @@ -1088,7 +1140,7 @@ static struct adis16400_chip_info adis16400_chips[] = {
>  		.temp_offset = 31000000 / 73860, /* 31 C = 0x00 */
>  		.set_freq = adis16334_set_freq,
>  		.get_freq = adis16334_get_freq,
> -		.timeouts = &adis16448_timeouts,
> +		.adis_data = ADIS16400_DATA(&adis16448_timeouts),
>  	}
>  };
>  
> @@ -1099,52 +1151,6 @@ static const struct iio_info adis16400_info = {
>  	.debugfs_reg_access = adis_debugfs_reg_access,
>  };
>  
> -static const char * const adis16400_status_error_msgs[] = {
> -	[ADIS16400_DIAG_STAT_ZACCL_FAIL] = "Z-axis accelerometer self-test failure",
> -	[ADIS16400_DIAG_STAT_YACCL_FAIL] = "Y-axis accelerometer self-test failure",
> -	[ADIS16400_DIAG_STAT_XACCL_FAIL] = "X-axis accelerometer self-test failure",
> -	[ADIS16400_DIAG_STAT_XGYRO_FAIL] = "X-axis gyroscope self-test failure",
> -	[ADIS16400_DIAG_STAT_YGYRO_FAIL] = "Y-axis gyroscope self-test failure",
> -	[ADIS16400_DIAG_STAT_ZGYRO_FAIL] = "Z-axis gyroscope self-test failure",
> -	[ADIS16400_DIAG_STAT_ALARM2] = "Alarm 2 active",
> -	[ADIS16400_DIAG_STAT_ALARM1] = "Alarm 1 active",
> -	[ADIS16400_DIAG_STAT_FLASH_CHK] = "Flash checksum error",
> -	[ADIS16400_DIAG_STAT_SELF_TEST] = "Self test error",
> -	[ADIS16400_DIAG_STAT_OVERFLOW] = "Sensor overrange",
> -	[ADIS16400_DIAG_STAT_SPI_FAIL] = "SPI failure",
> -	[ADIS16400_DIAG_STAT_FLASH_UPT] = "Flash update failed",
> -	[ADIS16400_DIAG_STAT_POWER_HIGH] = "Power supply above 5.25V",
> -	[ADIS16400_DIAG_STAT_POWER_LOW] = "Power supply below 4.75V",
> -};
> -
> -static const struct adis_data adis16400_data = {
> -	.msc_ctrl_reg = ADIS16400_MSC_CTRL,
> -	.glob_cmd_reg = ADIS16400_GLOB_CMD,
> -	.diag_stat_reg = ADIS16400_DIAG_STAT,
> -
> -	.read_delay = 50,
> -	.write_delay = 50,
> -
> -	.self_test_mask = ADIS16400_MSC_CTRL_MEM_TEST,
> -
> -	.status_error_msgs = adis16400_status_error_msgs,
> -	.status_error_mask = BIT(ADIS16400_DIAG_STAT_ZACCL_FAIL) |
> -		BIT(ADIS16400_DIAG_STAT_YACCL_FAIL) |
> -		BIT(ADIS16400_DIAG_STAT_XACCL_FAIL) |
> -		BIT(ADIS16400_DIAG_STAT_XGYRO_FAIL) |
> -		BIT(ADIS16400_DIAG_STAT_YGYRO_FAIL) |
> -		BIT(ADIS16400_DIAG_STAT_ZGYRO_FAIL) |
> -		BIT(ADIS16400_DIAG_STAT_ALARM2) |
> -		BIT(ADIS16400_DIAG_STAT_ALARM1) |
> -		BIT(ADIS16400_DIAG_STAT_FLASH_CHK) |
> -		BIT(ADIS16400_DIAG_STAT_SELF_TEST) |
> -		BIT(ADIS16400_DIAG_STAT_OVERFLOW) |
> -		BIT(ADIS16400_DIAG_STAT_SPI_FAIL) |
> -		BIT(ADIS16400_DIAG_STAT_FLASH_UPT) |
> -		BIT(ADIS16400_DIAG_STAT_POWER_HIGH) |
> -		BIT(ADIS16400_DIAG_STAT_POWER_LOW),
> -};
> -
>  static void adis16400_setup_chan_mask(struct adis16400_state *st)
>  {
>  	const struct adis16400_chip_info *chip_info = st->variant;
> @@ -1158,23 +1164,6 @@ static void adis16400_setup_chan_mask(struct adis16400_state *st)
>  			st->avail_scan_mask[0] |= BIT(ch->scan_index);
>  	}
>  }
> -
> -static struct adis_data *adis16400_adis_data_alloc(struct adis16400_state *st,
> -						   struct device *dev)
> -{
> -	struct adis_data *data;
> -
> -	data = devm_kmalloc(dev, sizeof(struct adis_data), GFP_KERNEL);
> -	if (!data)
> -		return ERR_PTR(-ENOMEM);
> -
> -	memcpy(data, &adis16400_data, sizeof(*data));
> -
> -	data->timeouts = st->variant->timeouts;
> -
> -	return data;
> -}
> -
>  static int adis16400_probe(struct spi_device *spi)
>  {
>  	struct adis16400_state *st;
> @@ -1207,9 +1196,7 @@ static int adis16400_probe(struct spi_device *spi)
>  			st->adis.burst->extra_len = sizeof(u16);
>  	}
>  
> -	adis16400_data = adis16400_adis_data_alloc(st, &spi->dev);
> -	if (IS_ERR(adis16400_data))
> -		return PTR_ERR(adis16400_data);
> +	adis16400_data = &st->variant->adis_data;
>  
>  	ret = adis_init(&st->adis, indio_dev, spi, adis16400_data);
>  	if (ret)


  reply	other threads:[~2020-02-14 14:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-10 13:25 [PATCH v2 1/9] iio: imu: adis16480: initialize adis_data statically Alexandru Ardelean
2020-02-10 13:25 ` [PATCH v2 2/9] iio: imu: adis16400: " Alexandru Ardelean
2020-02-14 14:29   ` Jonathan Cameron [this message]
2020-02-10 13:26 ` [PATCH v2 3/9] iio: gyro: adis16136: " Alexandru Ardelean
2020-02-14 14:30   ` Jonathan Cameron
2020-02-10 13:26 ` [PATCH v2 4/9] iio: imu: adis: add unlocked __adis_initial_startup() Alexandru Ardelean
2020-02-14 14:31   ` Jonathan Cameron
2020-02-10 13:26 ` [PATCH v2 5/9] iio: imu: adis: Add self_test_reg variable Alexandru Ardelean
2020-02-14 14:33   ` Jonathan Cameron
2020-02-10 13:26 ` [PATCH v2 6/9] iio: imu: adis: Refactor adis_initial_startup Alexandru Ardelean
2020-02-14 14:39   ` Jonathan Cameron
2020-02-10 13:26 ` [PATCH v2 7/9] iio: imu: adis: add support product ID check in adis_initial_startup Alexandru Ardelean
2020-02-14 14:41   ` Jonathan Cameron
2020-02-10 13:26 ` [PATCH v2 8/9] iio: adis16480: Make use of __adis_initial_startup Alexandru Ardelean
2020-02-14 14:44   ` Jonathan Cameron
2020-02-10 13:26 ` [PATCH v2 9/9] iio: adis16460: " Alexandru Ardelean
2020-02-14 14:45   ` Jonathan Cameron
2020-02-14 14:28 ` [PATCH v2 1/9] iio: imu: adis16480: initialize adis_data statically Jonathan Cameron

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=20200214142923.7838cdf7@archlinux \
    --to=jic23@kernel.org \
    --cc=alexandru.ardelean@analog.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    /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.