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 3/9] iio: gyro: adis16136: initialize adis_data statically
Date: Fri, 14 Feb 2020 14:30:29 +0000	[thread overview]
Message-ID: <20200214143029.33ec16b4@archlinux> (raw)
In-Reply-To: <20200210132606.9315-3-alexandru.ardelean@analog.com>

On Mon, 10 Feb 2020 15:26:00 +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/gyro/adis16136.c | 61 +++++++++++++-----------------------
>  1 file changed, 21 insertions(+), 40 deletions(-)
> 
> diff --git a/drivers/iio/gyro/adis16136.c b/drivers/iio/gyro/adis16136.c
> index d5e03a406d4a..1db1131e5c67 100644
> --- a/drivers/iio/gyro/adis16136.c
> +++ b/drivers/iio/gyro/adis16136.c
> @@ -59,7 +59,7 @@
>  struct adis16136_chip_info {
>  	unsigned int precision;
>  	unsigned int fullscale;
> -	const struct adis_timeout *timeouts;
> +	const struct adis_data adis_data;
>  };
>  
>  struct adis16136 {
> @@ -466,22 +466,21 @@ static const char * const adis16136_status_error_msgs[] = {
>  	[ADIS16136_DIAG_STAT_FLASH_CHKSUM_FAIL] = "Flash checksum error",
>  };
>  
> -static const struct adis_data adis16136_data = {
> -	.diag_stat_reg = ADIS16136_REG_DIAG_STAT,
> -	.glob_cmd_reg = ADIS16136_REG_GLOB_CMD,
> -	.msc_ctrl_reg = ADIS16136_REG_MSC_CTRL,
> -
> -	.self_test_mask = ADIS16136_MSC_CTRL_SELF_TEST,
> -
> -	.read_delay = 10,
> -	.write_delay = 10,
> -
> -	.status_error_msgs = adis16136_status_error_msgs,
> -	.status_error_mask = BIT(ADIS16136_DIAG_STAT_FLASH_UPDATE_FAIL) |
> -		BIT(ADIS16136_DIAG_STAT_SPI_FAIL) |
> -		BIT(ADIS16136_DIAG_STAT_SELF_TEST_FAIL) |
> -		BIT(ADIS16136_DIAG_STAT_FLASH_CHKSUM_FAIL),
> -};
> +#define ADIS16136_DATA(_timeouts)					\
> +{									\
> +	.diag_stat_reg = ADIS16136_REG_DIAG_STAT,			\
> +	.glob_cmd_reg = ADIS16136_REG_GLOB_CMD,				\
> +	.msc_ctrl_reg = ADIS16136_REG_MSC_CTRL,				\
> +	.self_test_mask = ADIS16136_MSC_CTRL_SELF_TEST,			\
> +	.read_delay = 10,						\
> +	.write_delay = 10,						\
> +	.status_error_msgs = adis16136_status_error_msgs,		\
> +	.status_error_mask = BIT(ADIS16136_DIAG_STAT_FLASH_UPDATE_FAIL) |	\
> +		BIT(ADIS16136_DIAG_STAT_SPI_FAIL) |			\
> +		BIT(ADIS16136_DIAG_STAT_SELF_TEST_FAIL) |		\
> +		BIT(ADIS16136_DIAG_STAT_FLASH_CHKSUM_FAIL),		\
> +	.timeouts = (_timeouts),					\
> +}
>  
>  enum adis16136_id {
>  	ID_ADIS16133,
> @@ -506,41 +505,25 @@ static const struct adis16136_chip_info adis16136_chip_info[] = {
>  	[ID_ADIS16133] = {
>  		.precision = IIO_DEGREE_TO_RAD(1200),
>  		.fullscale = 24000,
> -		.timeouts = &adis16133_timeouts,
> +		.adis_data = ADIS16136_DATA(&adis16133_timeouts),
>  	},
>  	[ID_ADIS16135] = {
>  		.precision = IIO_DEGREE_TO_RAD(300),
>  		.fullscale = 24000,
> -		.timeouts = &adis16133_timeouts,
> +		.adis_data = ADIS16136_DATA(&adis16133_timeouts),
>  	},
>  	[ID_ADIS16136] = {
>  		.precision = IIO_DEGREE_TO_RAD(450),
>  		.fullscale = 24623,
> -		.timeouts = &adis16136_timeouts,
> +		.adis_data = ADIS16136_DATA(&adis16136_timeouts),
>  	},
>  	[ID_ADIS16137] = {
>  		.precision = IIO_DEGREE_TO_RAD(1000),
>  		.fullscale = 24609,
> -		.timeouts = &adis16136_timeouts,
> +		.adis_data = ADIS16136_DATA(&adis16136_timeouts),
>  	},
>  };
>  
> -static struct adis_data *adis16136_adis_data_alloc(struct adis16136 *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, &adis16136_data, sizeof(*data));
> -
> -	data->timeouts = st->chip_info->timeouts;
> -
> -	return data;
> -}
> -
>  static int adis16136_probe(struct spi_device *spi)
>  {
>  	const struct spi_device_id *id = spi_get_device_id(spi);
> @@ -565,9 +548,7 @@ static int adis16136_probe(struct spi_device *spi)
>  	indio_dev->info = &adis16136_info;
>  	indio_dev->modes = INDIO_DIRECT_MODE;
>  
> -	adis16136_data = adis16136_adis_data_alloc(adis16136, &spi->dev);
> -	if (IS_ERR(adis16136_data))
> -		return PTR_ERR(adis16136_data);
> +	adis16136_data = &adis16136->chip_info->adis_data;
>  
>  	ret = adis_init(&adis16136->adis, indio_dev, spi, adis16136_data);
>  	if (ret)


  reply	other threads:[~2020-02-14 14:30 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
2020-02-10 13:26 ` [PATCH v2 3/9] iio: gyro: adis16136: " Alexandru Ardelean
2020-02-14 14:30   ` Jonathan Cameron [this message]
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=20200214143029.33ec16b4@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.