diff mbox series

[3/5] hwmon: (gpio-fan) Ensure lock is held during set_fan_speed()

Message ID 20250210145934.761280-4-alexander.stein@ew.tq-group.com (mailing list archive)
State New
Headers show
Series gpio-fan: regulator support | expand

Commit Message

Alexander Stein Feb. 10, 2025, 2:59 p.m. UTC
Instead of just documenting by comment, ensure locking per code.

Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
 drivers/hwmon/gpio-fan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c
index b779240328d59..322b161d5ca1f 100644
--- a/drivers/hwmon/gpio-fan.c
+++ b/drivers/hwmon/gpio-fan.c
@@ -124,9 +124,10 @@  static int __get_fan_ctrl(struct gpio_fan_data *fan_data)
 	return ctrl_val;
 }
 
-/* Must be called with fan_data->lock held, except during initialization. */
 static void set_fan_speed(struct gpio_fan_data *fan_data, int speed_index)
 {
+	WARN_ON_ONCE(!mutex_is_locked(&fan_data->lock));
+
 	if (fan_data->speed_index == speed_index)
 		return;