All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi/rockchip: avoid uninitialized-use warning
@ 2015-01-28 13:25 ` Arnd Bergmann
  0 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2015-01-28 13:25 UTC (permalink / raw)
  To: Mark Brown; +Cc: Addy Ke, Doug Anderson, linux-arm-kernel, linux-spi

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>

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)
 	rs->state &= ~TXBUSY;
 	spin_unlock_irqrestore(&rs->lock, flags);
 
+	rxdesc = NULL;
 	if (rs->rx) {
 		rxconf.direction = rs->dma_rx.direction;
 		rxconf.src_addr = rs->dma_rx.addr;
@@ -453,6 +454,7 @@ static void rockchip_spi_prepare_dma(struct rockchip_spi *rs)
 		rxdesc->callback_param = rs;
 	}
 
+	txdesc = NULL;
 	if (rs->tx) {
 		txconf.direction = rs->dma_tx.direction;
 		txconf.dst_addr = rs->dma_tx.addr;
@@ -470,7 +472,7 @@ static void rockchip_spi_prepare_dma(struct rockchip_spi *rs)
 	}
 
 	/* rx must be started before tx due to spi instinct */
-	if (rs->rx) {
+	if (rxdesc) {
 		spin_lock_irqsave(&rs->lock, flags);
 		rs->state |= RXBUSY;
 		spin_unlock_irqrestore(&rs->lock, flags);
@@ -478,7 +480,7 @@ static void rockchip_spi_prepare_dma(struct rockchip_spi *rs)
 		dma_async_issue_pending(rs->dma_rx.ch);
 	}
 
-	if (rs->tx) {
+	if (txdesc) {
 		spin_lock_irqsave(&rs->lock, flags);
 		rs->state |= TXBUSY;
 		spin_unlock_irqrestore(&rs->lock, flags);

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

* [PATCH] spi/rockchip: avoid uninitialized-use warning
@ 2015-01-28 13:25 ` Arnd Bergmann
  0 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2015-01-28 13:25 UTC (permalink / raw)
  To: linux-arm-kernel

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>

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)
 	rs->state &= ~TXBUSY;
 	spin_unlock_irqrestore(&rs->lock, flags);
 
+	rxdesc = NULL;
 	if (rs->rx) {
 		rxconf.direction = rs->dma_rx.direction;
 		rxconf.src_addr = rs->dma_rx.addr;
@@ -453,6 +454,7 @@ static void rockchip_spi_prepare_dma(struct rockchip_spi *rs)
 		rxdesc->callback_param = rs;
 	}
 
+	txdesc = NULL;
 	if (rs->tx) {
 		txconf.direction = rs->dma_tx.direction;
 		txconf.dst_addr = rs->dma_tx.addr;
@@ -470,7 +472,7 @@ static void rockchip_spi_prepare_dma(struct rockchip_spi *rs)
 	}
 
 	/* rx must be started before tx due to spi instinct */
