Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'spi-5.15' into spi-5.16

+21 -16
+7
drivers/spi/spi-mux.c
··· 137 137 priv = spi_controller_get_devdata(ctlr); 138 138 priv->spi = spi; 139 139 140 + /* 141 + * Increase lockdep class as these lock are taken while the parent bus 142 + * already holds their instance's lock. 143 + */ 144 + lockdep_set_subclass(&ctlr->io_mutex, 1); 145 + lockdep_set_subclass(&ctlr->add_lock, 1); 146 + 140 147 priv->mux = devm_mux_control_get(&spi->dev, NULL); 141 148 if (IS_ERR(priv->mux)) { 142 149 ret = dev_err_probe(&spi->dev, PTR_ERR(priv->mux),
+11 -16
drivers/spi/spi.c
··· 477 477 */ 478 478 static DEFINE_MUTEX(board_lock); 479 479 480 - /* 481 - * Prevents addition of devices with same chip select and 482 - * addition of devices below an unregistering controller. 483 - */ 484 - static DEFINE_MUTEX(spi_add_lock); 485 - 486 480 /** 487 481 * spi_alloc_device - Allocate a new SPI device 488 482 * @ctlr: Controller to which device is connected ··· 629 635 /* Set the bus ID string */ 630 636 spi_dev_set_name(spi); 631 637 632 - mutex_lock(&spi_add_lock); 638 + mutex_lock(&ctlr->add_lock); 633 639 status = __spi_add_device(spi); 634 - mutex_unlock(&spi_add_lock); 640 + mutex_unlock(&ctlr->add_lock); 635 641 return status; 636 642 } 637 643 ··· 650 656 /* Set the bus ID string */ 651 657 spi_dev_set_name(spi); 652 658 653 - WARN_ON(!mutex_is_locked(&spi_add_lock)); 659 + WARN_ON(!mutex_is_locked(&ctlr->add_lock)); 654 660 return __spi_add_device(spi); 655 661 } 656 662 ··· 2626 2632 return NULL; 2627 2633 2628 2634 device_initialize(&ctlr->dev); 2635 + INIT_LIST_HEAD(&ctlr->queue); 2636 + spin_lock_init(&ctlr->queue_lock); 2637 + spin_lock_init(&ctlr->bus_lock_spinlock); 2638 + mutex_init(&ctlr->bus_lock_mutex); 2639 + mutex_init(&ctlr->io_mutex); 2640 + mutex_init(&ctlr->add_lock); 2629 2641 ctlr->bus_num = -1; 2630 2642 ctlr->num_chipselect = 1; 2631 2643 ctlr->slave = slave; ··· 2904 2904 return id; 2905 2905 ctlr->bus_num = id; 2906 2906 } 2907 - INIT_LIST_HEAD(&ctlr->queue); 2908 - spin_lock_init(&ctlr->queue_lock); 2909 - spin_lock_init(&ctlr->bus_lock_spinlock); 2910 - mutex_init(&ctlr->bus_lock_mutex); 2911 - mutex_init(&ctlr->io_mutex); 2912 2907 ctlr->bus_lock_flag = 0; 2913 2908 init_completion(&ctlr->xfer_completion); 2914 2909 if (!ctlr->max_dma_len) ··· 3040 3045 3041 3046 /* Prevent addition of new devices, unregister existing ones */ 3042 3047 if (IS_ENABLED(CONFIG_SPI_DYNAMIC)) 3043 - mutex_lock(&spi_add_lock); 3048 + mutex_lock(&ctlr->add_lock); 3044 3049 3045 3050 device_for_each_child(&ctlr->dev, NULL, __unregister); 3046 3051 ··· 3071 3076 mutex_unlock(&board_lock); 3072 3077 3073 3078 if (IS_ENABLED(CONFIG_SPI_DYNAMIC)) 3074 - mutex_unlock(&spi_add_lock); 3079 + mutex_unlock(&ctlr->add_lock); 3075 3080 } 3076 3081 EXPORT_SYMBOL_GPL(spi_unregister_controller); 3077 3082
+3
include/linux/spi/spi.h
··· 527 527 /* I/O mutex */ 528 528 struct mutex io_mutex; 529 529 530 + /* Used to avoid adding the same CS twice */ 531 + struct mutex add_lock; 532 + 530 533 /* lock and mutex for SPI bus locking */ 531 534 spinlock_t bus_lock_spinlock; 532 535 struct mutex bus_lock_mutex;