[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241114231002.98595-8-l.rubusch@gmail.com>
Date: Thu, 14 Nov 2024 23:09:47 +0000
From: Lothar Rubusch <l.rubusch@...il.com>
To: lars@...afoo.de,
Michael.Hennerich@...log.com,
jic23@...nel.org,
linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: l.rubusch@....ch,
Lothar Rubusch <l.rubusch@...il.com>
Subject: [PATCH 07/22] iio: accel: adxl345: initialize IRQ number
Add the possibility to claim an interrupt and init the state structure
with interrupt number and interrupt line to use. The adxl345 can use
two different interrupt lines, mainly to signal FIFO watermark events,
single or double tap, activity, etc. Hence, having the interrupt line
available is crucial to implement such features.
Signed-off-by: Lothar Rubusch <l.rubusch@...il.com>
---
drivers/iio/accel/adxl345.h | 1 +
drivers/iio/accel/adxl345_core.c | 6 ++++++
drivers/iio/accel/adxl345_i2c.c | 2 +-
drivers/iio/accel/adxl345_spi.c | 8 ++++++--
4 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/accel/adxl345.h b/drivers/iio/accel/adxl345.h
index 3d5c8719db..cf4132715c 100644
--- a/drivers/iio/accel/adxl345.h
+++ b/drivers/iio/accel/adxl345.h
@@ -62,6 +62,7 @@ struct adxl345_chip_info {
};
int adxl345_core_probe(struct device *dev, struct regmap *regmap,
+ int irq,
int (*setup)(struct device*, struct regmap*));
#endif /* _ADXL345_H_ */
diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
index bcec3a8e05..57bc530cc3 100644
--- a/drivers/iio/accel/adxl345_core.c
+++ b/drivers/iio/accel/adxl345_core.c
@@ -11,6 +11,7 @@
#include <linux/property.h>
#include <linux/regmap.h>
#include <linux/units.h>
+#include <linux/interrupt.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
@@ -18,6 +19,7 @@
#include "adxl345.h"
struct adxl34x_state {
+ int irq;
const struct adxl345_chip_info *info;
struct regmap *regmap;
};
@@ -194,12 +196,14 @@ static const struct iio_info adxl345_info = {
* also covers the adxl375 and adxl346 accelerometer
* @dev: Driver model representation of the device
* @regmap: Regmap instance for the device
+ * @irq: Interrupt handling for async usage
* @setup: Setup routine to be executed right before the standard device
* setup
*
* Return: 0 on success, negative errno on error
*/
int adxl345_core_probe(struct device *dev, struct regmap *regmap,
+ int irq,
int (*setup)(struct device*, struct regmap*))
{
struct adxl34x_state *st;
@@ -222,6 +226,8 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap,
st = iio_priv(indio_dev);
st->regmap = regmap;
+
+ st->irq = irq;
st->info = device_get_match_data(dev);
if (!st->info)
return -ENODEV;
diff --git a/drivers/iio/accel/adxl345_i2c.c b/drivers/iio/accel/adxl345_i2c.c
index 4065b8f7c8..604b706c29 100644
--- a/drivers/iio/accel/adxl345_i2c.c
+++ b/drivers/iio/accel/adxl345_i2c.c
@@ -27,7 +27,7 @@ static int adxl345_i2c_probe(struct i2c_client *client)
if (IS_ERR(regmap))
return dev_err_probe(&client->dev, PTR_ERR(regmap), "Error initializing regmap\n");
- return adxl345_core_probe(&client->dev, regmap, NULL);
+ return adxl345_core_probe(&client->dev, regmap, client->irq, NULL);
}
static const struct adxl345_chip_info adxl345_i2c_info = {
diff --git a/drivers/iio/accel/adxl345_spi.c b/drivers/iio/accel/adxl345_spi.c
index 61fd9a6f5f..39e7d71e1d 100644
--- a/drivers/iio/accel/adxl345_spi.c
+++ b/drivers/iio/accel/adxl345_spi.c
@@ -39,9 +39,13 @@ static int adxl345_spi_probe(struct spi_device *spi)
return dev_err_probe(&spi->dev, PTR_ERR(regmap), "Error initializing regmap\n");
if (spi->mode & SPI_3WIRE)
- return adxl345_core_probe(&spi->dev, regmap, adxl345_spi_setup);
+ return adxl345_core_probe(&spi->dev, regmap,
+ spi->irq,
+ adxl345_spi_setup);
else
- return adxl345_core_probe(&spi->dev, regmap, NULL);
+ return adxl345_core_probe(&spi->dev, regmap,
+ spi->irq,
+ NULL);
}
static const struct adxl345_chip_info adxl345_spi_info = {
--
2.39.2
Powered by blists - more mailing lists