aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2015-01-28 08:25:10 -0500
committerMark Brown <broonie@kernel.org>2015-01-28 12:36:37 -0500
commit97cf56697a31e083c04aa3ec30710f24bbdac86f (patch)
tree1e85e3fc8d79fa854451f4825be029ff71f434fe /drivers/spi
parent97bf6af1f928216fd6c5a66e8a57bfa95a659672 (diff)
spi/rockchip: avoid uninitialized-use warning
We currently get a warning about potentially uninitialized variables in the rockchip spi driver, at least in certain toolchain versions: spi/spi-rockchip.c: In function 'rockchip_spi_prepare_dma': include/linux/dmaengine.h:796:2: warning: 'txdesc' may be used uninitialized in this function include/linux/dmaengine.h:796:2: warning: 'rxdesc' may be used uninitialized in this function The reason seems to be that gcc cannot know whether the value of the rs->rx and rs->tx variables change between the two points these are accessed. The code is actually correct, but to make this clearer to the compiler, this changes the conditionals to test for the local rxdesc/txdesc variables instead, which it knows won't change. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-rockchip.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index daabbabd26b0..1a777dc261d6 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -437,6 +437,7 @@ static void rockchip_spi_prepare_dma(struct rockchip_spi *rs)
437 rs->state &= ~TXBUSY; 437 rs->state &= ~TXBUSY;
438 spin_unlock_irqrestore(&rs->lock, flags); 438 spin_unlock_irqrestore(&rs->lock, flags);
439 439
440 rxdesc = NULL;
440 if (rs->rx) { 441 if (rs->rx) {
441 rxconf.direction = rs->dma_rx.direction; 442 rxconf.direction = rs->dma_rx.direction;
442 rxconf.src_addr = rs->dma_rx.addr; 443 rxconf.src_addr = rs->dma_rx.addr;
@@ -453,6 +454,7 @@ static void rockchip_spi_prepare_dma(struct rockchip_spi *rs)
453 rxdesc->callback_param = rs; 454 rxdesc->callback_param = rs;
454 } 455 }
455 456
457 txdesc = NULL;
456 if (rs->tx) { 458 if (rs->tx) {
457 txconf.direction = rs->dma_tx.direction; 459 txconf.direction = rs->dma_tx.direction;
458 txconf.dst_addr = rs->dma_tx.addr; 460 txconf.dst_addr = rs->dma_tx.addr;
@@ -470,7 +472,7 @@ static void rockchip_spi_prepare_dma(struct rockchip_spi *rs)
470 } 472 }
471 473
472 /* rx must be started before tx due to spi instinct */ 474 /* rx must be started before tx due to spi instinct */
473 if (rs->rx) { 475 if (rxdesc) {
474 spin_lock_irqsave(&rs->lock, flags); 476 spin_lock_irqsave(&rs->lock, flags);
475 rs->state |= RXBUSY; 477 rs->state |= RXBUSY;
476 spin_unlock_irqrestore(&rs->lock, flags); 478 spin_unlock_irqrestore(&rs->lock, flags);
@@ -478,7 +480,7 @@ static void rockchip_spi_prepare_dma(struct rockchip_spi *rs)
478 dma_async_issue_pending(rs->dma_rx.ch); 480 dma_async_issue_pending(rs->dma_rx.ch);
479 } 481 }
480 482
481 if (rs->tx) { 483 if (txdesc) {
482 spin_lock_irqsave(&rs->lock, flags); 484 spin_lock_irqsave(&rs->lock, flags);
483 rs->state |= TXBUSY; 485 rs->state |= TXBUSY;
484 spin_unlock_irqrestore(&rs->lock, flags); 486 spin_unlock_irqrestore(&rs->lock, flags);