linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: mac8390 - Sort out memory/MMIO accesses and casts (was:  Re: drivers/net/mac8390.c: Remove useless memcpy casting)
@ 2010-04-15 19:34 Geert Uytterhoeven
  2010-04-16  2:14 ` Finn Thain
  0 siblings, 1 reply; 8+ messages in thread
From: Geert Uytterhoeven @ 2010-04-15 19:34 UTC (permalink / raw)
  To: Joe Perches, Finn Thain
  Cc: David S. Miller, netdev, Linux Kernel Mailing List, Linux/m68k

On Mon, Mar 8, 2010 at 18:16, Joe Perches <joe@perches.com> wrote:
> On Sun, 2010-03-07 at 10:19 +0100, Geert Uytterhoeven wrote:
>> ... hence you introduced 3 compiler warnings:
>>
>> drivers/net/mac8390.c:249: warning: passing argument 1 of
>> '__builtin_memcpy' makes pointer from integer without a cast
>> drivers/net/mac8390.c:254: warning: passing argument 1 of
>> 'word_memcpy_tocard' makes pointer from integer without a cast
>> drivers/net/mac8390.c:256: warning: passing argument 2 of
>> 'word_memcpy_fromcard' makes pointer from integer without a cast
>
> Thanks, I'll submit a patch to fix it by tomorrow or so.

It hasn't been fixed yet. But here's a better solution.
I do not have the hardware to test it, though.
Finn, does it {look OK,work}?

>From 7ef849741922afa7b613f271f414024c454a0d23 Mon Sep 17 00:00:00 2001
From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: Wed, 14 Apr 2010 18:48:50 +0200
Subject: [PATCH] net: mac8390 - Sort out memory/MMIO accesses and casts

commit 5c7fffd0e3b57cb63f50bbd710868f012d67654f ("drivers/net/mac8390.c: Remove
useless memcpy casting") removed too many casts, introducing the following
warnings:

| drivers/net/mac8390.c:248: warning: passing argument 1 of
'__builtin_memcpy' makes pointer from integer without a cast
| drivers/net/mac8390.c:253: warning: passing argument 1 of
'word_memcpy_tocard' makes pointer from integer without a cast
| drivers/net/mac8390.c:255: warning: passing argument 2 of
'word_memcpy_fromcard' makes pointer from integer without a cast

Instead of just readding the casts,
  - move all casts inside word_memcpy_{to,from}card(),
  - replace an incorrect memcpy() by memcpy_toio(),
  - add memcmp_withio() as a wrapper around memcmp(),
  - replace an incorrect memcpy_toio() by memcpy_fromio().

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 drivers/net/mac8390.c |   44 ++++++++++++++++++++++----------------------
 1 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/net/mac8390.c b/drivers/net/mac8390.c
index c8e68fd..8c96e9c 100644
--- a/drivers/net/mac8390.c
+++ b/drivers/net/mac8390.c
@@ -157,6 +157,8 @@ static void dayna_block_output(struct net_device
*dev, int count,
 #define memcpy_fromio(a, b, c)	memcpy((a), (void *)(b), (c))
 #define memcpy_toio(a, b, c)	memcpy((void *)(a), (b), (c))

+#define memcmp_withio(a, b, c)	memcmp((a), (void *)(b), (c))
+
 /* Slow Sane (16-bit chunk memory read/write) Cabletron uses this */
 static void slow_sane_get_8390_hdr(struct net_device *dev,
 				   struct e8390_pkt_hdr *hdr, int ring_page);
@@ -164,8 +166,8 @@ static void slow_sane_block_input(struct
net_device *dev, int count,
 				  struct sk_buff *skb, int ring_offset);
 static void slow_sane_block_output(struct net_device *dev, int count,
 				   const unsigned char *buf, int start_page);
-static void word_memcpy_tocard(void *tp, const void *fp, int count);
-static void word_memcpy_fromcard(void *tp, const void *fp, int count);
+static void word_memcpy_tocard(unsigned long tp, const void *fp, int count);
+static void word_memcpy_fromcard(void *tp, unsigned long fp, int count);

 static enum mac8390_type __init mac8390_ident(struct nubus_dev *dev)
 {
@@ -245,9 +247,9 @@ static enum mac8390_access __init
mac8390_testio(volatile unsigned long membase)
 	unsigned long outdata = 0xA5A0B5B0;
 	unsigned long indata =  0x00000000;
 	/* Try writing 32 bits */
-	memcpy(membase, &outdata, 4);
+	memcpy_toio(membase, &outdata, 4);
 	/* Now compare them */
-	if (memcmp((char *)&outdata, (char *)membase, 4) == 0)
+	if (memcmp_withio(&outdata, membase, 4) == 0)
 		return ACCESS_32;
 	/* Write 16 bit output */
 	word_memcpy_tocard(membase, &outdata, 4);
@@ -733,7 +735,7 @@ static void sane_get_8390_hdr(struct net_device *dev,
 			      struct e8390_pkt_hdr *hdr, int ring_page)
 {
 	unsigned long hdr_start = (ring_page - WD_START_PG)<<8;
-	memcpy_fromio((void *)hdr, (char *)dev->mem_start + hdr_start, 4);
+	memcpy_fromio(hdr, dev->mem_start + hdr_start, 4);
 	/* Fix endianness */
 	hdr->count = swab16(hdr->count);
 }
@@ -747,14 +749,13 @@ static void sane_block_input(struct net_device
*dev, int count,
 	if (xfer_start + count > ei_status.rmem_end) {
 		/* We must wrap the input move. */
 		int semi_count = ei_status.rmem_end - xfer_start;
-		memcpy_fromio(skb->data, (char *)dev->mem_start + xfer_base,
+		memcpy_fromio(skb->data, dev->mem_start + xfer_base,
 			      semi_count);
 		count -= semi_count;
-		memcpy_toio(skb->data + semi_count,
-			    (char *)ei_status.rmem_start, count);
-	} else {
-		memcpy_fromio(skb->data, (char *)dev->mem_start + xfer_base,
+		memcpy_fromio(skb->data + semi_count, ei_status.rmem_start,
 			      count);
+	} else {
+		memcpy_fromio(skb->data, dev->mem_start + xfer_base, count);
 	}
 }

@@ -763,7 +764,7 @@ static void sane_block_output(struct net_device
*dev, int count,
 {
 	long shmem = (start_page - WD_START_PG)<<8;

-	memcpy_toio((char *)dev->mem_start + shmem, buf, count);
+	memcpy_toio(dev->mem_start + shmem, buf, count);
 }

 /* dayna block input/output */
@@ -814,7 +815,7 @@ static void slow_sane_get_8390_hdr(struct net_device *dev,
 				   int ring_page)
 {
 	unsigned long hdr_start = (ring_page - WD_START_PG)<<8;
-	word_memcpy_fromcard(hdr, (char *)dev->mem_start + hdr_start, 4);
+	word_memcpy_fromcard(hdr, dev->mem_start + hdr_start, 4);
 	/* Register endianism - fix here rather than 8390.c */
 	hdr->count = (hdr->count&0xFF)<<8|(hdr->count>>8);
 }
@@ -828,15 +829,14 @@ static void slow_sane_block_input(struct
net_device *dev, int count,
 	if (xfer_start + count > ei_status.rmem_end) {
 		/* We must wrap the input move. */
 		int semi_count = ei_status.rmem_end - xfer_start;
-		word_memcpy_fromcard(skb->data,
-				     (char *)dev->mem_start + xfer_base,
+		word_memcpy_fromcard(skb->data, dev->mem_start + xfer_base,
 				     semi_count);
 		count -= semi_count;
 		word_memcpy_fromcard(skb->data + semi_count,
-				     (char *)ei_status.rmem_start, count);
+				     ei_status.rmem_start, count);
 	} else {
-		word_memcpy_fromcard(skb->data,
-				     (char *)dev->mem_start + xfer_base, count);
+		word_memcpy_fromcard(skb->data, dev->mem_start + xfer_base,
+				     count);
 	}
 }

@@ -845,12 +845,12 @@ static void slow_sane_block_output(struct
net_device *dev, int count,
 {
 	long shmem = (start_page - WD_START_PG)<<8;

-	word_memcpy_tocard((char *)dev->mem_start + shmem, buf, count);
+	word_memcpy_tocard(dev->mem_start + shmem, buf, count);
 }

-static void word_memcpy_tocard(void *tp, const void *fp, int count)
+static void word_memcpy_tocard(unsigned long tp, const void *fp, int count)
 {
-	volatile unsigned short *to = tp;
+	volatile unsigned short *to = (void *)tp;
 	const unsigned short *from = fp;

 	count++;
@@ -860,10 +860,10 @@ static void word_memcpy_tocard(void *tp, const
void *fp, int count)
 		*to++ = *from++;
 }

-static void word_memcpy_fromcard(void *tp, const void *fp, int count)
+static void word_memcpy_fromcard(void *tp, unsigned long fp, int count)
 {
 	unsigned short *to = tp;
-	const volatile unsigned short *from = fp;
+	const volatile unsigned short *from = (const void *)fp;

 	count++;
 	count /= 2;
-- 
1.6.0.4

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

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

* Re: [PATCH] net: mac8390 - Sort out memory/MMIO accesses and casts (was: Re: drivers/net/mac8390.c: Remove useless memcpy casting)
  2010-04-15 19:34 [PATCH] net: mac8390 - Sort out memory/MMIO accesses and casts (was: Re: drivers/net/mac8390.c: Remove useless memcpy casting) Geert Uytterhoeven
@ 2010-04-16  2:14 ` Finn Thain
  2010-05-23 13:15   ` Geert Uytterhoeven
  0 siblings, 1 reply; 8+ messages in thread
From: Finn Thain @ 2010-04-16  2:14 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Joe Perches, David S. Miller, netdev, Linux Kernel Mailing List,
	Linux/m68k


On Thu, 15 Apr 2010, Geert Uytterhoeven wrote:

> On Mon, Mar 8, 2010 at 18:16, Joe Perches <joe@perches.com> wrote:
>
> > Thanks, I'll submit a patch to fix it by tomorrow or so.
> 
> It hasn't been fixed yet.

Thanks for taking care of this, Geert.

> But here's a better solution. I do not have the hardware to test it, 
> though. Finn, does it {look OK,work}?

It looks fine. I can't test it right now, but I will do so when I get the 
opportunity.

Finn

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

* Re: [PATCH] net: mac8390 - Sort out memory/MMIO accesses and casts  (was: Re: drivers/net/mac8390.c: Remove useless memcpy casting)
  2010-04-16  2:14 ` Finn Thain
@ 2010-05-23 13:15   ` Geert Uytterhoeven
  2010-05-23 13:22     ` Finn Thain
  2010-05-28 17:21     ` Finn Thain
  0 siblings, 2 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2010-05-23 13:15 UTC (permalink / raw)
  To: Finn Thain
  Cc: Joe Perches, David S. Miller, netdev, Linux Kernel Mailing List,
	Linux/m68k

On Fri, Apr 16, 2010 at 04:14, Finn Thain <fthain@telegraphics.com.au> wrote:
> On Thu, 15 Apr 2010, Geert Uytterhoeven wrote:
>> On Mon, Mar 8, 2010 at 18:16, Joe Perches <joe@perches.com> wrote:
>> > Thanks, I'll submit a patch to fix it by tomorrow or so.
>>
>> It hasn't been fixed yet.
>
> Thanks for taking care of this, Geert.
>
>> But here's a better solution. I do not have the hardware to test it,
>> though. Finn, does it {look OK,work}?
>
> It looks fine. I can't test it right now, but I will do so when I get the
> opportunity.

Any news from the test front?

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

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

* Re: [PATCH] net: mac8390 - Sort out memory/MMIO accesses and casts (was: Re: drivers/net/mac8390.c: Remove useless memcpy casting)
  2010-05-23 13:15   ` Geert Uytterhoeven
