diff options
author | Marc Kleine-Budde <mkl@pengutronix.de> | 2011-02-19 16:08:33 -0500 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2011-02-21 07:13:39 -0500 |
commit | ea5a43db0f7123c5cb459d8f77454534bc62de4f (patch) | |
tree | 42b58250e6266466d344ab592e1cfd361265e486 /drivers/net/ax88796.c | |
parent | 9f072429592d70b0f88c4d66f83735cc693a9870 (diff) |
ax88796: don't use magic ei_status to acces private data
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/ax88796.c')
-rw-r--r-- | drivers/net/ax88796.c | 81 |
1 files changed, 42 insertions, 39 deletions
diff --git a/drivers/net/ax88796.c b/drivers/net/ax88796.c index 6d1d5ca112eb..c49c3b108133 100644 --- a/drivers/net/ax88796.c +++ b/drivers/net/ax88796.c | |||
@@ -152,8 +152,8 @@ static void ax_reset_8390(struct net_device *dev) | |||
152 | 152 | ||
153 | ei_outb(ei_inb(addr + NE_RESET), addr + NE_RESET); | 153 | ei_outb(ei_inb(addr + NE_RESET), addr + NE_RESET); |
154 | 154 | ||
155 | ei_status.txing = 0; | 155 | ei_local->txing = 0; |
156 | ei_status.dmaing = 0; | 156 | ei_local->dmaing = 0; |
157 | 157 | ||
158 | /* This check _should_not_ be necessary, omit eventually. */ | 158 | /* This check _should_not_ be necessary, omit eventually. */ |
159 | while ((ei_inb(addr + EN0_ISR) & ENISR_RESET) == 0) { | 159 | while ((ei_inb(addr + EN0_ISR) & ENISR_RESET) == 0) { |
@@ -176,15 +176,15 @@ static void ax_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, | |||
176 | void __iomem *nic_base = ei_local->mem; | 176 | void __iomem *nic_base = ei_local->mem; |
177 | 177 | ||
178 | /* This *shouldn't* happen. If it does, it's the last thing you'll see */ | 178 | /* This *shouldn't* happen. If it does, it's the last thing you'll see */ |
179 | if (ei_status.dmaing) { | 179 | if (ei_local->dmaing) { |
180 | dev_err(&ax->dev->dev, "%s: DMAing conflict in %s " | 180 | dev_err(&ax->dev->dev, "%s: DMAing conflict in %s " |
181 | "[DMAstat:%d][irqlock:%d].\n", | 181 | "[DMAstat:%d][irqlock:%d].\n", |
182 | dev->name, __func__, | 182 | dev->name, __func__, |
183 | ei_status.dmaing, ei_status.irqlock); | 183 | ei_local->dmaing, ei_local->irqlock); |
184 | return; | 184 | return; |
185 | } | 185 | } |
186 | 186 | ||
187 | ei_status.dmaing |= 0x01; | 187 | ei_local->dmaing |= 0x01; |
188 | ei_outb(E8390_NODMA + E8390_PAGE0 + E8390_START, nic_base + NE_CMD); | 188 | ei_outb(E8390_NODMA + E8390_PAGE0 + E8390_START, nic_base + NE_CMD); |
189 | ei_outb(sizeof(struct e8390_pkt_hdr), nic_base + EN0_RCNTLO); | 189 | ei_outb(sizeof(struct e8390_pkt_hdr), nic_base + EN0_RCNTLO); |
190 | ei_outb(0, nic_base + EN0_RCNTHI); | 190 | ei_outb(0, nic_base + EN0_RCNTHI); |
@@ -192,7 +192,7 @@ static void ax_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, | |||
192 | ei_outb(ring_page, nic_base + EN0_RSARHI); | 192 | ei_outb(ring_page, nic_base + EN0_RSARHI); |
193 | ei_outb(E8390_RREAD+E8390_START, nic_base + NE_CMD); | 193 | ei_outb(E8390_RREAD+E8390_START, nic_base + NE_CMD); |
194 | 194 | ||
195 | if (ei_status.word16) | 195 | if (ei_local->word16) |
196 | readsw(nic_base + NE_DATAPORT, hdr, | 196 | readsw(nic_base + NE_DATAPORT, hdr, |
197 | sizeof(struct e8390_pkt_hdr) >> 1); | 197 | sizeof(struct e8390_pkt_hdr) >> 1); |
198 | else | 198 | else |
@@ -200,7 +200,7 @@ static void ax_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, | |||
200 | sizeof(struct e8390_pkt_hdr)); | 200 | sizeof(struct e8390_pkt_hdr)); |
201 | 201 | ||
202 | ei_outb(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */ | 202 | ei_outb(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */ |
203 | ei_status.dmaing &= ~0x01; | 203 | ei_local->dmaing &= ~0x01; |
204 | 204 | ||
205 | le16_to_cpus(&hdr->count); | 205 | le16_to_cpus(&hdr->count); |
206 | } | 206 | } |
@@ -221,16 +221,16 @@ static void ax_block_input(struct net_device *dev, int count, | |||
221 | void __iomem *nic_base = ei_local->mem; | 221 | void __iomem *nic_base = ei_local->mem; |
222 | char *buf = skb->data; | 222 | char *buf = skb->data; |
223 | 223 | ||
224 | if (ei_status.dmaing) { | 224 | if (ei_local->dmaing) { |
225 | dev_err(&ax->dev->dev, | 225 | dev_err(&ax->dev->dev, |
226 | "%s: DMAing conflict in %s " | 226 | "%s: DMAing conflict in %s " |
227 | "[DMAstat:%d][irqlock:%d].\n", | 227 | "[DMAstat:%d][irqlock:%d].\n", |
228 | dev->name, __func__, | 228 | dev->name, __func__, |
229 | ei_status.dmaing, ei_status.irqlock); | 229 | ei_local->dmaing, ei_local->irqlock); |
230 | return; | 230 | return; |
231 | } | 231 | } |
232 | 232 | ||
233 | ei_status.dmaing |= 0x01; | 233 | ei_local->dmaing |= 0x01; |
234 | 234 | ||
235 | ei_outb(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base + NE_CMD); | 235 | ei_outb(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base + NE_CMD); |
236 | ei_outb(count & 0xff, nic_base + EN0_RCNTLO); | 236 | ei_outb(count & 0xff, nic_base + EN0_RCNTLO); |
@@ -239,7 +239,7 @@ static void ax_block_input(struct net_device *dev, int count, | |||
239 | ei_outb(ring_offset >> 8, nic_base + EN0_RSARHI); | 239 | ei_outb(ring_offset >> 8, nic_base + EN0_RSARHI); |
240 | ei_outb(E8390_RREAD+E8390_START, nic_base + NE_CMD); | 240 | ei_outb(E8390_RREAD+E8390_START, nic_base + NE_CMD); |
241 | 241 | ||
242 | if (ei_status.word16) { | 242 | if (ei_local->word16) { |
243 | readsw(nic_base + NE_DATAPORT, buf, count >> 1); | 243 | readsw(nic_base + NE_DATAPORT, buf, count >> 1); |
244 | if (count & 0x01) | 244 | if (count & 0x01) |
245 | buf[count-1] = ei_inb(nic_base + NE_DATAPORT); | 245 | buf[count-1] = ei_inb(nic_base + NE_DATAPORT); |
@@ -248,7 +248,7 @@ static void ax_block_input(struct net_device *dev, int count, | |||
248 | readsb(nic_base + NE_DATAPORT, buf, count); | 248 | readsb(nic_base + NE_DATAPORT, buf, count); |
249 | } | 249 | } |
250 | 250 | ||
251 | ei_status.dmaing &= ~1; | 251 | ei_local->dmaing &= ~1; |
252 | } | 252 | } |
253 | 253 | ||
254 | static void ax_block_output(struct net_device *dev, int count, | 254 | static void ax_block_output(struct net_device *dev, int count, |
@@ -264,19 +264,19 @@ static void ax_block_output(struct net_device *dev, int count, | |||
264 | * What effect will an odd byte count have on the 8390? I | 264 | * What effect will an odd byte count have on the 8390? I |
265 | * should check someday. | 265 | * should check someday. |
266 | */ | 266 | */ |
267 | if (ei_status.word16 && (count & 0x01)) | 267 | if (ei_local->word16 && (count & 0x01)) |
268 | count++; | 268 | count++; |
269 | 269 | ||
270 | /* This *shouldn't* happen. If it does, it's the last thing you'll see */ | 270 | /* This *shouldn't* happen. If it does, it's the last thing you'll see */ |
271 | if (ei_status.dmaing) { | 271 | if (ei_local->dmaing) { |
272 | dev_err(&ax->dev->dev, "%s: DMAing conflict in %s." | 272 | dev_err(&ax->dev->dev, "%s: DMAing conflict in %s." |
273 | "[DMAstat:%d][irqlock:%d]\n", | 273 | "[DMAstat:%d][irqlock:%d]\n", |
274 | dev->name, __func__, | 274 | dev->name, __func__, |
275 | ei_status.dmaing, ei_status.irqlock); | 275 | ei_local->dmaing, ei_local->irqlock); |
276 | return; | 276 | return; |
277 | } | 277 | } |
278 | 278 | ||
279 | ei_status.dmaing |= 0x01; | 279 | ei_local->dmaing |= 0x01; |
280 | /* We should already be in page 0, but to be safe... */ | 280 | /* We should already be in page 0, but to be safe... */ |
281 | ei_outb(E8390_PAGE0+E8390_START+E8390_NODMA, nic_base + NE_CMD); | 281 | ei_outb(E8390_PAGE0+E8390_START+E8390_NODMA, nic_base + NE_CMD); |
282 | 282 | ||
@@ -289,7 +289,7 @@ static void ax_block_output(struct net_device *dev, int count, | |||
289 | ei_outb(start_page, nic_base + EN0_RSARHI); | 289 | ei_outb(start_page, nic_base + EN0_RSARHI); |
290 | 290 | ||
291 | ei_outb(E8390_RWRITE+E8390_START, nic_base + NE_CMD); | 291 | ei_outb(E8390_RWRITE+E8390_START, nic_base + NE_CMD); |
292 | if (ei_status.word16) | 292 | if (ei_local->word16) |
293 | writesw(nic_base + NE_DATAPORT, buf, count >> 1); | 293 | writesw(nic_base + NE_DATAPORT, buf, count >> 1); |
294 | else | 294 | else |
295 | writesb(nic_base + NE_DATAPORT, buf, count); | 295 | writesb(nic_base + NE_DATAPORT, buf, count); |
@@ -307,7 +307,7 @@ static void ax_block_output(struct net_device *dev, int count, | |||
307 | } | 307 | } |
308 | 308 | ||
309 | ei_outb(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */ | 309 | ei_outb(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */ |
310 | ei_status.dmaing &= ~0x01; | 310 | ei_local->dmaing &= ~0x01; |
311 | } | 311 | } |
312 | 312 | ||
313 | /* definitions for accessing MII/EEPROM interface */ | 313 | /* definitions for accessing MII/EEPROM interface */ |
@@ -758,22 +758,22 @@ static int ax_init_dev(struct net_device *dev, int first_init) | |||
758 | 758 | ||
759 | ax_reset_8390(dev); | 759 | ax_reset_8390(dev); |
760 | 760 | ||
761 | ei_status.name = "AX88796"; | 761 | ei_local->name = "AX88796"; |
762 | ei_status.tx_start_page = start_page; | 762 | ei_local->tx_start_page = start_page; |
763 | ei_status.stop_page = stop_page; | 763 | ei_local->stop_page = stop_page; |
764 | ei_status.word16 = (ax->plat->wordlength == 2); | 764 | ei_local->word16 = (ax->plat->wordlength == 2); |
765 | ei_status.rx_start_page = start_page + TX_PAGES; | 765 | ei_local->rx_start_page = start_page + TX_PAGES; |
766 | 766 | ||
767 | #ifdef PACKETBUF_MEMSIZE | 767 | #ifdef PACKETBUF_MEMSIZE |
768 | /* Allow the packet buffer size to be overridden by know-it-alls. */ | 768 | /* Allow the packet buffer size to be overridden by know-it-alls. */ |
769 | ei_status.stop_page = ei_status.tx_start_page + PACKETBUF_MEMSIZE; | 769 | ei_local->stop_page = ei_local->tx_start_page + PACKETBUF_MEMSIZE; |
770 | #endif | 770 | #endif |
771 | 771 | ||
772 | ei_status.reset_8390 = &ax_reset_8390; | 772 | ei_local->reset_8390 = &ax_reset_8390; |
773 | ei_status.block_input = &ax_block_input; | 773 | ei_local->block_input = &ax_block_input; |
774 | ei_status.block_output = &ax_block_output; | 774 | ei_local->block_output = &ax_block_output; |
775 | ei_status.get_8390_hdr = &ax_get_8390_hdr; | 775 | ei_local->get_8390_hdr = &ax_get_8390_hdr; |
776 | ei_status.priv = 0; | 776 | ei_local->priv = 0; |
777 | 777 | ||
778 | dev->netdev_ops = &ax_netdev_ops; | 778 | dev->netdev_ops = &ax_netdev_ops; |
779 | dev->ethtool_ops = &ax_ethtool_ops; | 779 | dev->ethtool_ops = &ax_ethtool_ops; |
@@ -792,7 +792,7 @@ static int ax_init_dev(struct net_device *dev, int first_init) | |||
792 | 792 | ||
793 | if (first_init) | 793 | if (first_init) |
794 | dev_info(&ax->dev->dev, "%dbit, irq %d, %lx, MAC: %pM\n", | 794 | dev_info(&ax->dev->dev, "%dbit, irq %d, %lx, MAC: %pM\n", |
795 | ei_status.word16 ? 16 : 8, dev->irq, dev->base_addr, | 795 | ei_local->word16 ? 16 : 8, dev->irq, dev->base_addr, |
796 | dev->dev_addr); | 796 | dev->dev_addr); |
797 | 797 | ||
798 | ret = register_netdev(dev); | 798 | ret = register_netdev(dev); |
@@ -811,6 +811,7 @@ static int ax_init_dev(struct net_device *dev, int first_init) | |||
811 | static int ax_remove(struct platform_device *_dev) | 811 | static int ax_remove(struct platform_device *_dev) |
812 | { | 812 | { |
813 | struct net_device *dev = platform_get_drvdata(_dev); | 813 | struct net_device *dev = platform_get_drvdata(_dev); |
814 | struct ei_device *ei_local = netdev_priv(dev); | ||
814 | struct ax_device *ax; | 815 | struct ax_device *ax; |
815 | 816 | ||
816 | ax = to_ax_dev(dev); | 817 | ax = to_ax_dev(dev); |
@@ -818,7 +819,7 @@ static int ax_remove(struct platform_device *_dev) | |||
818 | unregister_netdev(dev); | 819 | unregister_netdev(dev); |
819 | free_irq(dev->irq, dev); | 820 | free_irq(dev->irq, dev); |
820 | 821 | ||
821 | iounmap(ei_status.mem); | 822 | iounmap(ei_local->mem); |
822 | release_resource(ax->mem); | 823 | release_resource(ax->mem); |
823 | kfree(ax->mem); | 824 | kfree(ax->mem); |
824 | 825 | ||
@@ -843,6 +844,7 @@ static int ax_remove(struct platform_device *_dev) | |||
843 | static int ax_probe(struct platform_device *pdev) | 844 | static int ax_probe(struct platform_device *pdev) |
844 | { | 845 | { |
845 | struct net_device *dev; | 846 | struct net_device *dev; |
847 | struct ei_device *ei_local; | ||
846 | struct ax_device *ax; | 848 | struct ax_device *ax; |
847 | struct resource *res; | 849 | struct resource *res; |
848 | size_t size; | 850 | size_t size; |
@@ -853,6 +855,7 @@ static int ax_probe(struct platform_device *pdev) | |||
853 | return -ENOMEM; | 855 | return -ENOMEM; |
854 | 856 | ||
855 | /* ok, let's setup our device */ | 857 | /* ok, let's setup our device */ |
858 | ei_local = netdev_priv(dev); | ||
856 | ax = to_ax_dev(dev); | 859 | ax = to_ax_dev(dev); |
857 | 860 | ||
858 | memset(ax, 0, sizeof(struct ax_device)); | 861 | memset(ax, 0, sizeof(struct ax_device)); |
@@ -863,7 +866,7 @@ static int ax_probe(struct platform_device *pdev) | |||
863 | ax->plat = pdev->dev.platform_data; | 866 | ax->plat = pdev->dev.platform_data; |
864 | platform_set_drvdata(pdev, dev); | 867 | platform_set_drvdata(pdev, dev); |
865 | 868 | ||
866 | ei_status.rxcr_base = ax->plat->rcr_val; | 869 | ei_local->rxcr_base = ax->plat->rcr_val; |
867 | 870 | ||
868 | /* find the platform resources */ | 871 | /* find the platform resources */ |
869 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 872 | res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
@@ -890,9 +893,9 @@ static int ax_probe(struct platform_device *pdev) | |||
890 | * by using the size of the resource provided | 893 | * by using the size of the resource provided |
891 | */ | 894 | */ |
892 | if (ax->plat->reg_offsets) | 895 | if (ax->plat->reg_offsets) |
893 | ei_status.reg_offset = ax->plat->reg_offsets; | 896 | ei_local->reg_offset = ax->plat->reg_offsets; |
894 | else { | 897 | else { |
895 | ei_status.reg_offset = ax->reg_offsets; | 898 | ei_local->reg_offset = ax->reg_offsets; |
896 | for (ret = 0; ret < 0x18; ret++) | 899 | for (ret = 0; ret < 0x18; ret++) |
897 | ax->reg_offsets[ret] = (size / 0x18) * ret; | 900 | ax->reg_offsets[ret] = (size / 0x18) * ret; |
898 | } | 901 | } |
@@ -904,10 +907,10 @@ static int ax_probe(struct platform_device *pdev) | |||
904 | goto exit_mem; | 907 | goto exit_mem; |
905 | } | 908 | } |
906 | 909 | ||
907 | ei_status.mem = ioremap(res->start, size); | 910 | ei_local->mem = ioremap(res->start, size); |
908 | dev->base_addr = (unsigned long)ei_status.mem; | 911 | dev->base_addr = (unsigned long)ei_local->mem; |
909 | 912 | ||
910 | if (ei_status.mem == NULL) { | 913 | if (ei_local->mem == NULL) { |
911 | dev_err(&pdev->dev, "Cannot ioremap area (%08llx,%08llx)\n", | 914 | dev_err(&pdev->dev, "Cannot ioremap area (%08llx,%08llx)\n", |
912 | (unsigned long long)res->start, | 915 | (unsigned long long)res->start, |
913 | (unsigned long long)res->end); | 916 | (unsigned long long)res->end); |
@@ -943,7 +946,7 @@ static int ax_probe(struct platform_device *pdev) | |||
943 | goto exit_mem2; | 946 | goto exit_mem2; |
944 | } | 947 | } |
945 | 948 | ||
946 | ei_status.reg_offset[0x1f] = ax->map2 - ei_status.mem; | 949 | ei_local->reg_offset[0x1f] = ax->map2 - ei_local->mem; |
947 | } | 950 | } |
948 | 951 | ||
949 | /* got resources, now initialise and register device */ | 952 | /* got resources, now initialise and register device */ |
@@ -962,7 +965,7 @@ static int ax_probe(struct platform_device *pdev) | |||
962 | kfree(ax->mem2); | 965 | kfree(ax->mem2); |
963 | 966 | ||
964 | exit_mem1: | 967 | exit_mem1: |
965 | iounmap(ei_status.mem); | 968 | iounmap(ei_local->mem); |
966 | 969 | ||
967 | exit_req: | 970 | exit_req: |
968 | release_resource(ax->mem); | 971 | release_resource(ax->mem); |