From: Jonathan Cameron <jic23@kernel.org>
To: Antoni Pokusinski <apokusinski01@gmail.com>
Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
linux-iio@vger.kernel.org, linux@roeck-us.net,
rodrigo.gobbi.7@gmail.com, naresh.solanki@9elements.com,
michal.simek@amd.com, grantpeltier93@gmail.com,
farouk.bouabid@cherry.de, marcelo.schmitt1@gmail.com
Subject: Re: [PATCH v3 3/4] iio: mpl3115: add support for DRDY interrupt
Date: Sun, 28 Sep 2025 11:32:34 +0100 [thread overview]
Message-ID: <20250928113234.3ba70df8@jic23-huawei> (raw)
In-Reply-To: <20250928100232.tafcimfsoljdq6nt@antoni-VivoBook-ASUSLaptop-X512FAY-K512FA>
> > > +static int mpl3115_trigger_probe(struct mpl3115_data *data,
> > > + struct iio_dev *indio_dev)
> > > +{
> > > + struct fwnode_handle *fwnode = dev_fwnode(&data->client->dev);
> > > + int ret, irq, irq_type, irq_cfg_flags = 0;
> > > +
> > > + irq = fwnode_irq_get_byname(fwnode, "INT1");
> > > + if (irq < 0) {
> > > + irq = fwnode_irq_get_byname(fwnode, "INT2");
> > > + if (irq < 0)
> > > + return 0;
> > > +
> > > + irq_cfg_flags |= MPL3115_INT2;
> > > + }
> > > +
> > > + irq_type = irq_get_trigger_type(irq);
> > > + if (irq_type != IRQF_TRIGGER_RISING && irq_type != IRQF_TRIGGER_FALLING)
> > > + return -EINVAL;
> > > +
> > > + irq_cfg_flags |= irq_type;
> > Commented on this before, but mixing flags that are local to this driver
> > with those that are global provides not guarantees against future changes
> > of the global ones to overlap with your local values.
> >
> > So just track these as two separate values rather than combining them.
> >
>
> So you mean 2 separate variables, one for INT1/INT2 and one for the
> trigger RISING/FALLING, am I right?
Yes.
> This was the approach in v1, but the code for writing the regs CTRL3 and
> CTRL5 should be improved, I was thinking something like:
>
> if (irq_pin == MPL3115_IRQ_INT1) {
> write_byte_data(REG5, INT_CFG_DRDY);
> if (irq_type == IRQF_TRIGGER_RISING)
> write_byte_data(REG3, IPOL1);
> } else if (irq_type == IRQF_TRIGGER_RISING) {
> write_byte_data(REG3, IPOL2);
> }
>
> This is perhaps a bit less readable than the switch(int_cfg_flags) with 4
> cases... but IMO it's still quite ok and it's less verbose since we do not
> duplicate the write_byte_data(REG5, INT_CFG_DRDY).
That looks ok to me.
...
indio_dev->name,
> > > + iio_device_id(indio_dev));
> > > + if (!data->drdy_trig)
> > > + return -ENOMEM;
> > > +
> > > + data->drdy_trig->ops = &mpl3115_trigger_ops;
> > > + iio_trigger_set_drvdata(data->drdy_trig, indio_dev);
> > > + ret = devm_iio_trigger_register(&data->client->dev, data->drdy_trig);
> >
> > Whilst unlikely the race matters. It is this call that creates the infrastructure
> > that might allow the interrupt generation to be triggered via userspace controls.
> > So the handler should probably be in place firsts. I.e. do the devm_request_threaded_irq
> > before this.
> >
> Will fix in v4
Side process related note: If you agree with something, just crop it out! That means
we get to focus in quickly on the bits where there is more discussion to be done.
Your change log in v4 is where I'll see you made these changes.
When there is nothing to continue the discussion around in a thread, don't reply at all.
Thanks etc can come alongside the change log.
Thanks,
Jonathan
p.s. I have periodic sessions of mailing people about the process stuff once the
overall list traffic is larger than it should be for stuff like this. You just happened
to be an 'unlucky' recipient today!
next prev parent reply other threads:[~2025-09-28 10:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-26 22:01 [PATCH v3 0/4] iio: mpl3115: add support for DRDY interrupt Antoni Pokusinski
2025-09-26 22:01 ` [PATCH v3 1/4] dt-bindings: iio: pressure: add binding for mpl3115 Antoni Pokusinski
2025-09-26 22:01 ` [PATCH v3 2/4] iio: mpl3115: use guards from cleanup.h Antoni Pokusinski
2025-09-27 16:36 ` Jonathan Cameron
2025-09-28 9:41 ` Antoni Pokusinski
2025-09-26 22:01 ` [PATCH v3 3/4] iio: mpl3115: add support for DRDY interrupt Antoni Pokusinski
2025-09-27 16:51 ` Jonathan Cameron
2025-09-28 10:02 ` Antoni Pokusinski
2025-09-28 10:32 ` Jonathan Cameron [this message]
2025-09-26 22:01 ` [PATCH v3 4/4] iio: mpl3115: add support for sampling frequency Antoni Pokusinski
2025-09-27 16:54 ` 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=20250928113234.3ba70df8@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=apokusinski01@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=farouk.bouabid@cherry.de \
--cc=grantpeltier93@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=marcelo.schmitt1@gmail.com \
--cc=michal.simek@amd.com \
--cc=naresh.solanki@9elements.com \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
--cc=rodrigo.gobbi.7@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).