@ 2010-05-23 13:22     ` Finn Thain
  2010-05-28 17:21     ` Finn Thain
  1 sibling, 0 replies; 8+ messages in thread
From: Finn Thain @ 2010-05-23 13:22 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Joe Perches, David S. Miller, netdev, Linux Kernel Mailing List,
	Linux/m68k


On Sun, 23 May 2010, Geert Uytterhoeven wrote:

> Any news from the test front?

Not as yet. I did get as far as building 2.6.34 for m68k. I have a couple 
of other small patches to test with this release too. I hope to send them 
within the merge window (i.e. this week).

Finn

> 
> Gr{oetje,eeting}s,
> 
> 						Geert

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

* Re: [PATCH] net: mac8390 - Sort out memory/MMIO accesses and casts (was: Re: drivers/net/mac8390.c: Remove useless memcpy casting)
  2010-05-23 13:15   ` Geert Uytterhoeven
  2010-05-23 13:22     ` Finn Thain
@ 2010-05-28 17:21     ` Finn Thain
  2010-05-29  8:03       ` Geert Uytterhoeven
  1 sibling, 1 reply; 8+ messages in thread
From: Finn Thain @ 2010-05-28 17:21 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Joe Perches, David S. Miller, netdev, Linux Kernel Mailing List,
	Linux/m68k


On Sun, 23 May 2010, Geert Uytterhoeven wrote:

> >> But here's a better solution. I do not have the hardware to test it, 
> >> though. Finn, does it {look OK,work}?
> >
> > It looks fine. I can't test it right now, but I will do so when I get 
> > the opportunity.
> 
> Any news from the test front?

This is commit ba0f916ca7ac79356e2ed32a85c3aa8255b104e7, right?
If so, it tests OK here.

Finn

> 
> Gr{oetje,eeting}s,
> 
> 						Geert

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

