From: Dan Carpenter <dan.carpenter@oracle.com>
To: patrice.chotard@foss.st.com
Cc: linux-spi@vger.kernel.org
Subject: [bug report] spi: stm32_qspi: Add transfer_one_message() spi callback
Date: Thu, 25 Aug 2022 19:09:06 +0300 [thread overview]
Message-ID: <Yweeol1yneu0FI+E@kili> (raw)
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
reply other threads:[~2022-08-25 16:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Yweeol1yneu0FI+E@kili \
--to=dan.carpenter@oracle.com \
--cc=linux-spi@vger.kernel.org \
--cc=patrice.chotard@foss.st.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.