]> Git Repo - linux.git/commitdiff
Merge remote-tracking branch 'spi/topic/core' into spi-next
authorMark Brown <[email protected]>
Fri, 10 Nov 2017 21:33:43 +0000 (21:33 +0000)
committerMark Brown <[email protected]>
Fri, 10 Nov 2017 21:33:43 +0000 (21:33 +0000)
1  2 
drivers/spi/spi.c

diff --combined drivers/spi/spi.c
index 3ff0ee88c467a58faa9c6a1544fd620e6852b250,5673cca1d1d06f3609874286bf0b444359e2ba83..b33a727a0158b19ebae1364a21fd8c9dff22e4e5
@@@ -45,6 -45,7 +45,6 @@@
  
  #define CREATE_TRACE_POINTS
  #include <trace/events/spi.h>
 -#define SPI_DYN_FIRST_BUS_NUM 0
  
  static DEFINE_IDR(spi_master_idr);
  
@@@ -2085,7 -2086,7 +2085,7 @@@ int spi_register_controller(struct spi_
        struct device           *dev = ctlr->dev.parent;
        struct boardinfo        *bi;
        int                     status = -ENODEV;
 -      int                     id;
 +      int                     id, first_dynamic;
  
        if (!dev)
                return -ENODEV;
                }
        }
        if (ctlr->bus_num < 0) {
 +              first_dynamic = of_alias_get_highest_id("spi");
 +              if (first_dynamic < 0)
 +                      first_dynamic = 0;
 +              else
 +                      first_dynamic++;
 +
                mutex_lock(&board_lock);
 -              id = idr_alloc(&spi_master_idr, ctlr, SPI_DYN_FIRST_BUS_NUM, 0,
 -                             GFP_KERNEL);
 +              id = idr_alloc(&spi_master_idr, ctlr, first_dynamic,
 +                             0, GFP_KERNEL);
                mutex_unlock(&board_lock);
                if (WARN(id < 0, "couldn't get idr"))
                        return id;
@@@ -2200,7 -2195,7 +2200,7 @@@ static void devm_spi_unregister(struct 
   * Context: can sleep
   *
   * Register a SPI device as with spi_register_controller() which will
-  * automatically be unregister
+  * automatically be unregistered and freed.
   *
   * Return: zero on success, else a negative error code.
   */
@@@ -2241,16 -2236,17 +2241,18 @@@ static int __unregister(struct device *
   * only ones directly touching chip registers.
   *
   * This must be called from context that can sleep.
+  *
+  * Note that this function also drops a reference to the controller.
   */
  void spi_unregister_controller(struct spi_controller *ctlr)
  {
        struct spi_controller *found;
 +      int id = ctlr->bus_num;
        int dummy;
  
        /* First make sure that this controller was ever added */
        mutex_lock(&board_lock);
 -      found = idr_find(&spi_master_idr, ctlr->bus_num);
 +      found = idr_find(&spi_master_idr, id);
        mutex_unlock(&board_lock);
        if (found != ctlr) {
                dev_dbg(&ctlr->dev,
        device_unregister(&ctlr->dev);
        /* free bus id */
        mutex_lock(&board_lock);
 -      idr_remove(&spi_master_idr, ctlr->bus_num);
 +      idr_remove(&spi_master_idr, id);
        mutex_unlock(&board_lock);
  }
  EXPORT_SYMBOL_GPL(spi_unregister_controller);
This page took 0.088076 seconds and 4 git commands to generate.