Skip to contentSkip to conversation

dma: bcm2835: Fix compiler warning on arm64.

PATCH In review Eric Anholt 2 participants 3 messages Jun 4, 2016 – Jun 6, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma: bcm2835: Fix compiler warning on arm64.

The min() macro was complaining about mismatched types. The max len is at most SZ_1G, so we can just put it in an unsigned int.

---

Vinod, if you ack it, this one would be nice to be able to merge through the -soc tree, so that when we enable of arm64 builds of this driver we don't introduce a new compiler warning.

 drivers/dma/bcm2835-dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/bcm2835-dma.c +1 -1
index 6149b27c33ad..1fa11fc067c6 100644
@@ -393,7 +393,7 @@ static void bcm2835_dma_fill_cb_chain_with_sg(
 	unsigned int sg_len)
 {
 	struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
-	size_t max_len = bcm2835_dma_max_frame_length(c);
+	unsigned int max_len = bcm2835_dma_max_frame_length(c);
 	unsigned int i, len;
 	dma_addr_t addr;
 	struct scatterlist *sgent;
Signature · 1 line
2.8.0.rc3
#1 lore raw
Quoted 18 lines · Eric Anholt

The min() macro was complaining about mismatched types. The max len is at most SZ_1G, so we can just put it in an unsigned int.

---

Vinod, if you ack it, this one would be nice to be able to merge through the -soc tree, so that when we enable of arm64 builds of this driver we don't introduce a new compiler warning.

 drivers/dma/bcm2835-dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/bcm2835-dma.c +0 -0
index 6149b27c33ad..1fa11fc067c6 100644

drivers/dma/bcm2835-dma.c static void bcm2835_dma_fill_cb_chain_with_sg( · line 396

Quoted 5 lines
drivers/dma/bcm2835-dma.c +1 -1
@@ -393,7 +393,7 @@ static void bcm2835_dma_fill_cb_chain_with_sg(
 	unsigned int sg_len)
 {
 	struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
-	size_t max_len = bcm2835_dma_max_frame_length(c);
+	unsigned int max_len = bcm2835_dma_max_frame_length(c);

bcm2835_dma_max_frame_length() returns size_t. so this should also add a complain about type mismatch as well!

Also, wouldn't it be better to make both args of min() as size_t then?

Quoted 6 lines
drivers/dma/bcm2835-dma.c +0 -0
 	unsigned int i, len;
 	dma_addr_t addr;
 	struct scatterlist *sgent;
Signature · 1 line
2.8.0.rc3

Thanks

Signature · 1 line
~Vinod
#2 lore raw
Quoted 28 lines · Vinod Koul
Quoted 18 lines · Eric Anholt

The min() macro was complaining about mismatched types. The max len is at most SZ_1G, so we can just put it in an unsigned int.

---

Vinod, if you ack it, this one would be nice to be able to merge through the -soc tree, so that when we enable of arm64 builds of this driver we don't introduce a new compiler warning.

 drivers/dma/bcm2835-dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/bcm2835-dma.c +0 -0
index 6149b27c33ad..1fa11fc067c6 100644

drivers/dma/bcm2835-dma.c static void bcm2835_dma_fill_cb_chain_with_sg( · line 396

Quoted 5 lines
drivers/dma/bcm2835-dma.c +1 -1
@@ -393,7 +393,7 @@ static void bcm2835_dma_fill_cb_chain_with_sg(
 	unsigned int sg_len)
 {
 	struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
-	size_t max_len = bcm2835_dma_max_frame_length(c);
+	unsigned int max_len = bcm2835_dma_max_frame_length(c);

bcm2835_dma_max_frame_length() returns size_t. so this should also add a complain about type mismatch as well!

Quoted 1 line

Also, wouldn't it be better to make both args of min() as size_t then?

Assignments from different sizes don't produce warnings. The other arg
of the min() is a u32, and this value is known to be < u32, so I don't
see the problem. I could start promoting u32s to size_ts instead, but I
don't know where that would end.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160606/d65d5e79/attachment-0001.sig>