aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert@linux-m68k.org>2010-06-02 03:36:20 -0400
committerDavid S. Miller <davem@davemloft.net>2010-06-03 06:18:20 -0400
commit7e364e9668ceb5094622144ef4c931305329c175 (patch)
treea52fb0abcebad16edfd3def239067b7f64dd12d8
parent482c42f12667223ac93bd954ad7f87c6fef29393 (diff)
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> Tested-by: Finn Thain <fthain@telegraphics.com.au> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/mac8390.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/drivers/net/mac8390.c b/drivers/net/mac8390.c
index 3f8a64f88181..3832fa4961dd 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,
157#define memcpy_fromio(a, b, c) memcpy((a), (void *)(b), (c)) 157#define memcpy_fromio(a, b, c) memcpy((a), (void *)(b), (c))
158#define memcpy_toio(a, b, c) memcpy((void *)(a), (b), (c)) 158#define memcpy_toio(a, b, c) memcpy((void *)(a), (b), (c))
159 159
160#define memcmp_withio(a, b, c) memcmp((a), (void *)(b), (c))
161
160/* Slow Sane (16-bit chunk memory read/write) Cabletron uses this */ 162/* Slow Sane (16-bit chunk memory read/write) Cabletron uses this */
161static void slow_sane_get_8390_hdr(struct net_device *dev, 163static void slow_sane_get_8390_hdr(struct net_device *dev,
162 struct e8390_pkt_hdr *hdr, int ring_page); 164 struct e8390_pkt_hdr *hdr, int ring_page);
@@ -164,8 +166,8 @@ static void slow_sane_block_input(struct net_device *dev, int count,
164 struct sk_buff *skb, int ring_offset); 166 struct sk_buff *skb, int ring_offset);
165static void slow_sane_block_output(struct net_device *dev, int count, 167static void slow_sane_block_output(struct net_device *dev, int count,
166 const unsigned char *buf, int start_page); 168 const unsigned char *buf, int start_page);
167static void word_memcpy_tocard(void *tp, const void *fp, int count); 169static void word_memcpy_tocard(unsigned long tp, const void *fp, int count);
168static void word_memcpy_fromcard(void *tp, const void *fp, int count); 170static void word_memcpy_fromcard(void *tp, unsigned long fp, int count);
169 171
170static enum mac8390_type __init mac8390_ident(struct nubus_dev *dev) 172static enum mac8390_type __init mac8390_ident(struct nubus_dev *dev)
171{ 173{
@@ -245,9 +247,9 @@ static enum mac8390_access __init mac8390_testio(volatile unsigned long membase)
245 unsigned long outdata = 0xA5A0B5B0; 247 unsigned long outdata = 0xA5A0B5B0;
246 unsigned long indata = 0x00000000; 248 unsigned long indata = 0x00000000;
247 /* Try writing 32 bits */ 249 /* Try writing 32 bits */
248 memcpy(membase, &outdata, 4); 250 memcpy_toio(membase, &outdata, 4);
249 /* Now compare them */ 251 /* Now compare them */
250 if (memcmp((char *)&outdata, (char *)membase, 4) == 0) 252 if (memcmp_withio(&outdata, membase, 4) == 0)
251 return ACCESS_32; 253 return ACCESS_32;
252 /* Write 16 bit output */ 254 /* Write 16 bit output */
253 word_memcpy_tocard(membase, &outdata, 4); 255 word_memcpy_tocard(membase, &outdata, 4);
@@ -732,7 +734,7 @@ static void sane_get_8390_hdr(struct net_device *dev,
732 struct e8390_pkt_hdr *hdr, int ring_page) 734 struct e8390_pkt_hdr *hdr, int ring_page)
733{ 735{
734 unsigned long hdr_start = (ring_page - WD_START_PG)<<8; 736 unsigned long hdr_start = (ring_page - WD_START_PG)<<8;
735 memcpy_fromio((void *)hdr, (char *)dev->mem_start + hdr_start, 4); 737 memcpy_fromio(hdr, dev->mem_start + hdr_start, 4);
736 /* Fix endianness */ 738 /* Fix endianness */
737 hdr->count = swab16(hdr->count); 739 hdr->count = swab16(hdr->count);
738} 740}
@@ -746,14 +748,13 @@ static void sane_block_input(struct net_device *dev, int count,
746 if (xfer_start + count > ei_status.rmem_end) { 748 if (xfer_start + count > ei_status.rmem_end) {
747 /* We must wrap the input move. */ 749 /* We must wrap the input move. */
748 int semi_count = ei_status.rmem_end - xfer_start; 750 int semi_count = ei_status.rmem_end - xfer_start;
749 memcpy_fromio(skb->data, (char *)dev->mem_start + xfer_base, 751 memcpy_fromio(skb->data, dev->mem_start + xfer_base,
750 semi_count); 752 semi_count);
751 count -= semi_count; 753 count -= semi_count;
752 memcpy_toio(skb->data + semi_count, 754 memcpy_fromio(skb->data + semi_count, ei_status.rmem_start,
753 (char *)ei_status.rmem_start, count);
754 } else {
755 memcpy_fromio(skb->data, (char *)dev->mem_start + xfer_base,
756 count); 755 count);
756 } else {
757 memcpy_fromio(skb->data, dev->mem_start + xfer_base, count);
757 } 758 }
758} 759}
759 760
@@ -762,7 +763,7 @@ static void sane_block_output(struct net_device *dev, int count,
762{ 763{
763 long shmem = (start_page - WD_START_PG)<<8; 764 long shmem = (start_page - WD_START_PG)<<8;
764 765
765 memcpy_toio((char *)dev->mem_start + shmem, buf, count); 766 memcpy_toio(dev->mem_start + shmem, buf, count);
766} 767}
767 768
768/* dayna block input/output */ 769/* dayna block input/output */
@@ -813,7 +814,7 @@ static void slow_sane_get_8390_hdr(struct net_device *dev,
813 int ring_page) 814 int ring_page)
814{ 815{
815 unsigned long hdr_start = (ring_page - WD_START_PG)<<8; 816 unsigned long hdr_start = (ring_page - WD_START_PG)<<8;
816 word_memcpy_fromcard(hdr, (char *)dev->mem_start + hdr_start, 4); 817 word_memcpy_fromcard(hdr, dev->mem_start + hdr_start, 4);
817 /* Register endianism - fix here rather than 8390.c */ 818 /* Register endianism - fix here rather than 8390.c */
818 hdr->count = (hdr->count&0xFF)<<8|(hdr->count>>8); 819 hdr->count = (hdr->count&0xFF)<<8|(hdr->count>>8);
819} 820}
@@ -827,15 +828,14 @@ static void slow_sane_block_input(struct net_device *dev, int count,
827 if (xfer_start + count > ei_status.rmem_end) { 828 if (xfer_start + count > ei_status.rmem_end) {
828 /* We must wrap the input move. */ 829 /* We must wrap the input move. */
829 int semi_count = ei_status.rmem_end - xfer_start; 830 int semi_count = ei_status.rmem_end - xfer_start;
830 word_memcpy_fromcard(skb->data, 831 word_memcpy_fromcard(skb->data, dev->mem_start + xfer_base,
831 (char *)dev->mem_start + xfer_base,
832 semi_count); 832 semi_count);
833 count -= semi_count; 833 count -= semi_count;
834 word_memcpy_fromcard(skb->data + semi_count, 834 word_memcpy_fromcard(skb->data + semi_count,
835 (char *)ei_status.rmem_start, count); 835 ei_status.rmem_start, count);
836 } else { 836 } else {
837 word_memcpy_fromcard(skb->data, 837 word_memcpy_fromcard(skb->data, dev->mem_start + xfer_base,
838 (char *)dev->mem_start + xfer_base, count); 838 count);
839 } 839 }
840} 840}
841 841
@@ -844,12 +844,12 @@ static void slow_sane_block_output(struct net_device *dev, int count,
844{ 844{
845 long shmem = (start_page - WD_START_PG)<<8; 845 long shmem = (start_page - WD_START_PG)<<8;
846 846
847 word_memcpy_tocard((char *)dev->mem_start + shmem, buf, count); 847 word_memcpy_tocard(dev->mem_start + shmem, buf, count);
848} 848}
849 849
850static void word_memcpy_tocard(void *tp, const void *fp, int count) 850static void word_memcpy_tocard(unsigned long tp, const void *fp, int count)
851{ 851{
852 volatile unsigned short *to = tp; 852 volatile unsigned short *to = (void *)tp;
853 const unsigned short *from = fp; 853 const unsigned short *from = fp;
854 854
855 count++; 855 count++;
@@ -859,10 +859,10 @@ static void word_memcpy_tocard(void *tp, const void *fp, int count)
859 *to++ = *from++; 859 *to++ = *from++;
860} 860}
861 861
862static void word_memcpy_fromcard(void *tp, const void *fp, int count) 862static void word_memcpy_fromcard(void *tp, unsigned long fp, int count)
863{ 863{
864 unsigned short *to = tp; 864 unsigned short *to = tp;
865 const volatile unsigned short *from = fp; 865 const volatile unsigned short *from = (const void *)fp;
866 866
867 count++; 867 count++;
868 count /= 2; 868 count /= 2;