Input: max8997_haptic - add error handling for regulator and pwm
authorSachin Kamat <sachin.kamat@linaro.org>
Sun, 8 Jun 2014 06:10:25 +0000 (23:10 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sun, 8 Jun 2014 06:20:24 +0000 (23:20 -0700)
Let's start checking return value of regulator_enable and pwm_enable to
avoid errors. Fixes the following warning:

drivers/input/misc/max8997_haptic.c:185:19: warning: ignoring return value of ‘regulator_enable’, declared with attribute warn_unused_result [-Wunused-result]

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/misc/max8997_haptic.c

index 1fea5484941f8b6548d9d62ac7b39bd186429bc8..a363ebbd9cc08590c44cea54a739099d638448cd 100644 (file)
@@ -181,11 +181,21 @@ static void max8997_haptic_enable(struct max8997_haptic *chip)
        }
 
        if (!chip->enabled) {
-               chip->enabled = true;
-               regulator_enable(chip->regulator);
+               error = regulator_enable(chip->regulator);
+               if (error) {
+                       dev_err(chip->dev, "Failed to enable regulator\n");
+                       goto out;
+               }
                max8997_haptic_configure(chip);
-               if (chip->mode == MAX8997_EXTERNAL_MODE)
-                       pwm_enable(chip->pwm);
+               if (chip->mode == MAX8997_EXTERNAL_MODE) {
+                       error = pwm_enable(chip->pwm);
+                       if (error) {
+                               dev_err(chip->dev, "Failed to enable PWM\n");
+                               regulator_disable(chip->regulator);
+                               goto out;
+                       }
+               }
+               chip->enabled = true;
        }
 
 out: