Skip to contentSkip to conversation

dmaengine: mcf-edma: fix x86_64 allmodconfig compilation warning

PATCH New Angelo Dureghello 1 participant 1 message Sep 14, 2018 dmaengine

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 dmaengine: mcf-edma: fix x86_64 allmodconfig compilation warning

Hi Geert,

Quoted 49 lines · Angelo Dureghello

Hi Geert,

Quoted 8 lines · Geert Uytterhoeven

Hi Angelo,

Thanks for your patch!

Quoted 2 lines · Angelo Dureghello

This patch fixes the compilation warning reported
during x86_64 allmodconfig build.

Quoted 7 lines

Please quote the warning, so people know what it is about:

drivers/dma/mcf-edma.c: In function 'mcf_edma_filter_fn':
drivers/dma/mcf-edma.c:296:33: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]

       return (mcf_chan->slave_id == (u32)param);

Ok done.

Quoted 22 lines
Quoted 15 lines

---
Changes for v2:
- added Reported-By

---
 drivers/dma/mcf-edma.c                     | 3 ++-
 include/linux/platform_data/dma-mcf-edma.h | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/dma/mcf-edma.c +0 -0
index 4d30d5302649..e08e2409a102 100644

drivers/dma/mcf-edma.c bool mcf_edma_filter_fn(struct dma_chan *chan, void *param) · line 295

Quoted 4 lines
drivers/dma/mcf-edma.c +1 -0
@@ -292,8 +292,9 @@ bool mcf_edma_filter_fn(struct dma_chan *chan, void *param)
 {
        if (chan->device->dev->driver == &mcf_edma_driver.driver) {
                struct fsl_edma_chan *mcf_chan = to_fsl_edma_chan(chan);
+               unsigned int req = *(unsigned int *)param;

This looks a bit hackish to me.

Quoted 1 line
Quoted 5 lines
Quoted 1 line

- return (mcf_chan->slave_id == (u32)param);

The recommended way to cast from pointers to integers is to use uintptr_t, which always has the same size as a pointer, i.e.:

Quoted 9 lines

slave_id is acually an u32. So, if i understsand, when compiled on x86_64 using uintptr_t, the cast should trigger the same issue. I preferred, as i.e. ti/omap dma driver is doing, to simply use a pointer to an int (int[]) as passed type in param, so i can then indirectly access the integer. I tested proper functionality in ColdFire and that there are no warnings anymore in both ColdFire and x86_64 allmodconfig so the patch, hopefully, should be legal.

I misunderstood uintptr_t, verified now that it works fine for this case, reducing the patch to a single line change. So switching to it. Thanks !

Quoted 22 lines
Quoted 22 lines
        return (mcf_chan->slave_id == (uintptr_t)param);
Quoted 9 lines
drivers/dma/mcf-edma.c +1 -0
+               return (mcf_chan->slave_id == req);
        }
 
        return false;
include/linux/platform_data/dma-mcf-edma.h +0 -0
index d718ccfa3421..97cb79bda646 100644

include/linux/platform_data/dma-mcf-edma.h struct dma_slave_map; · line 27

Quoted 8 lines
include/linux/platform_data/dma-mcf-edma.h +1 -1
@@ -21,7 +21,7 @@ struct dma_slave_map;
 
 bool mcf_edma_filter_fn(struct dma_chan *chan, void *param);
 
-#define MCF_EDMA_FILTER_PARAM(ch)      ((void *)ch)
+#define MCF_EDMA_FILTER_PARAM(ch)      ((int[]) { (ch) })
 
 /**
  * struct mcf_edma_platform_data - platform specific data for eDMA engine

Gr{oetje,eeting}s,

Quoted 11 lines
Quoted 2 lines

Geert

Regards,
Angelo

Quoted 6 lines
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Regards,
Angelo