[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZXMJFVc3vUKFz4gP@debian-BULLSEYE-live-builder-AMD64>
Date: Fri, 8 Dec 2023 09:16:21 -0300
From: Marcelo Schmitt <marcelo.schmitt1@...il.com>
To: David Lechner <dlechner@...libre.com>
Cc: Marcelo Schmitt <marcelo.schmitt@...log.com>, apw@...onical.com,
joe@...ches.com, dwaipayanray1@...il.com, lukas.bulwahn@...il.com,
paul.cercueil@...log.com, Michael.Hennerich@...log.com,
lars@...afoo.de, jic23@...nel.org, robh+dt@...nel.org,
krzysztof.kozlowski+dt@...aro.org, conor+dt@...nel.org,
dan.carpenter@...aro.org, linux-iio@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 02/13] iio: adc: ad7091r: Populate device driver data
field
On 12/07, David Lechner wrote:
> On Thu, Dec 7, 2023 at 12:38 PM Marcelo Schmitt
> <marcelo.schmitt@...log.com> wrote:
> >
> > Set device driver data so it can be retrieved when handling alert
> > events, avoiding null pointer dereference.
> >
[...]
>
> Instead of introducing a new relationship between iio_dev and st, why
> not pass iio_dev to devm_request_threaded_irq() instead of st and then
> use iio_priv() to get st in ad7091r_event_handler?
>
> diff --git a/drivers/iio/adc/ad7091r-base.c b/drivers/iio/adc/ad7091r-base.c
> index 8e252cde735b..0e5d3d2e9c98 100644
> --- a/drivers/iio/adc/ad7091r-base.c
> +++ b/drivers/iio/adc/ad7091r-base.c
> @@ -174,8 +174,8 @@ static const struct iio_info ad7091r_info = {
>
> static irqreturn_t ad7091r_event_handler(int irq, void *private)
> {
> - struct ad7091r_state *st = (struct ad7091r_state *) private;
> - struct iio_dev *iio_dev = dev_get_drvdata(st->dev);
> + struct iio_dev *iio_dev = private;
> + struct ad7091r_state *st = iio_priv(iio_dev);
> unsigned int i, read_val;
> int ret;
> s64 timestamp = iio_get_time_ns(iio_dev);
> @@ -234,7 +234,7 @@ int ad7091r_probe(struct device *dev, const char *name,
> if (irq) {
> ret = devm_request_threaded_irq(dev, irq, NULL,
> ad7091r_event_handler,
> - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, name, st);
> + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, name, iio_dev);
> if (ret)
> return ret;
> }
Looks good, will do for v4.
Thanks
Powered by blists - more mailing lists