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: adxl372: factor out buffer and trigger setup

Extract the triggered buffer, trigger allocation, and IRQ request
logic from adxl372_probe() into a dedicated adxl372_buffer_setup()
helper. This reduces the probe function complexity and prepares for
conditionally disabling buffer support on device variants with
known FIFO issues.

No functional change intended.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Antoniu Miclaus and committed by
Jonathan Cameron
39df6dbf 2643500b

+50 -43
+50 -43
drivers/iio/accel/adxl372.c
··· 1190 1190 } 1191 1191 EXPORT_SYMBOL_NS_GPL(adxl372_readable_noinc_reg, "IIO_ADXL372"); 1192 1192 1193 + static int adxl372_buffer_setup(struct iio_dev *indio_dev) 1194 + { 1195 + struct adxl372_state *st = iio_priv(indio_dev); 1196 + struct device *dev = st->dev; 1197 + int ret; 1198 + 1199 + ret = devm_iio_triggered_buffer_setup_ext(dev, indio_dev, NULL, 1200 + adxl372_trigger_handler, 1201 + IIO_BUFFER_DIRECTION_IN, 1202 + &adxl372_buffer_ops, 1203 + adxl372_fifo_attributes); 1204 + if (ret) 1205 + return ret; 1206 + 1207 + if (!st->irq) 1208 + return 0; 1209 + 1210 + st->dready_trig = devm_iio_trigger_alloc(dev, "%s-dev%d", 1211 + indio_dev->name, 1212 + iio_device_id(indio_dev)); 1213 + if (!st->dready_trig) 1214 + return -ENOMEM; 1215 + 1216 + st->peak_datardy_trig = devm_iio_trigger_alloc(dev, "%s-dev%d-peak", 1217 + indio_dev->name, 1218 + iio_device_id(indio_dev)); 1219 + if (!st->peak_datardy_trig) 1220 + return -ENOMEM; 1221 + 1222 + st->dready_trig->ops = &adxl372_trigger_ops; 1223 + st->peak_datardy_trig->ops = &adxl372_peak_data_trigger_ops; 1224 + iio_trigger_set_drvdata(st->dready_trig, indio_dev); 1225 + iio_trigger_set_drvdata(st->peak_datardy_trig, indio_dev); 1226 + ret = devm_iio_trigger_register(dev, st->dready_trig); 1227 + if (ret) 1228 + return ret; 1229 + 1230 + ret = devm_iio_trigger_register(dev, st->peak_datardy_trig); 1231 + if (ret) 1232 + return ret; 1233 + 1234 + indio_dev->trig = iio_trigger_get(st->dready_trig); 1235 + 1236 + return devm_request_irq(dev, st->irq, 1237 + iio_trigger_generic_data_rdy_poll, 1238 + IRQF_TRIGGER_RISING | IRQF_NO_THREAD, 1239 + indio_dev->name, st->dready_trig); 1240 + } 1241 + 1193 1242 int adxl372_probe(struct device *dev, struct regmap *regmap, 1194 1243 int irq, const struct adxl372_chip_info *chip_info) 1195 1244 { ··· 1273 1224 return ret; 1274 1225 } 1275 1226 1276 - ret = devm_iio_triggered_buffer_setup_ext(dev, 1277 - indio_dev, NULL, 1278 - adxl372_trigger_handler, 1279 - IIO_BUFFER_DIRECTION_IN, 1280 - &adxl372_buffer_ops, 1281 - adxl372_fifo_attributes); 1227 + ret = adxl372_buffer_setup(indio_dev); 1282 1228 if (ret < 0) 1283 1229 return ret; 1284 - 1285 - if (st->irq) { 1286 - st->dready_trig = devm_iio_trigger_alloc(dev, 1287 - "%s-dev%d", 1288 - indio_dev->name, 1289 - iio_device_id(indio_dev)); 1290 - if (st->dready_trig == NULL) 1291 - return -ENOMEM; 1292 - 1293 - st->peak_datardy_trig = devm_iio_trigger_alloc(dev, 1294 - "%s-dev%d-peak", 1295 - indio_dev->name, 1296 - iio_device_id(indio_dev)); 1297 - if (!st->peak_datardy_trig) 1298 - return -ENOMEM; 1299 - 1300 - st->dready_trig->ops = &adxl372_trigger_ops; 1301 - st->peak_datardy_trig->ops = &adxl372_peak_data_trigger_ops; 1302 - iio_trigger_set_drvdata(st->dready_trig, indio_dev); 1303 - iio_trigger_set_drvdata(st->peak_datardy_trig, indio_dev); 1304 - ret = devm_iio_trigger_register(dev, st->dready_trig); 1305 - if (ret < 0) 1306 - return ret; 1307 - 1308 - ret = devm_iio_trigger_register(dev, st->peak_datardy_trig); 1309 - if (ret < 0) 1310 - return ret; 1311 - 1312 - indio_dev->trig = iio_trigger_get(st->dready_trig); 1313 - 1314 - ret = devm_request_irq(dev, st->irq, 1315 - iio_trigger_generic_data_rdy_poll, 1316 - IRQF_TRIGGER_RISING | IRQF_NO_THREAD, 1317 - indio_dev->name, st->dready_trig); 1318 - if (ret < 0) 1319 - return ret; 1320 - } 1321 1230 1322 1231 return devm_iio_device_register(dev, indio_dev); 1323 1232 }