Re: [PATCH 1/6] regulator: core: Add checking n_voltages if using list_voltage() to read voltage regulators

2012-08-13 Thread Mark Brown
On Sat, Aug 11, 2012 at 10:22:54AM +0800, Axel Lin wrote:

> We do have such case in drivers/regulator/max1586.c

They should have a read operation implemented.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/6] regulator: core: Add checking n_voltages if using list_voltage() to read voltage regulators

2012-08-13 Thread Mark Brown
On Sat, Aug 11, 2012 at 10:22:54AM +0800, Axel Lin wrote:

 We do have such case in drivers/regulator/max1586.c

They should have a read operation implemented.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/6] regulator: core: Add checking n_voltages if using list_voltage() to read voltage regulators

2012-08-10 Thread Axel Lin
2012/8/10 Mark Brown :
> On Fri, Aug 10, 2012 at 08:27:32PM +0800, Axel Lin wrote:
>> 2012/8/10 Mark Brown :
>
>> > We should be failing to register these regulators in the first place, or
>> > at least complaining extremely loudly about them.
>
>> Oh. My original intention is to prevent using list_voltage() to read
>> voltage regulators for the case "n_voltages > 1" in case of both get_voltage
>> and get_voltage_sel are not implemented.
>
> Yes, I see the intention - what I'm saying is that a regulator like that
> makes no sense in the first place.

We do have such case in drivers/regulator/max1586.c

/*
 * The Maxim 1586 controls V3 and V6 voltages, but offers no way of reading back
 * the set up value.
 */
static struct regulator_ops max1586_v3_ops = {
.set_voltage_sel = max1586_v3_set_voltage_sel,
.list_voltage = regulator_list_voltage_linear,
.map_voltage = regulator_map_voltage_linear,
};

static struct regulator_ops max1586_v6_ops = {
.set_voltage_sel = max1586_v6_set_voltage_sel,
.list_voltage = regulator_list_voltage_table,
};
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/6] regulator: core: Add checking n_voltages if using list_voltage() to read voltage regulators

2012-08-10 Thread Mark Brown
On Fri, Aug 10, 2012 at 08:27:32PM +0800, Axel Lin wrote:
> 2012/8/10 Mark Brown :

> > We should be failing to register these regulators in the first place, or
> > at least complaining extremely loudly about them.

> Oh. My original intention is to prevent using list_voltage() to read
> voltage regulators for the case "n_voltages > 1" in case of both get_voltage
> and get_voltage_sel are not implemented.

Yes, I see the intention - what I'm saying is that a regulator like that
makes no sense in the first place.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/6] regulator: core: Add checking n_voltages if using list_voltage() to read voltage regulators

2012-08-10 Thread Axel Lin
2012/8/10 Mark Brown :
> On Fri, Aug 10, 2012 at 09:32:33AM +0800, Axel Lin wrote:
>> Use list_voltage() to read single voltage regulators should be only applied 
>> to
>> single voltage regulators, thus add checking n_voltages for this case.
>
> We should be failing to register these regulators in the first place, or
> at least complaining extremely loudly about them.

Oh. My original intention is to prevent using list_voltage() to read
voltage regulators for the case "n_voltages > 1" in case of both get_voltage
and get_voltage_sel are not implemented.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/6] regulator: core: Add checking n_voltages if using list_voltage() to read voltage regulators

2012-08-10 Thread Mark Brown
On Fri, Aug 10, 2012 at 09:32:33AM +0800, Axel Lin wrote:
> Use list_voltage() to read single voltage regulators should be only applied to
> single voltage regulators, thus add checking n_voltages for this case.

We should be failing to register these regulators in the first place, or
at least complaining extremely loudly about them.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/6] regulator: core: Add checking n_voltages if using list_voltage() to read voltage regulators

2012-08-10 Thread Mark Brown
On Fri, Aug 10, 2012 at 09:32:33AM +0800, Axel Lin wrote:
 Use list_voltage() to read single voltage regulators should be only applied to
 single voltage regulators, thus add checking n_voltages for this case.

We should be failing to register these regulators in the first place, or
at least complaining extremely loudly about them.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/6] regulator: core: Add checking n_voltages if using list_voltage() to read voltage regulators

