mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Ardelean, Alexandru" <alexandru.Ardelean@analog.com>
To: "Tachici, Alexandru" <Alexandru.Tachici@analog.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>
Cc: "jic23@kernel.org" <jic23@kernel.org>
Subject: Re: [PATCH] iio: ad_sigma_delta: Add custom irq flags
Date: Mon, 6 Jan 2020 09:41:04 +0000	[thread overview]
Message-ID: <4315d67b125da94e9a172f3860bbfa3bf0086df0.camel@analog.com> (raw)
In-Reply-To: <20200106093852.29702-1-alexandru.tachici@analog.com>

On Mon, 2020-01-06 at 11:38 +0200, Alexandru Tachici wrote:
> [External]
> 
> The data-sheet of AD7124, from the Sigma-Delta ADC family,
> recommends that the falling edge of the DOUT line should be used for
> an interrupt.
> 
> The ad_sigma_delta implementation hardcodes the irq trigger type
> to low, assuming that all Sigma-Delta ADCs have the same interrupt-type.
> This causes unwanted behaviour. If DOUT line is already low, the
> interrupt will fire once, when enabled and the irq handler will send a
> read request to the device. At this time the device has not yet finished
> the previous conversion and will give a bad reading.
> 
> This patch allows drivers using the ad_sigma_delta layer to set the
> irq trigger type to the one specified in the corresponding data-sheet.
> 
> Signed-off-by: Alexandru Tachici <alexandru.tachici@analog.com>
> ---
>  drivers/iio/adc/ad_sigma_delta.c       | 11 ++++++++++-
>  include/linux/iio/adc/ad_sigma_delta.h |  5 +++++
>  2 files changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/ad_sigma_delta.c
> b/drivers/iio/adc/ad_sigma_delta.c
> index 8ba90486c787..ef8c356b11ee 100644
> --- a/drivers/iio/adc/ad_sigma_delta.c
> +++ b/drivers/iio/adc/ad_sigma_delta.c
> @@ -500,7 +500,7 @@ static int ad_sd_probe_trigger(struct iio_dev
> *indio_dev)
>  
>  	ret = request_irq(sigma_delta->spi->irq,
>  			  ad_sd_data_rdy_trig_poll,
> -			  IRQF_TRIGGER_LOW,
> +			  sigma_delta->irq_flags,
>  			  indio_dev->name,
>  			  sigma_delta);
>  	if (ret)
> @@ -586,8 +586,17 @@ EXPORT_SYMBOL_GPL(ad_sd_cleanup_buffer_and_trigger);
>  int ad_sd_init(struct ad_sigma_delta *sigma_delta, struct iio_dev
> *indio_dev,
>  	struct spi_device *spi, const struct ad_sigma_delta_info *info)
>  {
> +	unsigned long set_trigger_flags;
> +
>  	sigma_delta->spi = spi;
>  	sigma_delta->info = info;
> +	sigma_delta->num_slots = 1;
> +	sigma_delta->active_slots = 1;

The slots patch seems to have slipped some cherry-picks and conflicts.

> +
> +	set_trigger_flags = sigma_delta->irq_flags & IRQF_TRIGGER_MASK;
> +	if (set_trigger_flags == IRQF_TRIGGER_NONE)
> +		sigma_delta->irq_flags |= IRQF_TRIGGER_LOW;
> +
>  	iio_device_set_drvdata(indio_dev, sigma_delta);
>  
>  	return 0;
> diff --git a/include/linux/iio/adc/ad_sigma_delta.h
> b/include/linux/iio/adc/ad_sigma_delta.h
> index 8a4e25a7080c..0d3fa1e16f5e 100644
> --- a/include/linux/iio/adc/ad_sigma_delta.h
> +++ b/include/linux/iio/adc/ad_sigma_delta.h
> @@ -55,6 +55,8 @@ struct ad_sigma_delta_info {
>   * struct ad_sigma_delta - Sigma Delta device struct
>   * @spi: The spi device associated with the Sigma Delta device.
>   * @trig: The IIO trigger associated with the Sigma Delta device.
> + * @num_slots: Number of sequencer slots
> + * @irq_flags: flags for the interrupt used by the triggered buffer
>   *
>   * Most of the fields are private to the sigma delta library code and
> should not
>   * be accessed by individual drivers.
> @@ -63,6 +65,9 @@ struct ad_sigma_delta {
>  	struct spi_device	*spi;
>  	struct iio_trigger	*trig;
>  
> +	unsigned int		num_slots;
> +	unsigned long		irq_flags;
> +
>  /* private: */
>  	struct completion	completion;
>  	bool			irq_dis;

  reply	other threads:[~2020-01-06  9:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-06  9:38 Alexandru Tachici
2020-01-06  9:41 ` Ardelean, Alexandru [this message]
2020-01-06 13:54 ` kbuild test robot
2020-01-06 10:57 Alexandru Tachici
2020-01-07  8:41 ` Tachici, Alexandru

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=4315d67b125da94e9a172f3860bbfa3bf0086df0.camel@analog.com \
    --to=alexandru.ardelean@analog.com \
    --cc=Alexandru.Tachici@analog.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®