]> git.karo-electronics.de Git - linux-beck.git/commitdiff
Staging: iio: Place driver in sleep mode on error
authorCristina Opriceana <cristina.opriceana@gmail.com>
Sun, 22 Mar 2015 18:42:42 +0000 (20:42 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 23 Mar 2015 21:20:58 +0000 (22:20 +0100)
Put device in sleep mode if an error is encountered after
initialization in order to avoid wasting power.

Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/iio/magnetometer/hmc5843_core.c

index 0074af2750a5248a6b85fae522c1b940e9bb17dc..6f6e96d71462d6c9651fc284fe8615a510e5197b 100644 (file)
@@ -611,7 +611,7 @@ int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
        ret = iio_triggered_buffer_setup(indio_dev, NULL,
                                         hmc5843_trigger_handler, NULL);
        if (ret < 0)
-               return ret;
+               goto buffer_setup_err;
 
        ret = iio_device_register(indio_dev);
        if (ret < 0)
@@ -621,6 +621,8 @@ int hmc5843_common_probe(struct device *dev, struct regmap *regmap,
 
 buffer_cleanup:
        iio_triggered_buffer_cleanup(indio_dev);
+buffer_setup_err:
+       hmc5843_set_mode(iio_priv(indio_dev), HMC5843_MODE_SLEEP);
        return ret;
 }
 EXPORT_SYMBOL(hmc5843_common_probe);