@@ -645,6 +645,40 @@ struct regulator_dev {
645
645
spinlock_t err_lock ;
646
646
};
647
647
648
+ /*
649
+ * Convert error flags to corresponding notifications.
650
+ *
651
+ * Can be used by drivers which use the notification helpers to
652
+ * find out correct notification flags based on the error flags. Drivers
653
+ * can avoid storing both supported notification and error flags which
654
+ * may save few bytes.
655
+ */
656
+ static inline int regulator_err2notif (int err )
657
+ {
658
+ switch (err ) {
659
+ case REGULATOR_ERROR_UNDER_VOLTAGE :
660
+ return REGULATOR_EVENT_UNDER_VOLTAGE ;
661
+ case REGULATOR_ERROR_OVER_CURRENT :
662
+ return REGULATOR_EVENT_OVER_CURRENT ;
663
+ case REGULATOR_ERROR_REGULATION_OUT :
664
+ return REGULATOR_EVENT_REGULATION_OUT ;
665
+ case REGULATOR_ERROR_FAIL :
666
+ return REGULATOR_EVENT_FAIL ;
667
+ case REGULATOR_ERROR_OVER_TEMP :
668
+ return REGULATOR_EVENT_OVER_TEMP ;
669
+ case REGULATOR_ERROR_UNDER_VOLTAGE_WARN :
670
+ return REGULATOR_EVENT_UNDER_VOLTAGE_WARN ;
671
+ case REGULATOR_ERROR_OVER_CURRENT_WARN :
672
+ return REGULATOR_EVENT_OVER_CURRENT_WARN ;
673
+ case REGULATOR_ERROR_OVER_VOLTAGE_WARN :
674
+ return REGULATOR_EVENT_OVER_VOLTAGE_WARN ;
675
+ case REGULATOR_ERROR_OVER_TEMP_WARN :
676
+ return REGULATOR_EVENT_OVER_TEMP_WARN ;
677
+ }
678
+ return 0 ;
679
+ }
680
+
681
+
648
682
struct regulator_dev *
649
683
regulator_register (const struct regulator_desc * regulator_desc ,
650
684
const struct regulator_config * config );
0 commit comments