All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@jic23.retrosnub.co.uk>
To: Alexandru Ardelean <ardeleanalex@gmail.com>
Cc: linux-iio@vger.kernel.org,
	Alexandru Ardelean <alexandru.ardelean@analog.com>
Subject: Re: [PATCH 1/5] iio: imu: adis16400: move trigger handler into adis16400_core
Date: Sun, 24 Mar 2019 15:04:57 +0000	[thread overview]
Message-ID: <20190324150457.2331f31a@archlinux> (raw)
In-Reply-To: <20190322204442.4035-1-ardeleanalex@gmail.com>

On Fri, 22 Mar 2019 22:44:38 +0200
Alexandru Ardelean <ardeleanalex@gmail.com> wrote:

> From: Alexandru Ardelean <alexandru.ardelean@analog.com>
> 
> The trigger handler for the ADIS16400 is very different from the generic
> one in the ADIS library. Keeping it in a separate file won't make much
> sense once the update_scan_mode function will be made more generic and
> moved into the ADIS library.
> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Seems fine to me.

Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/imu/adis16400.h        |  2 --
>  drivers/iio/imu/adis16400_buffer.c | 41 --------------------------
>  drivers/iio/imu/adis16400_core.c   | 46 ++++++++++++++++++++++++++++++
>  3 files changed, 46 insertions(+), 43 deletions(-)
> 
> diff --git a/drivers/iio/imu/adis16400.h b/drivers/iio/imu/adis16400.h
> index 73b189c1c0fb..93b6c0c41fdd 100644
> --- a/drivers/iio/imu/adis16400.h
> +++ b/drivers/iio/imu/adis16400.h
> @@ -203,12 +203,10 @@ ssize_t adis16400_read_data_from_ring(struct device *dev,
>  
>  int adis16400_update_scan_mode(struct iio_dev *indio_dev,
>  	const unsigned long *scan_mask);
> -irqreturn_t adis16400_trigger_handler(int irq, void *p);
>  
>  #else /* CONFIG_IIO_BUFFER */
>  
>  #define adis16400_update_scan_mode NULL
> -#define adis16400_trigger_handler NULL
>  
>  #endif /* CONFIG_IIO_BUFFER */
>  
> diff --git a/drivers/iio/imu/adis16400_buffer.c b/drivers/iio/imu/adis16400_buffer.c
> index e70a5339acb1..268349eb51c7 100644
> --- a/drivers/iio/imu/adis16400_buffer.c
> +++ b/drivers/iio/imu/adis16400_buffer.c
> @@ -58,44 +58,3 @@ int adis16400_update_scan_mode(struct iio_dev *indio_dev,
>  
>  	return 0;
>  }
> -
> -irqreturn_t adis16400_trigger_handler(int irq, void *p)
> -{
> -	struct iio_poll_func *pf = p;
> -	struct iio_dev *indio_dev = pf->indio_dev;
> -	struct adis16400_state *st = iio_priv(indio_dev);
> -	struct adis *adis = &st->adis;
> -	u32 old_speed_hz = st->adis.spi->max_speed_hz;
> -	void *buffer;
> -	int ret;
> -
> -	if (!adis->buffer)
> -		return -ENOMEM;
> -
> -	if (!(st->variant->flags & ADIS16400_NO_BURST) &&
> -		st->adis.spi->max_speed_hz > ADIS16400_SPI_BURST) {
> -		st->adis.spi->max_speed_hz = ADIS16400_SPI_BURST;
> -		spi_setup(st->adis.spi);
> -	}
> -
> -	ret = spi_sync(adis->spi, &adis->msg);
> -	if (ret)
> -		dev_err(&adis->spi->dev, "Failed to read data: %d\n", ret);
> -
> -	if (!(st->variant->flags & ADIS16400_NO_BURST)) {
> -		st->adis.spi->max_speed_hz = old_speed_hz;
> -		spi_setup(st->adis.spi);
> -	}
> -
> -	if (st->variant->flags & ADIS16400_BURST_DIAG_STAT)
> -		buffer = adis->buffer + sizeof(u16);
> -	else
> -		buffer = adis->buffer;
> -
> -	iio_push_to_buffers_with_timestamp(indio_dev, buffer,
> -		pf->timestamp);
> -
> -	iio_trigger_notify_done(indio_dev->trig);
> -
> -	return IRQ_HANDLED;
> -}
> diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c
> index 9b697d35dbef..34d52863377a 100644
> --- a/drivers/iio/imu/adis16400_core.c
> +++ b/drivers/iio/imu/adis16400_core.c
> @@ -31,6 +31,7 @@
>  #include <linux/iio/iio.h>
>  #include <linux/iio/sysfs.h>
>  #include <linux/iio/buffer.h>
> +#include <linux/iio/trigger_consumer.h>
>  
>  #include "adis16400.h"
>  
> @@ -465,6 +466,51 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
>  	}
>  }
>  
> +#if IS_ENABLED(CONFIG_IIO_BUFFER)
> +static irqreturn_t adis16400_trigger_handler(int irq, void *p)
> +{
> +	struct iio_poll_func *pf = p;
> +	struct iio_dev *indio_dev = pf->indio_dev;
> +	struct adis16400_state *st = iio_priv(indio_dev);
> +	struct adis *adis = &st->adis;
> +	u32 old_speed_hz = st->adis.spi->max_speed_hz;
> +	void *buffer;
> +	int ret;
> +
> +	if (!adis->buffer)
> +		return -ENOMEM;
> +
> +	if (!(st->variant->flags & ADIS16400_NO_BURST) &&
> +		st->adis.spi->max_speed_hz > ADIS16400_SPI_BURST) {
> +		st->adis.spi->max_speed_hz = ADIS16400_SPI_BURST;
> +		spi_setup(st->adis.spi);
> +	}
> +
> +	ret = spi_sync(adis->spi, &adis->msg);
> +	if (ret)
> +		dev_err(&adis->spi->dev, "Failed to read data: %d\n", ret);
> +
> +	if (!(st->variant->flags & ADIS16400_NO_BURST)) {
> +		st->adis.spi->max_speed_hz = old_speed_hz;
> +		spi_setup(st->adis.spi);
> +	}
> +
> +	if (st->variant->flags & ADIS16400_BURST_DIAG_STAT)
> +		buffer = adis->buffer + sizeof(u16);
> +	else
> +		buffer = adis->buffer;
> +
> +	iio_push_to_buffers_with_timestamp(indio_dev, buffer,
> +		pf->timestamp);
> +
> +	iio_trigger_notify_done(indio_dev->trig);
> +
> +	return IRQ_HANDLED;
> +}
> +#else
> +#define adis16400_trigger_handler	NULL
> +#endif /* IS_ENABLED(CONFIG_IIO_BUFFER) */
> +
>  #define ADIS16400_VOLTAGE_CHAN(addr, bits, name, si, chn) { \
>  	.type = IIO_VOLTAGE, \
>  	.indexed = 1, \


      parent reply	other threads:[~2019-03-24 15:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-22 20:44 [PATCH 1/5] iio: imu: adis16400: move trigger handler into adis16400_core Alexandru Ardelean
2019-03-22 20:44 ` [PATCH 2/5] iio: imu: adis: generalize burst mode support Alexandru Ardelean
2019-03-24 15:08   ` Jonathan Cameron
2019-03-22 20:44 ` [PATCH 3/5] iio: imu: adis16400: move burst logic to ADIS lib Alexandru Ardelean
2019-03-24 15:10   ` Jonathan Cameron
2019-03-22 20:44 ` [PATCH 4/5] iio: imu: adis16400: rename adis16400_core.c -> adi16400.c Alexandru Ardelean
2019-03-24 15:12   ` Jonathan Cameron
2019-03-22 20:44 ` [PATCH 5/5] iio: imu: adis16400: move adis16400.h into adis16400.c Alexandru Ardelean
2019-03-24 15:20   ` Jonathan Cameron
2019-03-24 15:04 ` 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=20190324150457.2331f31a@archlinux \
    --to=jic23@jic23.retrosnub.co.uk \
    --cc=alexandru.ardelean@analog.com \
    --cc=ardeleanalex@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    /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.