Merge tag 'devicetree-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[cascardo/linux.git] / drivers / hwmon / gpio-fan.c
index 4efa173..36abf81 100644 (file)
@@ -79,7 +79,7 @@ static ssize_t show_fan_alarm(struct device *dev,
 {
        struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
        struct gpio_fan_alarm *alarm = fan_data->alarm;
-       int value = gpio_get_value(alarm->gpio);
+       int value = gpio_get_value_cansleep(alarm->gpio);
 
        if (alarm->active_low)
                value = !value;
@@ -131,7 +131,7 @@ static void __set_fan_ctrl(struct gpio_fan_data *fan_data, int ctrl_val)
        int i;
 
        for (i = 0; i < fan_data->num_ctrl; i++)
-               gpio_set_value(fan_data->ctrl[i], (ctrl_val >> i) & 1);
+               gpio_set_value_cansleep(fan_data->ctrl[i], (ctrl_val >> i) & 1);
 }
 
 static int __get_fan_ctrl(struct gpio_fan_data *fan_data)
@@ -142,7 +142,7 @@ static int __get_fan_ctrl(struct gpio_fan_data *fan_data)
        for (i = 0; i < fan_data->num_ctrl; i++) {
                int value;
 
-               value = gpio_get_value(fan_data->ctrl[i]);
+               value = gpio_get_value_cansleep(fan_data->ctrl[i]);
                ctrl_val |= (value << i);
        }
        return ctrl_val;
@@ -369,7 +369,8 @@ static int fan_ctrl_init(struct gpio_fan_data *fan_data,
                if (err)
                        return err;
 
-               err = gpio_direction_output(ctrl[i], gpio_get_value(ctrl[i]));
+               err = gpio_direction_output(ctrl[i],
+                                           gpio_get_value_cansleep(ctrl[i]));
                if (err)
                        return err;
        }
@@ -549,6 +550,14 @@ static int gpio_fan_probe(struct platform_device *pdev)
        return 0;
 }
 
+static void gpio_fan_shutdown(struct platform_device *pdev)
+{
+       struct gpio_fan_data *fan_data = dev_get_drvdata(&pdev->dev);
+
+       if (fan_data->ctrl)
+               set_fan_speed(fan_data, 0);
+}
+
 #ifdef CONFIG_PM_SLEEP
 static int gpio_fan_suspend(struct device *dev)
 {
@@ -580,6 +589,7 @@ static SIMPLE_DEV_PM_OPS(gpio_fan_pm, gpio_fan_suspend, gpio_fan_resume);
 
 static struct platform_driver gpio_fan_driver = {
        .probe          = gpio_fan_probe,
+       .shutdown       = gpio_fan_shutdown,
        .driver = {
                .name   = "gpio-fan",
                .pm     = GPIO_FAN_PM,