public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Abhash Jha <abhashkumarjha123@gmail.com>
Cc: linux-iio@vger.kernel.org, anshulusr@gmail.com, lars@metafoo.de,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/4] iio: light: ltr390: Interrupts and threshold event support
Date: Sat, 28 Sep 2024 16:45:16 +0100	[thread overview]
Message-ID: <20240928164516.548c923f@jic23-huawei> (raw)
In-Reply-To: <20240914181246.504450-4-abhashkumarjha123@gmail.com>

On Sat, 14 Sep 2024 23:42:45 +0530
Abhash Jha <abhashkumarjha123@gmail.com> wrote:

> Added support for threshold events for both the ALS and UVI channels.
> The events are reported when the threshold interrupt is triggered. Both
> rising and falling threshold types are supported.
> 
> Signed-off-by: Abhash Jha <abhashkumarjha123@gmail.com>
I made a few more tweaks whilst picking this up.
Please take a look at the result.

Jonathan

> ---
>  drivers/iio/light/ltr390.c | 212 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 212 insertions(+)
> 
> diff --git a/drivers/iio/light/ltr390.c b/drivers/iio/light/ltr390.c
> index e152009b5..57bf48595 100644
> --- a/drivers/iio/light/ltr390.c
> +++ b/drivers/iio/light/ltr390.c
> @@ -25,8 +25,11 @@
>  #include <linux/regmap.h>
>  #include <linux/bitfield.h>
>  #include <linux/device.h>
> +#include <linux/irq.h>
> +#include <linux/interrupt.h>
I moved these as well + cheeky move of the bitfield.h in here
as that was beginning to annoy me.

>  
>  #include <linux/iio/iio.h>
> +#include <linux/iio/events.h>

> +
>  static int ltr390_probe(struct i2c_client *client)
>  {
>  	struct ltr390_data *data;
> @@ -428,6 +627,19 @@ static int ltr390_probe(struct i2c_client *client)
>  	if (ret)
>  		return dev_err_probe(dev, ret, "failed to enable the sensor\n");
>  
> +	if (client->irq) {
> +		ret = devm_request_threaded_irq(&client->dev, client->irq,
we have dev, so I used it.
> +						NULL, ltr390_interrupt_handler,
> +						IRQF_TRIGGER_FALLING |
Dropped this specifying of direction. Direction should be set by firmware not the driver.
We have it done in some older drivers and can't fix that now, but for new
code we should never force it here.

> +						IRQF_ONESHOT,
> +						"ltr390_thresh_event",
> +						indio_dev);
> +		if (ret) {
> +			dev_err(&client->dev, "request irq (%d) failed\n", client->irq);
return dev_err_probe(dev, ret, ...

in keeping with other local code and as it is generally nicer.
> +			return ret;
> +		}
> +	}
> +
>  	return devm_iio_device_register(dev, indio_dev);
>  }
>  


  reply	other threads:[~2024-09-28 15:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-14 18:12 [PATCH v3 0/4] Threshold event and Sampling freq support for LTR390 Abhash Jha
2024-09-14 18:12 ` [PATCH v3 1/4] iio: light: ltr390: Added configurable sampling frequency support Abhash Jha
2024-09-14 18:12 ` [PATCH v3 2/4] iio: light: ltr390: Suspend and Resume support Abhash Jha
2024-09-28 15:36   ` Jonathan Cameron
2024-09-14 18:12 ` [PATCH v3 3/4] iio: light: ltr390: Interrupts and threshold event support Abhash Jha
2024-09-28 15:45   ` Jonathan Cameron [this message]
2024-09-14 18:12 ` [PATCH v3 4/4] iio: light: ltr390: Add interrupt persistance support Abhash Jha
2024-09-28 15:47 ` [PATCH v3 0/4] Threshold event and Sampling freq support for LTR390 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=20240928164516.548c923f@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=abhashkumarjha123@gmail.com \
    --cc=anshulusr@gmail.com \
    --cc=lars@metafoo.de \
    --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