-+ struct mt7621_spi *rs = spi_master_get_devdata(master);
-+ struct spi_device *spi = m->spi;
-+ unsigned int speed = spi->max_speed_hz;
-+ struct spi_transfer *t = NULL;
-+ int status = 0;
-+ int i, len = 0;
-+ int rx_len = 0;
-+ u32 data[9] = { 0 };
-+ u32 val;
-+
-+ mt7621_spi_wait_till_ready(spi);
-+
-+ list_for_each_entry(t, &m->transfers, transfer_list) {
-+ const u8 *buf = t->tx_buf;
-+
-+ if (t->rx_buf)
-+ rx_len += t->len;
-+
-+ if (!buf)
-+ continue;
-+
-+ if (t->speed_hz < speed)
-+ speed = t->speed_hz;
-+
-+ /*
-+ * m25p80 might attempt to write more data than we can handle.
-+ * truncate the message to what we can fit into the registers
-+ */
-+ if (len + t->len > 36)
-+ t->len = 36 - len;
++ int tx_len;
++
++ /*
++ * Combine with any pending write, and perform one or more half-duplex
++ * transactions reading 'len' bytes. Data to be written is already in
++ * MT7621_SPI_DATA.
++ */
++ tx_len = rs->pending_write;
++ rs->pending_write = 0;
++
++ while (rx_len || tx_len) {
++ int i;
++ u32 val = (min(tx_len, 4) * 8) << 24;
++ int rx = min(rx_len, 32);
++
++ if (tx_len > 4)
++ val |= (tx_len - 4) * 8;
++ val |= (rx * 8) << 12;
++ mt7621_spi_write(rs, MT7621_SPI_MOREBUF, val);
++
++ tx_len = 0;
++
++ val = mt7621_spi_read(rs, MT7621_SPI_TRANS);
++ val |= SPI_CTL_START;
++ mt7621_spi_write(rs, MT7621_SPI_TRANS, val);
++
++ mt7621_spi_wait_till_ready(rs);
++
++ for (i = 0; i < rx; i++) {
++ if ((i % 4) == 0)
++ val = mt7621_spi_read(rs, MT7621_SPI_DATA0 + i);
++ *buf++ = val & 0xff;
++ val >>= 8;
++ }