regulator: Don't create voltage sysfs entries if we can't read voltage
authorMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 2 Nov 2011 11:39:09 +0000 (11:39 +0000)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Wed, 23 Nov 2011 14:03:42 +0000 (14:03 +0000)
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/regulator/core.c

index 669d0216022195e36bcb8f59b25cf14de1dff6c9..679f92ec9a454fd8403927b6ccadd73b53c80d89 100644 (file)
@@ -2503,7 +2503,8 @@ static int add_regulator_attributes(struct regulator_dev *rdev)
        int                     status = 0;
 
        /* some attributes need specific methods to be displayed */
-       if (ops->get_voltage || ops->get_voltage_sel) {
+       if ((ops->get_voltage && ops->get_voltage(rdev) >= 0) ||
+           (ops->get_voltage_sel && ops->get_voltage_sel(rdev) >= 0)) {
                status = device_create_file(dev, &dev_attr_microvolts);
                if (status < 0)
                        return status;