mirror of
https://github.com/torvalds/linux.git
synced 2026-05-23 22:52:19 +02:00
hwmon: (gpio-fan) Add missing mutex locks
set_fan_speed() is expected to be called with fan_data->lock being locked. Add locking for proper synchronization. Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com> Link: https://lore.kernel.org/r/20250210145934.761280-3-alexander.stein@ew.tq-group.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
9f8e2e49c5
commit
9fee7d19ba
|
|
@ -393,7 +393,12 @@ static int gpio_fan_set_cur_state(struct thermal_cooling_device *cdev,
|
|||
if (state >= fan_data->num_speed)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&fan_data->lock);
|
||||
|
||||
set_fan_speed(fan_data, state);
|
||||
|
||||
mutex_unlock(&fan_data->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -489,7 +494,11 @@ MODULE_DEVICE_TABLE(of, of_gpio_fan_match);
|
|||
|
||||
static void gpio_fan_stop(void *data)
|
||||
{
|
||||
struct gpio_fan_data *fan_data = data;
|
||||
|
||||
mutex_lock(&fan_data->lock);
|
||||
set_fan_speed(data, 0);
|
||||
mutex_unlock(&fan_data->lock);
|
||||
}
|
||||
|
||||
static int gpio_fan_probe(struct platform_device *pdev)
|
||||
|
|
@ -562,7 +571,9 @@ static int gpio_fan_suspend(struct device *dev)
|
|||
|
||||
if (fan_data->gpios) {
|
||||
fan_data->resume_speed = fan_data->speed_index;
|
||||
mutex_lock(&fan_data->lock);
|
||||
set_fan_speed(fan_data, 0);
|
||||
mutex_unlock(&fan_data->lock);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
@ -572,8 +583,11 @@ static int gpio_fan_resume(struct device *dev)
|
|||
{
|
||||
struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
|
||||
|
||||
if (fan_data->gpios)
|
||||
if (fan_data->gpios) {
|
||||
mutex_lock(&fan_data->lock);
|
||||
set_fan_speed(fan_data, fan_data->resume_speed);
|
||||
mutex_unlock(&fan_data->lock);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user