diff options
author | Jean Delvare <khali@linux-fr.org> | 2010-04-14 16:14:08 +0200 |
---|---|---|
committer | Jean Delvare <khali@linux-fr.org> | 2010-04-14 16:14:08 +0200 |
commit | c7a78d2c2e2537fd24903e966f34aae50319d587 (patch) | |
tree | b53c5677e1528b8e5659c92a94f1e4fb0fca8923 /drivers/hwmon/sht15.c | |
parent | 328a2c22abd08911e37fa66f1358f829cecd72e9 (diff) | |
download | op-kernel-dev-c7a78d2c2e2537fd24903e966f34aae50319d587.zip op-kernel-dev-c7a78d2c2e2537fd24903e966f34aae50319d587.tar.gz |
hwmon: (sht15) Properly handle the case CONFIG_REGULATOR=n
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
Diffstat (limited to 'drivers/hwmon/sht15.c')
-rw-r--r-- | drivers/hwmon/sht15.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c index 9a15b1a..a610e78 100644 --- a/drivers/hwmon/sht15.c +++ b/drivers/hwmon/sht15.c @@ -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 */ |