Skip to contentSkip to conversation

IIO: use irq_get_trigger_type() instead of opencoding.

PATCH In review Jonathan Cameron 6 participants 38 messages Sep 1, 2024 – Sep 7, 2024

Subsystems (11)
lore
Share & tools
lore

Jonathan Cameron

author maintainer
#0 lore raw

cover IIO: use irq_get_trigger_type() instead of opencoding.

From: Jonathan Cameron <[email protected]>

Andy pointed out in a review that there is an irq_get_trigger_type() helper that first gets the irq data then extracts the type from it. This saves on opencoding those two steps when the irq data isn't used for anything else.

Update all the sites this pattern occurs in IIO to use the helper. In a few cases there will be a slightly different error message is somehow there is a valid irq number passed to this call and it doesn't have the data associated with it.

Jonathan Cameron (15):
iio: accel: adxl380: use irq_get_trigger_type()
iio: accel: fxls8962af: use irq_get_trigger_type()
iio: adc: ti-ads1015: use irq_get_trigger_type()
iio: common: st: use irq_get_trigger_type()
iio: gyro: fxas21002c: use irq_get_trigger_type()
iio: gyro: mpu3050: use irq_get_trigger_type()
iio: humidity: hts221: use irq_get_trigger_type()
iio: imu: bmi160: use irq_get_trigger_type()
iio: imu: bmi323: use irq_get_trigger_type()
iio: imu: inv_icm42600: use irq_get_trigger_type()
iio: imu: inv_mpu6050: use irq_get_trigger_type()
iio: imu: st_lsm6dsx: use irq_get_trigger_type()
iio: light: st_uvis25: use irq_get_trigger_type()
iio: magn: ak8974: use irq_get_trigger_type()
iio: pressure: bmp280: use irq_get_trigger_type()

 drivers/iio/accel/adxl380.c                        |  7 +------
 drivers/iio/accel/fxls8962af-core.c                |  2 +-
 drivers/iio/adc/ti-ads1015.c                       |  2 +-
 drivers/iio/common/st_sensors/st_sensors_trigger.c |  2 +-
 drivers/iio/gyro/fxas21002c_core.c                 |  2 +-
 drivers/iio/gyro/mpu3050-core.c                    |  2 +-
 drivers/iio/humidity/hts221_buffer.c               |  2 +-
 drivers/iio/imu/bmi160/bmi160_core.c               | 11 +----------
 drivers/iio/imu/bmi323/bmi323_core.c               |  8 +-------
 drivers/iio/imu/inv_icm42600/inv_icm42600_core.c   | 10 +---------
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c         |  9 +--------
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c       |  2 +-
 drivers/iio/light/st_uvis25_core.c                 |  2 +-
 drivers/iio/magnetometer/ak8974.c                  |  2 +-
 drivers/iio/pressure/bmp280-core.c                 |  2 +-
 15 files changed, 15 insertions(+), 50 deletions(-)
Signature · 1 line
2.46.0
author maintainer
#1 lore raw

PATCH 1/15 iio: accel: adxl380: use irq_get_trigger_type()

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

---
 drivers/iio/accel/adxl380.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/iio/accel/adxl380.c +1 -6
index 98863e22bb6b..9c9bee993fde 100644
@@ -1719,7 +1719,6 @@ static int adxl380_config_irq(struct iio_dev *indio_dev)
 {
 	struct adxl380_state *st = iio_priv(indio_dev);
 	unsigned long irq_flag;
-	struct irq_data *desc;
 	u32 irq_type;
 	u8 polarity;
 	int ret;
@@ -1737,11 +1736,7 @@ static int adxl380_config_irq(struct iio_dev *indio_dev)
 		st->int_map[1] = ADXL380_INT1_MAP1_REG;
 	}
 
