Commit be721979 authored by Mark Brown's avatar Mark Brown Committed by Samuel Ortiz

regulator: Provide mode to status conversion function

This is useful for implementing get_status() in terms of get_mode().
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 0c73b992
...@@ -1864,6 +1864,30 @@ int regulator_notifier_call_chain(struct regulator_dev *rdev, ...@@ -1864,6 +1864,30 @@ int regulator_notifier_call_chain(struct regulator_dev *rdev,
} }
EXPORT_SYMBOL_GPL(regulator_notifier_call_chain); EXPORT_SYMBOL_GPL(regulator_notifier_call_chain);
/**
* regulator_mode_to_status - convert a regulator mode into a status
*
* @mode: Mode to convert
*
* Convert a regulator mode into a status.
*/
int regulator_mode_to_status(unsigned int mode)
{
switch (mode) {
case REGULATOR_MODE_FAST:
return REGULATOR_STATUS_FAST;
case REGULATOR_MODE_NORMAL:
return REGULATOR_STATUS_NORMAL;
case REGULATOR_MODE_IDLE:
return REGULATOR_STATUS_IDLE;
case REGULATOR_STATUS_STANDBY:
return REGULATOR_STATUS_STANDBY;
default:
return 0;
}
}
EXPORT_SYMBOL_GPL(regulator_mode_to_status);
/* /*
* To avoid cluttering sysfs (and memory) with useless state, only * To avoid cluttering sysfs (and memory) with useless state, only
* create attributes that can be meaningfully displayed. * create attributes that can be meaningfully displayed.
......
...@@ -193,6 +193,8 @@ void *rdev_get_drvdata(struct regulator_dev *rdev); ...@@ -193,6 +193,8 @@ void *rdev_get_drvdata(struct regulator_dev *rdev);
struct device *rdev_get_dev(struct regulator_dev *rdev); struct device *rdev_get_dev(struct regulator_dev *rdev);
int rdev_get_id(struct regulator_dev *rdev); int rdev_get_id(struct regulator_dev *rdev);
int regulator_mode_to_status(unsigned int);
void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data); void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment