static int zynq_qspi_transfer(struct spi_device *qspi, struct spi_transfer *transfer) { struct zynq_qspi *zqspi = &qspi->master; unsigned cs_change = 1; int status = 0; debug("%s\n", __func__); while (1) { if (transfer->bits_per_word || transfer->speed_hz) { status = zynq_qspi_setup_transfer(qspi, transfer); if (status < 0) break; } /* Select the chip if required */ if (cs_change) zynq_qspi_chipselect(qspi, 1); cs_change = transfer->cs_change; if (!transfer->tx_buf && !transfer->rx_buf && transfer->len) { status = -1; break; } /* Request the transfer */ if (transfer->len) { status = zynq_qspi_start_transfer(qspi, transfer); zqspi->is_inst = 0; } if (status != transfer->len) { if (status > 0) status = -EMSGSIZE; break; } status = 0; if (transfer->delay_usecs) udelay(transfer->delay_usecs); if (cs_change) /* Deselect the chip */ zynq_qspi_chipselect(qspi, 0); break; } zynq_qspi_setup_transfer(qspi, NULL); return 0; }
static int zynq_qspi_transfer(struct zynq_qspi_priv *priv) { unsigned cs_change = 1; int status = 0; debug("%s\n", __func__); while (1) { /* Select the chip if required */ if (cs_change) zynq_qspi_chipselect(priv, 1); cs_change = priv->cs_change; if (!priv->txbuf && !priv->rxbuf && priv->len) { status = -1; break; } /* Request the transfer */ if (priv->len) { status = zynq_qspi_start_transfer(priv); priv->is_inst = 0; } if (status != priv->len) { if (status > 0) status = -EMSGSIZE; debug("zynq_qspi_transfer:%d len:%d\n", status, priv->len); break; } status = 0; if (cs_change) /* Deselect the chip */ zynq_qspi_chipselect(priv, 0); break; } return 0; }