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

Configure Feed

Select the types of activity you want to include in your feed.

iio: accel: adxl345: simplify interrupt mapping

Refactor the sensor interrupt mapping by utilizing regmap_assign_bits(),
which accepts a boolean value directly. Introduce a helper function to
streamline the identification of the configured interrupt line pin. Also,
use identifiers from units.h to represent the full 8-bit register when
setting bits.

This is a purely refactoring change and does not affect functionality.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20250702230315.19297-2-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Lothar Rubusch and committed by
Jonathan Cameron
7a7242d8 0755fd55

+20 -14
+20 -14
drivers/iio/accel/adxl345_core.c
··· 1088 1088 .hwfifo_set_watermark = adxl345_set_watermark, 1089 1089 }; 1090 1090 1091 + static int adxl345_get_int_line(struct device *dev, int *irq) 1092 + { 1093 + *irq = fwnode_irq_get_byname(dev_fwnode(dev), "INT1"); 1094 + if (*irq > 0) 1095 + return ADXL345_INT1; 1096 + 1097 + *irq = fwnode_irq_get_byname(dev_fwnode(dev), "INT2"); 1098 + if (*irq > 0) 1099 + return ADXL345_INT2; 1100 + 1101 + return ADXL345_INT_NONE; 1102 + } 1103 + 1091 1104 /** 1092 1105 * adxl345_core_probe() - Probe and setup for the accelerometer. 1093 1106 * @dev: Driver model representation of the device ··· 1216 1203 if (ret) 1217 1204 return ret; 1218 1205 1219 - irq = fwnode_irq_get_byname(dev_fwnode(dev), "INT1"); 1220 - if (irq < 0) { 1221 - intio = ADXL345_INT2; 1222 - irq = fwnode_irq_get_byname(dev_fwnode(dev), "INT2"); 1223 - if (irq < 0) 1224 - intio = ADXL345_INT_NONE; 1225 - } 1226 - 1206 + intio = adxl345_get_int_line(dev, &irq); 1227 1207 if (intio != ADXL345_INT_NONE) { 1228 1208 /* 1229 - * Any bits set to 0 in the INT map register send their respective 1230 - * interrupts to the INT1 pin, whereas bits set to 1 send their respective 1231 - * interrupts to the INT2 pin. The intio shall convert this accordingly. 1209 + * In the INT map register, bits set to 0 route their 1210 + * corresponding interrupts to the INT1 pin, while bits set to 1 1211 + * route them to the INT2 pin. The intio should handle this 1212 + * mapping accordingly. 1232 1213 */ 1233 - regval = intio ? 0xff : 0; 1234 - 1235 - ret = regmap_write(st->regmap, ADXL345_REG_INT_MAP, regval); 1214 + ret = regmap_assign_bits(st->regmap, ADXL345_REG_INT_MAP, 1215 + U8_MAX, intio); 1236 1216 if (ret) 1237 1217 return ret; 1238 1218