@@ -320,7 +320,9 @@ static void init_rdev_errors(struct regulator_irq *h)
320
320
* IRQF_ONESHOT when requesting the (threaded) irq.
321
321
* @common_errs: Errors which can be flagged by this IRQ for all rdevs.
322
322
* When IRQ is re-enabled these errors will be cleared
323
- * from all associated regulators
323
+ * from all associated regulators. Use this instead of the
324
+ * per_rdev_errs if you use
325
+ * regulator_irq_map_event_simple() for event mapping.
324
326
* @per_rdev_errs: Optional error flag array describing errors specific
325
327
* for only some of the regulators. These errors will be
326
328
* or'ed with common errors. If this is given the array
@@ -395,3 +397,40 @@ void regulator_irq_helper_cancel(void **handle)
395
397
}
396
398
}
397
399
EXPORT_SYMBOL_GPL (regulator_irq_helper_cancel );
400
+
401
+ /**
402
+ * regulator_irq_map_event_simple - regulator IRQ notification for trivial IRQs
403
+ *
404
+ * @irq: Number of IRQ that occurred
405
+ * @rid: Information about the event IRQ indicates
406
+ * @dev_mask: mask indicating the regulator originating the IRQ
407
+ *
408
+ * Regulators whose IRQ has single, well defined purpose (always indicate
409
+ * exactly one event, and are relevant to exactly one regulator device) can
410
+ * use this function as their map_event callbac for their regulator IRQ
411
+ * notification helperk. Exactly one rdev and exactly one error (in
412
+ * "common_errs"-field) can be given at IRQ helper registration for
413
+ * regulator_irq_map_event_simple() to be viable.
414
+ */
415
+ int regulator_irq_map_event_simple (int irq , struct regulator_irq_data * rid ,
416
+ unsigned long * dev_mask )
417
+ {
418
+ int err = rid -> states [0 ].possible_errs ;
419
+
420
+ * dev_mask = 1 ;
421
+ /*
422
+ * This helper should only be used in a situation where the IRQ
423
+ * can indicate only one type of problem for one specific rdev.
424
+ * Something fishy is going on if we are having multiple rdevs or ERROR
425
+ * flags here.
426
+ */
427
+ if (WARN_ON (rid -> num_states != 1 || hweight32 (err ) != 1 ))
428
+ return 0 ;
429
+
430
+ rid -> states [0 ].errors = err ;
431
+ rid -> states [0 ].notifs = regulator_err2notif (err );
432
+
433
+ return 0 ;
434
+ }
435
+ EXPORT_SYMBOL_GPL (regulator_irq_map_event_simple );
436
+
0 commit comments