set_fan_speed() writes the control GPIOs one bit at a time. Every other caller locks around it; gpio_fan_shutdown() doesn't. If it races a locked caller, the GPIO writes can interleave and leave the fan at a speed neither caller asked for.
Unified · Split
| @@ -612,8 +612,11 @@ static void gpio_fan_shutdown(struct platform_device *pdev) · 611 unmodified lines | ||
| 612 | 612 | { |
| 613 | 613 | struct gpio_fan_data *fan_data = platform_get_drvdata(pdev); |
| 614 | 614 | |
| 615 | − if (fan_data->gpios) | |
| 615 | + if (fan_data->gpios) { | |
| 616 | + mutex_lock(&fan_data->lock); | |
| 616 | 617 | set_fan_speed(fan_data, 0); |
| 618 | + mutex_unlock(&fan_data->lock); | |
| 619 | + } | |
| 617 | 620 | } |
| 618 | 621 | |
| 619 | 622 | static int gpio_fan_runtime_suspend(struct device *dev) |