@@ -1807,6 +1807,29 @@ static irqreturn_t adt7316_event_handler(int irq, void *private)
return IRQ_HANDLED;
}
+static int adt7316_setup_irq(struct device *dev, int irq)
+{
+ int irq_type;
+
+ irq_type = irqd_get_trigger_type(irq_get_irq_data(irq));
+
+ switch (irq_type) {
+ case IRQF_TRIGGER_HIGH:
+ case IRQF_TRIGGER_RISING:
+ break;
+ case IRQF_TRIGGER_LOW:
+ case IRQF_TRIGGER_FALLING:
+ break;
+ default:
+ dev_info(dev, "mode %d unsupported, using IRQF_TRIGGER_LOW\n",
+ irq_type);
+ irq_type = IRQF_TRIGGER_LOW;
+ break;
+ }
+
+ return irq_type;
+}
+
/*
* Show mask of enabled interrupts in Hex.
*/
@@ -2101,8 +2124,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus,
{
struct adt7316_chip_info *chip;
struct iio_dev *indio_dev;
- unsigned short *adt7316_platform_data = dev->platform_data;
- int irq_type = IRQF_TRIGGER_LOW;
+ int irq_type;
int ret = 0;
indio_dev = devm_iio_device_alloc(dev, sizeof(*chip));
@@ -2146,8 +2168,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus,
indio_dev->modes = INDIO_DIRECT_MODE;
if (chip->bus.irq > 0) {
- if (adt7316_platform_data[0])
- irq_type = adt7316_platform_data[0];
+ irq_type = adt7316_setup_irq(dev, chip->bus.irq);
ret = devm_request_threaded_irq(dev, chip->bus.irq,
NULL,
ADT7316 driver no more uses platform data and hence use device tree data instead of platform data for assigning irq_type field. Switch case figures out the type of irq and if it's the default case then assign the default value to the irq_type i.e. irq_type = IRQF_TRIGGER_LOW All this is implemented in a new function called adt7316_setup_irq. Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com> --- drivers/staging/iio/addac/adt7316.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-)