From: "Nuno Sá" <nuno.sa@analog.com>
To: <linux-iio@vger.kernel.org>, <devicetree@vger.kernel.org>
Cc: Jonathan Cameron <jic23@kernel.org>,
Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexandru Ardelean <alexandru.Ardelean@analog.com>,
Michael Hennerich <Michael.Hennerich@analog.com>
Subject: [PATCH v3 2/6] iio: imu: adis: Add irq mask variable
Date: Tue, 31 Mar 2020 13:48:07 +0200 [thread overview]
Message-ID: <20200331114811.7978-3-nuno.sa@analog.com> (raw)
In-Reply-To: <20200331114811.7978-1-nuno.sa@analog.com>
There are some ADIS devices that can configure the data ready pin
polarity. Hence, we cannot hardcode our IRQ mask as IRQF_TRIGGER_RISING
since we might want to have it as IRQF_TRIGGER_FALLING.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
Changes in v2:
* Add kernel doc-string for `irq-mask`.
Changes in v3:
* Removed unnecessary inline;
* Renamed `__adis_validate_irq_mask` to `adis_validate_irq_mask` to keep lib consistency;
* Cosmetics in logs.
drivers/iio/imu/adis_trigger.c | 26 ++++++++++++++++++++++++--
include/linux/iio/imu/adis.h | 2 ++
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/imu/adis_trigger.c b/drivers/iio/imu/adis_trigger.c
index a36810e0b1ab..df88b74f4c2b 100644
--- a/drivers/iio/imu/adis_trigger.c
+++ b/drivers/iio/imu/adis_trigger.c
@@ -34,6 +34,20 @@ static void adis_trigger_setup(struct adis *adis)
iio_trigger_set_drvdata(adis->trig, adis);
}
+static int adis_validate_irq_mask(struct adis *adis)
+{
+ if (!adis->irq_mask) {
+ adis->irq_mask = IRQF_TRIGGER_RISING;
+ return 0;
+ } else if (adis->irq_mask != IRQF_TRIGGER_RISING &&
+ adis->irq_mask != IRQF_TRIGGER_FALLING) {
+ dev_err(&adis->spi->dev, "Invalid IRQ mask: %08lx\n",
+ adis->irq_mask);
+ return -EINVAL;
+ }
+
+ return 0;
+}
/**
* adis_probe_trigger() - Sets up trigger for a adis device
* @adis: The adis device
@@ -54,9 +68,13 @@ int adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev)
adis_trigger_setup(adis);
+ ret = adis_validate_irq_mask(adis);
+ if (ret)
+ return ret;
+
ret = request_irq(adis->spi->irq,
&iio_trigger_generic_data_rdy_poll,
- IRQF_TRIGGER_RISING,
+ adis->irq_mask,
indio_dev->name,
adis->trig);
if (ret)
@@ -96,9 +114,13 @@ int devm_adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev)
adis_trigger_setup(adis);
+ ret = adis_validate_irq_mask(adis);
+ if (ret)
+ return ret;
+
ret = devm_request_irq(&adis->spi->dev, adis->spi->irq,
&iio_trigger_generic_data_rdy_poll,
- IRQF_TRIGGER_RISING,
+ adis->irq_mask,
indio_dev->name,
adis->trig);
if (ret)
diff --git a/include/linux/iio/imu/adis.h b/include/linux/iio/imu/adis.h
index ac94c483bf2b..ed41c6b96d14 100644
--- a/include/linux/iio/imu/adis.h
+++ b/include/linux/iio/imu/adis.h
@@ -87,6 +87,7 @@ struct adis_data {
* @msg: SPI message object
* @xfer: SPI transfer objects to be used for a @msg
* @current_page: Some ADIS devices have registers, this selects current page
+ * @irq_mask: IRQ handling flags as passed to request_irq()
* @buffer: Data buffer for information read from the device
* @tx: DMA safe TX buffer for SPI transfers
* @rx: DMA safe RX buffer for SPI transfers
@@ -113,6 +114,7 @@ struct adis {
struct spi_message msg;
struct spi_transfer *xfer;
unsigned int current_page;
+ unsigned long irq_mask;
void *buffer;
uint8_t tx[10] ____cacheline_aligned;
--
2.17.1
next prev parent reply other threads:[~2020-03-31 11:48 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-31 11:48 [PATCH v3 0/6] Support ADIS16475 and similar IMUs Nuno Sá
2020-03-31 11:48 ` [PATCH v3 1/6] iio: imu: adis: Add Managed device functions Nuno Sá
2020-04-04 16:24 ` Jonathan Cameron
2020-03-31 11:48 ` Nuno Sá [this message]
2020-03-31 17:40 ` [PATCH v3 2/6] iio: imu: adis: Add irq mask variable Andy Shevchenko
2020-04-01 7:22 ` Sa, Nuno
2020-04-01 10:27 ` Andy Shevchenko
2020-04-01 13:18 ` Sa, Nuno
2020-03-31 11:48 ` [PATCH v3 3/6] iio: adis: Add adis_update_bits() APIs Nuno Sá
2020-03-31 17:41 ` Andy Shevchenko
2020-04-01 7:14 ` Sa, Nuno
2020-03-31 11:48 ` [PATCH v3 4/6] iio: adis: Support different burst sizes Nuno Sá
2020-03-31 11:48 ` [PATCH v3 5/6] iio: imu: Add support for adis16475 Nuno Sá
2020-03-31 18:15 ` Andy Shevchenko
2020-04-01 7:13 ` Sa, Nuno
2020-04-01 10:22 ` Andy Shevchenko
2020-04-01 13:27 ` Sa, Nuno
2020-04-01 14:06 ` Andy Shevchenko
2020-04-01 14:18 ` Sa, Nuno
2020-04-01 16:24 ` Andy Shevchenko
2020-04-04 16:05 ` Jonathan Cameron
2020-04-04 16:01 ` Jonathan Cameron
2020-03-31 11:48 ` [PATCH v3 6/6] dt-bindings: iio: Add adis16475 documentation Nuno Sá
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=20200331114811.7978-3-nuno.sa@analog.com \
--to=nuno.sa@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=alexandru.Ardelean@analog.com \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pmeerw@pmeerw.net \
--cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).