@@ -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_ */
@@ -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;
@@ -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 = {
@@ -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 = {
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@gmail.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(-)