Commit c7a78d2c2e2537fd24903e966f34aae50319d587

Authored by Jean Delvare
1 parent 328a2c22ab

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

Showing 1 changed file with 6 additions and 1 deletions Side-by-side Diff

drivers/hwmon/sht15.c
... ... @@ -542,7 +542,12 @@
542 542 /* If a regulator is available, query what the supply voltage actually is!*/
543 543 data->reg = regulator_get(data->dev, "vcc");
544 544 if (!IS_ERR(data->reg)) {
545   - data->supply_uV = regulator_get_voltage(data->reg);
  545 + int voltage;
  546 +
  547 + voltage = regulator_get_voltage(data->reg);
  548 + if (voltage)
  549 + data->supply_uV = voltage;
  550 +
546 551 regulator_enable(data->reg);
547 552 /* setup a notifier block to update this if another device
548 553 * causes the voltage to change */