Merge branch 'spi-5.15' into spi-5.16
This commit is contained in:
commit
531558b56b
@ -137,6 +137,13 @@ static int spi_mux_probe(struct spi_device *spi)
|
||||
priv = spi_controller_get_devdata(ctlr);
|
||||
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);
|
||||
if (IS_ERR(priv->mux)) {
|
||||
ret = dev_err_probe(&spi->dev, PTR_ERR(priv->mux),
|
||||
|
@ -477,12 +477,6 @@ static LIST_HEAD(spi_controller_list);
|
||||
*/
|
||||
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
|
||||
* @ctlr: Controller to which device is connected
|
||||
@ -635,9 +629,9 @@ static int spi_add_device(struct spi_device *spi)
|
||||
/* Set the bus ID string */
|
||||
spi_dev_set_name(spi);
|
||||
|
||||
mutex_lock(&spi_add_lock);
|
||||
mutex_lock(&ctlr->add_lock);
|
||||
status = __spi_add_device(spi);
|
||||
mutex_unlock(&spi_add_lock);
|
||||
mutex_unlock(&ctlr->add_lock);
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -656,7 +650,7 @@ static int spi_add_device_locked(struct spi_device *spi)
|
||||
/* Set the bus ID string */
|
||||
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);
|
||||
}
|
||||
|
||||
@ -2632,6 +2626,12 @@ struct spi_controller *__spi_alloc_controller(struct device *dev,
|
||||
return NULL;
|
||||
|
||||
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->num_chipselect = 1;
|
||||
ctlr->slave = slave;
|
||||
@ -2904,11 +2904,6 @@ int spi_register_controller(struct spi_controller *ctlr)
|
||||
return 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;
|
||||
init_completion(&ctlr->xfer_completion);
|
||||
if (!ctlr->max_dma_len)
|
||||
@ -3045,7 +3040,7 @@ void spi_unregister_controller(struct spi_controller *ctlr)
|
||||
|
||||
/* Prevent addition of new devices, unregister existing ones */
|
||||
if (IS_ENABLED(CONFIG_SPI_DYNAMIC))
|
||||
mutex_lock(&spi_add_lock);
|
||||
mutex_lock(&ctlr->add_lock);
|
||||
|
||||
device_for_each_child(&ctlr->dev, NULL, __unregister);
|
||||
|
||||
@ -3076,7 +3071,7 @@ void spi_unregister_controller(struct spi_controller *ctlr)
|
||||
mutex_unlock(&board_lock);
|
||||
|
||||
if (IS_ENABLED(CONFIG_SPI_DYNAMIC))
|
||||
mutex_unlock(&spi_add_lock);
|
||||
mutex_unlock(&ctlr->add_lock);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(spi_unregister_controller);
|
||||
|
||||
|
@ -527,6 +527,9 @@ struct spi_controller {
|
||||
/* I/O mutex */
|
||||
struct mutex io_mutex;
|
||||
|
||||
/* Used to avoid adding the same CS twice */
|
||||
struct mutex add_lock;
|
||||
|
||||
/* lock and mutex for SPI bus locking */
|
||||
spinlock_t bus_lock_spinlock;
|
||||
struct mutex bus_lock_mutex;
|
||||
|
Loading…
Reference in New Issue
Block a user