From: Jonathan Cameron <jic23@kernel.org>
To: linux-iio@vger.kernel.org,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Alexandru Ardelean <aardelean@deviqon.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: [PATCH v3 3/5] iio: accel: mma9551: Add support to get irqs directly from fwnode
Date: Sun, 5 Dec 2021 20:02:48 +0000 [thread overview]
Message-ID: <20211205200250.2840902-4-jic23@kernel.org> (raw)
In-Reply-To: <20211205200250.2840902-1-jic23@kernel.org>
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Note the interrupt type should be specified by firmware, not the driver
so that is also dropped.
Drop previous gpio based retrieval method. Whilst in theory this
might cause problems with direction if anyone is using ACPI GioIo().
As Andy described in v1, such a situation would typically reflect
a pin that is actually used in both directions (not true here)
or missdesigned ACPI tables.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
drivers/iio/accel/mma9551.c | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)
diff --git a/drivers/iio/accel/mma9551.c b/drivers/iio/accel/mma9551.c
index 1b4a8b27f14a..537a7a04654a 100644
--- a/drivers/iio/accel/mma9551.c
+++ b/drivers/iio/accel/mma9551.c
@@ -19,7 +19,7 @@
#define MMA9551_DRV_NAME "mma9551"
#define MMA9551_IRQ_NAME "mma9551_event"
-#define MMA9551_GPIO_COUNT 4
+#define MMA9551_IRQ_COUNT 4
/* Tilt application (inclination in IIO terms). */
#define MMA9551_TILT_XZ_ANG_REG 0x00
@@ -46,7 +46,7 @@ struct mma9551_data {
struct i2c_client *client;
struct mutex mutex;
int event_enabled[3];
- int irqs[MMA9551_GPIO_COUNT];
+ int irqs[MMA9551_IRQ_COUNT];
};
static int mma9551_read_incli_chan(struct i2c_client *client,
@@ -400,36 +400,26 @@ static int mma9551_init(struct mma9551_data *data)
return mma9551_set_device_state(data->client, true);
}
-static int mma9551_gpio_probe(struct iio_dev *indio_dev)
+static int mma9551_irq_probe(struct iio_dev *indio_dev)
{
- struct gpio_desc *gpio;
int i, ret;
struct mma9551_data *data = iio_priv(indio_dev);
struct device *dev = &data->client->dev;
- for (i = 0; i < MMA9551_GPIO_COUNT; i++) {
- gpio = devm_gpiod_get_index(dev, NULL, i, GPIOD_IN);
- if (IS_ERR(gpio)) {
- dev_err(dev, "acpi gpio get index failed\n");
- return PTR_ERR(gpio);
- }
-
- ret = gpiod_to_irq(gpio);
- if (ret < 0)
+ for (i = 0; i < MMA9551_IRQ_COUNT; i++) {
+ ret = fwnode_irq_get(dev_fwnode(dev), i);
+ if (ret)
return ret;
data->irqs[i] = ret;
ret = devm_request_threaded_irq(dev, data->irqs[i],
- NULL, mma9551_event_handler,
- IRQF_TRIGGER_RISING | IRQF_ONESHOT,
- MMA9551_IRQ_NAME, indio_dev);
+ NULL, mma9551_event_handler,
+ IRQF_ONESHOT,
+ MMA9551_IRQ_NAME, indio_dev);
if (ret < 0) {
dev_err(dev, "request irq %d failed\n", data->irqs[i]);
return ret;
}
-
- dev_dbg(dev, "gpio resource, no:%d irq:%d\n",
- desc_to_gpio(gpio), data->irqs[i]);
}
return 0;
@@ -466,7 +456,7 @@ static int mma9551_probe(struct i2c_client *client,
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &mma9551_info;
- ret = mma9551_gpio_probe(indio_dev);
+ ret = mma9551_irq_probe(indio_dev);
if (ret < 0)
goto out_poweroff;
--
2.34.1
next prev parent reply other threads:[~2021-12-05 19:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-05 20:02 [PATCH v3 0/5] iio: accel: mma9551/mma9553 Cleanup and update Jonathan Cameron
2021-12-05 20:02 ` [PATCH v3 1/5] iio: accel: mma9551/mma9553: Drop explicit ACPI match support Jonathan Cameron
2021-12-05 20:02 ` [PATCH v3 2/5] iio: accel: mma9551/mma9553: Simplify pm logic Jonathan Cameron
2021-12-05 20:02 ` Jonathan Cameron [this message]
2021-12-05 20:39 ` [PATCH v3 3/5] iio: accel: mma9551: Add support to get irqs directly from fwnode Andy Shevchenko
2021-12-06 19:18 ` Jonathan Cameron
2021-12-05 20:02 ` [PATCH v3 4/5] iio: accel: mma9551: Use devm managed functions to tidy up probe() Jonathan Cameron
2021-12-05 20:02 ` [PATCH v3 5/5] iio: accel: mma9553: " 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=20211205200250.2840902-4-jic23@kernel.org \
--to=jic23@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=aardelean@deviqon.com \
--cc=andy.shevchenko@gmail.com \
--cc=lars@metafoo.de \
--cc=linux-iio@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