-	if (rs->rx) {
+	if (rxdesc) {
 		spin_lock_irqsave(&rs->lock, flags);
 		rs->state |= RXBUSY;
 		spin_unlock_irqrestore(&rs->lock, flags);
@@ -478,7 +480,7 @@ static void rockchip_spi_prepare_dma(struct rockchip_spi *rs)
 		dma_async_issue_pending(rs->dma_rx.ch);
 	}
 
-	if (rs->tx) {
+	if (txdesc) {
 		spin_lock_irqsave(&rs->lock, flags);
 		rs->state |= TXBUSY;
 		spin_unlock_irqrestore(&rs->lock, flags);

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

* [PATCH] spi: pl08x: do not select S3C64XX_PL080
  2015-01-28 13:25 ` Arnd Bergmann
@ 2015-01-28 13:27   ` Arnd Bergmann
  -1 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2015-01-28 13:27 UTC (permalink / raw)
  To: Mark Brown, linux-samsung-soc; +Cc: linux-arm-kernel, linux-spi

The pl08x driver originally selected S3C64XX_PL080 to avoid having
the legacy Samsung DMA interfaces. Those are now gone, so the
select is no longer needed, but it now causes problems when
CONFIG_DMA_ENGINE is disabled:

arch/arm/plat-samsung/built-in.o: In function `s3c64xx_spi0_set_platdata':
:(.init.text+0x518): undefined reference to `pl08x_filter_id'

This simply removes the 'select' to avoid this problem.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 9b81b39de54e..7727660e9702 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -470,7 +470,6 @@ config SPI_S3C24XX_FIQ
 config SPI_S3C64XX
 	tristate "Samsung S3C64XX series type SPI"
 	depends on (PLAT_SAMSUNG || ARCH_EXYNOS)
-	select S3C64XX_PL080 if ARCH_S3C64XX
 	help
 	  SPI driver for Samsung S3C64XX and newer SoCs.

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

* [PATCH] spi: pl08x: do not select S3C64XX_PL080
@ 2015-01-28 13:27   ` Arnd Bergmann
  0 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2015-01-28 13:27 UTC (permalink / raw)
  To: linux-arm-kernel

The pl08x driver originally selected S3C64XX_PL080 to avoid having
the legacy Samsung DMA interfaces. Those are now gone, so the
select is no longer needed, but it now causes problems when
CONFIG_DMA_ENGINE is disabled:

arch/arm/plat-samsung/built-in.o: In function `s3c64xx_spi0_set_platdata':
:(.init.text+0x518): undefined reference to `pl08x_filter_id'

This simply removes the 'select' to avoid this problem.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 9b81b39de54e..7727660e9702 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -470,7 +470,6 @@ config SPI_S3C24XX_FIQ
 config SPI_S3C64XX
 	tristate "Samsung S3C64XX series type SPI"
 	depends on (PLAT_SAMSUNG || ARCH_EXYNOS)
-	select S3C64XX_PL080 if ARCH_S3C64XX
 	help
 	  SPI driver for Samsung S3C64XX and newer SoCs.
 

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

* Re: [PATCH] spi/rockchip: avoid uninitialized-use warning
  2015-01-28 13:25 ` Arnd Bergmann
@ 2015-01-28 17:36   ` Mark Brown
  -1 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2015-01-28 17:36 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Addy Ke, Doug Anderson, linux-arm-kernel, linux-spi


[-- Attachment #1.1: Type: text/plain, Size: 222 bytes --]

On Wed, Jan 28, 2015 at 02:25:10PM +0100, Arnd Bergmann wrote:
> We currently get a warning about potentially uninitialized variables
> in the rockchip spi driver, at least in certain toolchain versions:

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH] spi/rockchip: avoid uninitialized-use warning
@ 2015-01-28 17:36   ` Mark Brown
  0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2015-01-28 17:36 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jan 28, 2015 at 02:25:10PM +0100, Arnd Bergmann wrote:
> We currently get a warning about potentially uninitialized variables
> in the rockchip spi driver, at least in certain toolchain versions:

Applied, thanks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150128/82d194a8/attachment.sig>

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

* Re: [PATCH] spi: pl08x: do not select S3C64XX_PL080
  2015-01-28 13:27   ` Arnd Bergmann
@ 2015-01-28 17:37     ` Mark Brown
  -1 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2015-01-28 17:37 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-samsung-soc, linux-arm-kernel, linux-spi


[-- Attachment #1.1: Type: text/plain, Size: 309 bytes --]

On Wed, Jan 28, 2015 at 02:27:06PM +0100, Arnd Bergmann wrote:
> The pl08x driver originally selected S3C64XX_PL080 to avoid having
> the legacy Samsung DMA interfaces. Those are now gone, so the
> select is no longer needed, but it now causes problems when
> CONFIG_DMA_ENGINE is disabled:

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH] spi: pl08x: do not select S3C64XX_PL080
@ 2015-01-28 17:37     ` Mark Brown
  0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2015-01-28 17:37 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jan 28, 2015 at 02:27:06PM +0100, Arnd Bergmann wrote:
> The pl08x driver originally selected S3C64XX_PL080 to avoid having
> the legacy Samsung DMA interfaces. Those are now gone, so the
> select is no longer needed, but it now causes problems when
> CONFIG_DMA_ENGINE is disabled:

Applied, thanks.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150128/df81a75a/attachment.sig>

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

end of thread, other threads:[~2015-01-28 17:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-28 13:25 [PATCH] spi/rockchip: avoid uninitialized-use warning Arnd Bergmann
2015-01-28 13:25 ` Arnd Bergmann
2015-01-28 13:27 ` [PATCH] spi: pl08x: do not select S3C64XX_PL080 Arnd Bergmann
2015-01-28 13:27   ` Arnd Bergmann
2015-01-28 17:37   ` Mark Brown
2015-01-28 17:37     ` Mark Brown
2015-01-28 17:36 ` [PATCH] spi/rockchip: avoid uninitialized-use warning Mark Brown
2015-01-28 17:36   ` Mark Brown

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.