2012-08-10 Thread Axel Lin
2012/8/10 Mark Brown broo...@opensource.wolfsonmicro.com:
 On Fri, Aug 10, 2012 at 09:32:33AM +0800, Axel Lin wrote:
 Use list_voltage() to read single voltage regulators should be only applied 
 to
 single voltage regulators, thus add checking n_voltages for this case.

 We should be failing to register these regulators in the first place, or
 at least complaining extremely loudly about them.

Oh. My original intention is to prevent using list_voltage() to read
voltage regulators for the case n_voltages  1 in case of both get_voltage
and get_voltage_sel are not implemented.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/6] regulator: core: Add checking n_voltages if using list_voltage() to read voltage regulators

2012-08-10 Thread Mark Brown
On Fri, Aug 10, 2012 at 08:27:32PM +0800, Axel Lin wrote:
 2012/8/10 Mark Brown broo...@opensource.wolfsonmicro.com:

  We should be failing to register these regulators in the first place, or
  at least complaining extremely loudly about them.

 Oh. My original intention is to prevent using list_voltage() to read
 voltage regulators for the case n_voltages  1 in case of both get_voltage
 and get_voltage_sel are not implemented.

Yes, I see the intention - what I'm saying is that a regulator like that
makes no sense in the first place.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 1/6] regulator: core: Add checking n_voltages if using list_voltage() to read voltage regulators

2012-08-10 Thread Axel Lin
2012/8/10 Mark Brown broo...@opensource.wolfsonmicro.com:
 On Fri, Aug 10, 2012 at 08:27:32PM +0800, Axel Lin wrote:
 2012/8/10 Mark Brown broo...@opensource.wolfsonmicro.com:

  We should be failing to register these regulators in the first place, or
  at least complaining extremely loudly about them.

 Oh. My original intention is to prevent using list_voltage() to read
 voltage regulators for the case n_voltages  1 in case of both get_voltage
 and get_voltage_sel are not implemented.

 Yes, I see the intention - what I'm saying is that a regulator like that
 makes no sense in the first place.

We do have such case in drivers/regulator/max1586.c

/*
 * The Maxim 1586 controls V3 and V6 voltages, but offers no way of reading back
 * the set up value.
 */
static struct regulator_ops max1586_v3_ops = {
.set_voltage_sel = max1586_v3_set_voltage_sel,
.list_voltage = regulator_list_voltage_linear,
.map_voltage = regulator_map_voltage_linear,
};

static struct regulator_ops max1586_v6_ops = {
.set_voltage_sel = max1586_v6_set_voltage_sel,
.list_voltage = regulator_list_voltage_table,
};
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/6] regulator: core: Add checking n_voltages if using list_voltage() to read voltage regulators

2012-08-09 Thread Axel Lin
Use list_voltage() to read single voltage regulators should be only applied to
single voltage regulators, thus add checking n_voltages for this case.

Signed-off-by: Axel Lin 
---
 drivers/regulator/core.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 0fffeae..5469f9f 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2395,7 +2395,8 @@ static int _regulator_get_voltage(struct regulator_dev 
*rdev)
ret = rdev->desc->ops->list_voltage(rdev, sel);
} else if (rdev->desc->ops->get_voltage) {
ret = rdev->desc->ops->get_voltage(rdev);
-   } else if (rdev->desc->ops->list_voltage) {
+   } else if (rdev->desc->ops->list_voltage &&
+  (rdev->desc->n_voltages == 1)) {
ret = rdev->desc->ops->list_voltage(rdev, 0);
} else {
return -EINVAL;
-- 
1.7.9.5



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/6] regulator: core: Add checking n_voltages if using list_voltage() to read voltage regulators

2012-08-09 Thread Axel Lin
Use list_voltage() to read single voltage regulators should be only applied to
single voltage regulators, thus add checking n_voltages for this case.

Signed-off-by: Axel Lin axel@gmail.com
---
 drivers/regulator/core.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 0fffeae..5469f9f 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2395,7 +2395,8 @@ static int _regulator_get_voltage(struct regulator_dev 
*rdev)
ret = rdev-desc-ops-list_voltage(rdev, sel);
} else if (rdev-desc-ops-get_voltage) {
ret = rdev-desc-ops-get_voltage(rdev);
-   } else if (rdev-desc-ops-list_voltage) {
+   } else if (rdev-desc-ops-list_voltage 
+  (rdev-desc-n_voltages == 1)) {
ret = rdev-desc-ops-list_voltage(rdev, 0);
} else {
return -EINVAL;
-- 
1.7.9.5



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/