iio: light: vcnl4000: Fix WARN_ON on uninitialized lock
authorMårten Lindahl <marten.lindahl@axis.com>
Tue, 31 Jan 2023 14:01:09 +0000 (15:01 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Thu, 2 Feb 2023 17:11:56 +0000 (17:11 +0000)
commit42ec40b0883c1cce58b06e8fa82049a61033151c
tree206cd7ee380807227b7c429243670ea9b118895a
parentd9b540ee461cca7edca0dd2c2a42625c6b9ffb8f
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
e21b5b1f2669 ("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: e21b5b1f2669 ("iio: light: vcnl4000: Preserve conf bits when toggle power")
Signed-off-by: Mårten Lindahl <marten.lindahl@axis.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230131140109.2067577-1-marten.lindahl@axis.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/light/vcnl4000.c