Skip to content

Commit

Permalink
hwmon: (sht15) Properly handle the case CONFIG_REGULATOR=n
Browse files Browse the repository at this point in the history
When CONFIG_REGULATOR isn't set, regulator_get_voltage() returns 0.
Properly handle this case by not trusting the value.

Reported-by: Jerome Oufella <jerome.oufella@savoirfairelinux.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Jonathan Cameron <jic23@cam.ac.uk>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: stable@kernel.org
  • Loading branch information
Jean Delvare committed Apr 14, 2010
1 parent 328a2c2 commit c7a78d2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/hwmon/sht15.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,12 @@ static int __devinit sht15_probe(struct platform_device *pdev)
/* If a regulator is available, query what the supply voltage actually is!*/
data->reg = regulator_get(data->dev, "vcc");
if (!IS_ERR(data->reg)) {
data->supply_uV = regulator_get_voltage(data->reg);
int voltage;

voltage = regulator_get_voltage(data->reg);
if (voltage)
data->supply_uV = voltage;

regulator_enable(data->reg);
/* setup a notifier block to update this if another device
* causes the voltage to change */
Expand Down

0 comments on commit c7a78d2

Please sign in to comment.