| From 8b7306ece49f9bbce92c3421ab2276afe0372c68 Mon Sep 17 00:00:00 2001 |
| From: Dmitry Osipenko <digetx@gmail.com> |
| Date: Mon, 24 Jun 2019 00:08:32 +0300 |
| Subject: [PATCH] regulator: core: Expose some of core functions needed by |
| couplers |
| |
| commit d22b85a1b97d12a4940ef9d778f6122546736f78 upstream. |
| |
| Expose some of internal functions that are required for implementation of |
| customized regulator couplers. |
| |
| Signed-off-by: Dmitry Osipenko <digetx@gmail.com> |
| Signed-off-by: Mark Brown <broonie@kernel.org> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c |
| index e7be71938441..ebab6064f028 100644 |
| --- a/drivers/regulator/core.c |
| +++ b/drivers/regulator/core.c |
| @@ -95,7 +95,6 @@ struct regulator_supply_alias { |
| |
| static int _regulator_is_enabled(struct regulator_dev *rdev); |
| static int _regulator_disable(struct regulator *regulator); |
| -static int _regulator_get_voltage(struct regulator_dev *rdev); |
| static int _regulator_get_current_limit(struct regulator_dev *rdev); |
| static unsigned int _regulator_get_mode(struct regulator_dev *rdev); |
| static int _notifier_call_chain(struct regulator_dev *rdev, |
| @@ -104,15 +103,12 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev, |
| int min_uV, int max_uV); |
| static int regulator_balance_voltage(struct regulator_dev *rdev, |
| suspend_state_t state); |
| -static int regulator_set_voltage_rdev(struct regulator_dev *rdev, |
| - int min_uV, int max_uV, |
| - suspend_state_t state); |
| static struct regulator *create_regulator(struct regulator_dev *rdev, |
| struct device *dev, |
| const char *supply_name); |
| static void _regulator_put(struct regulator *regulator); |
| |
| -static const char *rdev_get_name(struct regulator_dev *rdev) |
| +const char *rdev_get_name(struct regulator_dev *rdev) |
| { |
| if (rdev->constraints && rdev->constraints->name) |
| return rdev->constraints->name; |
| @@ -426,8 +422,8 @@ static struct device_node *of_get_regulator(struct device *dev, const char *supp |
| } |
| |
| /* Platform voltage constraint check */ |
| -static int regulator_check_voltage(struct regulator_dev *rdev, |
| - int *min_uV, int *max_uV) |
| +int regulator_check_voltage(struct regulator_dev *rdev, |
| + int *min_uV, int *max_uV) |
| { |
| BUG_ON(*min_uV > *max_uV); |
| |
| @@ -459,9 +455,9 @@ static int regulator_check_states(suspend_state_t state) |
| /* Make sure we select a voltage that suits the needs of all |
| * regulator consumers |
| */ |
| -static int regulator_check_consumers(struct regulator_dev *rdev, |
| - int *min_uV, int *max_uV, |
| - suspend_state_t state) |
| +int regulator_check_consumers(struct regulator_dev *rdev, |
| + int *min_uV, int *max_uV, |
| + suspend_state_t state) |
| { |
| struct regulator *regulator; |
| struct regulator_voltage *voltage; |
| @@ -572,7 +568,7 @@ static ssize_t regulator_uV_show(struct device *dev, |
| ssize_t ret; |
| |
| regulator_lock(rdev); |
| - ret = sprintf(buf, "%d\n", _regulator_get_voltage(rdev)); |
| + ret = sprintf(buf, "%d\n", regulator_get_voltage_rdev(rdev)); |
| regulator_unlock(rdev); |
| |
| return ret; |
| @@ -943,7 +939,7 @@ static int drms_uA_update(struct regulator_dev *rdev) |
| rdev_err(rdev, "failed to set load %d\n", current_uA); |
| } else { |
| /* get output voltage */ |
| - output_uV = _regulator_get_voltage(rdev); |
| + output_uV = regulator_get_voltage_rdev(rdev); |
| if (output_uV <= 0) { |
| rdev_err(rdev, "invalid output voltage found\n"); |
| return -EINVAL; |
| @@ -1056,7 +1052,7 @@ static void print_constraints(struct regulator_dev *rdev) |
| |
| if (!constraints->min_uV || |
| constraints->min_uV != constraints->max_uV) { |
| - ret = _regulator_get_voltage(rdev); |
| + ret = regulator_get_voltage_rdev(rdev); |
| if (ret > 0) |
| count += scnprintf(buf + count, len - count, |
| "at %d mV ", ret / 1000); |
| @@ -1115,7 +1111,7 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, |
| if (rdev->constraints->apply_uV && |
| rdev->constraints->min_uV && rdev->constraints->max_uV) { |
| int target_min, target_max; |
| - int current_uV = _regulator_get_voltage(rdev); |
| + int current_uV = regulator_get_voltage_rdev(rdev); |
| |
| if (current_uV == -ENOTRECOVERABLE) { |
| /* This regulator can't be read and must be initialized */ |
| @@ -1125,7 +1121,7 @@ static int machine_constraints_voltage(struct regulator_dev *rdev, |
| _regulator_do_set_voltage(rdev, |
| rdev->constraints->min_uV, |
| rdev->constraints->max_uV); |
| - current_uV = _regulator_get_voltage(rdev); |
| + current_uV = regulator_get_voltage_rdev(rdev); |
| } |
| |
| if (current_uV < 0) { |
| @@ -3069,7 +3065,7 @@ static int _regulator_call_set_voltage(struct regulator_dev *rdev, |
| struct pre_voltage_change_data data; |
| int ret; |
| |
| - data.old_uV = _regulator_get_voltage(rdev); |
| + data.old_uV = regulator_get_voltage_rdev(rdev); |
| data.min_uV = min_uV; |
| data.max_uV = max_uV; |
| ret = _notifier_call_chain(rdev, REGULATOR_EVENT_PRE_VOLTAGE_CHANGE, |
| @@ -3093,7 +3089,7 @@ static int _regulator_call_set_voltage_sel(struct regulator_dev *rdev, |
| struct pre_voltage_change_data data; |
| int ret; |
| |
| - data.old_uV = _regulator_get_voltage(rdev); |
| + data.old_uV = regulator_get_voltage_rdev(rdev); |
| data.min_uV = uV; |
| data.max_uV = uV; |
| ret = _notifier_call_chain(rdev, REGULATOR_EVENT_PRE_VOLTAGE_CHANGE, |
| @@ -3146,7 +3142,7 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev, |
| unsigned int selector; |
| int old_selector = -1; |
| const struct regulator_ops *ops = rdev->desc->ops; |
| - int old_uV = _regulator_get_voltage(rdev); |
| + int old_uV = regulator_get_voltage_rdev(rdev); |
| |
| trace_regulator_set_voltage(rdev_get_name(rdev), min_uV, max_uV); |
| |
| @@ -3173,7 +3169,7 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev, |
| best_val = ops->list_voltage(rdev, |
| selector); |
| else |
| - best_val = _regulator_get_voltage(rdev); |
| + best_val = regulator_get_voltage_rdev(rdev); |
| } |
| |
| } else if (ops->set_voltage_sel) { |
| @@ -3292,7 +3288,7 @@ static int regulator_set_voltage_unlocked(struct regulator *regulator, |
| * changing the voltage. |
| */ |
| if (!regulator_ops_is_valid(rdev, REGULATOR_CHANGE_VOLTAGE)) { |
| - current_uV = _regulator_get_voltage(rdev); |
| + current_uV = regulator_get_voltage_rdev(rdev); |
| if (min_uV <= current_uV && current_uV <= max_uV) { |
| voltage->min_uV = min_uV; |
| voltage->max_uV = max_uV; |
| @@ -3329,8 +3325,8 @@ static int regulator_set_voltage_unlocked(struct regulator *regulator, |
| return ret; |
| } |
| |
| -static int regulator_set_voltage_rdev(struct regulator_dev *rdev, int min_uV, |
| - int max_uV, suspend_state_t state) |
| +int regulator_set_voltage_rdev(struct regulator_dev *rdev, int min_uV, |
| + int max_uV, suspend_state_t state) |
| { |
| int best_supply_uV = 0; |
| int supply_change_uV = 0; |
| @@ -3358,7 +3354,7 @@ static int regulator_set_voltage_rdev(struct regulator_dev *rdev, int min_uV, |
| |
| best_supply_uV += rdev->desc->min_dropout_uV; |
| |
| - current_supply_uV = _regulator_get_voltage(rdev->supply->rdev); |
| + current_supply_uV = regulator_get_voltage_rdev(rdev->supply->rdev); |
| if (current_supply_uV < 0) { |
| ret = current_supply_uV; |
| goto out; |
| @@ -3409,7 +3405,7 @@ static int regulator_limit_voltage_step(struct regulator_dev *rdev, |
| return 1; |
| |
| if (*current_uV < 0) { |
| - *current_uV = _regulator_get_voltage(rdev); |
| + *current_uV = regulator_get_voltage_rdev(rdev); |
| |
| if (*current_uV < 0) |
| return *current_uV; |
| @@ -3514,7 +3510,7 @@ static int regulator_get_optimal_voltage(struct regulator_dev *rdev, |
| if (!_regulator_is_enabled(c_rdevs[i])) |
| continue; |
| |
| - tmp_act = _regulator_get_voltage(c_rdevs[i]); |
| + tmp_act = regulator_get_voltage_rdev(c_rdevs[i]); |
| if (tmp_act < 0) |
| return tmp_act; |
| |
| @@ -3556,7 +3552,7 @@ static int regulator_get_optimal_voltage(struct regulator_dev *rdev, |
| if (n_coupled > 1 && *current_uV == -1) { |
| |
| if (_regulator_is_enabled(rdev)) { |
| - ret = _regulator_get_voltage(rdev); |
| + ret = regulator_get_voltage_rdev(rdev); |
| if (ret < 0) |
| return ret; |
| |
| @@ -3920,7 +3916,7 @@ int regulator_sync_voltage(struct regulator *regulator) |
| } |
| EXPORT_SYMBOL_GPL(regulator_sync_voltage); |
| |
| -static int _regulator_get_voltage(struct regulator_dev *rdev) |
| +int regulator_get_voltage_rdev(struct regulator_dev *rdev) |
| { |
| int sel, ret; |
| bool bypassed; |
| @@ -3937,7 +3933,7 @@ static int _regulator_get_voltage(struct regulator_dev *rdev) |
| return -EPROBE_DEFER; |
| } |
| |
| - return _regulator_get_voltage(rdev->supply->rdev); |
| + return regulator_get_voltage_rdev(rdev->supply->rdev); |
| } |
| } |
| |
| @@ -3953,7 +3949,7 @@ static int _regulator_get_voltage(struct regulator_dev *rdev) |
| } else if (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1)) { |
| ret = rdev->desc->fixed_uV; |
| } else if (rdev->supply) { |
| - ret = _regulator_get_voltage(rdev->supply->rdev); |
| + ret = regulator_get_voltage_rdev(rdev->supply->rdev); |
| } else { |
| return -EINVAL; |
| } |
| @@ -3978,7 +3974,7 @@ int regulator_get_voltage(struct regulator *regulator) |
| int ret; |
| |
| regulator_lock_dependent(regulator->rdev, &ww_ctx); |
| - ret = _regulator_get_voltage(regulator->rdev); |
| + ret = regulator_get_voltage_rdev(regulator->rdev); |
| regulator_unlock_dependent(regulator->rdev, &ww_ctx); |
| |
| return ret; |
| @@ -5379,7 +5375,7 @@ static void regulator_summary_show_subtree(struct seq_file *s, |
| rdev->use_count, rdev->open_count, rdev->bypass_count, |
| regulator_opmode_to_str(opmode)); |
| |
| - seq_printf(s, "%5dmV ", _regulator_get_voltage(rdev) / 1000); |
| + seq_printf(s, "%5dmV ", regulator_get_voltage_rdev(rdev) / 1000); |
| seq_printf(s, "%5dmA ", |
| _regulator_get_current_limit_unlocked(rdev) / 1000); |
| |
| diff --git a/include/linux/regulator/coupler.h b/include/linux/regulator/coupler.h |
| index 98dd1f74d605..0212d6255e4e 100644 |
| --- a/include/linux/regulator/coupler.h |
| +++ b/include/linux/regulator/coupler.h |
| @@ -52,11 +52,46 @@ struct regulator_coupler { |
| |
| #ifdef CONFIG_REGULATOR |
| int regulator_coupler_register(struct regulator_coupler *coupler); |
| +const char *rdev_get_name(struct regulator_dev *rdev); |
| +int regulator_check_consumers(struct regulator_dev *rdev, |
| + int *min_uV, int *max_uV, |
| + suspend_state_t state); |
| +int regulator_check_voltage(struct regulator_dev *rdev, |
| + int *min_uV, int *max_uV); |
| +int regulator_get_voltage_rdev(struct regulator_dev *rdev); |
| +int regulator_set_voltage_rdev(struct regulator_dev *rdev, |
| + int min_uV, int max_uV, |
| + suspend_state_t state); |
| #else |
| static inline int regulator_coupler_register(struct regulator_coupler *coupler) |
| { |
| return 0; |
| } |
| +static inline const char *rdev_get_name(struct regulator_dev *rdev) |
| +{ |
| + return NULL; |
| +} |
| +static inline int regulator_check_consumers(struct regulator_dev *rdev, |
| + int *min_uV, int *max_uV, |
| + suspend_state_t state) |
| +{ |
| + return -EINVAL; |
| +} |
| +static inline int regulator_check_voltage(struct regulator_dev *rdev, |
| + int *min_uV, int *max_uV) |
| +{ |
| + return -EINVAL; |
| +} |
| +static inline int regulator_get_voltage_rdev(struct regulator_dev *rdev) |
| +{ |
| + return -EINVAL; |
| +} |
| +static inline int regulator_set_voltage_rdev(struct regulator_dev *rdev, |
| + int min_uV, int max_uV, |
| + suspend_state_t state) |
| +{ |
| + return -EINVAL; |
| +} |
| #endif |
| |
| #endif |
| -- |
| 2.7.4 |
| |