linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spi: Fix warning for Clang build
@ 2022-02-10  2:36 Li-hao Kuo
  2022-02-10 11:17 ` Mark Brown
  0 siblings, 1 reply; 8+ messages in thread
From: Li-hao Kuo @ 2022-02-10  2:36 UTC (permalink / raw)
  To: broonie, linux-spi, linux-kernel; +Cc: wells.lu, lh.kuo, trix, Li-hao Kuo

Clang build fails with
spi-sunplus-sp7021.c:405:2: error: variable 'ret' is used
  uninitialized whenever switch default is taken
        default:

Restore initializing ret. and add return error at default

Fixes: 47e8fe57a66f ("spi: Modify irq request position and modify parameters")
Reported-by: Tom Rix <trix@redhat.com>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Li-hao Kuo <lhjeff911@gmail.com>
---
 drivers/spi/spi-sunplus-sp7021.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-sunplus-sp7021.c b/drivers/spi/spi-sunplus-sp7021.c
index ba5ed9f..460993a 100644
--- a/drivers/spi/spi-sunplus-sp7021.c
+++ b/drivers/spi/spi-sunplus-sp7021.c
@@ -375,7 +375,7 @@ static int sp7021_spi_slave_transfer_one(struct spi_controller *ctlr, struct spi
 {
 	struct sp7021_spi_ctlr *pspim = spi_master_get_devdata(ctlr);
 	struct device *dev = pspim->dev;
-	int mode, ret;
+	int mode, ret = 0;
 
 	mode = SP7021_SPI_IDLE;
 	if (xfer->tx_buf && xfer->rx_buf) {
@@ -403,7 +403,7 @@ static int sp7021_spi_slave_transfer_one(struct spi_controller *ctlr, struct spi
 		ret = sp7021_spi_slave_rx(spi, xfer);
 		break;
 	default:
-		break;
+		return -EINVAL;
 	}
 	if (xfer->tx_buf)
 		dma_unmap_single(dev, xfer->tx_dma, xfer->len, DMA_TO_DEVICE);
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-02-14  2:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-10  2:36 [PATCH] spi: Fix warning for Clang build Li-hao Kuo
2022-02-10 11:17 ` Mark Brown
2022-02-11  3:32   ` Lh Kuo 郭力豪
2022-02-11  4:49     ` Tom Rix
2022-02-11  4:59       ` Lh Kuo 郭力豪
2022-02-11 11:57         ` Mark Brown
2022-02-13 18:11         ` Nathan Chancellor
2022-02-14  2:23           ` Lh Kuo 郭力豪

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).