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 1/9] iio: imu: adis16480: initialize adis_data statically
Date: Fri, 14 Feb 2020 14:28:17 +0000 [thread overview]
Message-ID: <20200214142817.3bd22a15@archlinux> (raw)
In-Reply-To: <20200210132606.9315-1-alexandru.ardelean@analog.com>
On Mon, 10 Feb 2020 15:25:58 +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.
>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Applied to the togreg branch of iio.git and pushed out as testing for the
autobuilders to poke at it.
Thanks,
Jonathan
> ---
>
> Changelog v1 -> v2:
> * initialize 'adis_data' statically on adis16480,adis16136 & adis16400
> * split 'iio: imu: adis: Refactor adis_initial_startup' patch
> - new: 'iio: imu: adis: add unlocked __adis_initial_startup()'
> - new: 'iio: imu: adis: add support product ID check in adis_initial_startup'
> - modified: 'iio: imu: adis: Refactor adis_initial_startup'
> * added 'prod_id' field together with 'prod_id_reg' on 'adis_data'
> each device that wants to use the 'prod_id_reg' must also provide an
> expected 'prod_id' value
>
> drivers/iio/imu/adis16480.c | 140 ++++++++++++++++--------------------
> 1 file changed, 62 insertions(+), 78 deletions(-)
>
> diff --git a/drivers/iio/imu/adis16480.c b/drivers/iio/imu/adis16480.c
> index dac87f1001fd..4c4de1b62769 100644
> --- a/drivers/iio/imu/adis16480.c
> +++ b/drivers/iio/imu/adis16480.c
> @@ -138,7 +138,7 @@ struct adis16480_chip_info {
> unsigned int max_dec_rate;
> const unsigned int *filter_freqs;
> bool has_pps_clk_mode;
> - const struct adis_timeout *timeouts;
> + const struct adis_data adis_data;
> };
>
> enum adis16480_int_pin {
> @@ -796,6 +796,55 @@ enum adis16480_variant {
> ADIS16497_3,
> };
>
> +#define ADIS16480_DIAG_STAT_XGYRO_FAIL 0
> +#define ADIS16480_DIAG_STAT_YGYRO_FAIL 1
> +#define ADIS16480_DIAG_STAT_ZGYRO_FAIL 2
> +#define ADIS16480_DIAG_STAT_XACCL_FAIL 3
> +#define ADIS16480_DIAG_STAT_YACCL_FAIL 4
> +#define ADIS16480_DIAG_STAT_ZACCL_FAIL 5
> +#define ADIS16480_DIAG_STAT_XMAGN_FAIL 8
> +#define ADIS16480_DIAG_STAT_YMAGN_FAIL 9
> +#define ADIS16480_DIAG_STAT_ZMAGN_FAIL 10
> +#define ADIS16480_DIAG_STAT_BARO_FAIL 11
> +
> +static const char * const adis16480_status_error_msgs[] = {
> + [ADIS16480_DIAG_STAT_XGYRO_FAIL] = "X-axis gyroscope self-test failure",
> + [ADIS16480_DIAG_STAT_YGYRO_FAIL] = "Y-axis gyroscope self-test failure",
> + [ADIS16480_DIAG_STAT_ZGYRO_FAIL] = "Z-axis gyroscope self-test failure",
> + [ADIS16480_DIAG_STAT_XACCL_FAIL] = "X-axis accelerometer self-test failure",
> + [ADIS16480_DIAG_STAT_YACCL_FAIL] = "Y-axis accelerometer self-test failure",
> + [ADIS16480_DIAG_STAT_ZACCL_FAIL] = "Z-axis accelerometer self-test failure",
> + [ADIS16480_DIAG_STAT_XMAGN_FAIL] = "X-axis magnetometer self-test failure",
> + [ADIS16480_DIAG_STAT_YMAGN_FAIL] = "Y-axis magnetometer self-test failure",
> + [ADIS16480_DIAG_STAT_ZMAGN_FAIL] = "Z-axis magnetometer self-test failure",
> + [ADIS16480_DIAG_STAT_BARO_FAIL] = "Barometer self-test failure",
> +};
> +
> +static int adis16480_enable_irq(struct adis *adis, bool enable);
> +
> +#define ADIS16480_DATA(_timeouts) \
> +{ \
> + .diag_stat_reg = ADIS16480_REG_DIAG_STS, \
> + .glob_cmd_reg = ADIS16480_REG_GLOB_CMD, \
> + .has_paging = true, \
> + .read_delay = 5, \
> + .write_delay = 5, \
> + .self_test_mask = BIT(1), \
> + .status_error_msgs = adis16480_status_error_msgs, \
> + .status_error_mask = BIT(ADIS16480_DIAG_STAT_XGYRO_FAIL) | \
> + BIT(ADIS16480_DIAG_STAT_YGYRO_FAIL) | \
> + BIT(ADIS16480_DIAG_STAT_ZGYRO_FAIL) | \
> + BIT(ADIS16480_DIAG_STAT_XACCL_FAIL) | \
> + BIT(ADIS16480_DIAG_STAT_YACCL_FAIL) | \
> + BIT(ADIS16480_DIAG_STAT_ZACCL_FAIL) | \
> + BIT(ADIS16480_DIAG_STAT_XMAGN_FAIL) | \
> + BIT(ADIS16480_DIAG_STAT_YMAGN_FAIL) | \
> + BIT(ADIS16480_DIAG_STAT_ZMAGN_FAIL) | \
> + BIT(ADIS16480_DIAG_STAT_BARO_FAIL), \
> + .enable_irq = adis16480_enable_irq, \
> + .timeouts = (_timeouts), \
> +}
> +
> static const struct adis_timeout adis16485_timeouts = {
> .reset_ms = 560,
> .sw_reset_ms = 120,
> @@ -838,7 +887,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
> .int_clk = 2460000,
> .max_dec_rate = 2048,
> .filter_freqs = adis16480_def_filter_freqs,
> - .timeouts = &adis16485_timeouts,
> + .adis_data = ADIS16480_DATA(&adis16485_timeouts),
> },
> [ADIS16480] = {
> .channels = adis16480_channels,
> @@ -851,7 +900,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
> .int_clk = 2460000,
> .max_dec_rate = 2048,
> .filter_freqs = adis16480_def_filter_freqs,
> - .timeouts = &adis16480_timeouts,
> + .adis_data = ADIS16480_DATA(&adis16480_timeouts),
> },
> [ADIS16485] = {
> .channels = adis16485_channels,
> @@ -864,7 +913,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
> .int_clk = 2460000,
> .max_dec_rate = 2048,
> .filter_freqs = adis16480_def_filter_freqs,
> - .timeouts = &adis16485_timeouts,
> + .adis_data = ADIS16480_DATA(&adis16485_timeouts),
> },
> [ADIS16488] = {
> .channels = adis16480_channels,
> @@ -877,7 +926,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
> .int_clk = 2460000,
> .max_dec_rate = 2048,
> .filter_freqs = adis16480_def_filter_freqs,
> - .timeouts = &adis16485_timeouts,
> + .adis_data = ADIS16480_DATA(&adis16485_timeouts),
> },
> [ADIS16490] = {
> .channels = adis16485_channels,
> @@ -891,7 +940,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
> .max_dec_rate = 4250,
> .filter_freqs = adis16495_def_filter_freqs,
> .has_pps_clk_mode = true,
> - .timeouts = &adis16495_timeouts,
> + .adis_data = ADIS16480_DATA(&adis16495_timeouts),
> },
> [ADIS16495_1] = {
> .channels = adis16485_channels,
> @@ -905,7 +954,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
> .max_dec_rate = 4250,
> .filter_freqs = adis16495_def_filter_freqs,
> .has_pps_clk_mode = true,
> - .timeouts = &adis16495_1_timeouts,
> + .adis_data = ADIS16480_DATA(&adis16495_1_timeouts),
> },
> [ADIS16495_2] = {
> .channels = adis16485_channels,
> @@ -919,7 +968,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
> .max_dec_rate = 4250,
> .filter_freqs = adis16495_def_filter_freqs,
> .has_pps_clk_mode = true,
> - .timeouts = &adis16495_1_timeouts,
> + .adis_data = ADIS16480_DATA(&adis16495_1_timeouts),
> },
> [ADIS16495_3] = {
> .channels = adis16485_channels,
> @@ -933,7 +982,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
> .max_dec_rate = 4250,
> .filter_freqs = adis16495_def_filter_freqs,
> .has_pps_clk_mode = true,
> - .timeouts = &adis16495_1_timeouts,
> + .adis_data = ADIS16480_DATA(&adis16495_1_timeouts),
> },
> [ADIS16497_1] = {
> .channels = adis16485_channels,
> @@ -947,7 +996,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
> .max_dec_rate = 4250,
> .filter_freqs = adis16495_def_filter_freqs,
> .has_pps_clk_mode = true,
> - .timeouts = &adis16495_1_timeouts,
> + .adis_data = ADIS16480_DATA(&adis16495_1_timeouts),
> },
> [ADIS16497_2] = {
> .channels = adis16485_channels,
> @@ -961,7 +1010,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
> .max_dec_rate = 4250,
> .filter_freqs = adis16495_def_filter_freqs,
> .has_pps_clk_mode = true,
> - .timeouts = &adis16495_1_timeouts,
> + .adis_data = ADIS16480_DATA(&adis16495_1_timeouts),
> },
> [ADIS16497_3] = {
> .channels = adis16485_channels,
> @@ -975,7 +1024,7 @@ static const struct adis16480_chip_info adis16480_chip_info[] = {
> .max_dec_rate = 4250,
> .filter_freqs = adis16495_def_filter_freqs,
> .has_pps_clk_mode = true,
> - .timeouts = &adis16495_1_timeouts,
> + .adis_data = ADIS16480_DATA(&adis16495_1_timeouts),
> },
> };
>
> @@ -1048,53 +1097,6 @@ static int adis16480_initial_setup(struct iio_dev *indio_dev)
> return 0;
> }
>
> -#define ADIS16480_DIAG_STAT_XGYRO_FAIL 0
> -#define ADIS16480_DIAG_STAT_YGYRO_FAIL 1
> -#define ADIS16480_DIAG_STAT_ZGYRO_FAIL 2
> -#define ADIS16480_DIAG_STAT_XACCL_FAIL 3
> -#define ADIS16480_DIAG_STAT_YACCL_FAIL 4
> -#define ADIS16480_DIAG_STAT_ZACCL_FAIL 5
> -#define ADIS16480_DIAG_STAT_XMAGN_FAIL 8
> -#define ADIS16480_DIAG_STAT_YMAGN_FAIL 9
> -#define ADIS16480_DIAG_STAT_ZMAGN_FAIL 10
> -#define ADIS16480_DIAG_STAT_BARO_FAIL 11
> -
> -static const char * const adis16480_status_error_msgs[] = {
> - [ADIS16480_DIAG_STAT_XGYRO_FAIL] = "X-axis gyroscope self-test failure",
> - [ADIS16480_DIAG_STAT_YGYRO_FAIL] = "Y-axis gyroscope self-test failure",
> - [ADIS16480_DIAG_STAT_ZGYRO_FAIL] = "Z-axis gyroscope self-test failure",
> - [ADIS16480_DIAG_STAT_XACCL_FAIL] = "X-axis accelerometer self-test failure",
> - [ADIS16480_DIAG_STAT_YACCL_FAIL] = "Y-axis accelerometer self-test failure",
> - [ADIS16480_DIAG_STAT_ZACCL_FAIL] = "Z-axis accelerometer self-test failure",
> - [ADIS16480_DIAG_STAT_XMAGN_FAIL] = "X-axis magnetometer self-test failure",
> - [ADIS16480_DIAG_STAT_YMAGN_FAIL] = "Y-axis magnetometer self-test failure",
> - [ADIS16480_DIAG_STAT_ZMAGN_FAIL] = "Z-axis magnetometer self-test failure",
> - [ADIS16480_DIAG_STAT_BARO_FAIL] = "Barometer self-test failure",
> -};
> -
> -static const struct adis_data adis16480_data = {
> - .diag_stat_reg = ADIS16480_REG_DIAG_STS,
> - .glob_cmd_reg = ADIS16480_REG_GLOB_CMD,
> - .has_paging = true,
> -
> - .read_delay = 5,
> - .write_delay = 5,
> -
> - .status_error_msgs = adis16480_status_error_msgs,
> - .status_error_mask = BIT(ADIS16480_DIAG_STAT_XGYRO_FAIL) |
> - BIT(ADIS16480_DIAG_STAT_YGYRO_FAIL) |
> - BIT(ADIS16480_DIAG_STAT_ZGYRO_FAIL) |
> - BIT(ADIS16480_DIAG_STAT_XACCL_FAIL) |
> - BIT(ADIS16480_DIAG_STAT_YACCL_FAIL) |
> - BIT(ADIS16480_DIAG_STAT_ZACCL_FAIL) |
> - BIT(ADIS16480_DIAG_STAT_XMAGN_FAIL) |
> - BIT(ADIS16480_DIAG_STAT_YMAGN_FAIL) |
> - BIT(ADIS16480_DIAG_STAT_ZMAGN_FAIL) |
> - BIT(ADIS16480_DIAG_STAT_BARO_FAIL),
> -
> - .enable_irq = adis16480_enable_irq,
> -};
> -
> static int adis16480_config_irq_pin(struct device_node *of_node,
> struct adis16480 *st)
> {
> @@ -1245,22 +1247,6 @@ static int adis16480_get_ext_clocks(struct adis16480 *st)
> return 0;
> }
>
> -static struct adis_data *adis16480_adis_data_alloc(struct adis16480 *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, &adis16480_data, sizeof(*data));
> -
> - data->timeouts = st->chip_info->timeouts;
> -
> - return data;
> -}
> -
> static int adis16480_probe(struct spi_device *spi)
> {
> const struct spi_device_id *id = spi_get_device_id(spi);
> @@ -1285,9 +1271,7 @@ static int adis16480_probe(struct spi_device *spi)
> indio_dev->info = &adis16480_info;
> indio_dev->modes = INDIO_DIRECT_MODE;
>
> - adis16480_data = adis16480_adis_data_alloc(st, &spi->dev);
> - if (IS_ERR(adis16480_data))
> - return PTR_ERR(adis16480_data);
> + adis16480_data = &st->chip_info->adis_data;
>
> ret = adis_init(&st->adis, indio_dev, spi, adis16480_data);
> if (ret)
prev parent reply other threads:[~2020-02-14 14:28 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
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 ` Jonathan Cameron [this message]
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=20200214142817.3bd22a15@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.