Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio:imu:adis: Use IRQF_NO_AUTOEN instead of irq request then disable

This is a bit involved as the adis library code already has some
sanity checking of the flags of the requested irq that we need
to ensure is happy to pass through the IRQF_NO_AUTOEN flag untouched.

Using this flag avoids us autoenabling the irq in the adis16460 and
adis16475 drivers which cover parts that don't have any means of
masking the interrupt on the device end.

Note, compile tested only!

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Alexandru Ardelean <ardeleanalex@gmail.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: Barry Song <song.bao.hua@hisilicon.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Link: https://lore.kernel.org/r/20210402184544.488862-7-jic23@kernel.org

+11 -9
+2 -2
drivers/iio/imu/adis16460.c
··· 403 403 if (ret) 404 404 return ret; 405 405 406 + /* We cannot mask the interrupt, so ensure it isn't auto enabled */ 407 + st->adis.irq_flag |= IRQF_NO_AUTOEN; 406 408 ret = devm_adis_setup_buffer_and_trigger(&st->adis, indio_dev, NULL); 407 409 if (ret) 408 410 return ret; 409 - 410 - adis16460_enable_irq(&st->adis, 0); 411 411 412 412 ret = __adis_initial_startup(&st->adis); 413 413 if (ret)
+3 -2
drivers/iio/imu/adis16475.c
··· 1258 1258 return -EINVAL; 1259 1259 } 1260 1260 1261 + /* We cannot mask the interrupt so ensure it's not enabled at request */ 1262 + st->adis.irq_flag |= IRQF_NO_AUTOEN; 1263 + 1261 1264 val = ADIS16475_MSG_CTRL_DR_POL(polarity); 1262 1265 ret = __adis_update_bits(&st->adis, ADIS16475_REG_MSG_CTRL, 1263 1266 ADIS16475_MSG_CTRL_DR_POL_MASK, val); ··· 1364 1361 adis16475_trigger_handler); 1365 1362 if (ret) 1366 1363 return ret; 1367 - 1368 - adis16475_enable_irq(&st->adis, false); 1369 1364 1370 1365 ret = devm_iio_device_register(&spi->dev, indio_dev); 1371 1366 if (ret)
+6 -5
drivers/iio/imu/adis_trigger.c
··· 29 29 30 30 static int adis_validate_irq_flag(struct adis *adis) 31 31 { 32 + unsigned long direction = adis->irq_flag & IRQF_TRIGGER_MASK; 32 33 /* 33 34 * Typically this devices have data ready either on the rising edge or 34 35 * on the falling edge of the data ready pin. This checks enforces that 35 36 * one of those is set in the drivers... It defaults to 36 - * IRQF_TRIGGER_RISING for backward compatibility wiht devices that 37 + * IRQF_TRIGGER_RISING for backward compatibility with devices that 37 38 * don't support changing the pin polarity. 38 39 */ 39 - if (!adis->irq_flag) { 40 - adis->irq_flag = IRQF_TRIGGER_RISING; 40 + if (direction == IRQF_TRIGGER_NONE) { 41 + adis->irq_flag |= IRQF_TRIGGER_RISING; 41 42 return 0; 42 - } else if (adis->irq_flag != IRQF_TRIGGER_RISING && 43 - adis->irq_flag != IRQF_TRIGGER_FALLING) { 43 + } else if (direction != IRQF_TRIGGER_RISING && 44 + direction != IRQF_TRIGGER_FALLING) { 44 45 dev_err(&adis->spi->dev, "Invalid IRQ mask: %08lx\n", 45 46 adis->irq_flag); 46 47 return -EINVAL;