Re: [PATCH v2 3/8] regulator: core: Expose some of core functions

2019-06-18 Thread Dmitry Osipenko
17.06.2019 18:32, Mark Brown пишет:
> On Tue, Jun 04, 2019 at 02:58:59AM +0300, Dmitry Osipenko wrote:
>> Expose some of internal functions that are required for implementation of
>> customized regulator couplers.
> 
>>  include/linux/regulator/driver.h | 11 ++
> 
> I'm a bit dubious about exposing any of this but there's no way we
> should be exposing it directly to random drivers, this needs a new
> header so it's more obvious that normal code shouldn't be using these
> interfaces.
> 

That's a good call! Will address it in the v3.


Re: [PATCH v2 3/8] regulator: core: Expose some of core functions

2019-06-17 Thread Mark Brown
On Tue, Jun 04, 2019 at 02:58:59AM +0300, Dmitry Osipenko wrote:
> Expose some of internal functions that are required for implementation of
> customized regulator couplers.

>  include/linux/regulator/driver.h | 11 ++

I'm a bit dubious about exposing any of this but there's no way we
should be exposing it directly to random drivers, this needs a new
header so it's more obvious that normal code shouldn't be using these
interfaces.


signature.asc
Description: PGP signature


[PATCH v2 3/8] regulator: core: Expose some of core functions

2019-06-03 Thread Dmitry Osipenko
Expose some of internal functions that are required for implementation of
customized regulator couplers.

Signed-off-by: Dmitry Osipenko 
---
 drivers/regulator/core.c | 58 +++-
 include/linux/regulator/driver.h | 11 ++
 2 files changed, 38 insertions(+), 31 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index c148dd7d306e..5a5b86d3edfb 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -94,7 +94,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,
@@ -103,15 +102,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;
@@ -425,8 +421,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);
 
@@ -458,9 +454,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;
@@ -571,7 +567,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;
@@ -942,7 +938,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;
@@ -1055,7 +1051,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);
@@ -1114,7 +1110,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 
*/
@@ -1124,7 +1120,7 @@ static int machine_constraints_voltage(struct 
regulator_dev *rdev,
_regulator_do_set_voltage(rdev,
  rdev->constraints->min_uV,
  rdev->constraints->max_uV);
-