diff options
Diffstat (limited to 'drivers/net/mac8390.c')
-rw-r--r-- | drivers/net/mac8390.c | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/drivers/net/mac8390.c b/drivers/net/mac8390.c index 1136c9a22b67..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 */ |
161 | static void slow_sane_get_8390_hdr(struct net_device *dev, | 163 | static 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); |
165 | static void slow_sane_block_output(struct net_device *dev, int count, | 167 | static 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); |
167 | static void word_memcpy_tocard(void *tp, const void *fp, int count); | 169 | static void word_memcpy_tocard(unsigned long tp, const void *fp, int count); |
168 | static void word_memcpy_fromcard(void *tp, const void *fp, int count); | 170 | static void word_memcpy_fromcard(void *tp, unsigned long fp, int count); |
169 | 171 | ||
170 | static enum mac8390_type __init mac8390_ident(struct nubus_dev *dev) | 172 | static 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); |
@@ -554,7 +556,7 @@ static int __init mac8390_initdev(struct net_device *dev, | |||
554 | case MAC8390_APPLE: | 556 | case MAC8390_APPLE: |
555 | switch (mac8390_testio(dev->mem_start)) { | 557 | switch (mac8390_testio(dev->mem_start)) { |
556 | case ACCESS_UNKNOWN: | 558 | case ACCESS_UNKNOWN: |
557 | pr_info("Don't know how to access card memory!\n"); | 559 | pr_err("Don't know how to access card memory!\n"); |
558 | return -ENODEV; | 560 | return -ENODEV; |
559 | break; | 561 | break; |
560 | 562 | ||
@@ -641,12 +643,13 @@ static int __init mac8390_initdev(struct net_device *dev, | |||
641 | 643 | ||
642 | static int mac8390_open(struct net_device *dev) | 644 | static int mac8390_open(struct net_device *dev) |
643 | { | 645 | { |
646 | int err; | ||
647 | |||
644 | __ei_open(dev); | 648 | __ei_open(dev); |
645 | if (request_irq(dev->irq, __ei_interrupt, 0, "8390 Ethernet", dev)) { | 649 | err = request_irq(dev->irq, __ei_interrupt, 0, "8390 Ethernet", dev); |
646 | pr_info("%s: unable to get IRQ %d.\n", dev->name, dev->irq); | 650 | if (err) |
647 | return -EAGAIN; | 651 | pr_err("%s: unable to get IRQ %d\n", dev->name, dev->irq); |
648 | } | 652 | return err; |
649 | return 0; | ||
650 | } | 653 | } |
651 | 654 | ||
652 | static int mac8390_close(struct net_device *dev) | 655 | static int mac8390_close(struct net_device *dev) |
@@ -731,7 +734,7 @@ static void sane_get_8390_hdr(struct net_device *dev, | |||
731 | struct e8390_pkt_hdr *hdr, int ring_page) | 734 | struct e8390_pkt_hdr *hdr, int ring_page) |
732 | { | 735 | { |
733 | unsigned long hdr_start = (ring_page - WD_START_PG)<<8; | 736 | unsigned long hdr_start = (ring_page - WD_START_PG)<<8; |
734 | memcpy_fromio((void *)hdr, (char *)dev->mem_start + hdr_start, 4); | 737 | memcpy_fromio(hdr, dev->mem_start + hdr_start, 4); |
735 | /* Fix endianness */ | 738 | /* Fix endianness */ |
736 | hdr->count = swab16(hdr->count); | 739 | hdr->count = swab16(hdr->count); |
737 | } | 740 | } |
@@ -745,14 +748,13 @@ static void sane_block_input(struct net_device *dev, int count, | |||
745 | if (xfer_start + count > ei_status.rmem_end) { | 748 | if (xfer_start + count > ei_status.rmem_end) { |
746 | /* We must wrap the input move. */ | 749 | /* We must wrap the input move. */ |
747 | int semi_count = ei_status.rmem_end - xfer_start; | 750 | int semi_count = ei_status.rmem_end - xfer_start; |
748 | memcpy_fromio(skb->data, (char *)dev->mem_start + xfer_base, | 751 | memcpy_fromio(skb->data, dev->mem_start + xfer_base, |
749 | semi_count); | 752 | semi_count); |
750 | count -= semi_count; | 753 | count -= semi_count; |
751 | memcpy_toio(skb->data + semi_count, | 754 | memcpy_fromio(skb->data + semi_count, ei_status.rmem_start, |
752 | (char *)ei_status.rmem_start, count); | ||
753 | } else { | ||
754 | memcpy_fromio(skb->data, (char *)dev->mem_start + xfer_base, | ||
755 | count); | 755 | count); |
756 | } else { | ||
757 | memcpy_fromio(skb->data, dev->mem_start + xfer_base, count); | ||
756 | } | 758 | } |
757 | } | 759 | } |
758 | 760 | ||
@@ -761,7 +763,7 @@ static void sane_block_output(struct net_device *dev, int count, | |||
761 | { | 763 | { |
762 | long shmem = (start_page - WD_START_PG)<<8; | 764 | long shmem = (start_page - WD_START_PG)<<8; |
763 | 765 | ||
764 | memcpy_toio((char *)dev->mem_start + shmem, buf, count); | 766 | memcpy_toio(dev->mem_start + shmem, buf, count); |
765 | } | 767 | } |
766 | 768 | ||
767 | /* dayna block input/output */ | 769 | /* dayna block input/output */ |
@@ -812,7 +814,7 @@ static void slow_sane_get_8390_hdr(struct net_device *dev, | |||
812 | int ring_page) | 814 | int ring_page) |
813 | { | 815 | { |
814 | unsigned long hdr_start = (ring_page - WD_START_PG)<<8; | 816 | unsigned long hdr_start = (ring_page - WD_START_PG)<<8; |
815 | word_memcpy_fromcard(hdr, (char *)dev->mem_start + hdr_start, 4); | 817 | word_memcpy_fromcard(hdr, dev->mem_start + hdr_start, 4); |
816 | /* Register endianism - fix here rather than 8390.c */ | 818 | /* Register endianism - fix here rather than 8390.c */ |
817 | hdr->count = (hdr->count&0xFF)<<8|(hdr->count>>8); | 819 | hdr->count = (hdr->count&0xFF)<<8|(hdr->count>>8); |
818 | } | 820 | } |
@@ -826,15 +828,14 @@ static void slow_sane_block_input(struct net_device *dev, int count, | |||
826 | if (xfer_start + count > ei_status.rmem_end) { | 828 | if (xfer_start + count > ei_status.rmem_end) { |
827 | /* We must wrap the input move. */ | 829 | /* We must wrap the input move. */ |
828 | int semi_count = ei_status.rmem_end - xfer_start; | 830 | int semi_count = ei_status.rmem_end - xfer_start; |
829 | word_memcpy_fromcard(skb->data, | 831 | word_memcpy_fromcard(skb->data, dev->mem_start + xfer_base, |
830 | (char *)dev->mem_start + xfer_base, | ||
831 | semi_count); | 832 | semi_count); |
832 | count -= semi_count; | 833 | count -= semi_count; |
833 | word_memcpy_fromcard(skb->data + semi_count, | 834 | word_memcpy_fromcard(skb->data + semi_count, |
834 | (char *)ei_status.rmem_start, count); | 835 | ei_status.rmem_start, count); |
835 | } else { | 836 | } else { |
836 | word_memcpy_fromcard(skb->data, | 837 | word_memcpy_fromcard(skb->data, dev->mem_start + xfer_base, |
837 | (char *)dev->mem_start + xfer_base, count); | 838 | count); |
838 | } | 839 | } |
839 | } | 840 | } |
840 | 841 | ||
@@ -843,12 +844,12 @@ static void slow_sane_block_output(struct net_device *dev, int count, | |||
843 | { | 844 | { |
844 | long shmem = (start_page - WD_START_PG)<<8; | 845 | long shmem = (start_page - WD_START_PG)<<8; |
845 | 846 | ||
846 | word_memcpy_tocard((char *)dev->mem_start + shmem, buf, count); | 847 | word_memcpy_tocard(dev->mem_start + shmem, buf, count); |
847 | } | 848 | } |
848 | 849 | ||
849 | static void word_memcpy_tocard(void *tp, const void *fp, int count) | 850 | static void word_memcpy_tocard(unsigned long tp, const void *fp, int count) |
850 | { | 851 | { |
851 | volatile unsigned short *to = tp; | 852 | volatile unsigned short *to = (void *)tp; |
852 | const unsigned short *from = fp; | 853 | const unsigned short *from = fp; |
853 | 854 | ||
854 | count++; | 855 | count++; |
@@ -858,10 +859,10 @@ static void word_memcpy_tocard(void *tp, const void *fp, int count) | |||
858 | *to++ = *from++; | 859 | *to++ = *from++; |
859 | } | 860 | } |
860 | 861 | ||
861 | static void word_memcpy_fromcard(void *tp, const void *fp, int count) | 862 | static void word_memcpy_fromcard(void *tp, unsigned long fp, int count) |
862 | { | 863 | { |
863 | unsigned short *to = tp; | 864 | unsigned short *to = tp; |
864 | const volatile unsigned short *from = fp; | 865 | const volatile unsigned short *from = (const void *)fp; |
865 | 866 | ||
866 | count++; | 867 | count++; |
867 | count /= 2; | 868 | count /= 2; |