* Re: [PATCH] net: mac8390 - Sort out memory/MMIO accesses and casts  (was: Re: drivers/net/mac8390.c: Remove useless memcpy casting)
  2010-05-28 17:21     ` Finn Thain
@ 2010-05-29  8:03       ` Geert Uytterhoeven
  2010-06-02 17:24         ` Geert Uytterhoeven
  0 siblings, 1 reply; 8+ messages in thread
From: Geert Uytterhoeven @ 2010-05-29  8:03 UTC (permalink / raw)
  To: Finn Thain
  Cc: Joe Perches, David S. Miller, netdev, Linux Kernel Mailing List,
	Linux/m68k

On Fri, May 28, 2010 at 19:21, Finn Thain <fthain@telegraphics.com.au> wrote:
> On Sun, 23 May 2010, Geert Uytterhoeven wrote:
>> >> But here's a better solution. I do not have the hardware to test it,
>> >> though. Finn, does it {look OK,work}?
>> >
>> > It looks fine. I can't test it right now, but I will do so when I get
>> > the opportunity.
>>
>> Any news from the test front?
>
> This is commit ba0f916ca7ac79356e2ed32a85c3aa8255b104e7, right?

Yep.

> If so, it tests OK here.

Thanks for testing!

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

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

* Re: [PATCH] net: mac8390 - Sort out memory/MMIO accesses and casts  (was: Re: drivers/net/mac8390.c: Remove useless memcpy casting)
  2010-05-29  8:03       ` Geert Uytterhoeven
@ 2010-06-02 17:24         ` Geert Uytterhoeven
  2010-06-02 17:26           ` [PATCH] net: mac8390 - Sort out memory/MMIO accesses and casts David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Geert Uytterhoeven @ 2010-06-02 17:24 UTC (permalink / raw)
  To: Finn Thain
  Cc: Joe Perches, David S. Miller, netdev, Linux Kernel Mailing List,
	Linux/m68k

On Sat, May 29, 2010 at 10:03, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> On Fri, May 28, 2010 at 19:21, Finn Thain <fthain@telegraphics.com.au> wrote:
>> On Sun, 23 May 2010, Geert Uytterhoeven wrote:
>>> >> But here's a better solution. I do not have the hardware to test it,
>>> >> though. Finn, does it {look OK,work}?
>>> >
>>> > It looks fine. I can't test it right now, but I will do so when I get
>>> > the opportunity.
>>>
>>> Any news from the test front?
>>
>> This is commit ba0f916ca7ac79356e2ed32a85c3aa8255b104e7, right?
>
> Yep.
>
>> If so, it tests OK here.
>
> Thanks for testing!

David, will you take this one too?

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

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

* Re: [PATCH] net: mac8390 - Sort out memory/MMIO accesses and casts
  2010-06-02 17:24         ` Geert Uytterhoeven
@ 2010-06-02 17:26           ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2010-06-02 17:26 UTC (permalink / raw)
  To: geert; +Cc: fthain, joe, netdev, linux-kernel, linux-m68k

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: Wed, 2 Jun 2010 19:24:08 +0200

> On Sat, May 29, 2010 at 10:03, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>> On Fri, May 28, 2010 at 19:21, Finn Thain <fthain@telegraphics.com.au> wrote:
>>> On Sun, 23 May 2010, Geert Uytterhoeven wrote:
>>>> >> But here's a better solution. I do not have the hardware to test it,
>>>> >> though. Finn, does it {look OK,work}?
>>>> >
>>>> > It looks fine. I can't test it right now, but I will do so when I get
>>>> > the opportunity.
>>>>
>>>> Any news from the test front?
>>>
>>> This is commit ba0f916ca7ac79356e2ed32a85c3aa8255b104e7, right?
>>
>> Yep.
>>
>>> If so, it tests OK here.
>>
>> Thanks for testing!
> 
> David, will you take this one too?

Please post a fresh copy, there is no way that sucker still applies cleanly
as there have been some changes in this area recently.

Thanks.

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

end of thread, other threads:[~2010-06-02 17:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-15 19:34 [PATCH] net: mac8390 - Sort out memory/MMIO accesses and casts (was: Re: drivers/net/mac8390.c: Remove useless memcpy casting) Geert Uytterhoeven
2010-04-16  2:14 ` Finn Thain
2010-05-23 13:15   ` Geert Uytterhoeven
2010-05-23 13:22     ` Finn Thain
2010-05-28 17:21     ` Finn Thain
2010-05-29  8:03       ` Geert Uytterhoeven
2010-06-02 17:24         ` Geert Uytterhoeven
2010-06-02 17:26           ` [PATCH] net: mac8390 - Sort out memory/MMIO accesses and casts David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).