@@ -83,6 +83,7 @@ struct regulator_supply_alias {
83
83
84
84
static int _regulator_is_enabled (struct regulator_dev * rdev );
85
85
static int _regulator_disable (struct regulator * regulator );
86
+ static int _regulator_get_error_flags (struct regulator_dev * rdev , unsigned int * flags );
86
87
static int _regulator_get_current_limit (struct regulator_dev * rdev );
87
88
static unsigned int _regulator_get_mode (struct regulator_dev * rdev );
88
89
static int _notifier_call_chain (struct regulator_dev * rdev ,
@@ -911,6 +912,30 @@ static ssize_t bypass_show(struct device *dev,
911
912
}
912
913
static DEVICE_ATTR_RO (bypass );
913
914
915
+ #define REGULATOR_ERROR_ATTR (name , bit ) \
916
+ static ssize_t name##_show(struct device *dev, struct device_attribute *attr, \
917
+ char *buf) \
918
+ { \
919
+ int ret; \
920
+ unsigned int flags; \
921
+ struct regulator_dev *rdev = dev_get_drvdata(dev); \
922
+ ret = _regulator_get_error_flags(rdev, &flags); \
923
+ if (ret) \
924
+ return ret; \
925
+ return sysfs_emit(buf, "%d\n", !!(flags & (bit))); \
926
+ } \
927
+ static DEVICE_ATTR_RO(name)
928
+
929
+ REGULATOR_ERROR_ATTR (under_voltage , REGULATOR_ERROR_UNDER_VOLTAGE );
930
+ REGULATOR_ERROR_ATTR (over_current , REGULATOR_ERROR_OVER_CURRENT );
931
+ REGULATOR_ERROR_ATTR (regulation_out , REGULATOR_ERROR_REGULATION_OUT );
932
+ REGULATOR_ERROR_ATTR (fail , REGULATOR_ERROR_FAIL );
933
+ REGULATOR_ERROR_ATTR (over_temp , REGULATOR_ERROR_OVER_TEMP );
934
+ REGULATOR_ERROR_ATTR (under_voltage_warn , REGULATOR_ERROR_UNDER_VOLTAGE_WARN );
935
+ REGULATOR_ERROR_ATTR (over_current_warn , REGULATOR_ERROR_OVER_CURRENT_WARN );
936
+ REGULATOR_ERROR_ATTR (over_voltage_warn , REGULATOR_ERROR_OVER_VOLTAGE_WARN );
937
+ REGULATOR_ERROR_ATTR (over_temp_warn , REGULATOR_ERROR_OVER_TEMP_WARN );
938
+
914
939
/* Calculate the new optimum regulator operating mode based on the new total
915
940
* consumer load. All locks held by caller
916
941
*/
@@ -4984,6 +5009,15 @@ static struct attribute *regulator_dev_attrs[] = {
4984
5009
& dev_attr_max_microvolts .attr ,
4985
5010
& dev_attr_min_microamps .attr ,
4986
5011
& dev_attr_max_microamps .attr ,
5012
+ & dev_attr_under_voltage .attr ,
5013
+ & dev_attr_over_current .attr ,
5014
+ & dev_attr_regulation_out .attr ,
5015
+ & dev_attr_fail .attr ,
5016
+ & dev_attr_over_temp .attr ,
5017
+ & dev_attr_under_voltage_warn .attr ,
5018
+ & dev_attr_over_current_warn .attr ,
5019
+ & dev_attr_over_voltage_warn .attr ,
5020
+ & dev_attr_over_temp_warn .attr ,
4987
5021
& dev_attr_suspend_standby_state .attr ,
4988
5022
& dev_attr_suspend_mem_state .attr ,
4989
5023
& dev_attr_suspend_disk_state .attr ,
@@ -5039,6 +5073,17 @@ static umode_t regulator_attr_is_visible(struct kobject *kobj,
5039
5073
if (attr == & dev_attr_bypass .attr )
5040
5074
return ops -> get_bypass ? mode : 0 ;
5041
5075
5076
+ if (attr == & dev_attr_under_voltage .attr ||
5077
+ attr == & dev_attr_over_current .attr ||
5078
+ attr == & dev_attr_regulation_out .attr ||
5079
+ attr == & dev_attr_fail .attr ||
5080
+ attr == & dev_attr_over_temp .attr ||
5081
+ attr == & dev_attr_under_voltage_warn .attr ||
5082
+ attr == & dev_attr_over_current_warn .attr ||
5083
+ attr == & dev_attr_over_voltage_warn .attr ||
5084
+ attr == & dev_attr_over_temp_warn .attr )
5085
+ return ops -> get_error_flags ? mode : 0 ;
5086
+
5042
5087
/* constraints need specific supporting methods */
5043
5088
if (attr == & dev_attr_min_microvolts .attr ||
5044
5089
attr == & dev_attr_max_microvolts .attr )
0 commit comments