]> Pileus Git - ~andy/linux/commitdiff
Merge remote-tracking branch 'spi/topic/pdata' into spi-next
authorMark Brown <broonie@linaro.org>
Sun, 1 Sep 2013 12:49:03 +0000 (13:49 +0100)
committerMark Brown <broonie@linaro.org>
Sun, 1 Sep 2013 12:49:03 +0000 (13:49 +0100)
1  2 
drivers/spi/spi-altera.c
drivers/spi/spi-bcm63xx.c
drivers/spi/spi-bfin-v3.c
drivers/spi/spi-davinci.c
drivers/spi/spi-ep93xx.c
drivers/spi/spi-mpc512x-psc.c
drivers/spi/spi-nuc900.c
drivers/spi/spi-oc-tiny.c
drivers/spi/spi-omap-100k.c
drivers/spi/spi-xilinx.c

diff --combined drivers/spi/spi-altera.c
index 156eb888655e1c1529da6b09591427b9e772d76e,e53caac13aec06f836640ad0bd6f5f8f317a694f..f38855f7653622d742127c7ff6af7223b4c5ee91
@@@ -103,6 -103,16 +103,6 @@@ static void altera_spi_chipsel(struct s
        }
  }
  
 -static int altera_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t)
 -{
 -      return 0;
 -}
 -
 -static int altera_spi_setup(struct spi_device *spi)
 -{
 -      return 0;
 -}
 -
  static inline unsigned int hw_txbyte(struct altera_spi *hw, int count)
  {
        if (hw->tx) {
@@@ -124,7 -134,7 +124,7 @@@ static int altera_spi_txrx(struct spi_d
        hw->tx = t->tx_buf;
        hw->rx = t->rx_buf;
        hw->count = 0;
 -      hw->bytes_per_word = t->bits_per_word / 8;
 +      hw->bytes_per_word = DIV_ROUND_UP(t->bits_per_word, 8);
        hw->len = t->len / hw->bytes_per_word;
  
        if (hw->irq >= 0) {
                hw->imr &= ~ALTERA_SPI_CONTROL_IRRDY_MSK;
                writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
        } else {
 -              /* send the first byte */
 -              writel(hw_txbyte(hw, 0), hw->base + ALTERA_SPI_TXDATA);
 -
 -              while (1) {
 +              while (hw->count < hw->len) {
                        unsigned int rxd;
  
 +                      writel(hw_txbyte(hw, hw->count),
 +                             hw->base + ALTERA_SPI_TXDATA);
 +
                        while (!(readl(hw->base + ALTERA_SPI_STATUS) &
                                 ALTERA_SPI_STATUS_RRDY_MSK))
                                cpu_relax();
                        }
  
                        hw->count++;
 -
 -                      if (hw->count < hw->len)
 -                              writel(hw_txbyte(hw, hw->count),
 -                                     hw->base + ALTERA_SPI_TXDATA);
 -                      else
 -                              break;
                }
 -
        }
  
        return hw->count * hw->bytes_per_word;
@@@ -200,7 -217,7 +200,7 @@@ static irqreturn_t altera_spi_irq(int i
  
  static int altera_spi_probe(struct platform_device *pdev)
  {
-       struct altera_spi_platform_data *platp = pdev->dev.platform_data;
+       struct altera_spi_platform_data *platp = dev_get_platdata(&pdev->dev);
        struct altera_spi *hw;
        struct spi_master *master;
        struct resource *res;
        master->bus_num = pdev->id;
        master->num_chipselect = 16;
        master->mode_bits = SPI_CS_HIGH;
 -      master->setup = altera_spi_setup;
  
        hw = spi_master_get_devdata(master);
        platform_set_drvdata(pdev, hw);
        hw->bitbang.master = spi_master_get(master);
        if (!hw->bitbang.master)
                return err;
 -      hw->bitbang.setup_transfer = altera_spi_setupxfer;
        hw->bitbang.chipselect = altera_spi_chipsel;
        hw->bitbang.txrx_bufs = altera_spi_txrx;
  
        /* find and map our resources */
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 -      if (!res)
 -              goto exit_busy;
 -      if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res),
 -                                   pdev->name))
 -              goto exit_busy;
 -      hw->base = devm_ioremap_nocache(&pdev->dev, res->start,
 -                                      resource_size(res));
 -      if (!hw->base)
 -              goto exit_busy;
 +      hw->base = devm_ioremap_resource(&pdev->dev, res);
 +      if (IS_ERR(hw->base)) {
 +              err = PTR_ERR(hw->base);
 +              goto exit;
 +      }
        /* program defaults into the registers */
        hw->imr = 0;            /* disable spi interrupts */
        writel(hw->imr, hw->base + ALTERA_SPI_CONTROL);
        dev_info(&pdev->dev, "base %p, irq %d\n", hw->base, hw->irq);
  
        return 0;
 -
 -exit_busy:
 -      err = -EBUSY;
  exit:
        spi_master_put(master);
        return err;
index a21fef4a3bb110df50890e90d9c60bd67e1cce8e,f2b548f5ae99f623ebc1d8dc9cc228b8cf78d811..de197f72e082dd200455fe5f0eb39d811c5f91a5
@@@ -353,13 -353,20 +353,13 @@@ static int bcm63xx_spi_probe(struct pla
  {
        struct resource *r;
        struct device *dev = &pdev->dev;
-       struct bcm63xx_spi_pdata *pdata = pdev->dev.platform_data;
+       struct bcm63xx_spi_pdata *pdata = dev_get_platdata(&pdev->dev);
        int irq;
        struct spi_master *master;
        struct clk *clk;
        struct bcm63xx_spi *bs;
        int ret;
  
 -      r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 -      if (!r) {
 -              dev_err(dev, "no iomem\n");
 -              ret = -ENXIO;
 -              goto out;
 -      }
 -
        irq = platform_get_irq(pdev, 0);
        if (irq < 0) {
                dev_err(dev, "no irq\n");
        platform_set_drvdata(pdev, master);
        bs->pdev = pdev;
  
 +      r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        bs->regs = devm_ioremap_resource(&pdev->dev, r);
        if (IS_ERR(bs->regs)) {
                ret = PTR_ERR(bs->regs);
@@@ -474,8 -480,7 +474,7 @@@ static int bcm63xx_spi_remove(struct pl
  #ifdef CONFIG_PM
  static int bcm63xx_spi_suspend(struct device *dev)
  {
-       struct spi_master *master =
-                       platform_get_drvdata(to_platform_device(dev));
+       struct spi_master *master = dev_get_drvdata(dev);
        struct bcm63xx_spi *bs = spi_master_get_devdata(master);
  
        spi_master_suspend(master);
  
  static int bcm63xx_spi_resume(struct device *dev)
  {
-       struct spi_master *master =
-                       platform_get_drvdata(to_platform_device(dev));
+       struct spi_master *master = dev_get_drvdata(dev);
        struct bcm63xx_spi *bs = spi_master_get_devdata(master);
  
        clk_prepare_enable(bs->clk);
index e4394ebf08f385f9af9d32c037c9bbc0711d3f8c,35f2db72af9208ce3fdd2be7572f524d2d770f69..f4bf81347d68fd60d6f0a4d01f8702d412a70d20
@@@ -773,7 -773,7 +773,7 @@@ static irqreturn_t bfin_spi_rx_dma_isr(
  static int bfin_spi_probe(struct platform_device *pdev)
  {
        struct device *dev = &pdev->dev;
-       struct bfin_spi3_master *info = dev->platform_data;
+       struct bfin_spi3_master *info = dev_get_platdata(dev);
        struct spi_master *master;
        struct bfin_spi_master *drv_data;
        struct resource *mem, *res;
                return -ENXIO;
        }
  
 -      /* get register base and tx/rx dma */
 -      mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 -      if (!mem) {
 -              dev_err(dev, "can not get register base\n");
 -              return -ENXIO;
 -      }
 -
        res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
        if (!res) {
                dev_err(dev, "can not get tx dma resource\n");
        drv_data->pin_req = info->pin_req;
        drv_data->sclk = sclk;
  
 +      mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        drv_data->regs = devm_ioremap_resource(dev, mem);
        if (IS_ERR(drv_data->regs)) {
                ret = PTR_ERR(drv_data->regs);
index 707966bd56103181d31887b53cca01c1d9bd9776,5cd6398e970e5a9e9774307694775d5ccbefb48a..8fbfe2483ffdd12c20683e50194877c1a1ac85ca
@@@ -609,7 -609,7 +609,7 @@@ static int davinci_spi_bufs(struct spi_
                else
                        buf = (void *)t->tx_buf;
                t->tx_dma = dma_map_single(&spi->dev, buf,
 -                              t->len, DMA_FROM_DEVICE);
 +                              t->len, DMA_TO_DEVICE);
                if (!t->tx_dma) {
                        ret = -EFAULT;
                        goto err_tx_map;
@@@ -872,8 -872,8 +872,8 @@@ static int davinci_spi_probe(struct pla
                goto free_master;
        }
  
-       if (pdev->dev.platform_data) {
-               pdata = pdev->dev.platform_data;
+       if (dev_get_platdata(&pdev->dev)) {
+               pdata = dev_get_platdata(&pdev->dev);
                dspi->pdata = *pdata;
        } else {
                /* update dspi pdata with that from the DT */
diff --combined drivers/spi/spi-ep93xx.c
index 31611f7d7be9b5445d0a76b93cd2def836217ab1,50831c837677fe7a6028a2b6e0f3161f11daf764..d22c00a227b683ea22b404d680575ae4a27efc9e
@@@ -26,6 -26,7 +26,6 @@@
  #include <linux/interrupt.h>
  #include <linux/module.h>
  #include <linux/platform_device.h>
 -#include <linux/workqueue.h>
  #include <linux/sched.h>
  #include <linux/scatterlist.h>
  #include <linux/spi/spi.h>
  
  /**
   * struct ep93xx_spi - EP93xx SPI controller structure
 - * @lock: spinlock that protects concurrent accesses to fields @running,
 - *        @current_msg and @msg_queue
   * @pdev: pointer to platform device
   * @clk: clock for the controller
   * @regs_base: pointer to ioremap()'d registers
   * @sspdr_phys: physical address of the SSPDR register
   * @min_rate: minimum clock rate (in Hz) supported by the controller
   * @max_rate: maximum clock rate (in Hz) supported by the controller
 - * @running: is the queue running
 - * @wq: workqueue used by the driver
 - * @msg_work: work that is queued for the driver
   * @wait: wait here until given transfer is completed
 - * @msg_queue: queue for the messages
   * @current_msg: message that is currently processed (or %NULL if none)
   * @tx: current byte in transfer to transmit
   * @rx: current byte in transfer to receive
   * @tx_sgt: sg table for TX transfers
   * @zeropage: dummy page used as RX buffer when only TX buffer is passed in by
   *            the client
 - *
 - * This structure holds EP93xx SPI controller specific information. When
 - * @running is %true, driver accepts transfer requests from protocol drivers.
 - * @current_msg is used to hold pointer to the message that is currently
 - * processed. If @current_msg is %NULL, it means that no processing is going
 - * on.
 - *
 - * Most of the fields are only written once and they can be accessed without
 - * taking the @lock. Fields that are accessed concurrently are: @current_msg,
 - * @running, and @msg_queue.
   */
  struct ep93xx_spi {
 -      spinlock_t                      lock;
        const struct platform_device    *pdev;
        struct clk                      *clk;
        void __iomem                    *regs_base;
        unsigned long                   sspdr_phys;
        unsigned long                   min_rate;
        unsigned long                   max_rate;
 -      bool                            running;
 -      struct workqueue_struct         *wq;
 -      struct work_struct              msg_work;
        struct completion               wait;
 -      struct list_head                msg_queue;
        struct spi_message              *current_msg;
        size_t                          tx;
        size_t                          rx;
  /**
   * struct ep93xx_spi_chip - SPI device hardware settings
   * @spi: back pointer to the SPI device
 - * @rate: max rate in hz this chip supports
 - * @div_cpsr: cpsr (pre-scaler) divider
 - * @div_scr: scr divider
 - * @dss: bits per word (4 - 16 bits)
   * @ops: private chip operations
 - *
 - * This structure is used to store hardware register specific settings for each
 - * SPI device. Settings are written to hardware by function
 - * ep93xx_spi_chip_setup().
   */
  struct ep93xx_spi_chip {
        const struct spi_device         *spi;
 -      unsigned long                   rate;
 -      u8                              div_cpsr;
 -      u8                              div_scr;
 -      u8                              dss;
        struct ep93xx_spi_chip_ops      *ops;
  };
  
  /* converts bits per word to CR0.DSS value */
  #define bits_per_word_to_dss(bpw)     ((bpw) - 1)
  
 -static inline void
 -ep93xx_spi_write_u8(const struct ep93xx_spi *espi, u16 reg, u8 value)
 +static void ep93xx_spi_write_u8(const struct ep93xx_spi *espi,
 +                              u16 reg, u8 value)
  {
 -      __raw_writeb(value, espi->regs_base + reg);
 +      writeb(value, espi->regs_base + reg);
  }
  
 -static inline u8
 -ep93xx_spi_read_u8(const struct ep93xx_spi *spi, u16 reg)
 +static u8 ep93xx_spi_read_u8(const struct ep93xx_spi *spi, u16 reg)
  {
 -      return __raw_readb(spi->regs_base + reg);
 +      return readb(spi->regs_base + reg);
  }
  
 -static inline void
 -ep93xx_spi_write_u16(const struct ep93xx_spi *espi, u16 reg, u16 value)
 +static void ep93xx_spi_write_u16(const struct ep93xx_spi *espi,
 +                               u16 reg, u16 value)
  {
 -      __raw_writew(value, espi->regs_base + reg);
 +      writew(value, espi->regs_base + reg);
  }
  
 -static inline u16
 -ep93xx_spi_read_u16(const struct ep93xx_spi *spi, u16 reg)
 +static u16 ep93xx_spi_read_u16(const struct ep93xx_spi *spi, u16 reg)
  {
 -      return __raw_readw(spi->regs_base + reg);
 +      return readw(spi->regs_base + reg);
  }
  
  static int ep93xx_spi_enable(const struct ep93xx_spi *espi)
@@@ -194,13 -230,17 +194,13 @@@ static void ep93xx_spi_disable_interrup
  /**
   * ep93xx_spi_calc_divisors() - calculates SPI clock divisors
   * @espi: ep93xx SPI controller struct
 - * @chip: divisors are calculated for this chip
   * @rate: desired SPI output clock rate
 - *
 - * Function calculates cpsr (clock pre-scaler) and scr divisors based on
 - * given @rate and places them to @chip->div_cpsr and @chip->div_scr. If,
 - * for some reason, divisors cannot be calculated nothing is stored and
 - * %-EINVAL is returned.
 + * @div_cpsr: pointer to return the cpsr (pre-scaler) divider
 + * @div_scr: pointer to return the scr divider
   */
  static int ep93xx_spi_calc_divisors(const struct ep93xx_spi *espi,
 -                                  struct ep93xx_spi_chip *chip,
 -                                  unsigned long rate)
 +                                  unsigned long rate,
 +                                  u8 *div_cpsr, u8 *div_scr)
  {
        unsigned long spi_clk_rate = clk_get_rate(espi->clk);
        int cpsr, scr;
        /*
         * Make sure that max value is between values supported by the
         * controller. Note that minimum value is already checked in
 -       * ep93xx_spi_transfer().
 +       * ep93xx_spi_transfer_one_message().
         */
        rate = clamp(rate, espi->min_rate, espi->max_rate);
  
        for (cpsr = 2; cpsr <= 254; cpsr += 2) {
                for (scr = 0; scr <= 255; scr++) {
                        if ((spi_clk_rate / (cpsr * (scr + 1))) <= rate) {
 -                              chip->div_scr = (u8)scr;
 -                              chip->div_cpsr = (u8)cpsr;
 +                              *div_scr = (u8)scr;
 +                              *div_cpsr = (u8)cpsr;
                                return 0;
                        }
                }
@@@ -279,10 -319,72 +279,10 @@@ static int ep93xx_spi_setup(struct spi_
                spi_set_ctldata(spi, chip);
        }
  
 -      if (spi->max_speed_hz != chip->rate) {
 -              int err;
 -
 -              err = ep93xx_spi_calc_divisors(espi, chip, spi->max_speed_hz);
 -              if (err != 0) {
 -                      spi_set_ctldata(spi, NULL);
 -                      kfree(chip);
 -                      return err;
 -              }
 -              chip->rate = spi->max_speed_hz;
 -      }
 -
 -      chip->dss = bits_per_word_to_dss(spi->bits_per_word);
 -
        ep93xx_spi_cs_control(spi, false);
        return 0;
  }
  
 -/**
 - * ep93xx_spi_transfer() - queue message to be transferred
 - * @spi: target SPI device
 - * @msg: message to be transferred
 - *
 - * This function is called by SPI device drivers when they are going to transfer
 - * a new message. It simply puts the message in the queue and schedules
 - * workqueue to perform the actual transfer later on.
 - *
 - * Returns %0 on success and negative error in case of failure.
 - */
 -static int ep93xx_spi_transfer(struct spi_device *spi, struct spi_message *msg)
 -{
 -      struct ep93xx_spi *espi = spi_master_get_devdata(spi->master);
 -      struct spi_transfer *t;
 -      unsigned long flags;
 -
 -      if (!msg || !msg->complete)
 -              return -EINVAL;
 -
 -      /* first validate each transfer */
 -      list_for_each_entry(t, &msg->transfers, transfer_list) {
 -              if (t->speed_hz && t->speed_hz < espi->min_rate)
 -                              return -EINVAL;
 -      }
 -
 -      /*
 -       * Now that we own the message, let's initialize it so that it is
 -       * suitable for us. We use @msg->status to signal whether there was
 -       * error in transfer and @msg->state is used to hold pointer to the
 -       * current transfer (or %NULL if no active current transfer).
 -       */
 -      msg->state = NULL;
 -      msg->status = 0;
 -      msg->actual_length = 0;
 -
 -      spin_lock_irqsave(&espi->lock, flags);
 -      if (!espi->running) {
 -              spin_unlock_irqrestore(&espi->lock, flags);
 -              return -ESHUTDOWN;
 -      }
 -      list_add_tail(&msg->queue, &espi->msg_queue);
 -      queue_work(espi->wq, &espi->msg_work);
 -      spin_unlock_irqrestore(&espi->lock, flags);
 -
 -      return 0;
 -}
 -
  /**
   * ep93xx_spi_cleanup() - cleans up master controller specific state
   * @spi: SPI device to cleanup
@@@ -307,40 -409,39 +307,40 @@@ static void ep93xx_spi_cleanup(struct s
   * ep93xx_spi_chip_setup() - configures hardware according to given @chip
   * @espi: ep93xx SPI controller struct
   * @chip: chip specific settings
 - *
 - * This function sets up the actual hardware registers with settings given in
 - * @chip. Note that no validation is done so make sure that callers validate
 - * settings before calling this.
 + * @speed_hz: transfer speed
 + * @bits_per_word: transfer bits_per_word
   */
 -static void ep93xx_spi_chip_setup(const struct ep93xx_spi *espi,
 -                                const struct ep93xx_spi_chip *chip)
 +static int ep93xx_spi_chip_setup(const struct ep93xx_spi *espi,
 +                               const struct ep93xx_spi_chip *chip,
 +                               u32 speed_hz, u8 bits_per_word)
  {
 +      u8 dss = bits_per_word_to_dss(bits_per_word);
 +      u8 div_cpsr = 0;
 +      u8 div_scr = 0;
        u16 cr0;
 +      int err;
  
 -      cr0 = chip->div_scr << SSPCR0_SCR_SHIFT;
 +      err = ep93xx_spi_calc_divisors(espi, speed_hz, &div_cpsr, &div_scr);
 +      if (err)
 +              return err;
 +
 +      cr0 = div_scr << SSPCR0_SCR_SHIFT;
        cr0 |= (chip->spi->mode & (SPI_CPHA|SPI_CPOL)) << SSPCR0_MODE_SHIFT;
 -      cr0 |= chip->dss;
 +      cr0 |= dss;
  
        dev_dbg(&espi->pdev->dev, "setup: mode %d, cpsr %d, scr %d, dss %d\n",
 -              chip->spi->mode, chip->div_cpsr, chip->div_scr, chip->dss);
 +              chip->spi->mode, div_cpsr, div_scr, dss);
        dev_dbg(&espi->pdev->dev, "setup: cr0 %#x", cr0);
  
 -      ep93xx_spi_write_u8(espi, SSPCPSR, chip->div_cpsr);
 +      ep93xx_spi_write_u8(espi, SSPCPSR, div_cpsr);
        ep93xx_spi_write_u16(espi, SSPCR0, cr0);
 -}
 -
 -static inline int bits_per_word(const struct ep93xx_spi *espi)
 -{
 -      struct spi_message *msg = espi->current_msg;
 -      struct spi_transfer *t = msg->state;
  
 -      return t->bits_per_word;
 +      return 0;
  }
  
  static void ep93xx_do_write(struct ep93xx_spi *espi, struct spi_transfer *t)
  {
 -      if (bits_per_word(espi) > 8) {
 +      if (t->bits_per_word > 8) {
                u16 tx_val = 0;
  
                if (t->tx_buf)
  
  static void ep93xx_do_read(struct ep93xx_spi *espi, struct spi_transfer *t)
  {
 -      if (bits_per_word(espi) > 8) {
 +      if (t->bits_per_word > 8) {
                u16 rx_val;
  
                rx_val = ep93xx_spi_read_u16(espi, SSPDR);
@@@ -445,7 -546,7 +445,7 @@@ ep93xx_spi_dma_prepare(struct ep93xx_sp
        size_t len = t->len;
        int i, ret, nents;
  
 -      if (bits_per_word(espi) > 8)
 +      if (t->bits_per_word > 8)
                buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES;
        else
                buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE;
        }
  
        if (WARN_ON(len)) {
 -              dev_warn(&espi->pdev->dev, "len = %d expected 0!", len);
 +              dev_warn(&espi->pdev->dev, "len = %zu expected 0!", len);
                return ERR_PTR(-EINVAL);
        }
  
@@@ -607,16 -708,37 +607,16 @@@ static void ep93xx_spi_process_transfer
                                        struct spi_transfer *t)
  {
        struct ep93xx_spi_chip *chip = spi_get_ctldata(msg->spi);
 +      int err;
  
        msg->state = t;
  
 -      /*
 -       * Handle any transfer specific settings if needed. We use
 -       * temporary chip settings here and restore original later when
 -       * the transfer is finished.
 -       */
 -      if (t->speed_hz || t->bits_per_word) {
 -              struct ep93xx_spi_chip tmp_chip = *chip;
 -
 -              if (t->speed_hz) {
 -                      int err;
 -
 -                      err = ep93xx_spi_calc_divisors(espi, &tmp_chip,
 -                                                     t->speed_hz);
 -                      if (err) {
 -                              dev_err(&espi->pdev->dev,
 -                                      "failed to adjust speed\n");
 -                              msg->status = err;
 -                              return;
 -                      }
 -              }
 -
 -              if (t->bits_per_word)
 -                      tmp_chip.dss = bits_per_word_to_dss(t->bits_per_word);
 -
 -              /*
 -               * Set up temporary new hw settings for this transfer.
 -               */
 -              ep93xx_spi_chip_setup(espi, &tmp_chip);
 +      err = ep93xx_spi_chip_setup(espi, chip, t->speed_hz, t->bits_per_word);
 +      if (err) {
 +              dev_err(&espi->pdev->dev,
 +                      "failed to setup chip for transfer\n");
 +              msg->status = err;
 +              return;
        }
  
        espi->rx = 0;
                        ep93xx_spi_cs_control(msg->spi, true);
                }
        }
 -
 -      if (t->speed_hz || t->bits_per_word)
 -              ep93xx_spi_chip_setup(espi, chip);
  }
  
  /*
@@@ -713,8 -838,10 +713,8 @@@ static void ep93xx_spi_process_message(
        espi->fifo_level = 0;
  
        /*
 -       * Update SPI controller registers according to spi device and assert
 -       * the chipselect.
 +       * Assert the chipselect.
         */
 -      ep93xx_spi_chip_setup(espi, spi_get_ctldata(msg->spi));
        ep93xx_spi_cs_control(msg->spi, true);
  
        list_for_each_entry(t, &msg->transfers, transfer_list) {
        ep93xx_spi_disable(espi);
  }
  
 -#define work_to_espi(work) (container_of((work), struct ep93xx_spi, msg_work))
 -
 -/**
 - * ep93xx_spi_work() - EP93xx SPI workqueue worker function
 - * @work: work struct
 - *
 - * Workqueue worker function. This function is called when there are new
 - * SPI messages to be processed. Message is taken out from the queue and then
 - * passed to ep93xx_spi_process_message().
 - *
 - * After message is transferred, protocol driver is notified by calling
 - * @msg->complete(). In case of error, @msg->status is set to negative error
 - * number, otherwise it contains zero (and @msg->actual_length is updated).
 - */
 -static void ep93xx_spi_work(struct work_struct *work)
 +static int ep93xx_spi_transfer_one_message(struct spi_master *master,
 +                                         struct spi_message *msg)
  {
 -      struct ep93xx_spi *espi = work_to_espi(work);
 -      struct spi_message *msg;
 +      struct ep93xx_spi *espi = spi_master_get_devdata(master);
 +      struct spi_transfer *t;
  
 -      spin_lock_irq(&espi->lock);
 -      if (!espi->running || espi->current_msg ||
 -              list_empty(&espi->msg_queue)) {
 -              spin_unlock_irq(&espi->lock);
 -              return;
 +      /* first validate each transfer */
 +      list_for_each_entry(t, &msg->transfers, transfer_list) {
 +              if (t->speed_hz < espi->min_rate)
 +                      return -EINVAL;
        }
 -      msg = list_first_entry(&espi->msg_queue, struct spi_message, queue);
 -      list_del_init(&msg->queue);
 -      espi->current_msg = msg;
 -      spin_unlock_irq(&espi->lock);
  
 -      ep93xx_spi_process_message(espi, msg);
 +      msg->state = NULL;
 +      msg->status = 0;
 +      msg->actual_length = 0;
  
 -      /*
 -       * Update the current message and re-schedule ourselves if there are
 -       * more messages in the queue.
 -       */
 -      spin_lock_irq(&espi->lock);
 +      espi->current_msg = msg;
 +      ep93xx_spi_process_message(espi, msg);
        espi->current_msg = NULL;
 -      if (espi->running && !list_empty(&espi->msg_queue))
 -              queue_work(espi->wq, &espi->msg_work);
 -      spin_unlock_irq(&espi->lock);
  
 -      /* notify the protocol driver that we are done with this message */
 -      msg->complete(msg->context);
 +      spi_finalize_current_message(master);
 +
 +      return 0;
  }
  
  static irqreturn_t ep93xx_spi_interrupt(int irq, void *dev_id)
@@@ -874,26 -1022,16 +874,26 @@@ static int ep93xx_spi_probe(struct plat
        int irq;
        int error;
  
-       info = pdev->dev.platform_data;
+       info = dev_get_platdata(&pdev->dev);
  
 +      irq = platform_get_irq(pdev, 0);
 +      if (irq < 0) {
 +              dev_err(&pdev->dev, "failed to get irq resources\n");
 +              return -EBUSY;
 +      }
 +
 +      res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 +      if (!res) {
 +              dev_err(&pdev->dev, "unable to get iomem resource\n");
 +              return -ENODEV;
 +      }
 +
        master = spi_alloc_master(&pdev->dev, sizeof(*espi));
 -      if (!master) {
 -              dev_err(&pdev->dev, "failed to allocate spi master\n");
 +      if (!master)
                return -ENOMEM;
 -      }
  
        master->setup = ep93xx_spi_setup;
 -      master->transfer = ep93xx_spi_transfer;
 +      master->transfer_one_message = ep93xx_spi_transfer_one_message;
        master->cleanup = ep93xx_spi_cleanup;
        master->bus_num = pdev->id;
        master->num_chipselect = info->num_chipselect;
  
        espi = spi_master_get_devdata(master);
  
 -      espi->clk = clk_get(&pdev->dev, NULL);
 +      espi->clk = devm_clk_get(&pdev->dev, NULL);
        if (IS_ERR(espi->clk)) {
                dev_err(&pdev->dev, "unable to get spi clock\n");
                error = PTR_ERR(espi->clk);
                goto fail_release_master;
        }
  
 -      spin_lock_init(&espi->lock);
        init_completion(&espi->wait);
  
        /*
        espi->min_rate = clk_get_rate(espi->clk) / (254 * 256);
        espi->pdev = pdev;
  
 -      irq = platform_get_irq(pdev, 0);
 -      if (irq < 0) {
 -              error = -EBUSY;
 -              dev_err(&pdev->dev, "failed to get irq resources\n");
 -              goto fail_put_clock;
 -      }
 -
 -      res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 -      if (!res) {
 -              dev_err(&pdev->dev, "unable to get iomem resource\n");
 -              error = -ENODEV;
 -              goto fail_put_clock;
 -      }
 -
        espi->sspdr_phys = res->start + SSPDR;
  
        espi->regs_base = devm_ioremap_resource(&pdev->dev, res);
        if (IS_ERR(espi->regs_base)) {
                error = PTR_ERR(espi->regs_base);
 -              goto fail_put_clock;
 +              goto fail_release_master;
        }
  
        error = devm_request_irq(&pdev->dev, irq, ep93xx_spi_interrupt,
                                0, "ep93xx-spi", espi);
        if (error) {
                dev_err(&pdev->dev, "failed to request irq\n");
 -              goto fail_put_clock;
 +              goto fail_release_master;
        }
  
        if (info->use_dma && ep93xx_spi_setup_dma(espi))
                dev_warn(&pdev->dev, "DMA setup failed. Falling back to PIO\n");
  
 -      espi->wq = create_singlethread_workqueue("ep93xx_spid");
 -      if (!espi->wq) {
 -              dev_err(&pdev->dev, "unable to create workqueue\n");
 -              error = -ENOMEM;
 -              goto fail_free_dma;
 -      }
 -      INIT_WORK(&espi->msg_work, ep93xx_spi_work);
 -      INIT_LIST_HEAD(&espi->msg_queue);
 -      espi->running = true;
 -
        /* make sure that the hardware is disabled */
        ep93xx_spi_write_u8(espi, SSPCR1, 0);
  
        error = spi_register_master(master);
        if (error) {
                dev_err(&pdev->dev, "failed to register SPI master\n");
 -              goto fail_free_queue;
 +              goto fail_free_dma;
        }
  
        dev_info(&pdev->dev, "EP93xx SPI Controller at 0x%08lx irq %d\n",
  
        return 0;
  
 -fail_free_queue:
 -      destroy_workqueue(espi->wq);
  fail_free_dma:
        ep93xx_spi_release_dma(espi);
 -fail_put_clock:
 -      clk_put(espi->clk);
  fail_release_master:
        spi_master_put(master);
  
@@@ -966,7 -1133,31 +966,7 @@@ static int ep93xx_spi_remove(struct pla
        struct spi_master *master = platform_get_drvdata(pdev);
        struct ep93xx_spi *espi = spi_master_get_devdata(master);
  
 -      spin_lock_irq(&espi->lock);
 -      espi->running = false;
 -      spin_unlock_irq(&espi->lock);
 -
 -      destroy_workqueue(espi->wq);
 -
 -      /*
 -       * Complete remaining messages with %-ESHUTDOWN status.
 -       */
 -      spin_lock_irq(&espi->lock);
 -      while (!list_empty(&espi->msg_queue)) {
 -              struct spi_message *msg;
 -
 -              msg = list_first_entry(&espi->msg_queue,
 -                                     struct spi_message, queue);
 -              list_del_init(&msg->queue);
 -              msg->status = -ESHUTDOWN;
 -              spin_unlock_irq(&espi->lock);
 -              msg->complete(msg->context);
 -              spin_lock_irq(&espi->lock);
 -      }
 -      spin_unlock_irq(&espi->lock);
 -
        ep93xx_spi_release_dma(espi);
 -      clk_put(espi->clk);
  
        spi_unregister_master(master);
        return 0;
index 85581f30794545b71afbf75e5d5b769a8b5761b6,de0976cf0ae2b24531e4accd1f042c889e55a814..dbc5e999a1f5689c1a526ace9f3dc4061f924223
@@@ -38,8 -38,7 +38,8 @@@ struct mpc512x_psc_spi 
        struct mpc512x_psc_fifo __iomem *fifo;
        unsigned int irq;
        u8 bits_per_word;
 -      u32 mclk;
 +      struct clk *clk_mclk;
 +      u32 mclk_rate;
  
        struct completion txisrdone;
  };
@@@ -73,7 -72,6 +73,7 @@@ static void mpc512x_psc_spi_activate_cs
        struct mpc52xx_psc __iomem *psc = mps->psc;
        u32 sicr;
        u32 ccr;
 +      int speed;
        u16 bclkdiv;
  
        sicr = in_be32(&psc->sicr);
  
        ccr = in_be32(&psc->ccr);
        ccr &= 0xFF000000;
 -      if (cs->speed_hz)
 -              bclkdiv = (mps->mclk / cs->speed_hz) - 1;
 -      else
 -              bclkdiv = (mps->mclk / 1000000) - 1;    /* default 1MHz */
 +      speed = cs->speed_hz;
 +      if (!speed)
 +              speed = 1000000;        /* default 1MHz */
 +      bclkdiv = (mps->mclk_rate / speed) - 1;
  
        ccr |= (((bclkdiv & 0xff) << 16) | (((bclkdiv >> 8) & 0xff) << 8));
        out_be32(&psc->ccr, ccr);
@@@ -388,11 -386,19 +388,11 @@@ static int mpc512x_psc_spi_port_config(
  {
        struct mpc52xx_psc __iomem *psc = mps->psc;
        struct mpc512x_psc_fifo __iomem *fifo = mps->fifo;
 -      struct clk *spiclk;
 -      int ret = 0;
 -      char name[32];
        u32 sicr;
        u32 ccr;
 +      int speed;
        u16 bclkdiv;
  
 -      sprintf(name, "psc%d_mclk", master->bus_num);
 -      spiclk = clk_get(&master->dev, name);
 -      clk_enable(spiclk);
 -      mps->mclk = clk_get_rate(spiclk);
 -      clk_put(spiclk);
 -
        /* Reset the PSC into a known state */
        out_8(&psc->command, MPC52xx_PSC_RST_RX);
        out_8(&psc->command, MPC52xx_PSC_RST_TX);
  
        ccr = in_be32(&psc->ccr);
        ccr &= 0xFF000000;
 -      bclkdiv = (mps->mclk / 1000000) - 1;    /* default 1MHz */
 +      speed = 1000000;        /* default 1MHz */
 +      bclkdiv = (mps->mclk_rate / speed) - 1;
        ccr |= (((bclkdiv & 0xff) << 16) | (((bclkdiv >> 8) & 0xff) << 8));
        out_be32(&psc->ccr, ccr);
  
  
        mps->bits_per_word = 8;
  
 -      return ret;
 +      return 0;
  }
  
  static irqreturn_t mpc512x_psc_spi_isr(int irq, void *dev_id)
@@@ -469,14 -474,11 +469,14 @@@ static int mpc512x_psc_spi_do_probe(str
                                              u32 size, unsigned int irq,
                                              s16 bus_num)
  {
-       struct fsl_spi_platform_data *pdata = dev->platform_data;
+       struct fsl_spi_platform_data *pdata = dev_get_platdata(dev);
        struct mpc512x_psc_spi *mps;
        struct spi_master *master;
        int ret;
        void *tempp;
 +      int psc_num;
 +      char clk_name[16];
 +      struct clk *clk;
  
        master = spi_alloc_master(dev, sizeof *mps);
        if (master == NULL)
                goto free_master;
        init_completion(&mps->txisrdone);
  
 +      psc_num = master->bus_num;
 +      snprintf(clk_name, sizeof(clk_name), "psc%d_mclk", psc_num);
 +      clk = devm_clk_get(dev, clk_name);
 +      if (IS_ERR(clk))
 +              goto free_irq;
 +      ret = clk_prepare_enable(clk);
 +      if (ret)
 +              goto free_irq;
 +      mps->clk_mclk = clk;
 +      mps->mclk_rate = clk_get_rate(clk);
 +
        ret = mpc512x_psc_spi_port_config(master, mps);
        if (ret < 0)
 -              goto free_irq;
 +              goto free_clock;
  
        ret = spi_register_master(master);
        if (ret < 0)
 -              goto free_irq;
 +              goto free_clock;
  
        return ret;
  
 +free_clock:
 +      clk_disable_unprepare(mps->clk_mclk);
  free_irq:
        free_irq(mps->irq, mps);
  free_master:
@@@ -558,7 -547,6 +558,7 @@@ static int mpc512x_psc_spi_do_remove(st
        struct mpc512x_psc_spi *mps = spi_master_get_devdata(master);
  
        spi_unregister_master(master);
 +      clk_disable_unprepare(mps->clk_mclk);
        free_irq(mps->irq, mps);
        if (mps->psc)
                iounmap(mps->psc);
diff --combined drivers/spi/spi-nuc900.c
index b21f8f20060a96b647f82d6a5099f15eb1796af9,e19a3074ac53358e6f9ff75631e2ce2fa9978e0a..47a68b43bcd5057f3fec2ffda5d2fe9c1dda0a9c
@@@ -174,6 -174,17 +174,6 @@@ static void nuc900_spi_gobusy(struct nu
        spin_unlock_irqrestore(&hw->lock, flags);
  }
  
 -static int nuc900_spi_setupxfer(struct spi_device *spi,
 -                               struct spi_transfer *t)
 -{
 -      return 0;
 -}
 -
 -static int nuc900_spi_setup(struct spi_device *spi)
 -{
 -      return 0;
 -}
 -
  static inline unsigned int hw_txbyte(struct nuc900_spi *hw, int count)
  {
        return hw->tx ? hw->tx[count] : 0;
@@@ -350,7 -361,7 +350,7 @@@ static int nuc900_spi_probe(struct plat
  
        hw = spi_master_get_devdata(master);
        hw->master = spi_master_get(master);
-       hw->pdata  = pdev->dev.platform_data;
+       hw->pdata  = dev_get_platdata(&pdev->dev);
        hw->dev = &pdev->dev;
  
        if (hw->pdata == NULL) {
        platform_set_drvdata(pdev, hw);
        init_completion(&hw->done);
  
 -      master->mode_bits          = SPI_MODE_0;
 +      master->mode_bits          = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
        master->num_chipselect     = hw->pdata->num_cs;
        master->bus_num            = hw->pdata->bus_num;
        hw->bitbang.master         = hw->master;
 -      hw->bitbang.setup_transfer = nuc900_spi_setupxfer;
        hw->bitbang.chipselect     = nuc900_spi_chipsel;
        hw->bitbang.txrx_bufs      = nuc900_spi_txrx;
 -      hw->bitbang.master->setup  = nuc900_spi_setup;
  
        hw->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (hw->res == NULL) {
index d36ba907743dc60c1f62dbe35013e9d34d1ed9af,8de5056c4ade4e561662222e496cb5b8b6bc1695..333cb1badcd73be1da1656196139040cce133096
@@@ -285,7 -285,7 +285,7 @@@ static int tiny_spi_of_probe(struct pla
  
  static int tiny_spi_probe(struct platform_device *pdev)
  {
-       struct tiny_spi_platform_data *platp = pdev->dev.platform_data;
+       struct tiny_spi_platform_data *platp = dev_get_platdata(&pdev->dev);
        struct tiny_spi *hw;
        struct spi_master *master;
        struct resource *res;
  
        /* find and map our resources */
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 -      if (!res)
 -              goto exit_busy;
 -      if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res),
 -                                   pdev->name))
 -              goto exit_busy;
 -      hw->base = devm_ioremap_nocache(&pdev->dev, res->start,
 -                                      resource_size(res));
 -      if (!hw->base)
 -              goto exit_busy;
 +      hw->base = devm_ioremap_resource(&pdev->dev, res);
 +      if (IS_ERR(hw->base)) {
 +              err = PTR_ERR(hw->base);
 +              goto exit;
 +      }
        /* irq is optional */
        hw->irq = platform_get_irq(pdev, 0);
        if (hw->irq >= 0) {
        if (platp) {
                hw->gpio_cs_count = platp->gpio_cs_count;
                hw->gpio_cs = platp->gpio_cs;
 -              if (platp->gpio_cs_count && !platp->gpio_cs)
 -                      goto exit_busy;
 +              if (platp->gpio_cs_count && !platp->gpio_cs) {
 +                      err = -EBUSY;
 +                      goto exit;
 +              }
                hw->freq = platp->freq;
                hw->baudwidth = platp->baudwidth;
        } else {
  exit_gpio:
        while (i-- > 0)
                gpio_free(hw->gpio_cs[i]);
 -exit_busy:
 -      err = -EBUSY;
  exit:
        spi_master_put(master);
        return err;
index cdcc72c5d380b3364936d377ddcc2f7f866829c6,b0e1d88f1635e66e63afd82ce95d108a4e03746c..69ecf05757dda6d5f8fc42f7718f7754af43f03c
  #define SPI_SHUTDOWN  1
  
  struct omap1_spi100k {
 -      struct work_struct      work;
 -
 -      /* lock protects queue and registers */
 -      spinlock_t              lock;
 -      struct list_head        msg_queue;
        struct spi_master       *master;
        struct clk              *ick;
        struct clk              *fck;
@@@ -99,6 -104,8 +99,6 @@@ struct omap1_spi100k_cs 
        int                     word_len;
  };
  
 -static struct workqueue_struct *omap1_spi100k_wq;
 -
  #define MOD_REG_BIT(val, mask, set) do { \
        if (set) \
                val |= mask; \
@@@ -303,102 -310,170 +303,102 @@@ static int omap1_spi100k_setup(struct s
  
        spi100k_open(spi->master);
  
 -      clk_enable(spi100k->ick);
 -      clk_enable(spi100k->fck);
 +      clk_prepare_enable(spi100k->ick);
 +      clk_prepare_enable(spi100k->fck);
  
        ret = omap1_spi100k_setup_transfer(spi, NULL);
  
 -      clk_disable(spi100k->ick);
 -      clk_disable(spi100k->fck);
 +      clk_disable_unprepare(spi100k->ick);
 +      clk_disable_unprepare(spi100k->fck);
  
        return ret;
  }
  
 -static void omap1_spi100k_work(struct work_struct *work)
 +static int omap1_spi100k_prepare_hardware(struct spi_master *master)
  {
 -      struct omap1_spi100k    *spi100k;
 -      int status = 0;
 +      struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
  
 -      spi100k = container_of(work, struct omap1_spi100k, work);
 -      spin_lock_irq(&spi100k->lock);
 +      clk_prepare_enable(spi100k->ick);
 +      clk_prepare_enable(spi100k->fck);
  
 -      clk_enable(spi100k->ick);
 -      clk_enable(spi100k->fck);
 +      return 0;
 +}
  
 -      /* We only enable one channel at a time -- the one whose message is
 -       * at the head of the queue -- although this controller would gladly
 -       * arbitrate among multiple channels.  This corresponds to "single
 -       * channel" master mode.  As a side effect, we need to manage the
 -       * chipselect with the FORCE bit ... CS != channel enable.
 -       */
 -       while (!list_empty(&spi100k->msg_queue)) {
 -              struct spi_message              *m;
 -              struct spi_device               *spi;
 -              struct spi_transfer             *t = NULL;
 -              int                             cs_active = 0;
 -              struct omap1_spi100k_cs         *cs;
 -              int                             par_override = 0;
 -
 -              m = container_of(spi100k->msg_queue.next, struct spi_message,
 -                               queue);
 -
 -              list_del_init(&m->queue);
 -              spin_unlock_irq(&spi100k->lock);
 -
 -              spi = m->spi;
 -              cs = spi->controller_state;
 -
 -              list_for_each_entry(t, &m->transfers, transfer_list) {
 -                      if (t->tx_buf == NULL && t->rx_buf == NULL && t->len) {
 -                              status = -EINVAL;
 +static int omap1_spi100k_transfer_one_message(struct spi_master *master,
 +                                            struct spi_message *m)
 +{
 +      struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
 +      struct spi_device *spi = m->spi;
 +      struct spi_transfer *t = NULL;
 +      int cs_active = 0;
 +      int par_override = 0;
 +      int status = 0;
 +
 +      list_for_each_entry(t, &m->transfers, transfer_list) {
 +              if (t->tx_buf == NULL && t->rx_buf == NULL && t->len) {
 +                      status = -EINVAL;
 +                      break;
 +              }
 +              if (par_override || t->speed_hz || t->bits_per_word) {
 +                      par_override = 1;
 +                      status = omap1_spi100k_setup_transfer(spi, t);
 +                      if (status < 0)
                                break;
 -                      }
 -                      if (par_override || t->speed_hz || t->bits_per_word) {
 -                              par_override = 1;
 -                              status = omap1_spi100k_setup_transfer(spi, t);
 -                              if (status < 0)
 -                                      break;
 -                              if (!t->speed_hz && !t->bits_per_word)
 -                                      par_override = 0;
 -                      }
 +                      if (!t->speed_hz && !t->bits_per_word)
 +                              par_override = 0;
 +              }
  
 -                      if (!cs_active) {
 -                              omap1_spi100k_force_cs(spi100k, 1);
 -                              cs_active = 1;
 -                      }
 +              if (!cs_active) {
 +                      omap1_spi100k_force_cs(spi100k, 1);
 +                      cs_active = 1;
 +              }
  
 -                      if (t->len) {
 -                              unsigned count;
 +              if (t->len) {
 +                      unsigned count;
  
 -                              count = omap1_spi100k_txrx_pio(spi, t);
 -                              m->actual_length += count;
 +                      count = omap1_spi100k_txrx_pio(spi, t);
 +                      m->actual_length += count;
  
 -                              if (count != t->len) {
 -                                      status = -EIO;
 -                                      break;
 -                              }
 +                      if (count != t->len) {
 +                              status = -EIO;
 +                              break;
                        }
 +              }
  
 -                      if (t->delay_usecs)
 -                              udelay(t->delay_usecs);
 +              if (t->delay_usecs)
 +                      udelay(t->delay_usecs);
  
 -                      /* ignore the "leave it on after last xfer" hint */
 +              /* ignore the "leave it on after last xfer" hint */
  
 -                      if (t->cs_change) {
 -                              omap1_spi100k_force_cs(spi100k, 0);
 -                              cs_active = 0;
 -                      }
 -              }
 -
 -              /* Restore defaults if they were overriden */
 -              if (par_override) {
 -                      par_override = 0;
 -                      status = omap1_spi100k_setup_transfer(spi, NULL);
 +              if (t->cs_change) {
 +                      omap1_spi100k_force_cs(spi100k, 0);
 +                      cs_active = 0;
                }
 +      }
  
 -              if (cs_active)
 -                      omap1_spi100k_force_cs(spi100k, 0);
 +      /* Restore defaults if they were overriden */
 +      if (par_override) {
 +              par_override = 0;
 +              status = omap1_spi100k_setup_transfer(spi, NULL);
 +      }
  
 -              m->status = status;
 -              m->complete(m->context);
 +      if (cs_active)
 +              omap1_spi100k_force_cs(spi100k, 0);
  
 -              spin_lock_irq(&spi100k->lock);
 -      }
 +      m->status = status;
  
 -      clk_disable(spi100k->ick);
 -      clk_disable(spi100k->fck);
 -      spin_unlock_irq(&spi100k->lock);
 +      spi_finalize_current_message(master);
  
 -      if (status < 0)
 -              printk(KERN_WARNING "spi transfer failed with %d\n", status);
 +      return status;
  }
  
 -static int omap1_spi100k_transfer(struct spi_device *spi, struct spi_message *m)
 +static int omap1_spi100k_unprepare_hardware(struct spi_master *master)
  {
 -      struct omap1_spi100k    *spi100k;
 -      unsigned long           flags;
 -      struct spi_transfer     *t;
 -
 -      m->actual_length = 0;
 -      m->status = -EINPROGRESS;
 -
 -      spi100k = spi_master_get_devdata(spi->master);
 -
 -      /* Don't accept new work if we're shutting down */
 -      if (spi100k->state == SPI_SHUTDOWN)
 -              return -ESHUTDOWN;
 -
 -      /* reject invalid messages and transfers */
 -      if (list_empty(&m->transfers) || !m->complete)
 -              return -EINVAL;
 -
 -      list_for_each_entry(t, &m->transfers, transfer_list) {
 -              const void      *tx_buf = t->tx_buf;
 -              void            *rx_buf = t->rx_buf;
 -              unsigned        len = t->len;
 -
 -              if (t->speed_hz > OMAP1_SPI100K_MAX_FREQ
 -                              || (len && !(rx_buf || tx_buf))) {
 -                      dev_dbg(&spi->dev, "transfer: %d Hz, %d %s%s, %d bpw\n",
 -                                      t->speed_hz,
 -                                      len,
 -                                      tx_buf ? "tx" : "",
 -                                      rx_buf ? "rx" : "",
 -                                      t->bits_per_word);
 -                      return -EINVAL;
 -              }
 -
 -              if (t->speed_hz && t->speed_hz < OMAP1_SPI100K_MAX_FREQ/(1<<16)) {
 -                      dev_dbg(&spi->dev, "%d Hz max exceeds %d\n",
 -                                      t->speed_hz,
 -                                      OMAP1_SPI100K_MAX_FREQ/(1<<16));
 -                      return -EINVAL;
 -              }
 -
 -      }
 -
 -      spin_lock_irqsave(&spi100k->lock, flags);
 -      list_add_tail(&m->queue, &spi100k->msg_queue);
 -      queue_work(omap1_spi100k_wq, &spi100k->work);
 -      spin_unlock_irqrestore(&spi100k->lock, flags);
 +      struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
  
 -      return 0;
 -}
 +      clk_disable_unprepare(spi100k->ick);
 +      clk_disable_unprepare(spi100k->fck);
  
 -static int omap1_spi100k_reset(struct omap1_spi100k *spi100k)
 -{
        return 0;
  }
  
@@@ -421,15 -496,11 +421,15 @@@ static int omap1_spi100k_probe(struct p
               master->bus_num = pdev->id;
  
        master->setup = omap1_spi100k_setup;
 -      master->transfer = omap1_spi100k_transfer;
 +      master->transfer_one_message = omap1_spi100k_transfer_one_message;
 +      master->prepare_transfer_hardware = omap1_spi100k_prepare_hardware;
 +      master->unprepare_transfer_hardware = omap1_spi100k_unprepare_hardware;
        master->cleanup = NULL;
        master->num_chipselect = 2;
        master->mode_bits = MODEBITS;
        master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
 +      master->min_speed_hz = OMAP1_SPI100K_MAX_FREQ/(1<<16);
 +      master->max_speed_hz = OMAP1_SPI100K_MAX_FREQ;
  
        platform_set_drvdata(pdev, master);
  
         * You should allocate this with ioremap() before initializing
         * the SPI.
         */
-       spi100k->base = (void __iomem *) pdev->dev.platform_data;
+       spi100k->base = (void __iomem *)dev_get_platdata(&pdev->dev);
  
 -      INIT_WORK(&spi100k->work, omap1_spi100k_work);
 -
 -      spin_lock_init(&spi100k->lock);
 -      INIT_LIST_HEAD(&spi100k->msg_queue);
 -      spi100k->ick = clk_get(&pdev->dev, "ick");
 +      spi100k->ick = devm_clk_get(&pdev->dev, "ick");
        if (IS_ERR(spi100k->ick)) {
                dev_dbg(&pdev->dev, "can't get spi100k_ick\n");
                status = PTR_ERR(spi100k->ick);
 -              goto err1;
 +              goto err;
        }
  
 -      spi100k->fck = clk_get(&pdev->dev, "fck");
 +      spi100k->fck = devm_clk_get(&pdev->dev, "fck");
        if (IS_ERR(spi100k->fck)) {
                dev_dbg(&pdev->dev, "can't get spi100k_fck\n");
                status = PTR_ERR(spi100k->fck);
 -              goto err2;
 +              goto err;
        }
  
 -      if (omap1_spi100k_reset(spi100k) < 0)
 -              goto err3;
 -
        status = spi_register_master(master);
        if (status < 0)
 -              goto err3;
 +              goto err;
  
        spi100k->state = SPI_RUNNING;
  
        return status;
  
 -err3:
 -      clk_put(spi100k->fck);
 -err2:
 -      clk_put(spi100k->ick);
 -err1:
 +err:
        spi_master_put(master);
        return status;
  }
@@@ -475,14 -557,33 +475,14 @@@ static int omap1_spi100k_remove(struct 
        struct spi_master       *master;
        struct omap1_spi100k    *spi100k;
        struct resource         *r;
 -      unsigned                limit = 500;
 -      unsigned long           flags;
        int                     status = 0;
  
        master = platform_get_drvdata(pdev);
        spi100k = spi_master_get_devdata(master);
  
 -      spin_lock_irqsave(&spi100k->lock, flags);
 -
 -      spi100k->state = SPI_SHUTDOWN;
 -      while (!list_empty(&spi100k->msg_queue) && limit--) {
 -              spin_unlock_irqrestore(&spi100k->lock, flags);
 -              msleep(10);
 -              spin_lock_irqsave(&spi100k->lock, flags);
 -      }
 -
 -      if (!list_empty(&spi100k->msg_queue))
 -              status = -EBUSY;
 -
 -      spin_unlock_irqrestore(&spi100k->lock, flags);
 -
        if (status != 0)
                return status;
  
 -      clk_put(spi100k->fck);
 -      clk_put(spi100k->ick);
 -
        r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  
        spi_unregister_master(master);
@@@ -495,11 -596,30 +495,11 @@@ static struct platform_driver omap1_spi
                .name           = "omap1_spi100k",
                .owner          = THIS_MODULE,
        },
 +      .probe          = omap1_spi100k_probe,
        .remove         = omap1_spi100k_remove,
  };
  
 -
 -static int __init omap1_spi100k_init(void)
 -{
 -      omap1_spi100k_wq = create_singlethread_workqueue(
 -                      omap1_spi100k_driver.driver.name);
 -
 -      if (omap1_spi100k_wq == NULL)
 -              return -1;
 -
 -      return platform_driver_probe(&omap1_spi100k_driver, omap1_spi100k_probe);
 -}
 -
 -static void __exit omap1_spi100k_exit(void)
 -{
 -      platform_driver_unregister(&omap1_spi100k_driver);
 -
 -      destroy_workqueue(omap1_spi100k_wq);
 -}
 -
 -module_init(omap1_spi100k_init);
 -module_exit(omap1_spi100k_exit);
 +module_platform_driver(omap1_spi100k_driver);
  
  MODULE_DESCRIPTION("OMAP7xx SPI 100k controller driver");
  MODULE_AUTHOR("Fabrice Crohas <fcrohas@gmail.com>");
diff --combined drivers/spi/spi-xilinx.c
index fb56fcfdf65e76b3110ea75bdbb6d9f61141cb93,08ea84a6eb3283418484d4012298271ec6ab77ae..0bf1b2c457a1dc6b71cc69641216ac6bb8b4a87b
@@@ -80,10 -80,9 +80,9 @@@ struct xilinx_spi 
        /* bitbang has to be first */
        struct spi_bitbang bitbang;
        struct completion done;
-       struct resource mem; /* phys mem */
        void __iomem    *regs;  /* virt. address of the control registers */
  
-       u32             irq;
+       int             irq;
  
        u8 *rx_ptr;             /* pointer in the Tx buffer */
        const u8 *tx_ptr;       /* pointer in the Rx buffer */
@@@ -233,6 -232,21 +232,6 @@@ static int xilinx_spi_setup_transfer(st
        return 0;
  }
  
 -static int xilinx_spi_setup(struct spi_device *spi)
 -{
 -      /* always return 0, we can not check the number of bits.
 -       * There are cases when SPI setup is called before any driver is
 -       * there, in that case the SPI core defaults to 8 bits, which we
 -       * do not support in some cases. But if we return an error, the
 -       * SPI device would not be registered and no driver can get hold of it
 -       * When the driver is there, it will call SPI setup again with the
 -       * correct number of bits per transfer.
 -       * If a driver setups with the wrong bit number, it will fail when
 -       * it tries to do a transfer
 -       */
 -      return 0;
 -}
 -
  static void xilinx_spi_fill_tx_fifo(struct xilinx_spi *xspi)
  {
        u8 sr;
@@@ -340,17 -354,34 +339,34 @@@ static const struct of_device_id xilinx
  };
  MODULE_DEVICE_TABLE(of, xilinx_spi_of_match);
  
- struct spi_master *xilinx_spi_init(struct device *dev, struct resource *mem,
-       u32 irq, s16 bus_num, int num_cs, int bits_per_word)
+ static int xilinx_spi_probe(struct platform_device *pdev)
  {
-       struct spi_master *master;
        struct xilinx_spi *xspi;
-       int ret;
+       struct xspi_platform_data *pdata;
+       struct resource *res;
+       int ret, num_cs = 0, bits_per_word = 8;
+       struct spi_master *master;
        u32 tmp;
+       u8 i;
+       pdata = dev_get_platdata(&pdev->dev);
+       if (pdata) {
+               num_cs = pdata->num_chipselect;
+               bits_per_word = pdata->bits_per_word;
+       } else {
+               of_property_read_u32(pdev->dev.of_node, "xlnx,num-ss-bits",
+                                         &num_cs);
+       }
  
-       master = spi_alloc_master(dev, sizeof(struct xilinx_spi));
+       if (!num_cs) {
+               dev_err(&pdev->dev,
+                       "Missing slave select configuration data\n");
+               return -EINVAL;
+       }
+       master = spi_alloc_master(&pdev->dev, sizeof(struct xilinx_spi));
        if (!master)
-               return NULL;
+               return -ENODEV;
  
        /* the spi->mode bits understood by this driver: */
        master->mode_bits = SPI_CPOL | SPI_CPHA;
        xspi->bitbang.chipselect = xilinx_spi_chipselect;
        xspi->bitbang.setup_transfer = xilinx_spi_setup_transfer;
        xspi->bitbang.txrx_bufs = xilinx_spi_txrx_bufs;
 -      xspi->bitbang.master->setup = xilinx_spi_setup;
        init_completion(&xspi->done);
  
-       if (!request_mem_region(mem->start, resource_size(mem),
-               XILINX_SPI_NAME))
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       xspi->regs = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(xspi->regs)) {
+               ret = PTR_ERR(xspi->regs);
                goto put_master;
-       xspi->regs = ioremap(mem->start, resource_size(mem));
-       if (xspi->regs == NULL) {
-               dev_warn(dev, "ioremap failure\n");
-               goto map_failed;
        }
  
-       master->bus_num = bus_num;
+       master->bus_num = pdev->dev.id;
        master->num_chipselect = num_cs;
-       master->dev.of_node = dev->of_node;
-       xspi->mem = *mem;
-       xspi->irq = irq;
+       master->dev.of_node = pdev->dev.of_node;
  
        /*
         * Detect endianess on the IP via loop bit in CR. Detection
        } else if (xspi->bits_per_word == 32) {
                xspi->tx_fn = xspi_tx32;
                xspi->rx_fn = xspi_rx32;
-       } else
-               goto unmap_io;
+       } else {
+               ret = -EINVAL;
+               goto put_master;
+       }
  
        /* SPI controller initializations */
        xspi_init_hw(xspi);
  
+       xspi->irq = platform_get_irq(pdev, 0);
+       if (xspi->irq < 0) {
+               ret = xspi->irq;
+               goto put_master;
+       }
        /* Register for SPI Interrupt */
-       ret = request_irq(xspi->irq, xilinx_spi_irq, 0, XILINX_SPI_NAME, xspi);
+       ret = devm_request_irq(&pdev->dev, xspi->irq, xilinx_spi_irq, 0,
+                              dev_name(&pdev->dev), xspi);
        if (ret)
-               goto unmap_io;
+               goto put_master;
  
        ret = spi_bitbang_start(&xspi->bitbang);
        if (ret) {
-               dev_err(dev, "spi_bitbang_start FAILED\n");
-               goto free_irq;
-       }
-       dev_info(dev, "at 0x%08llX mapped to 0x%p, irq=%d\n",
-               (unsigned long long)mem->start, xspi->regs, xspi->irq);
-       return master;
- free_irq:
-       free_irq(xspi->irq, xspi);
- unmap_io:
-       iounmap(xspi->regs);
- map_failed:
-       release_mem_region(mem->start, resource_size(mem));
- put_master:
-       spi_master_put(master);
-       return NULL;
- }
- EXPORT_SYMBOL(xilinx_spi_init);
- void xilinx_spi_deinit(struct spi_master *master)
- {
-       struct xilinx_spi *xspi;
-       xspi = spi_master_get_devdata(master);
-       spi_bitbang_stop(&xspi->bitbang);
-       free_irq(xspi->irq, xspi);
-       iounmap(xspi->regs);
-       release_mem_region(xspi->mem.start, resource_size(&xspi->mem));
-       spi_master_put(xspi->bitbang.master);
- }
- EXPORT_SYMBOL(xilinx_spi_deinit);
- static int xilinx_spi_probe(struct platform_device *dev)
- {
-       struct xspi_platform_data *pdata;
-       struct resource *r;
-       int irq, num_cs = 0, bits_per_word = 8;
-       struct spi_master *master;
-       u8 i;
-       pdata = dev->dev.platform_data;
-       if (pdata) {
-               num_cs = pdata->num_chipselect;
-               bits_per_word = pdata->bits_per_word;
-       }
- #ifdef CONFIG_OF
-       if (dev->dev.of_node) {
-               const __be32 *prop;
-               int len;
-               /* number of slave select bits is required */
-               prop = of_get_property(dev->dev.of_node, "xlnx,num-ss-bits",
-                                      &len);
-               if (prop && len >= sizeof(*prop))
-                       num_cs = __be32_to_cpup(prop);
-       }
- #endif
-       if (!num_cs) {
-               dev_err(&dev->dev, "Missing slave select configuration data\n");
-               return -EINVAL;
+               dev_err(&pdev->dev, "spi_bitbang_start FAILED\n");
+               goto put_master;
        }
  
-       r = platform_get_resource(dev, IORESOURCE_MEM, 0);
-       if (!r)
-               return -ENODEV;
-       irq = platform_get_irq(dev, 0);
-       if (irq < 0)
-               return -ENXIO;
-       master = xilinx_spi_init(&dev->dev, r, irq, dev->id, num_cs,
-                                bits_per_word);
-       if (!master)
-               return -ENODEV;
+       dev_info(&pdev->dev, "at 0x%08llX mapped to 0x%p, irq=%d\n",
+               (unsigned long long)res->start, xspi->regs, xspi->irq);
  
        if (pdata) {
                for (i = 0; i < pdata->num_devices; i++)
                        spi_new_device(master, pdata->devices + i);
        }
  
-       platform_set_drvdata(dev, master);
+       platform_set_drvdata(pdev, master);
        return 0;
+ put_master:
+       spi_master_put(master);
+       return ret;
  }
  
- static int xilinx_spi_remove(struct platform_device *dev)
+ static int xilinx_spi_remove(struct platform_device *pdev)
  {
-       xilinx_spi_deinit(platform_get_drvdata(dev));
+       struct spi_master *master = platform_get_drvdata(pdev);
+       struct xilinx_spi *xspi = spi_master_get_devdata(master);
+       void __iomem *regs_base = xspi->regs;
+       spi_bitbang_stop(&xspi->bitbang);
+       /* Disable all the interrupts just in case */
+       xspi->write_fn(0, regs_base + XIPIF_V123B_IIER_OFFSET);
+       /* Disable the global IPIF interrupt */
+       xspi->write_fn(0, regs_base + XIPIF_V123B_DGIER_OFFSET);
+       spi_master_put(xspi->bitbang.master);
  
        return 0;
  }