Message ID | 20241205171343.308963-8-l.rubusch@gmail.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | iio: accel: adxl345: add FIFO operating with IRQ triggered watermark events | expand |
On Thu, 5 Dec 2024 17:13:40 +0000 Lothar Rubusch <l.rubusch@gmail.com> wrote: > Add the possibility to claim an interrupt. Init the state structure > with an interrupt line obtained from the DT. The adxl345 can use > two different interrupt lines for event handling. Only one is used. > > Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com> > --- > drivers/iio/accel/adxl345_core.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c > index 1d020b0d79c..e0a8b32239f 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,8 +19,10 @@ > #include "adxl345.h" > > struct adxl345_state { > + int irq; Ordering is non obvious. I'd keep the pointers first and have this before intio. > const struct adxl345_chip_info *info; > struct regmap *regmap; > + u8 intio; > }; > > #define ADXL345_CHANNEL(index, axis) { \ > @@ -212,6 +215,17 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap, > > st = iio_priv(indio_dev); > st->regmap = regmap; > + > + st->intio = -1; It's a u8 so negative doesn't seem sensible choice. > + st->irq = fwnode_irq_get_byname(dev_fwnode(dev), "INT1"); > + if (st->irq > 0) Where one leg needs {} convention is to use it for all of them. https://www.kernel.org/doc/html/v4.10/process/coding-style.html#placing-braces-and-spaces last part. > + st->intio = ADXL345_INT1; > + else { > + st->irq = fwnode_irq_get_byname(dev_fwnode(dev), "INT2"); > + if (st->irq > 0) > + st->intio = ADXL345_INT2; > + } > + > st->info = device_get_match_data(dev); > if (!st->info) > return -ENODEV;
diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c index 1d020b0d79c..e0a8b32239f 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,8 +19,10 @@ #include "adxl345.h" struct adxl345_state { + int irq; const struct adxl345_chip_info *info; struct regmap *regmap; + u8 intio; }; #define ADXL345_CHANNEL(index, axis) { \ @@ -212,6 +215,17 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap, st = iio_priv(indio_dev); st->regmap = regmap; + + st->intio = -1; + st->irq = fwnode_irq_get_byname(dev_fwnode(dev), "INT1"); + if (st->irq > 0) + st->intio = ADXL345_INT1; + else { + st->irq = fwnode_irq_get_byname(dev_fwnode(dev), "INT2"); + if (st->irq > 0) + st->intio = ADXL345_INT2; + } + st->info = device_get_match_data(dev); if (!st->info) return -ENODEV;
Add the possibility to claim an interrupt. Init the state structure with an interrupt line obtained from the DT. The adxl345 can use two different interrupt lines for event handling. Only one is used. Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com> --- drivers/iio/accel/adxl345_core.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)