Skip to contentSkip to conversation

mmc:Add pointer cast to uintptr_t for slave_id_rx and tx in the function, sh_mmcif_request_dma_one

PATCH Kuninori Morimoto 4 participants 9 messages May 12, 2015 – Jul 21, 2015 5 messages not in the archive MMC, SD and SDIO

lore
Share & tools
lore

Kuninori Morimoto

author Acked-by
#1 lore raw
In reply to a message not in the archive

Hi

Quoted 6 lines · Nicholas Krause

This adds a cast to the variables,slave_id_rx and slave_id_rx to uintptr_t before casting to void* in order to avoid build warning on 64bit platforms for the function, sh_mmcif_request_dma_one.

---

# 1 open line is needed between log and Signed-off-by ?

Quoted 21 lines
 drivers/mmc/host/sh_mmcif.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/sh_mmcif.c +2 -2
index 7eff087..e276558 100644
@@ -398,8 +398,8 @@ sh_mmcif_request_dma_one(struct sh_mmcif_host *host,
 
 	if (pdata)
 		slave_data = direction == DMA_MEM_TO_DEV ?
-			(void *)pdata->slave_id_tx :
-			(void *)pdata->slave_id_rx;
+			(void *)(uintptr_t)pdata->slave_id_tx :
+			(void *)(uintptr_t)pdata->slave_id_rx;
 
 	chan = dma_request_slave_channel_compat(mask, shdma_chan_filter,
 				slave_data, &host->pd->dev,
Signature · 1 line
2.1.4
#2 lore raw
In reply to a message not in the archive

Hi Ulf

Can you please teach us about status of this patch ?

Quoted 26 lines

This adds a cast to the variables,slave_id_rx and slave_id_rx to uintptr_t before casting to void* in order to avoid build warning on 64bit platforms for the function, sh_mmcif_request_dma_one.

---
 drivers/mmc/host/sh_mmcif.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/sh_mmcif.c +2 -2
index 7eff087..e276558 100644
@@ -398,8 +398,8 @@ sh_mmcif_request_dma_one(struct sh_mmcif_host *host,
 
 	if (pdata)
 		slave_data = direction == DMA_MEM_TO_DEV ?
-			(void *)pdata->slave_id_tx :
-			(void *)pdata->slave_id_rx;
+			(void *)(uintptr_t)pdata->slave_id_tx :
+			(void *)(uintptr_t)pdata->slave_id_rx;
 
 	chan = dma_request_slave_channel_compat(mask, shdma_chan_filter,
 				slave_data, &host->pd->dev,
Signature · 1 line
2.1.4
#3 lore raw
Quoted 4 lines · Kuninori Morimoto

Can you please teach us about status of this patch ?

Quoted 3 lines

This adds a cast to the variables,slave_id_rx and slave_id_rx to uintptr_t before casting to void* in order to avoid build warning on 64bit platforms for the function, sh_mmcif_request_dma_one.

[]

Quoted 1 line

drivers/mmc/host/sh_mmcif.c

Quoted 1 line
drivers/mmc/host/sh_mmcif.c +0 -0

[]

Quoted 8 lines

drivers/mmc/host/sh_mmcif.c sh_mmcif_request_dma_one(struct sh_mmcif_host *host, · line 402

Quoted 8 lines
drivers/mmc/host/sh_mmcif.c +2 -2
@@ -398,8 +398,8 @@ sh_mmcif_request_dma_one(struct sh_mmcif_host *host,
 
 	if (pdata)
 		slave_data = direction == DMA_MEM_TO_DEV ?
-			(void *)pdata->slave_id_tx :
-			(void *)pdata->slave_id_rx;
+			(void *)(uintptr_t)pdata->slave_id_tx :
+			(void *)(uintptr_t)pdata->slave_id_rx;

It's far more common (~10:1) in the kernel to cast using

	(<type> *)(unsigned long)<foo>
than
	(<type> *)(uintptr_t)<foo>
#5 lore raw
In reply to a message not in the archive

Hi Joe, Nick

Quoted 20 lines
Quoted 16 lines
Quoted 3 lines
Quoted 3 lines

This adds a cast to the variables,slave_id_rx and slave_id_rx to uintptr_t before casting to void* in order to avoid build warning on 64bit platforms for the function, sh_mmcif_request_dma_one.

[]

Quoted 1 line

drivers/mmc/host/sh_mmcif.c

Quoted 1 line
drivers/mmc/host/sh_mmcif.c +0 -0

[]

Quoted 8 lines

drivers/mmc/host/sh_mmcif.c sh_mmcif_request_dma_one(struct sh_mmcif_host *host, · line 402

Quoted 8 lines
drivers/mmc/host/sh_mmcif.c +2 -2
@@ -398,8 +398,8 @@ sh_mmcif_request_dma_one(struct sh_mmcif_host *host,
 
 	if (pdata)
 		slave_data = direction == DMA_MEM_TO_DEV ?
-			(void *)pdata->slave_id_tx :
-			(void *)pdata->slave_id_rx;
+			(void *)(uintptr_t)pdata->slave_id_tx :
+			(void *)(uintptr_t)pdata->slave_id_rx;

It's far more common (~10:1) in the kernel to cast using

Quoted 4 lines
	(<type> *)(unsigned long)<foo>
than
	(<type> *)(uintptr_t)<foo>
Quoted 5 lines

Joe,
I agree it's more common in the kernel but one of the maintainers when I sent this patch a month ago requested I use uintpr_t instead of unsigned long for the casting. Otherwise I would have done the cast to fix the build warning with unsigned long instead.

This mail
http://thread.gmane.org/gmane.linux.kernel.mmc/32304

Best regards
---
Kuninori Morimoto

#6 lore raw
Quoted 22 lines · Kuninori Morimoto

Hi Joe, Nick

Quoted 20 lines
Quoted 20 lines
Quoted 3 lines
Quoted 3 lines

This adds a cast to the variables,slave_id_rx and slave_id_rx to uintptr_t before casting to void* in order to avoid build warning on 64bit platforms for the function, sh_mmcif_request_dma_one.

[]

Quoted 1 line

drivers/mmc/host/sh_mmcif.c

Quoted 1 line
drivers/mmc/host/sh_mmcif.c +0 -0

[]

Quoted 8 lines

drivers/mmc/host/sh_mmcif.c sh_mmcif_request_dma_one(struct sh_mmcif_host *host, · line 402

Quoted 8 lines
drivers/mmc/host/sh_mmcif.c +2 -2
@@ -398,8 +398,8 @@ sh_mmcif_request_dma_one(struct sh_mmcif_host *host,
 
 	if (pdata)
 		slave_data = direction == DMA_MEM_TO_DEV ?
-			(void *)pdata->slave_id_tx :
-			(void *)pdata->slave_id_rx;
+			(void *)(uintptr_t)pdata->slave_id_tx :
+			(void *)(uintptr_t)pdata->slave_id_rx;

It's far more common (~10:1) in the kernel to cast using

	(<type> *)(unsigned long)<foo>
than
	(<type> *)(uintptr_t)<foo>
Quoted 8 lines
Quoted 5 lines

Joe,
I agree it's more common in the kernel but one of the maintainers when I sent this patch a month ago requested I use uintpr_t instead of unsigned long for the casting. Otherwise I would have done the cast to fix the build warning with unsigned long instead.

This mail
http://thread.gmane.org/gmane.linux.kernel.mmc/32304

uintptr_t was introduced to avoid ptrdiff_t misuse in commit 142956af5250 ("fix abuses of ptrdiff_t") by Al Viro.

unsigned long is preponderant, long is used about 1/4 as often as unsigned long, uintptr_t is relatively uncommon.

If someone wants to go and convert the 800 or so casts to long or unsigned long to uintptr_t so that's the style most frequently used, that'd be different. I'm not going to submit any patches for that.

#8 lore raw
In reply to a message not in the archive
Quoted 40 lines · nick
Quoted 38 lines · Joe Perches
Quoted 22 lines · Kuninori Morimoto

Hi Joe, Nick

Quoted 20 lines
Quoted 20 lines
Quoted 3 lines
Quoted 3 lines

This adds a cast to the variables,slave_id_rx and slave_id_rx to uintptr_t before casting to void* in order to avoid build warning on 64bit platforms for the function, sh_mmcif_request_dma_one.

[]

Quoted 1 line

drivers/mmc/host/sh_mmcif.c

Quoted 1 line
drivers/mmc/host/sh_mmcif.c +0 -0

[]

Quoted 8 lines

drivers/mmc/host/sh_mmcif.c sh_mmcif_request_dma_one(struct sh_mmcif_host *host, · line 402

Quoted 8 lines
drivers/mmc/host/sh_mmcif.c +2 -2
@@ -398,8 +398,8 @@ sh_mmcif_request_dma_one(struct sh_mmcif_host *host,
 
 	if (pdata)
 		slave_data = direction == DMA_MEM_TO_DEV ?
-			(void *)pdata->slave_id_tx :
-			(void *)pdata->slave_id_rx;
+			(void *)(uintptr_t)pdata->slave_id_tx :
+			(void *)(uintptr_t)pdata->slave_id_rx;

It's far more common (~10:1) in the kernel to cast using

	(<type> *)(unsigned long)<foo>
than
	(<type> *)(uintptr_t)<foo>
Quoted 8 lines
Quoted 5 lines

Joe,
I agree it's more common in the kernel but one of the maintainers when I sent this patch a month ago requested I use uintpr_t instead of unsigned long for the casting. Otherwise I would have done the cast to fix the build warning with unsigned long instead.

This mail
http://thread.gmane.org/gmane.linux.kernel.mmc/32304

uintptr_t was introduced to avoid ptrdiff_t misuse in commit 142956af5250 ("fix abuses of ptrdiff_t") by Al Viro.

unsigned long is preponderant, long is used about 1/4 as often as unsigned long, uintptr_t is relatively uncommon.

Quoted 8 lines
Quoted 6 lines

If someone wants to go and convert the 800 or so casts to long or unsigned long to uintptr_t so that's the style most frequently used, that'd be different. I'm not going to submit any patches for that.

I am not disagreeing it was just easier to listen to the maintainer rather then get in a technical argument over which type is better for the cast.

Ulf Hansson is the maintainer.

Laurent has authored a couple patches to that file and he gave you his opinion about using uintptr_t.

I'm giving an opinion too, just with a little statistics.

I think it's better to use the style that the kernel generally uses.

I'll stop replying now.

#9 lore raw
Quoted 36 lines · On Tuesday 23 June 2015 17:54:33 Joe Perches wrote:
Quoted 23 lines · nick
Quoted 22 lines · Joe Perches
Quoted 6 lines · Kuninori Morimoto
Quoted 6 lines
Quoted 6 lines

It's far more common (~10:1) in the kernel to cast using
(<type> *)(unsigned long)<foo>
than
(<type> *)(uintptr_t)<foo>

Quoted 8 lines
Quoted 5 lines

Joe,
I agree it's more common in the kernel but one of the maintainers when I sent this patch a month ago requested I use uintpr_t instead of unsigned long for the casting. Otherwise I would have done the cast to fix the build warning with unsigned long instead.

This mail
http://thread.gmane.org/gmane.linux.kernel.mmc/32304

uintptr_t was introduced to avoid ptrdiff_t misuse in commit 142956af5250 ("fix abuses of ptrdiff_t") by Al Viro.

unsigned long is preponderant, long is used about 1/4 as often as unsigned long, uintptr_t is relatively uncommon.

Quoted 8 lines
Quoted 6 lines

If someone wants to go and convert the 800 or so casts to long or unsigned long to uintptr_t so that's the style most frequently used, that'd be different. I'm not going to submit any patches for that.

I am not disagreeing it was just easier to listen to the maintainer rather then get in a technical argument over which type is better for the cast.

Laurent has authored a couple patches to that file and he gave you his opinion about using uintptr_t.

Quoted 6 lines

I'm giving an opinion too, just with a little statistics.

I think it's better to use the style that the kernel generally uses.

I'll stop replying now.

Instead of debating the type of cast that is used here, it would be nicer to do a patch that avoids the cast in the driver entirely, by changing the pdata to contain a void* type from the start, and to pass the shdma_chan_filter function pointer along with it from platform code.

That would make the sh_mmcif driver independent of the underlying dma driver.

Arnd

#11 lore raw
In reply to a message not in the archive
Quoted 57 lines · nick
Quoted 49 lines · Arnd Bergmann
Quoted 36 lines · On Tuesday 23 June 2015 17:54:33 Joe Perches wrote:
Quoted 23 lines · nick
Quoted 22 lines · Joe Perches
Quoted 6 lines · Kuninori Morimoto
Quoted 6 lines
Quoted 6 lines

It's far more common (~10:1) in the kernel to cast using
(<type> *)(unsigned long)<foo>
than
(<type> *)(uintptr_t)<foo>

Quoted 8 lines
Quoted 5 lines

Joe,
I agree it's more common in the kernel but one of the maintainers when I sent this patch a month ago requested I use uintpr_t instead of unsigned long for the casting. Otherwise I would have done the cast to fix the build warning with unsigned long instead.

This mail
http://thread.gmane.org/gmane.linux.kernel.mmc/32304

uintptr_t was introduced to avoid ptrdiff_t misuse in commit 142956af5250 ("fix abuses of ptrdiff_t") by Al Viro.

unsigned long is preponderant, long is used about 1/4 as often as unsigned long, uintptr_t is relatively uncommon.

Quoted 8 lines
Quoted 6 lines

If someone wants to go and convert the 800 or so casts to long or unsigned long to uintptr_t so that's the style most frequently used, that'd be different. I'm not going to submit any patches for that.

I am not disagreeing it was just easier to listen to the maintainer rather then get in a technical argument over which type is better for the cast.

Laurent has authored a couple patches to that file and he gave you his opinion about using uintptr_t.

Quoted 6 lines

I'm giving an opinion too, just with a little statistics.

I think it's better to use the style that the kernel generally uses.

I'll stop replying now.

Instead of debating the type of cast that is used here, it would be nicer to do a patch that avoids the cast in the driver entirely, by changing the pdata to contain a void* type from the start, and to pass the shdma_chan_filter function pointer along with it from platform code.

Quoted 5 lines

That would make the sh_mmcif driver independent of the underlying dma driver.

Arnd

Quoted 7 lines

Arnd,
I would have to agree with you but would like the other people in this discussion to agree before I rewrite this function and pdata structure to do this. Otherwise this patch will be the current solution for this.
Cheers,
Nick
P.S. Sorry for the late reply been very busy.

Let's follow Arnd's suggestion!

Kind regards
Uffe

#13 lore raw
In reply to a message not in the archive

[...]

Quoted 6 lines
Quoted 6 lines

Let's follow Arnd's suggestion!

Kind regards
Uffe

Quoted 7 lines

Uffe,
I also have this patch lying around and wasn't able to get a reply on it.
From 0c2cd9c7faecf70a5468659845e3561c4ceb4069 Mon Sep 17 00:00:00 2001
From: Nicholas Krause <[email protected]>
Date: Thu, 2 Jul 2015 21:08:18 -0400
Subject: [PATCH] mmc:Fix refcount leak in the function mmc_queue_resume for the semaphone thread_sem

I am working through my backlog, been out of office for a while. I will come to it soon, sorry for the delay.

Kind regards
Uffe