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

iio: humidity: hts221: support active-low interrupts

Add support for active low interrupts (IRQF_TRIGGER_LOW and
IRQF_TRIGGER_FALLING). Configure the device as active high or low
according to the requested irq line.

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Lorenzo Bianconi and committed by
Jonathan Cameron
e7b4b45e e3e25446

+13 -2
+1
drivers/iio/humidity/hts221.h
··· 61 61 extern const struct dev_pm_ops hts221_pm_ops; 62 62 63 63 int hts221_config_drdy(struct hts221_hw *hw, bool enable); 64 + int hts221_write_with_mask(struct hts221_hw *hw, u8 addr, u8 mask, u8 val); 64 65 int hts221_probe(struct iio_dev *iio_dev); 65 66 int hts221_set_enable(struct hts221_hw *hw, bool enable); 66 67 int hts221_allocate_buffers(struct hts221_hw *hw);
+11
drivers/iio/humidity/hts221_buffer.c
··· 22 22 23 23 #include "hts221.h" 24 24 25 + #define HTS221_REG_DRDY_HL_ADDR 0x22 26 + #define HTS221_REG_DRDY_HL_MASK BIT(7) 25 27 #define HTS221_REG_STATUS_ADDR 0x27 26 28 #define HTS221_RH_DRDY_MASK BIT(1) 27 29 #define HTS221_TEMP_DRDY_MASK BIT(0) ··· 69 67 int hts221_allocate_trigger(struct hts221_hw *hw) 70 68 { 71 69 struct iio_dev *iio_dev = iio_priv_to_dev(hw); 70 + bool irq_active_low = false; 72 71 unsigned long irq_type; 73 72 int err; 74 73 ··· 79 76 case IRQF_TRIGGER_HIGH: 80 77 case IRQF_TRIGGER_RISING: 81 78 break; 79 + case IRQF_TRIGGER_LOW: 80 + case IRQF_TRIGGER_FALLING: 81 + irq_active_low = true; 82 + break; 82 83 default: 83 84 dev_info(hw->dev, 84 85 "mode %lx unsupported, using IRQF_TRIGGER_RISING\n", ··· 91 84 break; 92 85 } 93 86 87 + err = hts221_write_with_mask(hw, HTS221_REG_DRDY_HL_ADDR, 88 + HTS221_REG_DRDY_HL_MASK, irq_active_low); 89 + if (err < 0) 90 + return err; 94 91 err = devm_request_threaded_irq(hw->dev, hw->irq, NULL, 95 92 hts221_trigger_handler_thread, 96 93 irq_type | IRQF_ONESHOT,
+1 -2
drivers/iio/humidity/hts221_core.c
··· 135 135 IIO_CHAN_SOFT_TIMESTAMP(2), 136 136 }; 137 137 138 - static int hts221_write_with_mask(struct hts221_hw *hw, u8 addr, u8 mask, 139 - u8 val) 138 + int hts221_write_with_mask(struct hts221_hw *hw, u8 addr, u8 mask, u8 val) 140 139 { 141 140 u8 data; 142 141 int err;