* [PATCH 1/2] regulator: core: provide fixed voltage in desc for single voltage rail
@ 2013-09-10 10:15 Laxman Dewangan
2013-09-10 10:15 ` [PATCH 2/2] regulator: fixed: get rid of {get|list}_voltage() Laxman Dewangan
2013-09-10 17:20 ` [PATCH 1/2] regulator: core: provide fixed voltage in desc for single voltage rail Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Laxman Dewangan @ 2013-09-10 10:15 UTC (permalink / raw)
To: broonie; +Cc: lgirdwood, linux-kernel, Laxman Dewangan
If given rail has the single voltage (n_voltages = 1) then provide the
rail voltage through regulator descriptor so that core can use this
value for finding voltage.
This will avoid the implementation of the callback for get_voltage() or
list_voltage() callback on regulator driver.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
drivers/regulator/core.c | 5 ++++-
include/linux/regulator/driver.h | 2 ++
2 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index a01b8b3..abc899e 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2489,6 +2489,8 @@ static int _regulator_get_voltage(struct regulator_dev *rdev)
ret = rdev->desc->ops->get_voltage(rdev);
} else if (rdev->desc->ops->list_voltage) {
ret = rdev->desc->ops->list_voltage(rdev, 0);
+ } else if (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1)) {
+ ret = rdev->desc->fixed_uV;
} else {
return -EINVAL;
}
@@ -3170,7 +3172,8 @@ static int add_regulator_attributes(struct regulator_dev *rdev)
/* some attributes need specific methods to be displayed */
if ((ops->get_voltage && ops->get_voltage(rdev) >= 0) ||
(ops->get_voltage_sel && ops->get_voltage_sel(rdev) >= 0) ||
- (ops->list_voltage && ops->list_voltage(rdev, 0) >= 0)) {
+ (ops->list_voltage && ops->list_voltage(rdev, 0) >= 0) ||
+ (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1))) {
status = device_create_file(dev, &dev_attr_microvolts);
if (status < 0)
return status;
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 67e13aa..9e8241a 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -207,6 +207,7 @@ enum regulator_type {
* @min_uV: Voltage given by the lowest selector (if linear mapping)
* @uV_step: Voltage increase with each selector (if linear mapping)
* @linear_min_sel: Minimal selector for starting linear mapping
+ * @fixed_uV: Fixed voltage of rails.
* @ramp_delay: Time to settle down after voltage change (unit: uV/us)
* @volt_table: Voltage mapping table (if table based mapping)
*
@@ -239,6 +240,7 @@ struct regulator_desc {
unsigned int min_uV;
unsigned int uV_step;
unsigned int linear_min_sel;
+ int fixed_uV;
unsigned int ramp_delay;
const struct regulator_linear_range *linear_ranges;
--
1.7.1.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] regulator: fixed: get rid of {get|list}_voltage()
2013-09-10 10:15 [PATCH 1/2] regulator: core: provide fixed voltage in desc for single voltage rail Laxman Dewangan
@ 2013-09-10 10:15 ` Laxman Dewangan
2013-09-10 17:20 ` [PATCH 1/2] regulator: core: provide fixed voltage in desc for single voltage rail Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Laxman Dewangan @ 2013-09-10 10:15 UTC (permalink / raw)
To: broonie; +Cc: lgirdwood, linux-kernel, Laxman Dewangan
Provide the rail supply voltage through descriptor to the
core and remove the callbacks which implement the get_voltage
and list_voltage.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
drivers/regulator/fixed.c | 28 ++--------------------------
1 files changed, 2 insertions(+), 26 deletions(-)
diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c
index 7610920..de811f3 100644
--- a/drivers/regulator/fixed.c
+++ b/drivers/regulator/fixed.c
@@ -34,7 +34,6 @@
struct fixed_voltage_data {
struct regulator_desc desc;
struct regulator_dev *dev;
- int microvolts;
};
@@ -108,30 +107,7 @@ of_get_fixed_voltage_config(struct device *dev)
return config;
}
-static int fixed_voltage_get_voltage(struct regulator_dev *dev)
-{
- struct fixed_voltage_data *data = rdev_get_drvdata(dev);
-
- if (data->microvolts)
- return data->microvolts;
- else
- return -EINVAL;
-}
-
-static int fixed_voltage_list_voltage(struct regulator_dev *dev,
- unsigned selector)
-{
- struct fixed_voltage_data *data = rdev_get_drvdata(dev);
-
- if (selector != 0)
- return -EINVAL;
-
- return data->microvolts;
-}
-
static struct regulator_ops fixed_voltage_ops = {
- .get_voltage = fixed_voltage_get_voltage,
- .list_voltage = fixed_voltage_list_voltage,
};
static int reg_fixed_voltage_probe(struct platform_device *pdev)
@@ -186,7 +162,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
if (config->microvolts)
drvdata->desc.n_voltages = 1;
- drvdata->microvolts = config->microvolts;
+ drvdata->desc.fixed_uV = config->microvolts;
if (config->gpio >= 0)
cfg.ena_gpio = config->gpio;
@@ -222,7 +198,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, drvdata);
dev_dbg(&pdev->dev, "%s supplying %duV\n", drvdata->desc.name,
- drvdata->microvolts);
+ drvdata->desc.fixed_uV);
return 0;
--
1.7.1.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] regulator: core: provide fixed voltage in desc for single voltage rail
2013-09-10 10:15 [PATCH 1/2] regulator: core: provide fixed voltage in desc for single voltage rail Laxman Dewangan
2013-09-10 10:15 ` [PATCH 2/2] regulator: fixed: get rid of {get|list}_voltage() Laxman Dewangan
@ 2013-09-10 17:20 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2013-09-10 17:20 UTC (permalink / raw)
To: Laxman Dewangan; +Cc: lgirdwood, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 260 bytes --]
On Tue, Sep 10, 2013 at 03:45:05PM +0530, Laxman Dewangan wrote:
> If given rail has the single voltage (n_voltages = 1) then provide the
> rail voltage through regulator descriptor so that core can use this
> value for finding voltage.
Applied both, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-09-10 17:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-10 10:15 [PATCH 1/2] regulator: core: provide fixed voltage in desc for single voltage rail Laxman Dewangan
2013-09-10 10:15 ` [PATCH 2/2] regulator: fixed: get rid of {get|list}_voltage() Laxman Dewangan
2013-09-10 17:20 ` [PATCH 1/2] regulator: core: provide fixed voltage in desc for single voltage rail Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®