spi-mux: Fix false-positive lockdep splats
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Wed, 13 Oct 2021 13:37:10 +0000 (15:37 +0200)
committerMark Brown <broonie@kernel.org>
Thu, 14 Oct 2021 12:32:19 +0000 (13:32 +0100)
commit16a8e2fbb2d49111004efc1c7342e083eafabeb0
treeec9c22b3f88095ffa7e4885b9dfa7ba5ced1ab06
parent6098475d4cb48d821bdf453c61118c56e26294f0
spi-mux: Fix false-positive lockdep splats

io_mutex is taken by spi_setup() and spi-mux's .setup() callback calls
spi_setup() which results in a nested lock of io_mutex.

add_lock is taken by spi_add_device(). The device_add() call in there
can result in calling spi-mux's .probe() callback which registers its
own spi controller which in turn results in spi_add_device() being
called again.

To fix this initialize the controller's locks already in
spi_alloc_controller() to give spi_mux_probe() a chance to set the
lockdep subclass.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20211013133710.2679703-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-mux.c
drivers/spi/spi.c