Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+6 -1
+6 -1
drivers/hwmon/sht15.c
··· 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 */