-	desc = irq_get_irq_data(st->irq);
-	if (!desc)
-		return dev_err_probe(st->dev, -EINVAL, "Could not find IRQ %d\n", st->irq);
-
-	irq_type = irqd_get_trigger_type(desc);
+	irq_type = irq_get_trigger_type(st->irq);
 	if (irq_type == IRQ_TYPE_LEVEL_HIGH) {
 		polarity = 0;
 		irq_flag = IRQF_TRIGGER_HIGH | IRQF_ONESHOT;
Signature · 1 line
2.46.0
author maintainer
#2 lore raw

PATCH 2/15 iio: accel: fxls8962af: use irq_get_trigger_type()

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

---
 drivers/iio/accel/fxls8962af-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/fxls8962af-core.c +1 -1
index acadabec4df7..a50c47f5179f 100644
@@ -1103,7 +1103,7 @@ static int fxls8962af_irq_setup(struct iio_dev *indio_dev, int irq)
 	if (ret)
 		return ret;
 
-	irq_type = irqd_get_trigger_type(irq_get_irq_data(irq));
+	irq_type = irq_get_trigger_type(irq);
 
 	switch (irq_type) {
 	case IRQF_TRIGGER_HIGH:
Signature · 1 line
2.46.0
author maintainer
#5 lore raw

PATCH 3/15 iio: adc: ti-ads1015: use irq_get_trigger_type()

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

---
 drivers/iio/adc/ti-ads1015.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ti-ads1015.c +1 -1
index ca432c49eab1..70f60d018049 100644
@@ -1033,7 +1033,7 @@ static int ads1015_probe(struct i2c_client *client)
 
 	if (client->irq && chip->has_comparator) {
 		unsigned long irq_trig =
-			irqd_get_trigger_type(irq_get_irq_data(client->irq));
+			irq_get_trigger_type(client->irq);
 		unsigned int cfg_comp_mask = ADS1015_CFG_COMP_QUE_MASK |
 			ADS1015_CFG_COMP_LAT_MASK | ADS1015_CFG_COMP_POL_MASK;
 		unsigned int cfg_comp =
Signature · 1 line
2.46.0
author maintainer
#7 lore raw

PATCH 4/15 iio: common: st: use irq_get_trigger_type()

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

---
 drivers/iio/common/st_sensors/st_sensors_trigger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/common/st_sensors/st_sensors_trigger.c +1 -1
index a0df9250a69f..1c51ac110078 100644
@@ -134,7 +134,7 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
 	iio_trigger_set_drvdata(sdata->trig, indio_dev);
 	sdata->trig->ops = trigger_ops;
 
-	irq_trig = irqd_get_trigger_type(irq_get_irq_data(sdata->irq));
+	irq_trig = irq_get_trigger_type(sdata->irq);
 	/*
 	 * If the IRQ is triggered on falling edge, we need to mark the
 	 * interrupt as active low, if the hardware supports this.
Signature · 1 line
2.46.0
author maintainer
#10 lore raw

PATCH 5/15 iio: gyro: fxas21002c: use irq_get_trigger_type()

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

---
 drivers/iio/gyro/fxas21002c_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/gyro/fxas21002c_core.c +1 -1
index c28d17ca6f5e..877a2b07cb23 100644
@@ -849,7 +849,7 @@ static int fxas21002c_trigger_probe(struct fxas21002c_data *data)
 	if (!data->dready_trig)
 		return -ENOMEM;
 
-	irq_trig = irqd_get_trigger_type(irq_get_irq_data(data->irq));
+	irq_trig = irq_get_trigger_type(data->irq);
 
 	if (irq_trig == IRQF_TRIGGER_RISING) {
 		ret = regmap_field_write(data->regmap_fields[F_IPOL], 1);
Signature · 1 line
2.46.0
author maintainer
#12 lore raw

PATCH 6/15 iio: gyro: mpu3050: use irq_get_trigger_type()

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

---
 drivers/iio/gyro/mpu3050-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/gyro/mpu3050-core.c +1 -1
index 35af68b41408..b38d0678277e 100644
@@ -1059,7 +1059,7 @@ static int mpu3050_trigger_probe(struct iio_dev *indio_dev, int irq)
 	/* Check if IRQ is open drain */
 	mpu3050->irq_opendrain = device_property_read_bool(dev, "drive-open-drain");
 
-	irq_trig = irqd_get_trigger_type(irq_get_irq_data(irq));
+	irq_trig = irq_get_trigger_type(irq);
 	/*
 	 * Configure the interrupt generator hardware to supply whatever
 	 * the interrupt is configured for, edges low/high level low/high,
Signature · 1 line
2.46.0
author maintainer
#15 lore raw

PATCH 7/15 iio: humidity: hts221: use irq_get_trigger_type()

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

---
 drivers/iio/humidity/hts221_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/humidity/hts221_buffer.c +1 -1
index 11ef38994a95..0272065cc44a 100644
@@ -81,7 +81,7 @@ int hts221_allocate_trigger(struct iio_dev *iio_dev)
 	unsigned long irq_type;
 	int err;
 
-	irq_type = irqd_get_trigger_type(irq_get_irq_data(hw->irq));
+	irq_type = irq_get_trigger_type(hw->irq);
 
 	switch (irq_type) {
 	case IRQF_TRIGGER_HIGH:
Signature · 1 line
2.46.0
author maintainer
#18 lore raw

PATCH 8/15 iio: imu: bmi160: use irq_get_trigger_type()

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

---
 drivers/iio/imu/bmi160/bmi160_core.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/iio/imu/bmi160/bmi160_core.c +1 -10
index 495e8a74ac67..3665fcd5ff0d 100644
@@ -690,17 +690,8 @@ static int bmi160_config_device_irq(struct iio_dev *indio_dev, int irq_type,
 static int bmi160_setup_irq(struct iio_dev *indio_dev, int irq,
 			    enum bmi160_int_pin pin)
 {
-	struct irq_data *desc;
-	u32 irq_type;
 	int ret;
-
-	desc = irq_get_irq_data(irq);
-	if (!desc) {
-		dev_err(&indio_dev->dev, "Could not find IRQ %d\n", irq);
-		return -EINVAL;
-	}
-
-	irq_type = irqd_get_trigger_type(desc);
+	u32 irq_type = irq_get_trigger_type(irq);
 
 	ret = bmi160_config_device_irq(indio_dev, irq_type, pin);
 	if (ret)
Signature · 1 line
2.46.0
author maintainer
#21 lore raw

PATCH 9/15 iio: imu: bmi323: use irq_get_trigger_type()

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

---
 drivers/iio/imu/bmi323/bmi323_core.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/iio/imu/bmi323/bmi323_core.c +1 -7
index 671401ce80dc..89eab40bcfdf 100644
@@ -1881,7 +1881,6 @@ static int bmi323_trigger_probe(struct bmi323_data *data,
 	struct fwnode_handle *fwnode;
 	enum bmi323_irq_pin irq_pin;
 	int ret, irq, irq_type;
-	struct irq_data *desc;
 
 	fwnode = dev_fwnode(data->dev);
 	if (!fwnode)
@@ -1898,12 +1897,7 @@ static int bmi323_trigger_probe(struct bmi323_data *data,
 		irq_pin = BMI323_IRQ_INT2;
 	}
 
-	desc = irq_get_irq_data(irq);
-	if (!desc)
-		return dev_err_probe(data->dev, -EINVAL,
-				     "Could not find IRQ %d\n", irq);
-
-	irq_type = irqd_get_trigger_type(desc);
+	irq_type = irq_get_trigger_type(irq);
 	switch (irq_type) {
 	case IRQF_TRIGGER_RISING:
 		latch = false;
Signature · 1 line
2.46.0
author maintainer
#22 lore raw

PATCH 10/15 iio: imu: inv_icm42600: use irq_get_trigger_type()

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

---
 drivers/iio/imu/inv_icm42600/inv_icm42600_core.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/iio/imu/inv_icm42600/inv_icm42600_core.c +1 -9
index c3924cc6190e..93b5d7a3339c 100644
@@ -673,7 +673,6 @@ int inv_icm42600_core_probe(struct regmap *regmap, int chip, int irq,
 {
 	struct device *dev = regmap_get_device(regmap);
 	struct inv_icm42600_state *st;
-	struct irq_data *irq_desc;
 	int irq_type;
 	bool open_drain;
 	int ret;
@@ -683,14 +682,7 @@ int inv_icm42600_core_probe(struct regmap *regmap, int chip, int irq,
 		return -ENODEV;
 	}
 
-	/* get irq properties, set trigger falling by default */
-	irq_desc = irq_get_irq_data(irq);
-	if (!irq_desc) {
-		dev_err(dev, "could not find IRQ %d\n", irq);
-		return -EINVAL;
-	}
-
-	irq_type = irqd_get_trigger_type(irq_desc);
+	irq_type = irq_get_trigger_type(irq);
 	if (!irq_type)
 		irq_type = IRQF_TRIGGER_FALLING;
 
Signature · 1 line
2.46.0
author maintainer
#23 lore raw

PATCH 11/15 iio: imu: inv_mpu6050: use irq_get_trigger_type()

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

---
 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +1 -8
index 14d95f34e981..fdb48c5e5686 100644
@@ -1859,7 +1859,6 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
 	struct inv_mpu6050_platform_data *pdata;
 	struct device *dev = regmap_get_device(regmap);
 	int result;
-	struct irq_data *desc;
 	int irq_type;
 
 	indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
@@ -1893,13 +1892,7 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
 	}
 
 	if (irq > 0) {
-		desc = irq_get_irq_data(irq);
-		if (!desc) {
-			dev_err(dev, "Could not find IRQ %d\n", irq);
-			return -EINVAL;
-		}
-
-		irq_type = irqd_get_trigger_type(desc);
+		irq_type = irq_get_trigger_type(irq);
 		if (!irq_type)
 			irq_type = IRQF_TRIGGER_RISING;
 	} else {
Signature · 1 line
2.46.0
author maintainer
#24 lore raw

PATCH 12/15 iio: imu: st_lsm6dsx: use irq_get_trigger_type()

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +1 -1
index ed0267929725..ca1a2c24d7ce 100644
@@ -2531,7 +2531,7 @@ static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw)
 	bool irq_active_low;
 	int err;
 
-	irq_type = irqd_get_trigger_type(irq_get_irq_data(hw->irq));
+	irq_type = irq_get_trigger_type(hw->irq);
 
 	switch (irq_type) {
 	case IRQF_TRIGGER_HIGH:
Signature · 1 line
2.46.0
author maintainer
#27 lore raw

PATCH 13/15 iio: light: st_uvis25: use irq_get_trigger_type()

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

---
 drivers/iio/light/st_uvis25_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/st_uvis25_core.c +1 -1
index fba3997574bb..4a58591c3bea 100644
@@ -174,7 +174,7 @@ static int st_uvis25_allocate_trigger(struct iio_dev *iio_dev)
 	unsigned long irq_type;
 	int err;
 
-	irq_type = irqd_get_trigger_type(irq_get_irq_data(hw->irq));
+	irq_type = irq_get_trigger_type(hw->irq);
 
 	switch (irq_type) {
 	case IRQF_TRIGGER_HIGH:
Signature · 1 line
2.46.0
author maintainer
#32 lore raw

PATCH 14/15 iio: magn: ak8974: use irq_get_trigger_type()

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

---
 drivers/iio/magnetometer/ak8974.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/magnetometer/ak8974.c +1 -1
index 961b1e0bfb13..8306a18706ac 100644
@@ -910,7 +910,7 @@ static int ak8974_probe(struct i2c_client *i2c)
 
 	/* If we have a valid DRDY IRQ, make use of it */
 	if (irq > 0) {
-		irq_trig = irqd_get_trigger_type(irq_get_irq_data(irq));
+		irq_trig = irq_get_trigger_type(irq);
 		if (irq_trig == IRQF_TRIGGER_RISING) {
 			dev_info(&i2c->dev, "enable rising edge DRDY IRQ\n");
 		} else if (irq_trig == IRQF_TRIGGER_FALLING) {
Signature · 1 line
2.46.0
author maintainer
#34 lore raw

PATCH 15/15 iio: pressure: bmp280: use irq_get_trigger_type()

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

---
 drivers/iio/pressure/bmp280-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/pressure/bmp280-core.c +1 -1
index da379230c837..b156dd763cf3 100644
@@ -2596,7 +2596,7 @@ static int bmp085_fetch_eoc_irq(struct device *dev,
 	unsigned long irq_trig;
 	int ret;
 
-	irq_trig = irqd_get_trigger_type(irq_get_irq_data(irq));
+	irq_trig = irq_get_trigger_type(irq);
 	if (irq_trig != IRQF_TRIGGER_RISING) {
 		dev_err(dev, "non-rising trigger given for EOC interrupt, trying to enforce it\n");
 		irq_trig = IRQF_TRIGGER_RISING;
Signature · 1 line
2.46.0
maintainer Reviewed-by on v1 12/15
#25 lore raw

Re: [PATCH 12/15] iio: imu: st_lsm6dsx: use irq_get_trigger_type()

In reply to Jonathan Cameron
Quoted 27 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +1 -1
index ed0267929725..ca1a2c24d7ce 100644
@@ -2531,7 +2531,7 @@ static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw)
 	bool irq_active_low;
 	int err;
 
-	irq_type = irqd_get_trigger_type(irq_get_irq_data(hw->irq));
+	irq_type = irq_get_trigger_type(hw->irq);
 
 	switch (irq_type) {
 	case IRQF_TRIGGER_HIGH:
Signature · 1 line
2.46.0
#4 lore raw

Re: [PATCH 02/15] iio: accel: fxls8962af: use irq_get_trigger_type()

In reply to Jonathan Cameron
Quoted 4 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

...

drivers/iio/accel/fxls8962af-core.c static int fxls8962af_irq_setup(struct iio_dev *indio_dev, int irq) · line 1106

Quoted 4 lines
drivers/iio/accel/fxls8962af-core.c +1 -1
-	irq_type = irqd_get_trigger_type(irq_get_irq_data(irq));
+	irq_type = irq_get_trigger_type(irq);

While at it, I would drop this blank line as well. Because the next line is quite coupled with the previous one.

Quoted 1 line

switch (irq_type) {

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#6 lore raw

Re: [PATCH 03/15] iio: adc: ti-ads1015: use irq_get_trigger_type()

In reply to Jonathan Cameron
Quoted 4 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

...

drivers/iio/adc/ti-ads1015.c static int ads1015_probe(struct i2c_client *client) · line 1036

Quoted 3 lines
drivers/iio/adc/ti-ads1015.c +1 -1
 		unsigned long irq_trig =
-			irqd_get_trigger_type(irq_get_irq_data(client->irq));
+			irq_get_trigger_type(client->irq);

Now a single line?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#8 lore raw

Re: [PATCH 04/15] iio: common: st: use irq_get_trigger_type()

In reply to Jonathan Cameron
Quoted 4 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

...

drivers/iio/common/st_sensors/st_sensors_trigger.c int st_sensors_allocate_trigger(struct iio_dev *indio_dev, · line 137

Quoted 2 lines
drivers/iio/common/st_sensors/st_sensors_trigger.c +1 -1
-	irq_trig = irqd_get_trigger_type(irq_get_irq_data(sdata->irq));
+	irq_trig = irq_get_trigger_type(sdata->irq);

Usually I think the

	/* ...comment on flow... */
	foo = bar();
	...something with foo that is commented above...

is slightly better as after reading the comment we immediately see where the foo comes from.

drivers/iio/common/st_sensors/st_sensors_trigger.c int st_sensors_allocate_trigger(struct iio_dev *indio_dev, · line 140

Quoted 3 lines
drivers/iio/common/st_sensors/st_sensors_trigger.c +0 -0
 	/*
 	 * If the IRQ is triggered on falling edge, we need to mark the
 	 * interrupt as active low, if the hardware supports this.

But, it's not a big deal.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#11 lore raw

Re: [PATCH 05/15] iio: gyro: fxas21002c: use irq_get_trigger_type()

In reply to Jonathan Cameron
Quoted 4 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

...

drivers/iio/gyro/fxas21002c_core.c static int fxas21002c_trigger_probe(struct fxas21002c_data *data) · line 852

Quoted 4 lines
drivers/iio/gyro/fxas21002c_core.c +1 -1
-	irq_trig = irqd_get_trigger_type(irq_get_irq_data(data->irq));
+	irq_trig = irq_get_trigger_type(data->irq);

No blank line?

Quoted 2 lines
drivers/iio/gyro/fxas21002c_core.c +0 -0
 	if (irq_trig == IRQF_TRIGGER_RISING) {
 		ret = regmap_field_write(data->regmap_fields[F_IPOL], 1);
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#19 lore raw

Re: [PATCH 08/15] iio: imu: bmi160: use irq_get_trigger_type()

In reply to Jonathan Cameron
Quoted 4 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

...

drivers/iio/imu/bmi160/bmi160_core.c static int bmi160_config_device_irq(struct iio_dev *indio_dev, int irq_type, · line 694

Quoted 13 lines

{

drivers/iio/imu/bmi160/bmi160_core.c +1 -10
-	struct irq_data *desc;
-	u32 irq_type;
 	int ret;
-
-	desc = irq_get_irq_data(irq);
-	if (!desc) {
-		dev_err(&indio_dev->dev, "Could not find IRQ %d\n", irq);
-		return -EINVAL;
-	}
-
-	irq_type = irqd_get_trigger_type(desc);
+	u32 irq_type = irq_get_trigger_type(irq);

Hmm... You broke the reversed xmas tree ordering.
Anyway, can we actually

Quoted 1 line

ret = bmi160_config_device_irq(indio_dev, irq_type, pin);

	ret = bmi160_config_device_irq(indio_dev, irq_get_trigger_type(irq), pin);

instead?

Quoted 1 line

if (ret)

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#16 lore raw

Re: [PATCH 07/15] iio: humidity: hts221: use irq_get_trigger_type()

In reply to Jonathan Cameron
Quoted 4 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

...

drivers/iio/humidity/hts221_buffer.c int hts221_allocate_trigger(struct iio_dev *iio_dev) · line 84

Quoted 4 lines
drivers/iio/humidity/hts221_buffer.c +1 -1
-	irq_type = irqd_get_trigger_type(irq_get_irq_data(hw->irq));
+	irq_type = irq_get_trigger_type(hw->irq);

No blank line?

Quoted 2 lines
drivers/iio/humidity/hts221_buffer.c +0 -0
 	switch (irq_type) {
 	case IRQF_TRIGGER_HIGH:
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#26 lore raw

Re: [PATCH 12/15] iio: imu: st_lsm6dsx: use irq_get_trigger_type()

In reply to Jonathan Cameron
Quoted 4 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

...

drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw) · line 2534

Quoted 4 lines
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +1 -1
-	irq_type = irqd_get_trigger_type(irq_get_irq_data(hw->irq));
+	irq_type = irq_get_trigger_type(hw->irq);

No blank line?

Quoted 2 lines
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +0 -0
 	switch (irq_type) {
 	case IRQF_TRIGGER_HIGH:
Signature · 2 lines
With Best Regards,
Andy Shevchenko
Reviewed-by on the v1 series
#36 lore raw
In reply to Jonathan Cameron
Quoted 11 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Andy pointed out in a review that there is an irq_get_trigger_type() helper that first gets the irq data then extracts the type from it. This saves on opencoding those two steps when the irq data isn't used for anything else.

Update all the sites this pattern occurs in IIO to use the helper. In a few cases there will be a slightly different error message is somehow there is a valid irq number passed to this call and it doesn't have the data associated with it.

There are some nit-picks, up to you how to proceed with them (only one seems better to address is where the reversed xmas tree ordering is broken).

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#28 lore raw

Re: [PATCH 13/15] iio: light: st_uvis25: use irq_get_trigger_type()

In reply to Jonathan Cameron
Quoted 4 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

...

drivers/iio/light/st_uvis25_core.c static int st_uvis25_allocate_trigger(struct iio_dev *iio_dev) · line 177

Quoted 4 lines
drivers/iio/light/st_uvis25_core.c +1 -1
-	irq_type = irqd_get_trigger_type(irq_get_irq_data(hw->irq));
+	irq_type = irq_get_trigger_type(hw->irq);

No blank line?

Quoted 2 lines
drivers/iio/light/st_uvis25_core.c +0 -0
 	switch (irq_type) {
 	case IRQF_TRIGGER_HIGH:
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#14 lore raw

Re: [PATCH 06/15] iio: gyro: mpu3050: use irq_get_trigger_type()

In reply to Jonathan Cameron
Quoted 4 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

...

drivers/iio/gyro/mpu3050-core.c static int mpu3050_trigger_probe(struct iio_dev *indio_dev, int irq) · line 1062

Quoted 2 lines
drivers/iio/gyro/mpu3050-core.c +1 -1
-	irq_trig = irqd_get_trigger_type(irq_get_irq_data(irq));
+	irq_trig = irq_get_trigger_type(irq);

Same remark about comment vs. assignment.

Quoted 3 lines
drivers/iio/gyro/mpu3050-core.c +0 -0
 	/*
 	 * Configure the interrupt generator hardware to supply whatever
 	 * the interrupt is configured for, edges low/high level low/high,
Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Reviewed-by on v1 7/15
#17 lore raw

Re: [PATCH 07/15] iio: humidity: hts221: use irq_get_trigger_type()

In reply to Jonathan Cameron
Quoted 27 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

---
 drivers/iio/humidity/hts221_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/humidity/hts221_buffer.c +1 -1
index 11ef38994a95..0272065cc44a 100644
@@ -81,7 +81,7 @@ int hts221_allocate_trigger(struct iio_dev *iio_dev)
 	unsigned long irq_type;
 	int err;
 
-	irq_type = irqd_get_trigger_type(irq_get_irq_data(hw->irq));
+	irq_type = irq_get_trigger_type(hw->irq);
 
 	switch (irq_type) {
 	case IRQF_TRIGGER_HIGH:
Signature · 1 line
2.46.0
maintainer Reviewed-by on v1 13/15
#31 lore raw

Re: [PATCH 13/15] iio: light: st_uvis25: use irq_get_trigger_type()

In reply to Jonathan Cameron
Quoted 26 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

---
 drivers/iio/light/st_uvis25_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/st_uvis25_core.c +1 -1
index fba3997574bb..4a58591c3bea 100644
@@ -174,7 +174,7 @@ static int st_uvis25_allocate_trigger(struct iio_dev *iio_dev)
 	unsigned long irq_type;
 	int err;
 
-	irq_type = irqd_get_trigger_type(irq_get_irq_data(hw->irq));
+	irq_type = irq_get_trigger_type(hw->irq);
 
 	switch (irq_type) {
 	case IRQF_TRIGGER_HIGH:
Signature · 1 line
2.46.0
Tested-by on v1 15/15
#35 lore raw

Re: [PATCH 15/15] iio: pressure: bmp280: use irq_get_trigger_type()

In reply to Jonathan Cameron
Quoted 26 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

---
 drivers/iio/pressure/bmp280-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/pressure/bmp280-core.c +1 -1
index da379230c837..b156dd763cf3 100644
@@ -2596,7 +2596,7 @@ static int bmp085_fetch_eoc_irq(struct device *dev,
 	unsigned long irq_trig;
 	int ret;
 
-	irq_trig = irqd_get_trigger_type(irq_get_irq_data(irq));
+	irq_trig = irq_get_trigger_type(irq);
 	if (irq_trig != IRQF_TRIGGER_RISING) {
 		dev_err(dev, "non-rising trigger given for EOC interrupt, trying to enforce it\n");
 		irq_trig = IRQF_TRIGGER_RISING;
Signature · 1 line
2.46.0

Hi Jonathan,

author maintainer
#29 lore raw

Re: [PATCH 13/15] iio: light: st_uvis25: use irq_get_trigger_type()

In reply to Andy Shevchenko
Quoted 6 lines · On Mon, 2 Sep 2024 14:47:59 +0300 Andy Shevchenko…
Quoted 4 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

Quoted 9 lines

...

drivers/iio/light/st_uvis25_core.c static int st_uvis25_allocate_trigger(struct iio_dev *iio_dev) · line 177

Quoted 4 lines
drivers/iio/light/st_uvis25_core.c +1 -1
-	irq_type = irqd_get_trigger_type(irq_get_irq_data(hw->irq));
+	irq_type = irq_get_trigger_type(hw->irq);  

No blank line?

Might was well roll it into the switch now you mention it!

Jonathan

Quoted 3 lines
Quoted 2 lines
drivers/iio/light/st_uvis25_core.c +0 -0
 	switch (irq_type) {
 	case IRQF_TRIGGER_HIGH:  
#30 lore raw

Re: [PATCH 13/15] iio: light: st_uvis25: use irq_get_trigger_type()

Quoted 3 lines · Jonathan Cameron
Quoted 1 line · On Mon, 2 Sep 2024 14:47:59 +0300 Andy Shevchenko…

On Sun, Sep 01, 2024 at 02:59:48PM +0100, Jonathan Cameron wrote:

...

Quoted 8 lines
Quoted 6 lines

drivers/iio/light/st_uvis25_core.c static int st_uvis25_allocate_trigger(struct iio_dev *iio_dev) · line 177

Quoted 4 lines
drivers/iio/light/st_uvis25_core.c +1 -1
-	irq_type = irqd_get_trigger_type(irq_get_irq_data(hw->irq));
+	irq_type = irq_get_trigger_type(hw->irq);  

No blank line?

Might was well roll it into the switch now you mention it!

I think it's discussable (from the readability perspective), but FWIW, I'm fine with any of your choices here.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
drivers/iio/light/st_uvis25_core.c +0 -0
 	switch (irq_type) {
 	case IRQF_TRIGGER_HIGH:  
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author maintainer
#9 lore raw

Re: [PATCH 04/15] iio: common: st: use irq_get_trigger_type()

In reply to Andy Shevchenko
Quoted 17 lines · On Mon, 2 Sep 2024 14:44:06 +0300 Andy Shevchenko…
Quoted 4 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

...

drivers/iio/common/st_sensors/st_sensors_trigger.c int st_sensors_allocate_trigger(struct iio_dev *indio_dev, · line 137

Quoted 2 lines
drivers/iio/common/st_sensors/st_sensors_trigger.c +1 -1
-	irq_trig = irqd_get_trigger_type(irq_get_irq_data(sdata->irq));
+	irq_trig = irq_get_trigger_type(sdata->irq);  

Usually I think the

	/* ...comment on flow... */
	foo = bar();
	...something with foo that is commented above...
Quoted 8 lines

is slightly better as after reading the comment we immediately see where the foo comes from.

drivers/iio/common/st_sensors/st_sensors_trigger.c int st_sensors_allocate_trigger(struct iio_dev *indio_dev, · line 140

Quoted 3 lines
drivers/iio/common/st_sensors/st_sensors_trigger.c +0 -0
 	/*
 	 * If the IRQ is triggered on falling edge, we need to mark the
 	 * interrupt as active low, if the hardware supports this.  

But, it's not a big deal.

Agreed it makes sense.

This just goes to show how little I looked at surrounding code when putting this set together.

I've reordered and added a note on that to the description.

Quoted 1 line
author maintainer
#20 lore raw

Re: [PATCH 08/15] iio: imu: bmi160: use irq_get_trigger_type()

In reply to Andy Shevchenko
Quoted 8 lines · On Mon, 2 Sep 2024 14:45:52 +0300 Andy Shevchenko…
Quoted 4 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Use irq_get_trigger_type() to replace getting the irq data then the type in two steps.

...

Quoted 16 lines

drivers/iio/imu/bmi160/bmi160_core.c static int bmi160_config_device_irq(struct iio_dev *indio_dev, int irq_type, · line 694

Quoted 13 lines

{

drivers/iio/imu/bmi160/bmi160_core.c +1 -10
-	struct irq_data *desc;
-	u32 irq_type;
 	int ret;
-
-	desc = irq_get_irq_data(irq);
-	if (!desc) {
-		dev_err(&indio_dev->dev, "Could not find IRQ %d\n", irq);
-		return -EINVAL;
-	}
-
-	irq_type = irqd_get_trigger_type(desc);
+	u32 irq_type = irq_get_trigger_type(irq);  

Hmm... You broke the reversed xmas tree ordering.
Anyway, can we actually

I put this back.

Quoted 6 lines
Quoted 2 lines

ret = bmi160_config_device_irq(indio_dev, irq_type, pin);

	ret = bmi160_config_device_irq(indio_dev, irq_get_trigger_type(irq), pin);

instead?

Nope. irq_type is passed into the probe_trigger function outside the context we can see in the patch.

Jonathan

Quoted 3 lines
Quoted 2 lines

if (ret)

author maintainer
#37 lore raw
In reply to Andy Shevchenko
Quoted 13 lines · On Mon, 2 Sep 2024 14:49:19 +0300 Andy Shevchenko…
Quoted 11 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Andy pointed out in a review that there is an irq_get_trigger_type() helper that first gets the irq data then extracts the type from it. This saves on opencoding those two steps when the irq data isn't used for anything else.

Update all the sites this pattern occurs in IIO to use the helper. In a few cases there will be a slightly different error message is somehow there is a valid irq number passed to this call and it doesn't have the data associated with it.

Quoted 5 lines

There are some nit-picks, up to you how to proceed with them (only one seems better to address is where the reversed xmas tree ordering is broken).

I made the changes suggested. Applied to the togreg branch of iio.git.

I think these will probably wait for next cycle now given timing.

Jonathan