[bug report] spi: stm32_qspi: Add transfer_one_message() spi callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Patrice Chotard,

The patch a557fca630cc: "spi: stm32_qspi: Add transfer_one_message()
spi callback" from Aug 23, 2022, leads to the following Smatch static
checker warning:

	drivers/spi/spi-stm32-qspi.c:627 stm32_qspi_transfer_one_message()
	error: uninitialized symbol 'ret'.

drivers/spi/spi-stm32-qspi.c
    558 static int stm32_qspi_transfer_one_message(struct spi_controller *ctrl,
    559                                            struct spi_message *msg)
    560 {
    561         struct stm32_qspi *qspi = spi_controller_get_devdata(ctrl);
    562         struct spi_transfer *transfer;
    563         struct spi_device *spi = msg->spi;
    564         struct spi_mem_op op;
    565         int ret;
    566 
    567         if (!spi->cs_gpiod)
    568                 return -EOPNOTSUPP;
    569 
    570         mutex_lock(&qspi->lock);
    571 
    572         gpiod_set_value_cansleep(spi->cs_gpiod, true);
    573 
    574         list_for_each_entry(transfer, &msg->transfers, transfer_list) {
    575                 u8 dummy_bytes = 0;
    576 
    577                 memset(&op, 0, sizeof(op));
    578 
    579                 dev_dbg(qspi->dev, "tx_buf:%p tx_nbits:%d rx_buf:%p rx_nbits:%d len:%d dummy_data:%d\n",
    580                         transfer->tx_buf, transfer->tx_nbits,
    581                         transfer->rx_buf, transfer->rx_nbits,
    582                         transfer->len, transfer->dummy_data);
    583 
    584                 /*
    585                  * QSPI hardware supports dummy bytes transfer.
    586                  * If current transfer is dummy byte, merge it with the next
    587                  * transfer in order to take into account QSPI block constraint
    588                  */
    589                 if (transfer->dummy_data) {
    590                         op.dummy.buswidth = transfer->tx_nbits;
    591                         op.dummy.nbytes = transfer->len;
    592                         dummy_bytes = transfer->len;
    593 
    594                         /* if happens, means that message is not correctly built */
    595                         if (list_is_last(&transfer->transfer_list, &msg->transfers))
    596                                 goto end_of_transfer;

The comments suggest this should be an error path.

    597 
    598                         transfer = list_next_entry(transfer, transfer_list);
    599                 }
    600 
    601                 op.data.nbytes = transfer->len;
    602 
    603                 if (transfer->rx_buf) {
    604                         qspi->fmode = CCR_FMODE_INDR;
    605                         op.data.buswidth = transfer->rx_nbits;
    606                         op.data.dir = SPI_MEM_DATA_IN;
    607                         op.data.buf.in = transfer->rx_buf;
    608                 } else {
    609                         qspi->fmode = CCR_FMODE_INDW;
    610                         op.data.buswidth = transfer->tx_nbits;
    611                         op.data.dir = SPI_MEM_DATA_OUT;
    612                         op.data.buf.out = transfer->tx_buf;
    613                 }
    614 
    615                 ret = stm32_qspi_send(spi, &op);
    616                 if (ret)
    617                         goto end_of_transfer;
    618 
    619                 msg->actual_length += transfer->len + dummy_bytes;
    620         }
    621 
    622 end_of_transfer:
    623         gpiod_set_value_cansleep(spi->cs_gpiod, false);
    624 
    625         mutex_unlock(&qspi->lock);
    626 
--> 627         msg->status = ret;
    628         spi_finalize_current_message(ctrl);
    629 
    630         return ret;
    631 }

regards,
dan carpenter



[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux