Skip to content

Commit 42ec40b

Browse files
martenlijic23
authored andcommitted
iio: light: vcnl4000: Fix WARN_ON on uninitialized lock
There are different init functions for the sensors in this driver in which only one initializes the generic vcnl4000_lock. With commit e21b5b1 ("iio: light: vcnl4000: Preserve conf bits when toggle power") the vcnl4040 sensor started to depend on the lock, but it was missed to initialize it in vcnl4040's init function. This has not been visible until we run lockdep on it: DEBUG_LOCKS_WARN_ON(lock->magic != lock) at kernel/locking/mutex.c:575 __mutex_lock+0x4f8/0x890 Call trace: __mutex_lock mutex_lock_nested vcnl4200_set_power_state vcnl4200_init vcnl4000_probe Fix this by initializing the lock in the probe function instead of doing it in the chip specific init functions. Fixes: e21b5b1 ("iio: light: vcnl4000: Preserve conf bits when toggle power") Signed-off-by: Mårten Lindahl <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent d9b540e commit 42ec40b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/iio/light/vcnl4000.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ static int vcnl4000_init(struct vcnl4000_data *data)
199199

200200
data->rev = ret & 0xf;
201201
data->al_scale = 250000;
202-
mutex_init(&data->vcnl4000_lock);
203202

204203
return data->chip_spec->set_power_state(data, true);
205204
};
@@ -1197,6 +1196,8 @@ static int vcnl4000_probe(struct i2c_client *client)
11971196
data->id = id->driver_data;
11981197
data->chip_spec = &vcnl4000_chip_spec_cfg[data->id];
11991198

1199+
mutex_init(&data->vcnl4000_lock);
1200+
12001201
ret = data->chip_spec->init(data);
12011202
if (ret < 0)
12021203
return ret;

0 commit comments

Comments
 (0)