Commit 531558b5 authored by Mark Brown's avatar Mark Brown

Merge branch 'spi-5.15' into spi-5.16

parents d9c55c95 16a8e2fb
...@@ -137,6 +137,13 @@ static int spi_mux_probe(struct spi_device *spi) ...@@ -137,6 +137,13 @@ static int spi_mux_probe(struct spi_device *spi)
priv = spi_controller_get_devdata(ctlr); priv = spi_controller_get_devdata(ctlr);
priv->spi = spi; priv->spi = spi;
/*
* Increase lockdep class as these lock are taken while the parent bus
* already holds their instance's lock.
*/
lockdep_set_subclass(&ctlr->io_mutex, 1);
lockdep_set_subclass(&ctlr->add_lock, 1);
priv->mux = devm_mux_control_get(&spi->dev, NULL); priv->mux = devm_mux_control_get(&spi->dev, NULL);
if (IS_ERR(priv->mux)) { if (IS_ERR(priv->mux)) {
ret = dev_err_probe(&spi->dev, PTR_ERR(priv->mux), ret = dev_err_probe(&spi->dev, PTR_ERR(priv->mux),
......
...@@ -477,12 +477,6 @@ static LIST_HEAD(spi_controller_list); ...@@ -477,12 +477,6 @@ static LIST_HEAD(spi_controller_list);
*/ */
static DEFINE_MUTEX(board_lock); static DEFINE_MUTEX(board_lock);
/*
* Prevents addition of devices with same chip select and
* addition of devices below an unregistering controller.
*/
static DEFINE_MUTEX(spi_add_lock);
/** /**
* spi_alloc_device - Allocate a new SPI device * spi_alloc_device - Allocate a new SPI device
* @ctlr: Controller to which device is connected * @ctlr: Controller to which device is connected
...@@ -635,9 +629,9 @@ static int spi_add_device(struct spi_device *spi) ...@@ -635,9 +629,9 @@ static int spi_add_device(struct spi_device *spi)
/* Set the bus ID string */ /* Set the bus ID string */
spi_dev_set_name(spi); spi_dev_set_name(spi);
mutex_lock(&spi_add_lock); mutex_lock(&ctlr->add_lock);
status = __spi_add_device(spi); status = __spi_add_device(spi);
mutex_unlock(&spi_add_lock); mutex_unlock(&ctlr->add_lock);
return status; return status;
} }
...@@ -656,7 +650,7 @@ static int spi_add_device_locked(struct spi_device *spi) ...@@ -656,7 +650,7 @@ static int spi_add_device_locked(struct spi_device *spi)
/* Set the bus ID string */ /* Set the bus ID string */
spi_dev_set_name(spi); spi_dev_set_name(spi);
WARN_ON(!mutex_is_locked(&spi_add_lock)); WARN_ON(!mutex_is_locked(&ctlr->add_lock));
return __spi_add_device(spi); return __spi_add_device(spi);
} }
...@@ -2632,6 +2626,12 @@ struct spi_controller *__spi_alloc_controller(struct device *dev, ...@@ -2632,6 +2626,12 @@ struct spi_controller *__spi_alloc_controller(struct device *dev,
return NULL; return NULL;
device_initialize(&ctlr->dev); device_initialize(&ctlr->dev);
INIT_LIST_HEAD(&ctlr->queue);
spin_lock_init(&ctlr->queue_lock);
spin_lock_init(&ctlr->bus_lock_spinlock);
mutex_init(&ctlr->bus_lock_mutex);
mutex_init(&ctlr->io_mutex);
mutex_init(&ctlr->add_lock);
ctlr->bus_num = -1; ctlr->bus_num = -1;
ctlr->num_chipselect = 1; ctlr->num_chipselect = 1;
ctlr->slave = slave; ctlr->slave = slave;
...@@ -2904,11 +2904,6 @@ int spi_register_controller(struct spi_controller *ctlr) ...@@ -2904,11 +2904,6 @@ int spi_register_controller(struct spi_controller *ctlr)
return id; return id;
ctlr->bus_num = id; ctlr->bus_num = id;
} }
INIT_LIST_HEAD(&ctlr->queue);
spin_lock_init(&ctlr->queue_lock);
spin_lock_init(&ctlr->bus_lock_spinlock);
mutex_init(&ctlr->bus_lock_mutex);
mutex_init(&ctlr->io_mutex);
ctlr->bus_lock_flag = 0; ctlr->bus_lock_flag = 0;
init_completion(&ctlr->xfer_completion); init_completion(&ctlr->xfer_completion);
if (!ctlr->max_dma_len) if (!ctlr->max_dma_len)
...@@ -3045,7 +3040,7 @@ void spi_unregister_controller(struct spi_controller *ctlr) ...@@ -3045,7 +3040,7 @@ void spi_unregister_controller(struct spi_controller *ctlr)
/* Prevent addition of new devices, unregister existing ones */ /* Prevent addition of new devices, unregister existing ones */
if (IS_ENABLED(CONFIG_SPI_DYNAMIC)) if (IS_ENABLED(CONFIG_SPI_DYNAMIC))
mutex_lock(&spi_add_lock); mutex_lock(&ctlr->add_lock);
device_for_each_child(&ctlr->dev, NULL, __unregister); device_for_each_child(&ctlr->dev, NULL, __unregister);
...@@ -3076,7 +3071,7 @@ void spi_unregister_controller(struct spi_controller *ctlr) ...@@ -3076,7 +3071,7 @@ void spi_unregister_controller(struct spi_controller *ctlr)
mutex_unlock(&board_lock); mutex_unlock(&board_lock);
if (IS_ENABLED(CONFIG_SPI_DYNAMIC)) if (IS_ENABLED(CONFIG_SPI_DYNAMIC))
mutex_unlock(&spi_add_lock); mutex_unlock(&ctlr->add_lock);
} }
EXPORT_SYMBOL_GPL(spi_unregister_controller); EXPORT_SYMBOL_GPL(spi_unregister_controller);
......
...@@ -527,6 +527,9 @@ struct spi_controller { ...@@ -527,6 +527,9 @@ struct spi_controller {
/* I/O mutex */ /* I/O mutex */
struct mutex io_mutex; struct mutex io_mutex;
/* Used to avoid adding the same CS twice */
struct mutex add_lock;
/* lock and mutex for SPI bus locking */ /* lock and mutex for SPI bus locking */
spinlock_t bus_lock_spinlock; spinlock_t bus_lock_spinlock;
struct mutex bus_lock_mutex; struct mutex bus_lock_mutex;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment