Merge branch 'for-5.7' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie...
authorMark Brown <broonie@kernel.org>
Wed, 20 May 2020 16:55:07 +0000 (17:55 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 20 May 2020 16:55:07 +0000 (17:55 +0100)
1  2 
drivers/spi/spi-bcm2835.c
drivers/spi/spi.c

@@@ -191,12 -191,12 +191,12 @@@ static void bcm2835_debugfs_remove(stru
  }
  #endif /* CONFIG_DEBUG_FS */
  
 -static inline u32 bcm2835_rd(struct bcm2835_spi *bs, unsigned reg)
 +static inline u32 bcm2835_rd(struct bcm2835_spi *bs, unsigned int reg)
  {
        return readl(bs->regs + reg);
  }
  
 -static inline void bcm2835_wr(struct bcm2835_spi *bs, unsigned reg, u32 val)
 +static inline void bcm2835_wr(struct bcm2835_spi *bs, unsigned int reg, u32 val)
  {
        writel(val, bs->regs + reg);
  }
@@@ -940,7 -940,6 +940,7 @@@ static int bcm2835_dma_init(struct spi_
        if (dma_mapping_error(ctlr->dma_tx->device->dev, bs->fill_tx_addr)) {
                dev_err(dev, "cannot map zero page - not using DMA mode\n");
                bs->fill_tx_addr = 0;
 +              ret = -ENOMEM;
                goto err_release;
        }
  
                                                     DMA_MEM_TO_DEV, 0);
        if (!bs->fill_tx_desc) {
                dev_err(dev, "cannot prepare fill_tx_desc - not using DMA mode\n");
 +              ret = -ENOMEM;
                goto err_release;
        }
  
        if (dma_mapping_error(ctlr->dma_rx->device->dev, bs->clear_rx_addr)) {
                dev_err(dev, "cannot map clear_rx_cs - not using DMA mode\n");
                bs->clear_rx_addr = 0;
 +              ret = -ENOMEM;
                goto err_release;
        }
  
                                           DMA_MEM_TO_DEV, 0);
                if (!bs->clear_rx_desc[i]) {
                        dev_err(dev, "cannot prepare clear_rx_desc - not using DMA mode\n");
 +                      ret = -ENOMEM;
                        goto err_release;
                }
  
@@@ -1351,7 -1347,7 +1351,7 @@@ static int bcm2835_spi_probe(struct pla
                goto out_dma_release;
        }
  
-       err = devm_spi_register_controller(&pdev->dev, ctlr);
+       err = spi_register_controller(ctlr);
        if (err) {
                dev_err(&pdev->dev, "could not register SPI controller: %d\n",
                        err);
@@@ -1378,6 -1374,8 +1378,8 @@@ static int bcm2835_spi_remove(struct pl
  
        bcm2835_debugfs_remove(bs);
  
+       spi_unregister_controller(ctlr);
        /* Clear FIFOs, and disable the HW block */
        bcm2835_wr(bs, BCM2835_SPI_CS,
                   BCM2835_SPI_CS_CLEAR_RX | BCM2835_SPI_CS_CLEAR_TX);
diff --combined drivers/spi/spi.c
@@@ -1075,7 -1075,7 +1075,7 @@@ static int spi_transfer_wait(struct spi
  {
        struct spi_statistics *statm = &ctlr->statistics;
        struct spi_statistics *stats = &msg->spi->statistics;
 -      unsigned long long ms = 1;
 +      unsigned long long ms;
  
        if (spi_controller_is_slave(ctlr)) {
                if (wait_for_completion_interruptible(&ctlr->xfer_completion)) {
@@@ -2632,7 -2632,7 +2632,7 @@@ int spi_register_controller(struct spi_
                if (ctlr->use_gpio_descriptors) {
                        status = spi_get_gpio_descs(ctlr);
                        if (status)
 -                              return status;
 +                              goto free_bus_id;
                        /*
                         * A controller using GPIO descriptors always
                         * supports SPI_CS_HIGH if need be.
                        /* Legacy code path for GPIOs from DT */
                        status = of_spi_get_gpio_numbers(ctlr);
                        if (status)
 -                              return status;
 +                              goto free_bus_id;
                }
        }
  
         * Even if it's just one always-selected device, there must
         * be at least one chipselect.
         */
 -      if (!ctlr->num_chipselect)
 -              return -EINVAL;
 +      if (!ctlr->num_chipselect) {
 +              status = -EINVAL;
 +              goto free_bus_id;
 +      }
  
        status = device_add(&ctlr->dev);
 -      if (status < 0) {
 -              /* free bus id */
 -              mutex_lock(&board_lock);
 -              idr_remove(&spi_master_idr, ctlr->bus_num);
 -              mutex_unlock(&board_lock);
 -              goto done;
 -      }
 +      if (status < 0)
 +              goto free_bus_id;
        dev_dbg(dev, "registered %s %s\n",
                        spi_controller_is_slave(ctlr) ? "slave" : "master",
                        dev_name(&ctlr->dev));
                status = spi_controller_initialize_queue(ctlr);
                if (status) {
                        device_del(&ctlr->dev);
 -                      /* free bus id */
 -                      mutex_lock(&board_lock);
 -                      idr_remove(&spi_master_idr, ctlr->bus_num);
 -                      mutex_unlock(&board_lock);
 -                      goto done;
 +                      goto free_bus_id;
                }
        }
        /* add statistics */
        /* Register devices from the device tree and ACPI */
        of_register_spi_devices(ctlr);
        acpi_register_spi_devices(ctlr);
 -done:
 +      return status;
 +
 +free_bus_id:
 +      mutex_lock(&board_lock);
 +      idr_remove(&spi_master_idr, ctlr->bus_num);
 +      mutex_unlock(&board_lock);
        return status;
  }
  EXPORT_SYMBOL_GPL(spi_register_controller);
@@@ -2761,6 -2763,8 +2761,8 @@@ void spi_unregister_controller(struct s
        struct spi_controller *found;
        int id = ctlr->bus_num;
  
+       device_for_each_child(&ctlr->dev, NULL, __unregister);
        /* First make sure that this controller was ever added */
        mutex_lock(&board_lock);
        found = idr_find(&spi_master_idr, id);
        list_del(&ctlr->list);
        mutex_unlock(&board_lock);
  
-       device_for_each_child(&ctlr->dev, NULL, __unregister);
        device_unregister(&ctlr->dev);
        /* free bus id */
        mutex_lock(&board_lock);