diff options
Diffstat (limited to 'drivers/net')
34 files changed, 1118 insertions, 1372 deletions
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c index 06e682334c7e..3ad7589d6a1c 100644 --- a/drivers/net/myri_sbus.c +++ b/drivers/net/myri_sbus.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* myri_sbus.c: MyriCOM MyriNET SBUS card driver. | 1 | /* myri_sbus.c: MyriCOM MyriNET SBUS card driver. |
2 | * | 2 | * |
3 | * Copyright (C) 1996, 1999, 2006 David S. Miller (davem@davemloft.net) | 3 | * Copyright (C) 1996, 1999, 2006, 2008 David S. Miller (davem@davemloft.net) |
4 | */ | 4 | */ |
5 | 5 | ||
6 | static char version[] = | 6 | static char version[] = |
@@ -22,6 +22,9 @@ static char version[] = | |||
22 | #include <linux/etherdevice.h> | 22 | #include <linux/etherdevice.h> |
23 | #include <linux/skbuff.h> | 23 | #include <linux/skbuff.h> |
24 | #include <linux/bitops.h> | 24 | #include <linux/bitops.h> |
25 | #include <linux/dma-mapping.h> | ||
26 | #include <linux/of.h> | ||
27 | #include <linux/of_device.h> | ||
25 | 28 | ||
26 | #include <net/dst.h> | 29 | #include <net/dst.h> |
27 | #include <net/arp.h> | 30 | #include <net/arp.h> |
@@ -33,7 +36,6 @@ static char version[] = | |||
33 | #include <asm/dma.h> | 36 | #include <asm/dma.h> |
34 | #include <asm/byteorder.h> | 37 | #include <asm/byteorder.h> |
35 | #include <asm/idprom.h> | 38 | #include <asm/idprom.h> |
36 | #include <asm/sbus.h> | ||
37 | #include <asm/openprom.h> | 39 | #include <asm/openprom.h> |
38 | #include <asm/oplib.h> | 40 | #include <asm/oplib.h> |
39 | #include <asm/auxio.h> | 41 | #include <asm/auxio.h> |
@@ -243,7 +245,8 @@ static void myri_clean_rings(struct myri_eth *mp) | |||
243 | u32 dma_addr; | 245 | u32 dma_addr; |
244 | 246 | ||
245 | dma_addr = sbus_readl(&rxd->myri_scatters[0].addr); | 247 | dma_addr = sbus_readl(&rxd->myri_scatters[0].addr); |
246 | sbus_unmap_single(mp->myri_sdev, dma_addr, RX_ALLOC_SIZE, SBUS_DMA_FROMDEVICE); | 248 | dma_unmap_single(&mp->myri_op->dev, dma_addr, |
249 | RX_ALLOC_SIZE, DMA_FROM_DEVICE); | ||
247 | dev_kfree_skb(mp->rx_skbs[i]); | 250 | dev_kfree_skb(mp->rx_skbs[i]); |
248 | mp->rx_skbs[i] = NULL; | 251 | mp->rx_skbs[i] = NULL; |
249 | } | 252 | } |
@@ -259,7 +262,9 @@ static void myri_clean_rings(struct myri_eth *mp) | |||
259 | u32 dma_addr; | 262 | u32 dma_addr; |
260 | 263 | ||
261 | dma_addr = sbus_readl(&txd->myri_gathers[0].addr); | 264 | dma_addr = sbus_readl(&txd->myri_gathers[0].addr); |
262 | sbus_unmap_single(mp->myri_sdev, dma_addr, (skb->len + 3) & ~3, SBUS_DMA_TODEVICE); | 265 | dma_unmap_single(&mp->myri_op->dev, dma_addr, |
266 | (skb->len + 3) & ~3, | ||
267 | DMA_TO_DEVICE); | ||
263 | dev_kfree_skb(mp->tx_skbs[i]); | 268 | dev_kfree_skb(mp->tx_skbs[i]); |
264 | mp->tx_skbs[i] = NULL; | 269 | mp->tx_skbs[i] = NULL; |
265 | } | 270 | } |
@@ -288,7 +293,9 @@ static void myri_init_rings(struct myri_eth *mp, int from_irq) | |||
288 | skb->dev = dev; | 293 | skb->dev = dev; |
289 | skb_put(skb, RX_ALLOC_SIZE); | 294 | skb_put(skb, RX_ALLOC_SIZE); |
290 | 295 | ||
291 | dma_addr = sbus_map_single(mp->myri_sdev, skb->data, RX_ALLOC_SIZE, SBUS_DMA_FROMDEVICE); | 296 | dma_addr = dma_map_single(&mp->myri_op->dev, |
297 | skb->data, RX_ALLOC_SIZE, | ||
298 | DMA_FROM_DEVICE); | ||
292 | sbus_writel(dma_addr, &rxd[i].myri_scatters[0].addr); | 299 | sbus_writel(dma_addr, &rxd[i].myri_scatters[0].addr); |
293 | sbus_writel(RX_ALLOC_SIZE, &rxd[i].myri_scatters[0].len); | 300 | sbus_writel(RX_ALLOC_SIZE, &rxd[i].myri_scatters[0].len); |
294 | sbus_writel(i, &rxd[i].ctx); | 301 | sbus_writel(i, &rxd[i].ctx); |
@@ -344,7 +351,8 @@ static void myri_tx(struct myri_eth *mp, struct net_device *dev) | |||
344 | 351 | ||
345 | DTX(("SKB[%d] ", entry)); | 352 | DTX(("SKB[%d] ", entry)); |
346 | dma_addr = sbus_readl(&sq->myri_txd[entry].myri_gathers[0].addr); | 353 | dma_addr = sbus_readl(&sq->myri_txd[entry].myri_gathers[0].addr); |
347 | sbus_unmap_single(mp->myri_sdev, dma_addr, skb->len, SBUS_DMA_TODEVICE); | 354 | dma_unmap_single(&mp->myri_op->dev, dma_addr, |
355 | skb->len, DMA_TO_DEVICE); | ||
348 | dev_kfree_skb(skb); | 356 | dev_kfree_skb(skb); |
349 | mp->tx_skbs[entry] = NULL; | 357 | mp->tx_skbs[entry] = NULL; |
350 | dev->stats.tx_packets++; | 358 | dev->stats.tx_packets++; |
@@ -423,9 +431,9 @@ static void myri_rx(struct myri_eth *mp, struct net_device *dev) | |||
423 | 431 | ||
424 | /* Check for errors. */ | 432 | /* Check for errors. */ |
425 | DRX(("rxd[%d]: %p len[%d] csum[%08x] ", entry, rxd, len, csum)); | 433 | DRX(("rxd[%d]: %p len[%d] csum[%08x] ", entry, rxd, len, csum)); |
426 | sbus_dma_sync_single_for_cpu(mp->myri_sdev, | 434 | dma_sync_single_for_cpu(&mp->myri_op->dev, |
427 | sbus_readl(&rxd->myri_scatters[0].addr), | 435 | sbus_readl(&rxd->myri_scatters[0].addr), |
428 | RX_ALLOC_SIZE, SBUS_DMA_FROMDEVICE); | 436 | RX_ALLOC_SIZE, DMA_FROM_DEVICE); |
429 | if (len < (ETH_HLEN + MYRI_PAD_LEN) || (skb->data[0] != MYRI_PAD_LEN)) { | 437 | if (len < (ETH_HLEN + MYRI_PAD_LEN) || (skb->data[0] != MYRI_PAD_LEN)) { |
430 | DRX(("ERROR[")); | 438 | DRX(("ERROR[")); |
431 | dev->stats.rx_errors++; | 439 | dev->stats.rx_errors++; |
@@ -442,10 +450,10 @@ static void myri_rx(struct myri_eth *mp, struct net_device *dev) | |||
442 | drops++; | 450 | drops++; |
443 | DRX(("DROP ")); | 451 | DRX(("DROP ")); |
444 | dev->stats.rx_dropped++; | 452 | dev->stats.rx_dropped++; |
445 | sbus_dma_sync_single_for_device(mp->myri_sdev, | 453 | dma_sync_single_for_device(&mp->myri_op->dev, |
446 | sbus_readl(&rxd->myri_scatters[0].addr), | 454 | sbus_readl(&rxd->myri_scatters[0].addr), |
447 | RX_ALLOC_SIZE, | 455 | RX_ALLOC_SIZE, |
448 | SBUS_DMA_FROMDEVICE); | 456 | DMA_FROM_DEVICE); |
449 | sbus_writel(RX_ALLOC_SIZE, &rxd->myri_scatters[0].len); | 457 | sbus_writel(RX_ALLOC_SIZE, &rxd->myri_scatters[0].len); |
450 | sbus_writel(index, &rxd->ctx); | 458 | sbus_writel(index, &rxd->ctx); |
451 | sbus_writel(1, &rxd->num_sg); | 459 | sbus_writel(1, &rxd->num_sg); |
@@ -464,17 +472,17 @@ static void myri_rx(struct myri_eth *mp, struct net_device *dev) | |||
464 | DRX(("skb_alloc(FAILED) ")); | 472 | DRX(("skb_alloc(FAILED) ")); |
465 | goto drop_it; | 473 | goto drop_it; |
466 | } | 474 | } |
467 | sbus_unmap_single(mp->myri_sdev, | 475 | dma_unmap_single(&mp->myri_op->dev, |
468 | sbus_readl(&rxd->myri_scatters[0].addr), | 476 | sbus_readl(&rxd->myri_scatters[0].addr), |
469 | RX_ALLOC_SIZE, | 477 | RX_ALLOC_SIZE, |
470 | SBUS_DMA_FROMDEVICE); | 478 | DMA_FROM_DEVICE); |
471 | mp->rx_skbs[index] = new_skb; | 479 | mp->rx_skbs[index] = new_skb; |
472 | new_skb->dev = dev; | 480 | new_skb->dev = dev; |
473 | skb_put(new_skb, RX_ALLOC_SIZE); | 481 | skb_put(new_skb, RX_ALLOC_SIZE); |
474 | dma_addr = sbus_map_single(mp->myri_sdev, | 482 | dma_addr = dma_map_single(&mp->myri_op->dev, |
475 | new_skb->data, | 483 | new_skb->data, |
476 | RX_ALLOC_SIZE, | 484 | RX_ALLOC_SIZE, |
477 | SBUS_DMA_FROMDEVICE); | 485 | DMA_FROM_DEVICE); |
478 | sbus_writel(dma_addr, &rxd->myri_scatters[0].addr); | 486 | sbus_writel(dma_addr, &rxd->myri_scatters[0].addr); |
479 | sbus_writel(RX_ALLOC_SIZE, &rxd->myri_scatters[0].len); | 487 | sbus_writel(RX_ALLOC_SIZE, &rxd->myri_scatters[0].len); |
480 | sbus_writel(index, &rxd->ctx); | 488 | sbus_writel(index, &rxd->ctx); |
@@ -500,10 +508,10 @@ static void myri_rx(struct myri_eth *mp, struct net_device *dev) | |||
500 | 508 | ||
501 | /* Reuse original ring buffer. */ | 509 | /* Reuse original ring buffer. */ |
502 | DRX(("reuse ")); | 510 | DRX(("reuse ")); |
503 | sbus_dma_sync_single_for_device(mp->myri_sdev, | 511 | dma_sync_single_for_device(&mp->myri_op->dev, |
504 | sbus_readl(&rxd->myri_scatters[0].addr), | 512 | sbus_readl(&rxd->myri_scatters[0].addr), |
505 | RX_ALLOC_SIZE, | 513 | RX_ALLOC_SIZE, |
506 | SBUS_DMA_FROMDEVICE); | 514 | DMA_FROM_DEVICE); |
507 | sbus_writel(RX_ALLOC_SIZE, &rxd->myri_scatters[0].len); | 515 | sbus_writel(RX_ALLOC_SIZE, &rxd->myri_scatters[0].len); |
508 | sbus_writel(index, &rxd->ctx); | 516 | sbus_writel(index, &rxd->ctx); |
509 | sbus_writel(1, &rxd->num_sg); | 517 | sbus_writel(1, &rxd->num_sg); |
@@ -652,7 +660,8 @@ static int myri_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
652 | sbus_writew((skb->data[4] << 8) | skb->data[5], &txd->addr[3]); | 660 | sbus_writew((skb->data[4] << 8) | skb->data[5], &txd->addr[3]); |
653 | } | 661 | } |
654 | 662 | ||
655 | dma_addr = sbus_map_single(mp->myri_sdev, skb->data, len, SBUS_DMA_TODEVICE); | 663 | dma_addr = dma_map_single(&mp->myri_op->dev, skb->data, |
664 | len, DMA_TO_DEVICE); | ||
656 | sbus_writel(dma_addr, &txd->myri_gathers[0].addr); | 665 | sbus_writel(dma_addr, &txd->myri_gathers[0].addr); |
657 | sbus_writel(len, &txd->myri_gathers[0].len); | 666 | sbus_writel(len, &txd->myri_gathers[0].len); |
658 | sbus_writel(1, &txd->num_sg); | 667 | sbus_writel(1, &txd->num_sg); |
@@ -891,30 +900,30 @@ static const struct header_ops myri_header_ops = { | |||
891 | .cache_update = myri_header_cache_update, | 900 | .cache_update = myri_header_cache_update, |
892 | }; | 901 | }; |
893 | 902 | ||
894 | static int __devinit myri_ether_init(struct sbus_dev *sdev) | 903 | static int __devinit myri_sbus_probe(struct of_device *op, const struct of_device_id *match) |
895 | { | 904 | { |
896 | static int num; | 905 | struct device_node *dp = op->node; |
897 | static unsigned version_printed; | 906 | static unsigned version_printed; |
898 | struct net_device *dev; | 907 | struct net_device *dev; |
899 | struct myri_eth *mp; | ||
900 | unsigned char prop_buf[32]; | ||
901 | int i; | ||
902 | DECLARE_MAC_BUF(mac); | 908 | DECLARE_MAC_BUF(mac); |
909 | struct myri_eth *mp; | ||
910 | const void *prop; | ||
911 | static int num; | ||
912 | int i, len; | ||
903 | 913 | ||
904 | DET(("myri_ether_init(%p,%d):\n", sdev, num)); | 914 | DET(("myri_ether_init(%p,%d):\n", op, num)); |
905 | dev = alloc_etherdev(sizeof(struct myri_eth)); | 915 | dev = alloc_etherdev(sizeof(struct myri_eth)); |
906 | |||
907 | if (!dev) | 916 | if (!dev) |
908 | return -ENOMEM; | 917 | return -ENOMEM; |
909 | 918 | ||
910 | if (version_printed++ == 0) | 919 | if (version_printed++ == 0) |
911 | printk(version); | 920 | printk(version); |
912 | 921 | ||
913 | SET_NETDEV_DEV(dev, &sdev->ofdev.dev); | 922 | SET_NETDEV_DEV(dev, &op->dev); |
914 | 923 | ||
915 | mp = (struct myri_eth *) dev->priv; | 924 | mp = netdev_priv(dev); |
916 | spin_lock_init(&mp->irq_lock); | 925 | spin_lock_init(&mp->irq_lock); |
917 | mp->myri_sdev = sdev; | 926 | mp->myri_op = op; |
918 | 927 | ||
919 | /* Clean out skb arrays. */ | 928 | /* Clean out skb arrays. */ |
920 | for (i = 0; i < (RX_RING_SIZE + 1); i++) | 929 | for (i = 0; i < (RX_RING_SIZE + 1); i++) |
@@ -924,55 +933,44 @@ static int __devinit myri_ether_init(struct sbus_dev *sdev) | |||
924 | mp->tx_skbs[i] = NULL; | 933 | mp->tx_skbs[i] = NULL; |
925 | 934 | ||
926 | /* First check for EEPROM information. */ | 935 | /* First check for EEPROM information. */ |
927 | i = prom_getproperty(sdev->prom_node, "myrinet-eeprom-info", | 936 | prop = of_get_property(dp, "myrinet-eeprom-info", &len); |
928 | (char *)&mp->eeprom, sizeof(struct myri_eeprom)); | 937 | |
929 | DET(("prom_getprop(myrinet-eeprom-info) returns %d\n", i)); | 938 | if (prop) |
930 | if (i == 0 || i == -1) { | 939 | memcpy(&mp->eeprom, prop, sizeof(struct myri_eeprom)); |
940 | if (!prop) { | ||
931 | /* No eeprom property, must cook up the values ourselves. */ | 941 | /* No eeprom property, must cook up the values ourselves. */ |
932 | DET(("No EEPROM: ")); | 942 | DET(("No EEPROM: ")); |
933 | mp->eeprom.bus_type = BUS_TYPE_SBUS; | 943 | mp->eeprom.bus_type = BUS_TYPE_SBUS; |
934 | mp->eeprom.cpuvers = prom_getintdefault(sdev->prom_node,"cpu_version",0); | 944 | mp->eeprom.cpuvers = |
935 | mp->eeprom.cval = prom_getintdefault(sdev->prom_node,"clock_value",0); | 945 | of_getintprop_default(dp, "cpu_version", 0); |
936 | mp->eeprom.ramsz = prom_getintdefault(sdev->prom_node,"sram_size",0); | 946 | mp->eeprom.cval = |
937 | DET(("cpuvers[%d] cval[%d] ramsz[%d]\n", mp->eeprom.cpuvers, | 947 | of_getintprop_default(dp, "clock_value", 0); |
938 | mp->eeprom.cval, mp->eeprom.ramsz)); | 948 | mp->eeprom.ramsz = of_getintprop_default(dp, "sram_size", 0); |
939 | if (mp->eeprom.cpuvers == 0) { | 949 | if (!mp->eeprom.cpuvers) |
940 | DET(("EEPROM: cpuvers was zero, setting to %04x\n",CPUVERS_2_3)); | ||
941 | mp->eeprom.cpuvers = CPUVERS_2_3; | 950 | mp->eeprom.cpuvers = CPUVERS_2_3; |
942 | } | 951 | if (mp->eeprom.cpuvers < CPUVERS_3_0) |
943 | if (mp->eeprom.cpuvers < CPUVERS_3_0) { | ||
944 | DET(("EEPROM: cpuvers < CPUVERS_3_0, clockval set to zero.\n")); | ||
945 | mp->eeprom.cval = 0; | 952 | mp->eeprom.cval = 0; |
946 | } | 953 | if (!mp->eeprom.ramsz) |
947 | if (mp->eeprom.ramsz == 0) { | ||
948 | DET(("EEPROM: ramsz == 0, setting to 128k\n")); | ||
949 | mp->eeprom.ramsz = (128 * 1024); | 954 | mp->eeprom.ramsz = (128 * 1024); |
950 | } | 955 | |
951 | i = prom_getproperty(sdev->prom_node, "myrinet-board-id", | 956 | prop = of_get_property(dp, "myrinet-board-id", &len); |
952 | &prop_buf[0], 10); | 957 | if (prop) |
953 | DET(("EEPROM: prom_getprop(myrinet-board-id) returns %d\n", i)); | 958 | memcpy(&mp->eeprom.id[0], prop, 6); |
954 | if ((i != 0) && (i != -1)) | ||
955 | memcpy(&mp->eeprom.id[0], &prop_buf[0], 6); | ||
956 | else | 959 | else |
957 | set_boardid_from_idprom(mp, num); | 960 | set_boardid_from_idprom(mp, num); |
958 | i = prom_getproperty(sdev->prom_node, "fpga_version", | 961 | |
959 | &mp->eeprom.fvers[0], 32); | 962 | prop = of_get_property(dp, "fpga_version", &len); |
960 | DET(("EEPROM: prom_getprop(fpga_version) returns %d\n", i)); | 963 | if (prop) |
961 | if (i == 0 || i == -1) | 964 | memcpy(&mp->eeprom.fvers[0], prop, 32); |
965 | else | ||
962 | memset(&mp->eeprom.fvers[0], 0, 32); | 966 | memset(&mp->eeprom.fvers[0], 0, 32); |
963 | 967 | ||
964 | if (mp->eeprom.cpuvers == CPUVERS_4_1) { | 968 | if (mp->eeprom.cpuvers == CPUVERS_4_1) { |
965 | DET(("EEPROM: cpuvers CPUVERS_4_1, ")); | 969 | if (mp->eeprom.ramsz == (128 * 1024)) |
966 | if (mp->eeprom.ramsz == (128 * 1024)) { | ||
967 | DET(("ramsize 128k, setting to 256k, ")); | ||
968 | mp->eeprom.ramsz = (256 * 1024); | 970 | mp->eeprom.ramsz = (256 * 1024); |
969 | } | 971 | if ((mp->eeprom.cval == 0x40414041) || |
970 | if ((mp->eeprom.cval==0x40414041)||(mp->eeprom.cval==0x90449044)){ | 972 | (mp->eeprom.cval == 0x90449044)) |
971 | DET(("changing cval from %08x to %08x ", | ||
972 | mp->eeprom.cval, 0x50e450e4)); | ||
973 | mp->eeprom.cval = 0x50e450e4; | 973 | mp->eeprom.cval = 0x50e450e4; |
974 | } | ||
975 | DET(("\n")); | ||
976 | } | 974 | } |
977 | } | 975 | } |
978 | #ifdef DEBUG_DETECT | 976 | #ifdef DEBUG_DETECT |
@@ -991,8 +989,8 @@ static int __devinit myri_ether_init(struct sbus_dev *sdev) | |||
991 | * XXX only a valid version for PCI cards? Ask feldy... | 989 | * XXX only a valid version for PCI cards? Ask feldy... |
992 | */ | 990 | */ |
993 | DET(("Mapping regs for cpuvers < CPUVERS_4_0\n")); | 991 | DET(("Mapping regs for cpuvers < CPUVERS_4_0\n")); |
994 | mp->regs = sbus_ioremap(&sdev->resource[0], 0, | 992 | mp->regs = of_ioremap(&op->resource[0], 0, |
995 | mp->reg_size, "MyriCOM Regs"); | 993 | mp->reg_size, "MyriCOM Regs"); |
996 | if (!mp->regs) { | 994 | if (!mp->regs) { |
997 | printk("MyriCOM: Cannot map MyriCOM registers.\n"); | 995 | printk("MyriCOM: Cannot map MyriCOM registers.\n"); |
998 | goto err; | 996 | goto err; |
@@ -1001,13 +999,12 @@ static int __devinit myri_ether_init(struct sbus_dev *sdev) | |||
1001 | mp->lregs = mp->lanai + (0x10000 * 2); | 999 | mp->lregs = mp->lanai + (0x10000 * 2); |
1002 | } else { | 1000 | } else { |
1003 | DET(("Mapping regs for cpuvers >= CPUVERS_4_0\n")); | 1001 | DET(("Mapping regs for cpuvers >= CPUVERS_4_0\n")); |
1004 | mp->cregs = sbus_ioremap(&sdev->resource[0], 0, | 1002 | mp->cregs = of_ioremap(&op->resource[0], 0, |
1005 | PAGE_SIZE, "MyriCOM Control Regs"); | 1003 | PAGE_SIZE, "MyriCOM Control Regs"); |
1006 | mp->lregs = sbus_ioremap(&sdev->resource[0], (256 * 1024), | 1004 | mp->lregs = of_ioremap(&op->resource[0], (256 * 1024), |
1007 | PAGE_SIZE, "MyriCOM LANAI Regs"); | 1005 | PAGE_SIZE, "MyriCOM LANAI Regs"); |
1008 | mp->lanai = | 1006 | mp->lanai = of_ioremap(&op->resource[0], (512 * 1024), |
1009 | sbus_ioremap(&sdev->resource[0], (512 * 1024), | 1007 | mp->eeprom.ramsz, "MyriCOM SRAM"); |
1010 | mp->eeprom.ramsz, "MyriCOM SRAM"); | ||
1011 | } | 1008 | } |
1012 | DET(("Registers mapped: cregs[%p] lregs[%p] lanai[%p]\n", | 1009 | DET(("Registers mapped: cregs[%p] lregs[%p] lanai[%p]\n", |
1013 | mp->cregs, mp->lregs, mp->lanai)); | 1010 | mp->cregs, mp->lregs, mp->lanai)); |
@@ -1039,16 +1036,15 @@ static int __devinit myri_ether_init(struct sbus_dev *sdev) | |||
1039 | myri_reset_on(mp->cregs); | 1036 | myri_reset_on(mp->cregs); |
1040 | 1037 | ||
1041 | /* Get the supported DVMA burst sizes from our SBUS. */ | 1038 | /* Get the supported DVMA burst sizes from our SBUS. */ |
1042 | mp->myri_bursts = prom_getintdefault(mp->myri_sdev->bus->prom_node, | 1039 | mp->myri_bursts = of_getintprop_default(dp->parent, |
1043 | "burst-sizes", 0x00); | 1040 | "burst-sizes", 0x00); |
1044 | 1041 | if (!sbus_can_burst64()) | |
1045 | if (!sbus_can_burst64(sdev)) | ||
1046 | mp->myri_bursts &= ~(DMA_BURST64); | 1042 | mp->myri_bursts &= ~(DMA_BURST64); |
1047 | 1043 | ||
1048 | DET(("MYRI bursts %02x\n", mp->myri_bursts)); | 1044 | DET(("MYRI bursts %02x\n", mp->myri_bursts)); |
1049 | 1045 | ||
1050 | /* Encode SBUS interrupt level in second control register. */ | 1046 | /* Encode SBUS interrupt level in second control register. */ |
1051 | i = prom_getint(sdev->prom_node, "interrupts"); | 1047 | i = of_getintprop_default(dp, "interrupts", 0); |
1052 | if (i == 0) | 1048 | if (i == 0) |
1053 | i = 4; | 1049 | i = 4; |
1054 | DET(("prom_getint(interrupts)==%d, irqlvl set to %04x\n", | 1050 | DET(("prom_getint(interrupts)==%d, irqlvl set to %04x\n", |
@@ -1063,7 +1059,7 @@ static int __devinit myri_ether_init(struct sbus_dev *sdev) | |||
1063 | dev->tx_timeout = &myri_tx_timeout; | 1059 | dev->tx_timeout = &myri_tx_timeout; |
1064 | dev->watchdog_timeo = 5*HZ; | 1060 | dev->watchdog_timeo = 5*HZ; |
1065 | dev->set_multicast_list = &myri_set_multicast; | 1061 | dev->set_multicast_list = &myri_set_multicast; |
1066 | dev->irq = sdev->irqs[0]; | 1062 | dev->irq = op->irqs[0]; |
1067 | 1063 | ||
1068 | /* Register interrupt handler now. */ | 1064 | /* Register interrupt handler now. */ |
1069 | DET(("Requesting MYRIcom IRQ line.\n")); | 1065 | DET(("Requesting MYRIcom IRQ line.\n")); |
@@ -1088,7 +1084,7 @@ static int __devinit myri_ether_init(struct sbus_dev *sdev) | |||
1088 | goto err_free_irq; | 1084 | goto err_free_irq; |
1089 | } | 1085 | } |
1090 | 1086 | ||
1091 | dev_set_drvdata(&sdev->ofdev.dev, mp); | 1087 | dev_set_drvdata(&op->dev, mp); |
1092 | 1088 | ||
1093 | num++; | 1089 | num++; |
1094 | 1090 | ||
@@ -1105,17 +1101,9 @@ err: | |||
1105 | return -ENODEV; | 1101 | return -ENODEV; |
1106 | } | 1102 | } |
1107 | 1103 | ||
1108 | 1104 | static int __devexit myri_sbus_remove(struct of_device *op) | |
1109 | static int __devinit myri_sbus_probe(struct of_device *dev, const struct of_device_id *match) | ||
1110 | { | ||
1111 | struct sbus_dev *sdev = to_sbus_device(&dev->dev); | ||
1112 | |||
1113 | return myri_ether_init(sdev); | ||
1114 | } | ||
1115 | |||
1116 | static int __devexit myri_sbus_remove(struct of_device *dev) | ||
1117 | { | 1105 | { |
1118 | struct myri_eth *mp = dev_get_drvdata(&dev->dev); | 1106 | struct myri_eth *mp = dev_get_drvdata(&op->dev); |
1119 | struct net_device *net_dev = mp->dev; | 1107 | struct net_device *net_dev = mp->dev; |
1120 | 1108 | ||
1121 | unregister_netdev(net_dev); | 1109 | unregister_netdev(net_dev); |
@@ -1123,21 +1111,21 @@ static int __devexit myri_sbus_remove(struct of_device *dev) | |||
1123 | free_irq(net_dev->irq, net_dev); | 1111 | free_irq(net_dev->irq, net_dev); |
1124 | 1112 | ||
1125 | if (mp->eeprom.cpuvers < CPUVERS_4_0) { | 1113 | if (mp->eeprom.cpuvers < CPUVERS_4_0) { |
1126 | sbus_iounmap(mp->regs, mp->reg_size); | 1114 | of_iounmap(&op->resource[0], mp->regs, mp->reg_size); |
1127 | } else { | 1115 | } else { |
1128 | sbus_iounmap(mp->cregs, PAGE_SIZE); | 1116 | of_iounmap(&op->resource[0], mp->cregs, PAGE_SIZE); |
1129 | sbus_iounmap(mp->lregs, (256 * 1024)); | 1117 | of_iounmap(&op->resource[0], mp->lregs, (256 * 1024)); |
1130 | sbus_iounmap(mp->lanai, (512 * 1024)); | 1118 | of_iounmap(&op->resource[0], mp->lanai, (512 * 1024)); |
1131 | } | 1119 | } |
1132 | 1120 | ||
1133 | free_netdev(net_dev); | 1121 | free_netdev(net_dev); |
1134 | 1122 | ||
1135 | dev_set_drvdata(&dev->dev, NULL); | 1123 | dev_set_drvdata(&op->dev, NULL); |
1136 | 1124 | ||
1137 | return 0; | 1125 | return 0; |
1138 | } | 1126 | } |
1139 | 1127 | ||
1140 | static struct of_device_id myri_sbus_match[] = { | 1128 | static const struct of_device_id myri_sbus_match[] = { |
1141 | { | 1129 | { |
1142 | .name = "MYRICOM,mlanai", | 1130 | .name = "MYRICOM,mlanai", |
1143 | }, | 1131 | }, |
@@ -1158,7 +1146,7 @@ static struct of_platform_driver myri_sbus_driver = { | |||
1158 | 1146 | ||
1159 | static int __init myri_sbus_init(void) | 1147 | static int __init myri_sbus_init(void) |
1160 | { | 1148 | { |
1161 | return of_register_driver(&myri_sbus_driver, &sbus_bus_type); | 1149 | return of_register_driver(&myri_sbus_driver, &of_bus_type); |
1162 | } | 1150 | } |
1163 | 1151 | ||
1164 | static void __exit myri_sbus_exit(void) | 1152 | static void __exit myri_sbus_exit(void) |
diff --git a/drivers/net/myri_sbus.h b/drivers/net/myri_sbus.h index 5d93fcc95d55..ff363e95d9cf 100644 --- a/drivers/net/myri_sbus.h +++ b/drivers/net/myri_sbus.h | |||
@@ -288,7 +288,7 @@ struct myri_eth { | |||
288 | struct myri_eeprom eeprom; /* Local copy of EEPROM. */ | 288 | struct myri_eeprom eeprom; /* Local copy of EEPROM. */ |
289 | unsigned int reg_size; /* Size of register space. */ | 289 | unsigned int reg_size; /* Size of register space. */ |
290 | unsigned int shmem_base; /* Offset to shared ram. */ | 290 | unsigned int shmem_base; /* Offset to shared ram. */ |
291 | struct sbus_dev *myri_sdev; /* Our SBUS device struct. */ | 291 | struct of_device *myri_op; /* Our OF device struct. */ |
292 | }; | 292 | }; |
293 | 293 | ||
294 | /* We use this to acquire receive skb's that we can DMA directly into. */ | 294 | /* We use this to acquire receive skb's that we can DMA directly into. */ |
diff --git a/drivers/net/niu.c b/drivers/net/niu.c index e3be81eba8a4..ebc812702903 100644 --- a/drivers/net/niu.c +++ b/drivers/net/niu.c | |||
@@ -9130,7 +9130,7 @@ static int __devexit niu_of_remove(struct of_device *op) | |||
9130 | return 0; | 9130 | return 0; |
9131 | } | 9131 | } |
9132 | 9132 | ||
9133 | static struct of_device_id niu_match[] = { | 9133 | static const struct of_device_id niu_match[] = { |
9134 | { | 9134 | { |
9135 | .name = "network", | 9135 | .name = "network", |
9136 | .compatible = "SUNW,niusl", | 9136 | .compatible = "SUNW,niusl", |
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c index 7112fd5e0e1b..08c4dd896077 100644 --- a/drivers/net/pcmcia/3c574_cs.c +++ b/drivers/net/pcmcia/3c574_cs.c | |||
@@ -355,9 +355,10 @@ static int tc574_config(struct pcmcia_device *link) | |||
355 | for (i = j = 0; j < 0x400; j += 0x20) { | 355 | for (i = j = 0; j < 0x400; j += 0x20) { |
356 | link->io.BasePort1 = j ^ 0x300; | 356 | link->io.BasePort1 = j ^ 0x300; |
357 | i = pcmcia_request_io(link, &link->io); | 357 | i = pcmcia_request_io(link, &link->io); |
358 | if (i == CS_SUCCESS) break; | 358 | if (i == 0) |
359 | break; | ||
359 | } | 360 | } |
360 | if (i != CS_SUCCESS) { | 361 | if (i != 0) { |
361 | cs_error(link, RequestIO, i); | 362 | cs_error(link, RequestIO, i); |
362 | goto failed; | 363 | goto failed; |
363 | } | 364 | } |
@@ -377,7 +378,7 @@ static int tc574_config(struct pcmcia_device *link) | |||
377 | tuple.TupleDataMax = 64; | 378 | tuple.TupleDataMax = 64; |
378 | tuple.TupleOffset = 0; | 379 | tuple.TupleOffset = 0; |
379 | tuple.DesiredTuple = 0x88; | 380 | tuple.DesiredTuple = 0x88; |
380 | if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { | 381 | if (pcmcia_get_first_tuple(link, &tuple) == 0) { |
381 | pcmcia_get_tuple_data(link, &tuple); | 382 | pcmcia_get_tuple_data(link, &tuple); |
382 | for (i = 0; i < 3; i++) | 383 | for (i = 0; i < 3; i++) |
383 | phys_addr[i] = htons(le16_to_cpu(buf[i])); | 384 | phys_addr[i] = htons(le16_to_cpu(buf[i])); |
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c index 29bd8532d323..c235cdba69c6 100644 --- a/drivers/net/pcmcia/3c589_cs.c +++ b/drivers/net/pcmcia/3c589_cs.c | |||
@@ -278,9 +278,10 @@ static int tc589_config(struct pcmcia_device *link) | |||
278 | if (multi && (j & 0x80)) continue; | 278 | if (multi && (j & 0x80)) continue; |
279 | link->io.BasePort1 = j ^ 0x300; | 279 | link->io.BasePort1 = j ^ 0x300; |
280 | i = pcmcia_request_io(link, &link->io); | 280 | i = pcmcia_request_io(link, &link->io); |
281 | if (i == CS_SUCCESS) break; | 281 | if (i == 0) |
282 | break; | ||
282 | } | 283 | } |
283 | if (i != CS_SUCCESS) { | 284 | if (i != 0) { |
284 | cs_error(link, RequestIO, i); | 285 | cs_error(link, RequestIO, i); |
285 | goto failed; | 286 | goto failed; |
286 | } | 287 | } |
@@ -295,7 +296,7 @@ static int tc589_config(struct pcmcia_device *link) | |||
295 | /* The 3c589 has an extra EEPROM for configuration info, including | 296 | /* The 3c589 has an extra EEPROM for configuration info, including |
296 | the hardware address. The 3c562 puts the address in the CIS. */ | 297 | the hardware address. The 3c562 puts the address in the CIS. */ |
297 | tuple.DesiredTuple = 0x88; | 298 | tuple.DesiredTuple = 0x88; |
298 | if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { | 299 | if (pcmcia_get_first_tuple(link, &tuple) == 0) { |
299 | pcmcia_get_tuple_data(link, &tuple); | 300 | pcmcia_get_tuple_data(link, &tuple); |
300 | for (i = 0; i < 3; i++) | 301 | for (i = 0; i < 3; i++) |
301 | phys_addr[i] = htons(le16_to_cpu(buf[i])); | 302 | phys_addr[i] = htons(le16_to_cpu(buf[i])); |
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c index 52bf11b73c6e..b37a498939ae 100644 --- a/drivers/net/pcmcia/axnet_cs.c +++ b/drivers/net/pcmcia/axnet_cs.c | |||
@@ -262,7 +262,7 @@ static int try_io_port(struct pcmcia_device *link) | |||
262 | if (link->io.NumPorts2 > 0) { | 262 | if (link->io.NumPorts2 > 0) { |
263 | /* for master/slave multifunction cards */ | 263 | /* for master/slave multifunction cards */ |
264 | link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; | 264 | link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; |
265 | link->irq.Attributes = | 265 | link->irq.Attributes = |
266 | IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; | 266 | IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; |
267 | } | 267 | } |
268 | } else { | 268 | } else { |
@@ -276,7 +276,8 @@ static int try_io_port(struct pcmcia_device *link) | |||
276 | link->io.BasePort1 = j ^ 0x300; | 276 | link->io.BasePort1 = j ^ 0x300; |
277 | link->io.BasePort2 = (j ^ 0x300) + 0x10; | 277 | link->io.BasePort2 = (j ^ 0x300) + 0x10; |
278 | ret = pcmcia_request_io(link, &link->io); | 278 | ret = pcmcia_request_io(link, &link->io); |
279 | if (ret == CS_SUCCESS) return ret; | 279 | if (ret == 0) |
280 | return ret; | ||
280 | } | 281 | } |
281 | return ret; | 282 | return ret; |
282 | } else { | 283 | } else { |
@@ -284,59 +285,50 @@ static int try_io_port(struct pcmcia_device *link) | |||
284 | } | 285 | } |
285 | } | 286 | } |
286 | 287 | ||
288 | static int axnet_configcheck(struct pcmcia_device *p_dev, | ||
289 | cistpl_cftable_entry_t *cfg, | ||
290 | cistpl_cftable_entry_t *dflt, | ||
291 | unsigned int vcc, | ||
292 | void *priv_data) | ||
293 | { | ||
294 | int i; | ||
295 | cistpl_io_t *io = &cfg->io; | ||
296 | |||
297 | if (cfg->index == 0 || cfg->io.nwin == 0) | ||
298 | return -ENODEV; | ||
299 | |||
300 | p_dev->conf.ConfigIndex = 0x05; | ||
301 | /* For multifunction cards, by convention, we configure the | ||
302 | network function with window 0, and serial with window 1 */ | ||
303 | if (io->nwin > 1) { | ||
304 | i = (io->win[1].len > io->win[0].len); | ||
305 | p_dev->io.BasePort2 = io->win[1-i].base; | ||
306 | p_dev->io.NumPorts2 = io->win[1-i].len; | ||
307 | } else { | ||
308 | i = p_dev->io.NumPorts2 = 0; | ||
309 | } | ||
310 | p_dev->io.BasePort1 = io->win[i].base; | ||
311 | p_dev->io.NumPorts1 = io->win[i].len; | ||
312 | p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
313 | if (p_dev->io.NumPorts1 + p_dev->io.NumPorts2 >= 32) | ||
314 | return try_io_port(p_dev); | ||
315 | |||
316 | return -ENODEV; | ||
317 | } | ||
318 | |||
287 | static int axnet_config(struct pcmcia_device *link) | 319 | static int axnet_config(struct pcmcia_device *link) |
288 | { | 320 | { |
289 | struct net_device *dev = link->priv; | 321 | struct net_device *dev = link->priv; |
290 | axnet_dev_t *info = PRIV(dev); | 322 | axnet_dev_t *info = PRIV(dev); |
291 | tuple_t tuple; | ||
292 | cisparse_t parse; | ||
293 | int i, j, last_ret, last_fn; | 323 | int i, j, last_ret, last_fn; |
294 | u_short buf[64]; | ||
295 | DECLARE_MAC_BUF(mac); | 324 | DECLARE_MAC_BUF(mac); |
296 | 325 | ||
297 | DEBUG(0, "axnet_config(0x%p)\n", link); | 326 | DEBUG(0, "axnet_config(0x%p)\n", link); |
298 | 327 | ||
299 | tuple.Attributes = 0; | ||
300 | tuple.TupleData = (cisdata_t *)buf; | ||
301 | tuple.TupleDataMax = sizeof(buf); | ||
302 | tuple.TupleOffset = 0; | ||
303 | |||
304 | /* don't trust the CIS on this; Linksys got it wrong */ | 328 | /* don't trust the CIS on this; Linksys got it wrong */ |
305 | link->conf.Present = 0x63; | 329 | link->conf.Present = 0x63; |
306 | 330 | last_ret = pcmcia_loop_config(link, axnet_configcheck, NULL); | |
307 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 331 | if (last_ret != 0) { |
308 | tuple.Attributes = 0; | ||
309 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
310 | while (last_ret == CS_SUCCESS) { | ||
311 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | ||
312 | cistpl_io_t *io = &(parse.cftable_entry.io); | ||
313 | |||
314 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
315 | pcmcia_parse_tuple(link, &tuple, &parse) != 0 || | ||
316 | cfg->index == 0 || cfg->io.nwin == 0) | ||
317 | goto next_entry; | ||
318 | |||
319 | link->conf.ConfigIndex = 0x05; | ||
320 | /* For multifunction cards, by convention, we configure the | ||
321 | network function with window 0, and serial with window 1 */ | ||
322 | if (io->nwin > 1) { | ||
323 | i = (io->win[1].len > io->win[0].len); | ||
324 | link->io.BasePort2 = io->win[1-i].base; | ||
325 | link->io.NumPorts2 = io->win[1-i].len; | ||
326 | } else { | ||
327 | i = link->io.NumPorts2 = 0; | ||
328 | } | ||
329 | link->io.BasePort1 = io->win[i].base; | ||
330 | link->io.NumPorts1 = io->win[i].len; | ||
331 | link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
332 | if (link->io.NumPorts1 + link->io.NumPorts2 >= 32) { | ||
333 | last_ret = try_io_port(link); | ||
334 | if (last_ret == CS_SUCCESS) break; | ||
335 | } | ||
336 | next_entry: | ||
337 | last_ret = pcmcia_get_next_tuple(link, &tuple); | ||
338 | } | ||
339 | if (last_ret != CS_SUCCESS) { | ||
340 | cs_error(link, RequestIO, last_ret); | 332 | cs_error(link, RequestIO, last_ret); |
341 | goto failed; | 333 | goto failed; |
342 | } | 334 | } |
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c index ea9414c4d900..831090c75622 100644 --- a/drivers/net/pcmcia/com20020_cs.c +++ b/drivers/net/pcmcia/com20020_cs.c | |||
@@ -260,21 +260,21 @@ static int com20020_config(struct pcmcia_device *link) | |||
260 | DEBUG(0, "com20020_config(0x%p)\n", link); | 260 | DEBUG(0, "com20020_config(0x%p)\n", link); |
261 | 261 | ||
262 | DEBUG(1,"arcnet: baseport1 is %Xh\n", link->io.BasePort1); | 262 | DEBUG(1,"arcnet: baseport1 is %Xh\n", link->io.BasePort1); |
263 | i = !CS_SUCCESS; | 263 | i = -ENODEV; |
264 | if (!link->io.BasePort1) | 264 | if (!link->io.BasePort1) |
265 | { | 265 | { |
266 | for (ioaddr = 0x100; ioaddr < 0x400; ioaddr += 0x10) | 266 | for (ioaddr = 0x100; ioaddr < 0x400; ioaddr += 0x10) |
267 | { | 267 | { |
268 | link->io.BasePort1 = ioaddr; | 268 | link->io.BasePort1 = ioaddr; |
269 | i = pcmcia_request_io(link, &link->io); | 269 | i = pcmcia_request_io(link, &link->io); |
270 | if (i == CS_SUCCESS) | 270 | if (i == 0) |
271 | break; | 271 | break; |
272 | } | 272 | } |
273 | } | 273 | } |
274 | else | 274 | else |
275 | i = pcmcia_request_io(link, &link->io); | 275 | i = pcmcia_request_io(link, &link->io); |
276 | 276 | ||
277 | if (i != CS_SUCCESS) | 277 | if (i != 0) |
278 | { | 278 | { |
279 | DEBUG(1,"arcnet: requestIO failed totally!\n"); | 279 | DEBUG(1,"arcnet: requestIO failed totally!\n"); |
280 | goto failed; | 280 | goto failed; |
@@ -287,7 +287,7 @@ static int com20020_config(struct pcmcia_device *link) | |||
287 | link->irq.AssignedIRQ, | 287 | link->irq.AssignedIRQ, |
288 | link->irq.IRQInfo1, link->irq.IRQInfo2); | 288 | link->irq.IRQInfo1, link->irq.IRQInfo2); |
289 | i = pcmcia_request_irq(link, &link->irq); | 289 | i = pcmcia_request_irq(link, &link->irq); |
290 | if (i != CS_SUCCESS) | 290 | if (i != 0) |
291 | { | 291 | { |
292 | DEBUG(1,"arcnet: requestIRQ failed totally!\n"); | 292 | DEBUG(1,"arcnet: requestIRQ failed totally!\n"); |
293 | goto failed; | 293 | goto failed; |
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index a550c9bd126f..69d916daa7bb 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c | |||
@@ -309,7 +309,8 @@ static int mfc_try_io_port(struct pcmcia_device *link) | |||
309 | printk(KERN_NOTICE "fmvj18x_cs: out of resource for serial\n"); | 309 | printk(KERN_NOTICE "fmvj18x_cs: out of resource for serial\n"); |
310 | } | 310 | } |
311 | ret = pcmcia_request_io(link, &link->io); | 311 | ret = pcmcia_request_io(link, &link->io); |
312 | if (ret == CS_SUCCESS) return ret; | 312 | if (ret == 0) |
313 | return ret; | ||
313 | } | 314 | } |
314 | return ret; | 315 | return ret; |
315 | } | 316 | } |
@@ -325,7 +326,7 @@ static int ungermann_try_io_port(struct pcmcia_device *link) | |||
325 | for (ioaddr = 0x300; ioaddr < 0x3e0; ioaddr += 0x20) { | 326 | for (ioaddr = 0x300; ioaddr < 0x3e0; ioaddr += 0x20) { |
326 | link->io.BasePort1 = ioaddr; | 327 | link->io.BasePort1 = ioaddr; |
327 | ret = pcmcia_request_io(link, &link->io); | 328 | ret = pcmcia_request_io(link, &link->io); |
328 | if (ret == CS_SUCCESS) { | 329 | if (ret == 0) { |
329 | /* calculate ConfigIndex value */ | 330 | /* calculate ConfigIndex value */ |
330 | link->conf.ConfigIndex = | 331 | link->conf.ConfigIndex = |
331 | ((link->io.BasePort1 & 0x0f0) >> 3) | 0x22; | 332 | ((link->io.BasePort1 & 0x0f0) >> 3) | 0x22; |
@@ -356,12 +357,12 @@ static int fmvj18x_config(struct pcmcia_device *link) | |||
356 | tuple.TupleOffset = 0; | 357 | tuple.TupleOffset = 0; |
357 | tuple.DesiredTuple = CISTPL_FUNCE; | 358 | tuple.DesiredTuple = CISTPL_FUNCE; |
358 | tuple.TupleOffset = 0; | 359 | tuple.TupleOffset = 0; |
359 | if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { | 360 | if (pcmcia_get_first_tuple(link, &tuple) == 0) { |
360 | /* Yes, I have CISTPL_FUNCE. Let's check CISTPL_MANFID */ | 361 | /* Yes, I have CISTPL_FUNCE. Let's check CISTPL_MANFID */ |
361 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 362 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; |
362 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | 363 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
363 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); | 364 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); |
364 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); | 365 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(&tuple, &parse)); |
365 | link->conf.ConfigIndex = parse.cftable_entry.index; | 366 | link->conf.ConfigIndex = parse.cftable_entry.index; |
366 | switch (link->manf_id) { | 367 | switch (link->manf_id) { |
367 | case MANFID_TDK: | 368 | case MANFID_TDK: |
@@ -430,10 +431,10 @@ static int fmvj18x_config(struct pcmcia_device *link) | |||
430 | link->irq.Attributes = | 431 | link->irq.Attributes = |
431 | IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED|IRQ_HANDLE_PRESENT; | 432 | IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED|IRQ_HANDLE_PRESENT; |
432 | ret = mfc_try_io_port(link); | 433 | ret = mfc_try_io_port(link); |
433 | if (ret != CS_SUCCESS) goto cs_failed; | 434 | if (ret != 0) goto cs_failed; |
434 | } else if (cardtype == UNGERMANN) { | 435 | } else if (cardtype == UNGERMANN) { |
435 | ret = ungermann_try_io_port(link); | 436 | ret = ungermann_try_io_port(link); |
436 | if (ret != CS_SUCCESS) goto cs_failed; | 437 | if (ret != 0) goto cs_failed; |
437 | } else { | 438 | } else { |
438 | CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); | 439 | CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); |
439 | } | 440 | } |
@@ -565,7 +566,7 @@ static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id) | |||
565 | req.Base = 0; req.Size = 0; | 566 | req.Base = 0; req.Size = 0; |
566 | req.AccessSpeed = 0; | 567 | req.AccessSpeed = 0; |
567 | i = pcmcia_request_window(&link, &req, &link->win); | 568 | i = pcmcia_request_window(&link, &req, &link->win); |
568 | if (i != CS_SUCCESS) { | 569 | if (i != 0) { |
569 | cs_error(link, RequestWindow, i); | 570 | cs_error(link, RequestWindow, i); |
570 | return -1; | 571 | return -1; |
571 | } | 572 | } |
@@ -599,7 +600,7 @@ static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id) | |||
599 | 600 | ||
600 | iounmap(base); | 601 | iounmap(base); |
601 | j = pcmcia_release_window(link->win); | 602 | j = pcmcia_release_window(link->win); |
602 | if (j != CS_SUCCESS) | 603 | if (j != 0) |
603 | cs_error(link, ReleaseWindow, j); | 604 | cs_error(link, ReleaseWindow, j); |
604 | return (i != 0x200) ? 0 : -1; | 605 | return (i != 0x200) ? 0 : -1; |
605 | 606 | ||
@@ -620,7 +621,7 @@ static int fmvj18x_setup_mfc(struct pcmcia_device *link) | |||
620 | req.Base = 0; req.Size = 0; | 621 | req.Base = 0; req.Size = 0; |
621 | req.AccessSpeed = 0; | 622 | req.AccessSpeed = 0; |
622 | i = pcmcia_request_window(&link, &req, &link->win); | 623 | i = pcmcia_request_window(&link, &req, &link->win); |
623 | if (i != CS_SUCCESS) { | 624 | if (i != 0) { |
624 | cs_error(link, RequestWindow, i); | 625 | cs_error(link, RequestWindow, i); |
625 | return -1; | 626 | return -1; |
626 | } | 627 | } |
@@ -642,7 +643,7 @@ static int fmvj18x_setup_mfc(struct pcmcia_device *link) | |||
642 | 643 | ||
643 | iounmap(base); | 644 | iounmap(base); |
644 | j = pcmcia_release_window(link->win); | 645 | j = pcmcia_release_window(link->win); |
645 | if (j != CS_SUCCESS) | 646 | if (j != 0) |
646 | cs_error(link, ReleaseWindow, j); | 647 | cs_error(link, ReleaseWindow, j); |
647 | return 0; | 648 | return 0; |
648 | 649 | ||
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c index 4eafa4f42cff..cf3cca4642f2 100644 --- a/drivers/net/pcmcia/ibmtr_cs.c +++ b/drivers/net/pcmcia/ibmtr_cs.c | |||
@@ -238,7 +238,7 @@ static int __devinit ibmtr_config(struct pcmcia_device *link) | |||
238 | /* Try PRIMARY card at 0xA20-0xA23 */ | 238 | /* Try PRIMARY card at 0xA20-0xA23 */ |
239 | link->io.BasePort1 = 0xA20; | 239 | link->io.BasePort1 = 0xA20; |
240 | i = pcmcia_request_io(link, &link->io); | 240 | i = pcmcia_request_io(link, &link->io); |
241 | if (i != CS_SUCCESS) { | 241 | if (i != 0) { |
242 | /* Couldn't get 0xA20-0xA23. Try ALTERNATE at 0xA24-0xA27. */ | 242 | /* Couldn't get 0xA20-0xA23. Try ALTERNATE at 0xA24-0xA27. */ |
243 | link->io.BasePort1 = 0xA24; | 243 | link->io.BasePort1 = 0xA24; |
244 | CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); | 244 | CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); |
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c index ee5dcbfd0ba9..448cd40aeba5 100644 --- a/drivers/net/pcmcia/nmclan_cs.c +++ b/drivers/net/pcmcia/nmclan_cs.c | |||
@@ -925,7 +925,7 @@ static void mace_tx_timeout(struct net_device *dev) | |||
925 | printk(KERN_NOTICE "%s: transmit timed out -- ", dev->name); | 925 | printk(KERN_NOTICE "%s: transmit timed out -- ", dev->name); |
926 | #if RESET_ON_TIMEOUT | 926 | #if RESET_ON_TIMEOUT |
927 | printk("resetting card\n"); | 927 | printk("resetting card\n"); |
928 | pcmcia_reset_card(link, NULL); | 928 | pcmcia_reset_card(link->socket); |
929 | #else /* #if RESET_ON_TIMEOUT */ | 929 | #else /* #if RESET_ON_TIMEOUT */ |
930 | printk("NOT resetting card\n"); | 930 | printk("NOT resetting card\n"); |
931 | #endif /* #if RESET_ON_TIMEOUT */ | 931 | #endif /* #if RESET_ON_TIMEOUT */ |
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index ebc1ae6bcbe5..e40d6301aa7a 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c | |||
@@ -310,7 +310,7 @@ static hw_info_t *get_hwinfo(struct pcmcia_device *link) | |||
310 | req.Base = 0; req.Size = 0; | 310 | req.Base = 0; req.Size = 0; |
311 | req.AccessSpeed = 0; | 311 | req.AccessSpeed = 0; |
312 | i = pcmcia_request_window(&link, &req, &link->win); | 312 | i = pcmcia_request_window(&link, &req, &link->win); |
313 | if (i != CS_SUCCESS) { | 313 | if (i != 0) { |
314 | cs_error(link, RequestWindow, i); | 314 | cs_error(link, RequestWindow, i); |
315 | return NULL; | 315 | return NULL; |
316 | } | 316 | } |
@@ -333,7 +333,7 @@ static hw_info_t *get_hwinfo(struct pcmcia_device *link) | |||
333 | 333 | ||
334 | iounmap(virt); | 334 | iounmap(virt); |
335 | j = pcmcia_release_window(link->win); | 335 | j = pcmcia_release_window(link->win); |
336 | if (j != CS_SUCCESS) | 336 | if (j != 0) |
337 | cs_error(link, ReleaseWindow, j); | 337 | cs_error(link, ReleaseWindow, j); |
338 | return (i < NR_INFO) ? hw_info+i : NULL; | 338 | return (i < NR_INFO) ? hw_info+i : NULL; |
339 | } /* get_hwinfo */ | 339 | } /* get_hwinfo */ |
@@ -504,7 +504,8 @@ static int try_io_port(struct pcmcia_device *link) | |||
504 | link->io.BasePort1 = j ^ 0x300; | 504 | link->io.BasePort1 = j ^ 0x300; |
505 | link->io.BasePort2 = (j ^ 0x300) + 0x10; | 505 | link->io.BasePort2 = (j ^ 0x300) + 0x10; |
506 | ret = pcmcia_request_io(link, &link->io); | 506 | ret = pcmcia_request_io(link, &link->io); |
507 | if (ret == CS_SUCCESS) return ret; | 507 | if (ret == 0) |
508 | return ret; | ||
508 | } | 509 | } |
509 | return ret; | 510 | return ret; |
510 | } else { | 511 | } else { |
@@ -512,58 +513,53 @@ static int try_io_port(struct pcmcia_device *link) | |||
512 | } | 513 | } |
513 | } | 514 | } |
514 | 515 | ||
516 | static int pcnet_confcheck(struct pcmcia_device *p_dev, | ||
517 | cistpl_cftable_entry_t *cfg, | ||
518 | cistpl_cftable_entry_t *dflt, | ||
519 | unsigned int vcc, | ||
520 | void *priv_data) | ||
521 | { | ||
522 | int *has_shmem = priv_data; | ||
523 | int i; | ||
524 | cistpl_io_t *io = &cfg->io; | ||
525 | |||
526 | if (cfg->index == 0 || cfg->io.nwin == 0) | ||
527 | return -EINVAL; | ||
528 | |||
529 | /* For multifunction cards, by convention, we configure the | ||
530 | network function with window 0, and serial with window 1 */ | ||
531 | if (io->nwin > 1) { | ||
532 | i = (io->win[1].len > io->win[0].len); | ||
533 | p_dev->io.BasePort2 = io->win[1-i].base; | ||
534 | p_dev->io.NumPorts2 = io->win[1-i].len; | ||
535 | } else { | ||
536 | i = p_dev->io.NumPorts2 = 0; | ||
537 | } | ||
538 | |||
539 | *has_shmem = ((cfg->mem.nwin == 1) && | ||
540 | (cfg->mem.win[0].len >= 0x4000)); | ||
541 | p_dev->io.BasePort1 = io->win[i].base; | ||
542 | p_dev->io.NumPorts1 = io->win[i].len; | ||
543 | p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
544 | if (p_dev->io.NumPorts1 + p_dev->io.NumPorts2 >= 32) | ||
545 | return try_io_port(p_dev); | ||
546 | |||
547 | return 0; | ||
548 | } | ||
549 | |||
515 | static int pcnet_config(struct pcmcia_device *link) | 550 | static int pcnet_config(struct pcmcia_device *link) |
516 | { | 551 | { |
517 | struct net_device *dev = link->priv; | 552 | struct net_device *dev = link->priv; |
518 | pcnet_dev_t *info = PRIV(dev); | 553 | pcnet_dev_t *info = PRIV(dev); |
519 | tuple_t tuple; | 554 | int last_ret, last_fn, start_pg, stop_pg, cm_offset; |
520 | cisparse_t parse; | ||
521 | int i, last_ret, last_fn, start_pg, stop_pg, cm_offset; | ||
522 | int has_shmem = 0; | 555 | int has_shmem = 0; |
523 | u_short buf[64]; | ||
524 | hw_info_t *local_hw_info; | 556 | hw_info_t *local_hw_info; |
525 | DECLARE_MAC_BUF(mac); | 557 | DECLARE_MAC_BUF(mac); |
526 | 558 | ||
527 | DEBUG(0, "pcnet_config(0x%p)\n", link); | 559 | DEBUG(0, "pcnet_config(0x%p)\n", link); |
528 | 560 | ||
529 | tuple.TupleData = (cisdata_t *)buf; | 561 | last_ret = pcmcia_loop_config(link, pcnet_confcheck, &has_shmem); |
530 | tuple.TupleDataMax = sizeof(buf); | 562 | if (last_ret) { |
531 | tuple.TupleOffset = 0; | ||
532 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
533 | tuple.Attributes = 0; | ||
534 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
535 | while (last_ret == CS_SUCCESS) { | ||
536 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | ||
537 | cistpl_io_t *io = &(parse.cftable_entry.io); | ||
538 | |||
539 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
540 | pcmcia_parse_tuple(link, &tuple, &parse) != 0 || | ||
541 | cfg->index == 0 || cfg->io.nwin == 0) | ||
542 | goto next_entry; | ||
543 | |||
544 | link->conf.ConfigIndex = cfg->index; | ||
545 | /* For multifunction cards, by convention, we configure the | ||
546 | network function with window 0, and serial with window 1 */ | ||
547 | if (io->nwin > 1) { | ||
548 | i = (io->win[1].len > io->win[0].len); | ||
549 | link->io.BasePort2 = io->win[1-i].base; | ||
550 | link->io.NumPorts2 = io->win[1-i].len; | ||
551 | } else { | ||
552 | i = link->io.NumPorts2 = 0; | ||
553 | } | ||
554 | has_shmem = ((cfg->mem.nwin == 1) && | ||
555 | (cfg->mem.win[0].len >= 0x4000)); | ||
556 | link->io.BasePort1 = io->win[i].base; | ||
557 | link->io.NumPorts1 = io->win[i].len; | ||
558 | link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
559 | if (link->io.NumPorts1 + link->io.NumPorts2 >= 32) { | ||
560 | last_ret = try_io_port(link); | ||
561 | if (last_ret == CS_SUCCESS) break; | ||
562 | } | ||
563 | next_entry: | ||
564 | last_ret = pcmcia_get_next_tuple(link, &tuple); | ||
565 | } | ||
566 | if (last_ret != CS_SUCCESS) { | ||
567 | cs_error(link, RequestIO, last_ret); | 563 | cs_error(link, RequestIO, last_ret); |
568 | goto failed; | 564 | goto failed; |
569 | } | 565 | } |
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index 250eb1954c34..c74d6656d266 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c | |||
@@ -409,10 +409,13 @@ static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, | |||
409 | { | 409 | { |
410 | int i; | 410 | int i; |
411 | 411 | ||
412 | if ((i = pcmcia_get_first_tuple(handle, tuple)) != CS_SUCCESS || | 412 | i = pcmcia_get_first_tuple(handle, tuple); |
413 | (i = pcmcia_get_tuple_data(handle, tuple)) != CS_SUCCESS) | 413 | if (i != 0) |
414 | return i; | 414 | return i; |
415 | return pcmcia_parse_tuple(handle, tuple, parse); | 415 | i = pcmcia_get_tuple_data(handle, tuple); |
416 | if (i != 0) | ||
417 | return i; | ||
418 | return pcmcia_parse_tuple(tuple, parse); | ||
416 | } | 419 | } |
417 | 420 | ||
418 | static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, | 421 | static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, |
@@ -420,10 +423,10 @@ static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, | |||
420 | { | 423 | { |
421 | int i; | 424 | int i; |
422 | 425 | ||
423 | if ((i = pcmcia_get_next_tuple(handle, tuple)) != CS_SUCCESS || | 426 | if ((i = pcmcia_get_next_tuple(handle, tuple)) != 0 || |
424 | (i = pcmcia_get_tuple_data(handle, tuple)) != CS_SUCCESS) | 427 | (i = pcmcia_get_tuple_data(handle, tuple)) != 0) |
425 | return i; | 428 | return i; |
426 | return pcmcia_parse_tuple(handle, tuple, parse); | 429 | return pcmcia_parse_tuple(tuple, parse); |
427 | } | 430 | } |
428 | 431 | ||
429 | /*====================================================================== | 432 | /*====================================================================== |
@@ -459,27 +462,36 @@ static int mhz_3288_power(struct pcmcia_device *link) | |||
459 | return 0; | 462 | return 0; |
460 | } | 463 | } |
461 | 464 | ||
465 | static int mhz_mfc_config_check(struct pcmcia_device *p_dev, | ||
466 | cistpl_cftable_entry_t *cf, | ||
467 | cistpl_cftable_entry_t *dflt, | ||
468 | unsigned int vcc, | ||
469 | void *priv_data) | ||
470 | { | ||
471 | int k; | ||
472 | p_dev->io.BasePort2 = cf->io.win[0].base; | ||
473 | for (k = 0; k < 0x400; k += 0x10) { | ||
474 | if (k & 0x80) | ||
475 | continue; | ||
476 | p_dev->io.BasePort1 = k ^ 0x300; | ||
477 | if (!pcmcia_request_io(p_dev, &p_dev->io)) | ||
478 | return 0; | ||
479 | } | ||
480 | return -ENODEV; | ||
481 | } | ||
482 | |||
462 | static int mhz_mfc_config(struct pcmcia_device *link) | 483 | static int mhz_mfc_config(struct pcmcia_device *link) |
463 | { | 484 | { |
464 | struct net_device *dev = link->priv; | 485 | struct net_device *dev = link->priv; |
465 | struct smc_private *smc = netdev_priv(dev); | 486 | struct smc_private *smc = netdev_priv(dev); |
466 | struct smc_cfg_mem *cfg_mem; | 487 | struct smc_cfg_mem *cfg_mem; |
467 | tuple_t *tuple; | ||
468 | cisparse_t *parse; | ||
469 | cistpl_cftable_entry_t *cf; | ||
470 | u_char *buf; | ||
471 | win_req_t req; | 488 | win_req_t req; |
472 | memreq_t mem; | 489 | memreq_t mem; |
473 | int i, k; | 490 | int i; |
474 | 491 | ||
475 | cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); | 492 | cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); |
476 | if (!cfg_mem) | 493 | if (!cfg_mem) |
477 | return CS_OUT_OF_RESOURCE; | 494 | return -ENOMEM; |
478 | |||
479 | tuple = &cfg_mem->tuple; | ||
480 | parse = &cfg_mem->parse; | ||
481 | cf = &parse->cftable_entry; | ||
482 | buf = cfg_mem->buf; | ||
483 | 495 | ||
484 | link->conf.Attributes |= CONF_ENABLE_SPKR; | 496 | link->conf.Attributes |= CONF_ENABLE_SPKR; |
485 | link->conf.Status = CCSR_AUDIO_ENA; | 497 | link->conf.Status = CCSR_AUDIO_ENA; |
@@ -489,27 +501,9 @@ static int mhz_mfc_config(struct pcmcia_device *link) | |||
489 | link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; | 501 | link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; |
490 | link->io.NumPorts2 = 8; | 502 | link->io.NumPorts2 = 8; |
491 | 503 | ||
492 | tuple->Attributes = tuple->TupleOffset = 0; | ||
493 | tuple->TupleData = (cisdata_t *)buf; | ||
494 | tuple->TupleDataMax = 255; | ||
495 | tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
496 | |||
497 | i = first_tuple(link, tuple, parse); | ||
498 | /* The Megahertz combo cards have modem-like CIS entries, so | 504 | /* The Megahertz combo cards have modem-like CIS entries, so |
499 | we have to explicitly try a bunch of port combinations. */ | 505 | we have to explicitly try a bunch of port combinations. */ |
500 | while (i == CS_SUCCESS) { | 506 | if (pcmcia_loop_config(link, mhz_mfc_config_check, NULL)) |
501 | link->conf.ConfigIndex = cf->index; | ||
502 | link->io.BasePort2 = cf->io.win[0].base; | ||
503 | for (k = 0; k < 0x400; k += 0x10) { | ||
504 | if (k & 0x80) continue; | ||
505 | link->io.BasePort1 = k ^ 0x300; | ||
506 | i = pcmcia_request_io(link, &link->io); | ||
507 | if (i == CS_SUCCESS) break; | ||
508 | } | ||
509 | if (i == CS_SUCCESS) break; | ||
510 | i = next_tuple(link, tuple, parse); | ||
511 | } | ||
512 | if (i != CS_SUCCESS) | ||
513 | goto free_cfg_mem; | 507 | goto free_cfg_mem; |
514 | dev->base_addr = link->io.BasePort1; | 508 | dev->base_addr = link->io.BasePort1; |
515 | 509 | ||
@@ -518,7 +512,7 @@ static int mhz_mfc_config(struct pcmcia_device *link) | |||
518 | req.Base = req.Size = 0; | 512 | req.Base = req.Size = 0; |
519 | req.AccessSpeed = 0; | 513 | req.AccessSpeed = 0; |
520 | i = pcmcia_request_window(&link, &req, &link->win); | 514 | i = pcmcia_request_window(&link, &req, &link->win); |
521 | if (i != CS_SUCCESS) | 515 | if (i != 0) |
522 | goto free_cfg_mem; | 516 | goto free_cfg_mem; |
523 | smc->base = ioremap(req.Base, req.Size); | 517 | smc->base = ioremap(req.Base, req.Size); |
524 | mem.CardOffset = mem.Page = 0; | 518 | mem.CardOffset = mem.Page = 0; |
@@ -526,14 +520,14 @@ static int mhz_mfc_config(struct pcmcia_device *link) | |||
526 | mem.CardOffset = link->conf.ConfigBase; | 520 | mem.CardOffset = link->conf.ConfigBase; |
527 | i = pcmcia_map_mem_page(link->win, &mem); | 521 | i = pcmcia_map_mem_page(link->win, &mem); |
528 | 522 | ||
529 | if ((i == CS_SUCCESS) | 523 | if ((i == 0) |
530 | && (smc->manfid == MANFID_MEGAHERTZ) | 524 | && (smc->manfid == MANFID_MEGAHERTZ) |
531 | && (smc->cardid == PRODID_MEGAHERTZ_EM3288)) | 525 | && (smc->cardid == PRODID_MEGAHERTZ_EM3288)) |
532 | mhz_3288_power(link); | 526 | mhz_3288_power(link); |
533 | 527 | ||
534 | free_cfg_mem: | 528 | free_cfg_mem: |
535 | kfree(cfg_mem); | 529 | kfree(cfg_mem); |
536 | return i; | 530 | return -ENODEV; |
537 | } | 531 | } |
538 | 532 | ||
539 | static int mhz_setup(struct pcmcia_device *link) | 533 | static int mhz_setup(struct pcmcia_device *link) |
@@ -560,12 +554,12 @@ static int mhz_setup(struct pcmcia_device *link) | |||
560 | /* Read the station address from the CIS. It is stored as the last | 554 | /* Read the station address from the CIS. It is stored as the last |
561 | (fourth) string in the Version 1 Version/ID tuple. */ | 555 | (fourth) string in the Version 1 Version/ID tuple. */ |
562 | tuple->DesiredTuple = CISTPL_VERS_1; | 556 | tuple->DesiredTuple = CISTPL_VERS_1; |
563 | if (first_tuple(link, tuple, parse) != CS_SUCCESS) { | 557 | if (first_tuple(link, tuple, parse) != 0) { |
564 | rc = -1; | 558 | rc = -1; |
565 | goto free_cfg_mem; | 559 | goto free_cfg_mem; |
566 | } | 560 | } |
567 | /* Ugh -- the EM1144 card has two VERS_1 tuples!?! */ | 561 | /* Ugh -- the EM1144 card has two VERS_1 tuples!?! */ |
568 | if (next_tuple(link, tuple, parse) != CS_SUCCESS) | 562 | if (next_tuple(link, tuple, parse) != 0) |
569 | first_tuple(link, tuple, parse); | 563 | first_tuple(link, tuple, parse); |
570 | if (parse->version_1.ns > 3) { | 564 | if (parse->version_1.ns > 3) { |
571 | station_addr = parse->version_1.str + parse->version_1.ofs[3]; | 565 | station_addr = parse->version_1.str + parse->version_1.ofs[3]; |
@@ -577,11 +571,11 @@ static int mhz_setup(struct pcmcia_device *link) | |||
577 | 571 | ||
578 | /* Another possibility: for the EM3288, in a special tuple */ | 572 | /* Another possibility: for the EM3288, in a special tuple */ |
579 | tuple->DesiredTuple = 0x81; | 573 | tuple->DesiredTuple = 0x81; |
580 | if (pcmcia_get_first_tuple(link, tuple) != CS_SUCCESS) { | 574 | if (pcmcia_get_first_tuple(link, tuple) != 0) { |
581 | rc = -1; | 575 | rc = -1; |
582 | goto free_cfg_mem; | 576 | goto free_cfg_mem; |
583 | } | 577 | } |
584 | if (pcmcia_get_tuple_data(link, tuple) != CS_SUCCESS) { | 578 | if (pcmcia_get_tuple_data(link, tuple) != 0) { |
585 | rc = -1; | 579 | rc = -1; |
586 | goto free_cfg_mem; | 580 | goto free_cfg_mem; |
587 | } | 581 | } |
@@ -660,46 +654,27 @@ static int mot_setup(struct pcmcia_device *link) | |||
660 | 654 | ||
661 | /*====================================================================*/ | 655 | /*====================================================================*/ |
662 | 656 | ||
657 | static int smc_configcheck(struct pcmcia_device *p_dev, | ||
658 | cistpl_cftable_entry_t *cf, | ||
659 | cistpl_cftable_entry_t *dflt, | ||
660 | unsigned int vcc, | ||
661 | void *priv_data) | ||
662 | { | ||
663 | p_dev->io.BasePort1 = cf->io.win[0].base; | ||
664 | p_dev->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; | ||
665 | return pcmcia_request_io(p_dev, &p_dev->io); | ||
666 | } | ||
667 | |||
663 | static int smc_config(struct pcmcia_device *link) | 668 | static int smc_config(struct pcmcia_device *link) |
664 | { | 669 | { |
665 | struct net_device *dev = link->priv; | 670 | struct net_device *dev = link->priv; |
666 | struct smc_cfg_mem *cfg_mem; | ||
667 | tuple_t *tuple; | ||
668 | cisparse_t *parse; | ||
669 | cistpl_cftable_entry_t *cf; | ||
670 | u_char *buf; | ||
671 | int i; | 671 | int i; |
672 | 672 | ||
673 | cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); | ||
674 | if (!cfg_mem) | ||
675 | return CS_OUT_OF_RESOURCE; | ||
676 | |||
677 | tuple = &cfg_mem->tuple; | ||
678 | parse = &cfg_mem->parse; | ||
679 | cf = &parse->cftable_entry; | ||
680 | buf = cfg_mem->buf; | ||
681 | |||
682 | tuple->Attributes = tuple->TupleOffset = 0; | ||
683 | tuple->TupleData = (cisdata_t *)buf; | ||
684 | tuple->TupleDataMax = 255; | ||
685 | tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
686 | |||
687 | link->io.NumPorts1 = 16; | 673 | link->io.NumPorts1 = 16; |
688 | i = first_tuple(link, tuple, parse); | 674 | i = pcmcia_loop_config(link, smc_configcheck, NULL); |
689 | while (i != CS_NO_MORE_ITEMS) { | 675 | if (!i) |
690 | if (i == CS_SUCCESS) { | 676 | dev->base_addr = link->io.BasePort1; |
691 | link->conf.ConfigIndex = cf->index; | ||
692 | link->io.BasePort1 = cf->io.win[0].base; | ||
693 | link->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; | ||
694 | i = pcmcia_request_io(link, &link->io); | ||
695 | if (i == CS_SUCCESS) break; | ||
696 | } | ||
697 | i = next_tuple(link, tuple, parse); | ||
698 | } | ||
699 | if (i == CS_SUCCESS) | ||
700 | dev->base_addr = link->io.BasePort1; | ||
701 | 677 | ||
702 | kfree(cfg_mem); | ||
703 | return i; | 678 | return i; |
704 | } | 679 | } |
705 | 680 | ||
@@ -715,7 +690,7 @@ static int smc_setup(struct pcmcia_device *link) | |||
715 | 690 | ||
716 | cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); | 691 | cfg_mem = kmalloc(sizeof(struct smc_cfg_mem), GFP_KERNEL); |
717 | if (!cfg_mem) | 692 | if (!cfg_mem) |
718 | return CS_OUT_OF_RESOURCE; | 693 | return -ENOMEM; |
719 | 694 | ||
720 | tuple = &cfg_mem->tuple; | 695 | tuple = &cfg_mem->tuple; |
721 | parse = &cfg_mem->parse; | 696 | parse = &cfg_mem->parse; |
@@ -728,12 +703,12 @@ static int smc_setup(struct pcmcia_device *link) | |||
728 | /* Check for a LAN function extension tuple */ | 703 | /* Check for a LAN function extension tuple */ |
729 | tuple->DesiredTuple = CISTPL_FUNCE; | 704 | tuple->DesiredTuple = CISTPL_FUNCE; |
730 | i = first_tuple(link, tuple, parse); | 705 | i = first_tuple(link, tuple, parse); |
731 | while (i == CS_SUCCESS) { | 706 | while (i == 0) { |
732 | if (parse->funce.type == CISTPL_FUNCE_LAN_NODE_ID) | 707 | if (parse->funce.type == CISTPL_FUNCE_LAN_NODE_ID) |
733 | break; | 708 | break; |
734 | i = next_tuple(link, tuple, parse); | 709 | i = next_tuple(link, tuple, parse); |
735 | } | 710 | } |
736 | if (i == CS_SUCCESS) { | 711 | if (i == 0) { |
737 | node_id = (cistpl_lan_node_id_t *)parse->funce.data; | 712 | node_id = (cistpl_lan_node_id_t *)parse->funce.data; |
738 | if (node_id->nb == 6) { | 713 | if (node_id->nb == 6) { |
739 | for (i = 0; i < 6; i++) | 714 | for (i = 0; i < 6; i++) |
@@ -780,9 +755,10 @@ static int osi_config(struct pcmcia_device *link) | |||
780 | for (i = j = 0; j < 4; j++) { | 755 | for (i = j = 0; j < 4; j++) { |
781 | link->io.BasePort2 = com[j]; | 756 | link->io.BasePort2 = com[j]; |
782 | i = pcmcia_request_io(link, &link->io); | 757 | i = pcmcia_request_io(link, &link->io); |
783 | if (i == CS_SUCCESS) break; | 758 | if (i == 0) |
759 | break; | ||
784 | } | 760 | } |
785 | if (i != CS_SUCCESS) { | 761 | if (i != 0) { |
786 | /* Fallback: turn off hard decode */ | 762 | /* Fallback: turn off hard decode */ |
787 | link->conf.ConfigIndex = 0x03; | 763 | link->conf.ConfigIndex = 0x03; |
788 | link->io.NumPorts2 = 0; | 764 | link->io.NumPorts2 = 0; |
@@ -815,13 +791,13 @@ static int osi_setup(struct pcmcia_device *link, u_short manfid, u_short cardid) | |||
815 | /* Read the station address from tuple 0x90, subtuple 0x04 */ | 791 | /* Read the station address from tuple 0x90, subtuple 0x04 */ |
816 | tuple->DesiredTuple = 0x90; | 792 | tuple->DesiredTuple = 0x90; |
817 | i = pcmcia_get_first_tuple(link, tuple); | 793 | i = pcmcia_get_first_tuple(link, tuple); |
818 | while (i == CS_SUCCESS) { | 794 | while (i == 0) { |
819 | i = pcmcia_get_tuple_data(link, tuple); | 795 | i = pcmcia_get_tuple_data(link, tuple); |
820 | if ((i != CS_SUCCESS) || (buf[0] == 0x04)) | 796 | if ((i != 0) || (buf[0] == 0x04)) |
821 | break; | 797 | break; |
822 | i = pcmcia_get_next_tuple(link, tuple); | 798 | i = pcmcia_get_next_tuple(link, tuple); |
823 | } | 799 | } |
824 | if (i != CS_SUCCESS) { | 800 | if (i != 0) { |
825 | rc = -1; | 801 | rc = -1; |
826 | goto free_cfg_mem; | 802 | goto free_cfg_mem; |
827 | } | 803 | } |
@@ -959,8 +935,11 @@ static int check_sig(struct pcmcia_device *link) | |||
959 | 935 | ||
960 | ======================================================================*/ | 936 | ======================================================================*/ |
961 | 937 | ||
962 | #define CS_EXIT_TEST(ret, svc, label) \ | 938 | #define CS_EXIT_TEST(ret, svc, label) \ |
963 | if (ret != CS_SUCCESS) { cs_error(link, svc, ret); goto label; } | 939 | if (ret != 0) { \ |
940 | cs_error(link, svc, ret); \ | ||
941 | goto label; \ | ||
942 | } | ||
964 | 943 | ||
965 | static int smc91c92_config(struct pcmcia_device *link) | 944 | static int smc91c92_config(struct pcmcia_device *link) |
966 | { | 945 | { |
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index c33a3d523566..e1fd585e7131 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c | |||
@@ -377,7 +377,7 @@ first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) | |||
377 | 377 | ||
378 | if ((err = pcmcia_get_first_tuple(handle, tuple)) == 0 && | 378 | if ((err = pcmcia_get_first_tuple(handle, tuple)) == 0 && |
379 | (err = pcmcia_get_tuple_data(handle, tuple)) == 0) | 379 | (err = pcmcia_get_tuple_data(handle, tuple)) == 0) |
380 | err = pcmcia_parse_tuple(handle, tuple, parse); | 380 | err = pcmcia_parse_tuple(tuple, parse); |
381 | return err; | 381 | return err; |
382 | } | 382 | } |
383 | 383 | ||
@@ -388,7 +388,7 @@ next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) | |||
388 | 388 | ||
389 | if ((err = pcmcia_get_next_tuple(handle, tuple)) == 0 && | 389 | if ((err = pcmcia_get_next_tuple(handle, tuple)) == 0 && |
390 | (err = pcmcia_get_tuple_data(handle, tuple)) == 0) | 390 | (err = pcmcia_get_tuple_data(handle, tuple)) == 0) |
391 | err = pcmcia_parse_tuple(handle, tuple, parse); | 391 | err = pcmcia_parse_tuple(tuple, parse); |
392 | return err; | 392 | return err; |
393 | } | 393 | } |
394 | 394 | ||
@@ -715,6 +715,47 @@ has_ce2_string(struct pcmcia_device * p_dev) | |||
715 | return 0; | 715 | return 0; |
716 | } | 716 | } |
717 | 717 | ||
718 | static int | ||
719 | xirc2ps_config_modem(struct pcmcia_device *p_dev, | ||
720 | cistpl_cftable_entry_t *cf, | ||
721 | cistpl_cftable_entry_t *dflt, | ||
722 | unsigned int vcc, | ||
723 | void *priv_data) | ||
724 | { | ||
725 | unsigned int ioaddr; | ||
726 | |||
727 | if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { | ||
728 | for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { | ||
729 | p_dev->io.BasePort2 = cf->io.win[0].base; | ||
730 | p_dev->io.BasePort1 = ioaddr; | ||
731 | if (!pcmcia_request_io(p_dev, &p_dev->io)) | ||
732 | return 0; | ||
733 | } | ||
734 | } | ||
735 | return -ENODEV; | ||
736 | } | ||
737 | |||
738 | static int | ||
739 | xirc2ps_config_check(struct pcmcia_device *p_dev, | ||
740 | cistpl_cftable_entry_t *cf, | ||
741 | cistpl_cftable_entry_t *dflt, | ||
742 | unsigned int vcc, | ||
743 | void *priv_data) | ||
744 | { | ||
745 | int *pass = priv_data; | ||
746 | |||
747 | if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { | ||
748 | p_dev->io.BasePort2 = cf->io.win[0].base; | ||
749 | p_dev->io.BasePort1 = p_dev->io.BasePort2 | ||
750 | + (*pass ? (cf->index & 0x20 ? -24:8) | ||
751 | : (cf->index & 0x20 ? 8:-24)); | ||
752 | if (!pcmcia_request_io(p_dev, &p_dev->io)) | ||
753 | return 0; | ||
754 | } | ||
755 | return -ENODEV; | ||
756 | |||
757 | } | ||
758 | |||
718 | /**************** | 759 | /**************** |
719 | * xirc2ps_config() is scheduled to run after a CARD_INSERTION event | 760 | * xirc2ps_config() is scheduled to run after a CARD_INSERTION event |
720 | * is received, to configure the PCMCIA socket, and to make the | 761 | * is received, to configure the PCMCIA socket, and to make the |
@@ -725,13 +766,12 @@ xirc2ps_config(struct pcmcia_device * link) | |||
725 | { | 766 | { |
726 | struct net_device *dev = link->priv; | 767 | struct net_device *dev = link->priv; |
727 | local_info_t *local = netdev_priv(dev); | 768 | local_info_t *local = netdev_priv(dev); |
769 | unsigned int ioaddr; | ||
728 | tuple_t tuple; | 770 | tuple_t tuple; |
729 | cisparse_t parse; | 771 | cisparse_t parse; |
730 | unsigned int ioaddr; | ||
731 | int err, i; | 772 | int err, i; |
732 | u_char buf[64]; | 773 | u_char buf[64]; |
733 | cistpl_lan_node_id_t *node_id = (cistpl_lan_node_id_t*)parse.funce.data; | 774 | cistpl_lan_node_id_t *node_id = (cistpl_lan_node_id_t*)parse.funce.data; |
734 | cistpl_cftable_entry_t *cf = &parse.cftable_entry; | ||
735 | DECLARE_MAC_BUF(mac); | 775 | DECLARE_MAC_BUF(mac); |
736 | 776 | ||
737 | local->dingo_ccr = NULL; | 777 | local->dingo_ccr = NULL; |
@@ -846,19 +886,8 @@ xirc2ps_config(struct pcmcia_device * link) | |||
846 | /* Take the Modem IO port from the CIS and scan for a free | 886 | /* Take the Modem IO port from the CIS and scan for a free |
847 | * Ethernet port */ | 887 | * Ethernet port */ |
848 | link->io.NumPorts1 = 16; /* no Mako stuff anymore */ | 888 | link->io.NumPorts1 = 16; /* no Mako stuff anymore */ |
849 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 889 | if (!pcmcia_loop_config(link, xirc2ps_config_modem, NULL)) |
850 | for (err = first_tuple(link, &tuple, &parse); !err; | 890 | goto port_found; |
851 | err = next_tuple(link, &tuple, &parse)) { | ||
852 | if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { | ||
853 | for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { | ||
854 | link->conf.ConfigIndex = cf->index ; | ||
855 | link->io.BasePort2 = cf->io.win[0].base; | ||
856 | link->io.BasePort1 = ioaddr; | ||
857 | if (!(err=pcmcia_request_io(link, &link->io))) | ||
858 | goto port_found; | ||
859 | } | ||
860 | } | ||
861 | } | ||
862 | } else { | 891 | } else { |
863 | link->io.NumPorts1 = 18; | 892 | link->io.NumPorts1 = 18; |
864 | /* We do 2 passes here: The first one uses the regular mapping and | 893 | /* We do 2 passes here: The first one uses the regular mapping and |
@@ -866,21 +895,9 @@ xirc2ps_config(struct pcmcia_device * link) | |||
866 | * mirrored every 32 bytes. Actually we use a mirrored port for | 895 | * mirrored every 32 bytes. Actually we use a mirrored port for |
867 | * the Mako if (on the first pass) the COR bit 5 is set. | 896 | * the Mako if (on the first pass) the COR bit 5 is set. |
868 | */ | 897 | */ |
869 | for (pass=0; pass < 2; pass++) { | 898 | for (pass=0; pass < 2; pass++) |
870 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 899 | if (!pcmcia_loop_config(link, xirc2ps_config_check, &pass)) |
871 | for (err = first_tuple(link, &tuple, &parse); !err; | ||
872 | err = next_tuple(link, &tuple, &parse)){ | ||
873 | if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8){ | ||
874 | link->conf.ConfigIndex = cf->index ; | ||
875 | link->io.BasePort2 = cf->io.win[0].base; | ||
876 | link->io.BasePort1 = link->io.BasePort2 | ||
877 | + (pass ? (cf->index & 0x20 ? -24:8) | ||
878 | : (cf->index & 0x20 ? 8:-24)); | ||
879 | if (!(err=pcmcia_request_io(link, &link->io))) | ||
880 | goto port_found; | 900 | goto port_found; |
881 | } | ||
882 | } | ||
883 | } | ||
884 | /* if special option: | 901 | /* if special option: |
885 | * try to configure as Ethernet only. | 902 | * try to configure as Ethernet only. |
886 | * .... */ | 903 | * .... */ |
diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c index 31e7384e312a..018d0fca9422 100644 --- a/drivers/net/sunbmac.c +++ b/drivers/net/sunbmac.c | |||
@@ -1,7 +1,6 @@ | |||
1 | /* $Id: sunbmac.c,v 1.30 2002/01/15 06:48:55 davem Exp $ | 1 | /* sunbmac.c: Driver for Sparc BigMAC 100baseT ethernet adapters. |
2 | * sunbmac.c: Driver for Sparc BigMAC 100baseT ethernet adapters. | ||
3 | * | 2 | * |
4 | * Copyright (C) 1997, 1998, 1999, 2003 David S. Miller (davem@redhat.com) | 3 | * Copyright (C) 1997, 1998, 1999, 2003, 2008 David S. Miller (davem@davemloft.net) |
5 | */ | 4 | */ |
6 | 5 | ||
7 | #include <linux/module.h> | 6 | #include <linux/module.h> |
@@ -23,6 +22,9 @@ | |||
23 | #include <linux/etherdevice.h> | 22 | #include <linux/etherdevice.h> |
24 | #include <linux/skbuff.h> | 23 | #include <linux/skbuff.h> |
25 | #include <linux/bitops.h> | 24 | #include <linux/bitops.h> |
25 | #include <linux/dma-mapping.h> | ||
26 | #include <linux/of.h> | ||
27 | #include <linux/of_device.h> | ||
26 | 28 | ||
27 | #include <asm/auxio.h> | 29 | #include <asm/auxio.h> |
28 | #include <asm/byteorder.h> | 30 | #include <asm/byteorder.h> |
@@ -32,15 +34,14 @@ | |||
32 | #include <asm/openprom.h> | 34 | #include <asm/openprom.h> |
33 | #include <asm/oplib.h> | 35 | #include <asm/oplib.h> |
34 | #include <asm/pgtable.h> | 36 | #include <asm/pgtable.h> |
35 | #include <asm/sbus.h> | ||
36 | #include <asm/system.h> | 37 | #include <asm/system.h> |
37 | 38 | ||
38 | #include "sunbmac.h" | 39 | #include "sunbmac.h" |
39 | 40 | ||
40 | #define DRV_NAME "sunbmac" | 41 | #define DRV_NAME "sunbmac" |
41 | #define DRV_VERSION "2.0" | 42 | #define DRV_VERSION "2.1" |
42 | #define DRV_RELDATE "11/24/03" | 43 | #define DRV_RELDATE "August 26, 2008" |
43 | #define DRV_AUTHOR "David S. Miller (davem@redhat.com)" | 44 | #define DRV_AUTHOR "David S. Miller (davem@davemloft.net)" |
44 | 45 | ||
45 | static char version[] = | 46 | static char version[] = |
46 | DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n"; | 47 | DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n"; |
@@ -96,8 +97,8 @@ static int qec_global_reset(void __iomem *gregs) | |||
96 | 97 | ||
97 | static void qec_init(struct bigmac *bp) | 98 | static void qec_init(struct bigmac *bp) |
98 | { | 99 | { |
100 | struct of_device *qec_op = bp->qec_op; | ||
99 | void __iomem *gregs = bp->gregs; | 101 | void __iomem *gregs = bp->gregs; |
100 | struct sbus_dev *qec_sdev = bp->qec_sdev; | ||
101 | u8 bsizes = bp->bigmac_bursts; | 102 | u8 bsizes = bp->bigmac_bursts; |
102 | u32 regval; | 103 | u32 regval; |
103 | 104 | ||
@@ -112,13 +113,13 @@ static void qec_init(struct bigmac *bp) | |||
112 | sbus_writel(GLOB_PSIZE_2048, gregs + GLOB_PSIZE); | 113 | sbus_writel(GLOB_PSIZE_2048, gregs + GLOB_PSIZE); |
113 | 114 | ||
114 | /* All of memsize is given to bigmac. */ | 115 | /* All of memsize is given to bigmac. */ |
115 | sbus_writel(qec_sdev->reg_addrs[1].reg_size, | 116 | sbus_writel(resource_size(&qec_op->resource[1]), |
116 | gregs + GLOB_MSIZE); | 117 | gregs + GLOB_MSIZE); |
117 | 118 | ||
118 | /* Half to the transmitter, half to the receiver. */ | 119 | /* Half to the transmitter, half to the receiver. */ |
119 | sbus_writel(qec_sdev->reg_addrs[1].reg_size >> 1, | 120 | sbus_writel(resource_size(&qec_op->resource[1]) >> 1, |
120 | gregs + GLOB_TSIZE); | 121 | gregs + GLOB_TSIZE); |
121 | sbus_writel(qec_sdev->reg_addrs[1].reg_size >> 1, | 122 | sbus_writel(resource_size(&qec_op->resource[1]) >> 1, |
122 | gregs + GLOB_RSIZE); | 123 | gregs + GLOB_RSIZE); |
123 | } | 124 | } |
124 | 125 | ||
@@ -239,9 +240,10 @@ static void bigmac_init_rings(struct bigmac *bp, int from_irq) | |||
239 | skb_reserve(skb, 34); | 240 | skb_reserve(skb, 34); |
240 | 241 | ||
241 | bb->be_rxd[i].rx_addr = | 242 | bb->be_rxd[i].rx_addr = |
242 | sbus_map_single(bp->bigmac_sdev, skb->data, | 243 | dma_map_single(&bp->bigmac_op->dev, |
243 | RX_BUF_ALLOC_SIZE - 34, | 244 | skb->data, |
244 | SBUS_DMA_FROMDEVICE); | 245 | RX_BUF_ALLOC_SIZE - 34, |
246 | DMA_FROM_DEVICE); | ||
245 | bb->be_rxd[i].rx_flags = | 247 | bb->be_rxd[i].rx_flags = |
246 | (RXD_OWN | ((RX_BUF_ALLOC_SIZE - 34) & RXD_LENGTH)); | 248 | (RXD_OWN | ((RX_BUF_ALLOC_SIZE - 34) & RXD_LENGTH)); |
247 | } | 249 | } |
@@ -776,9 +778,9 @@ static void bigmac_tx(struct bigmac *bp) | |||
776 | skb = bp->tx_skbs[elem]; | 778 | skb = bp->tx_skbs[elem]; |
777 | bp->enet_stats.tx_packets++; | 779 | bp->enet_stats.tx_packets++; |
778 | bp->enet_stats.tx_bytes += skb->len; | 780 | bp->enet_stats.tx_bytes += skb->len; |
779 | sbus_unmap_single(bp->bigmac_sdev, | 781 | dma_unmap_single(&bp->bigmac_op->dev, |
780 | this->tx_addr, skb->len, | 782 | this->tx_addr, skb->len, |
781 | SBUS_DMA_TODEVICE); | 783 | DMA_TO_DEVICE); |
782 | 784 | ||
783 | DTX(("skb(%p) ", skb)); | 785 | DTX(("skb(%p) ", skb)); |
784 | bp->tx_skbs[elem] = NULL; | 786 | bp->tx_skbs[elem] = NULL; |
@@ -831,18 +833,19 @@ static void bigmac_rx(struct bigmac *bp) | |||
831 | drops++; | 833 | drops++; |
832 | goto drop_it; | 834 | goto drop_it; |
833 | } | 835 | } |
834 | sbus_unmap_single(bp->bigmac_sdev, | 836 | dma_unmap_single(&bp->bigmac_op->dev, |
835 | this->rx_addr, | 837 | this->rx_addr, |
836 | RX_BUF_ALLOC_SIZE - 34, | 838 | RX_BUF_ALLOC_SIZE - 34, |
837 | SBUS_DMA_FROMDEVICE); | 839 | DMA_FROM_DEVICE); |
838 | bp->rx_skbs[elem] = new_skb; | 840 | bp->rx_skbs[elem] = new_skb; |
839 | new_skb->dev = bp->dev; | 841 | new_skb->dev = bp->dev; |
840 | skb_put(new_skb, ETH_FRAME_LEN); | 842 | skb_put(new_skb, ETH_FRAME_LEN); |
841 | skb_reserve(new_skb, 34); | 843 | skb_reserve(new_skb, 34); |
842 | this->rx_addr = sbus_map_single(bp->bigmac_sdev, | 844 | this->rx_addr = |
843 | new_skb->data, | 845 | dma_map_single(&bp->bigmac_op->dev, |
844 | RX_BUF_ALLOC_SIZE - 34, | 846 | new_skb->data, |
845 | SBUS_DMA_FROMDEVICE); | 847 | RX_BUF_ALLOC_SIZE - 34, |
848 | DMA_FROM_DEVICE); | ||
846 | this->rx_flags = | 849 | this->rx_flags = |
847 | (RXD_OWN | ((RX_BUF_ALLOC_SIZE - 34) & RXD_LENGTH)); | 850 | (RXD_OWN | ((RX_BUF_ALLOC_SIZE - 34) & RXD_LENGTH)); |
848 | 851 | ||
@@ -857,13 +860,13 @@ static void bigmac_rx(struct bigmac *bp) | |||
857 | } | 860 | } |
858 | skb_reserve(copy_skb, 2); | 861 | skb_reserve(copy_skb, 2); |
859 | skb_put(copy_skb, len); | 862 | skb_put(copy_skb, len); |
860 | sbus_dma_sync_single_for_cpu(bp->bigmac_sdev, | 863 | dma_sync_single_for_cpu(&bp->bigmac_op->dev, |
861 | this->rx_addr, len, | 864 | this->rx_addr, len, |
862 | SBUS_DMA_FROMDEVICE); | 865 | DMA_FROM_DEVICE); |
863 | skb_copy_to_linear_data(copy_skb, (unsigned char *)skb->data, len); | 866 | skb_copy_to_linear_data(copy_skb, (unsigned char *)skb->data, len); |
864 | sbus_dma_sync_single_for_device(bp->bigmac_sdev, | 867 | dma_sync_single_for_device(&bp->bigmac_op->dev, |
865 | this->rx_addr, len, | 868 | this->rx_addr, len, |
866 | SBUS_DMA_FROMDEVICE); | 869 | DMA_FROM_DEVICE); |
867 | 870 | ||
868 | /* Reuse original ring buffer. */ | 871 | /* Reuse original ring buffer. */ |
869 | this->rx_flags = | 872 | this->rx_flags = |
@@ -959,7 +962,8 @@ static int bigmac_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
959 | u32 mapping; | 962 | u32 mapping; |
960 | 963 | ||
961 | len = skb->len; | 964 | len = skb->len; |
962 | mapping = sbus_map_single(bp->bigmac_sdev, skb->data, len, SBUS_DMA_TODEVICE); | 965 | mapping = dma_map_single(&bp->bigmac_op->dev, skb->data, |
966 | len, DMA_TO_DEVICE); | ||
963 | 967 | ||
964 | /* Avoid a race... */ | 968 | /* Avoid a race... */ |
965 | spin_lock_irq(&bp->lock); | 969 | spin_lock_irq(&bp->lock); |
@@ -1051,12 +1055,8 @@ static void bigmac_set_multicast(struct net_device *dev) | |||
1051 | /* Ethtool support... */ | 1055 | /* Ethtool support... */ |
1052 | static void bigmac_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 1056 | static void bigmac_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
1053 | { | 1057 | { |
1054 | struct bigmac *bp = dev->priv; | ||
1055 | |||
1056 | strcpy(info->driver, "sunbmac"); | 1058 | strcpy(info->driver, "sunbmac"); |
1057 | strcpy(info->version, "2.0"); | 1059 | strcpy(info->version, "2.0"); |
1058 | sprintf(info->bus_info, "SBUS:%d", | ||
1059 | bp->qec_sdev->slot); | ||
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | static u32 bigmac_get_link(struct net_device *dev) | 1062 | static u32 bigmac_get_link(struct net_device *dev) |
@@ -1075,14 +1075,15 @@ static const struct ethtool_ops bigmac_ethtool_ops = { | |||
1075 | .get_link = bigmac_get_link, | 1075 | .get_link = bigmac_get_link, |
1076 | }; | 1076 | }; |
1077 | 1077 | ||
1078 | static int __devinit bigmac_ether_init(struct sbus_dev *qec_sdev) | 1078 | static int __devinit bigmac_ether_init(struct of_device *op, |
1079 | struct of_device *qec_op) | ||
1079 | { | 1080 | { |
1080 | struct net_device *dev; | ||
1081 | static int version_printed; | 1081 | static int version_printed; |
1082 | struct bigmac *bp; | 1082 | struct net_device *dev; |
1083 | u8 bsizes, bsizes_more; | 1083 | u8 bsizes, bsizes_more; |
1084 | int i; | ||
1085 | DECLARE_MAC_BUF(mac); | 1084 | DECLARE_MAC_BUF(mac); |
1085 | struct bigmac *bp; | ||
1086 | int i; | ||
1086 | 1087 | ||
1087 | /* Get a new device struct for this interface. */ | 1088 | /* Get a new device struct for this interface. */ |
1088 | dev = alloc_etherdev(sizeof(struct bigmac)); | 1089 | dev = alloc_etherdev(sizeof(struct bigmac)); |
@@ -1092,32 +1093,21 @@ static int __devinit bigmac_ether_init(struct sbus_dev *qec_sdev) | |||
1092 | if (version_printed++ == 0) | 1093 | if (version_printed++ == 0) |
1093 | printk(KERN_INFO "%s", version); | 1094 | printk(KERN_INFO "%s", version); |
1094 | 1095 | ||
1095 | dev->base_addr = (long) qec_sdev; | ||
1096 | for (i = 0; i < 6; i++) | 1096 | for (i = 0; i < 6; i++) |
1097 | dev->dev_addr[i] = idprom->id_ethaddr[i]; | 1097 | dev->dev_addr[i] = idprom->id_ethaddr[i]; |
1098 | 1098 | ||
1099 | /* Setup softc, with backpointers to QEC and BigMAC SBUS device structs. */ | 1099 | /* Setup softc, with backpointers to QEC and BigMAC SBUS device structs. */ |
1100 | bp = dev->priv; | 1100 | bp = netdev_priv(dev); |
1101 | bp->qec_sdev = qec_sdev; | 1101 | bp->qec_op = qec_op; |
1102 | bp->bigmac_sdev = qec_sdev->child; | 1102 | bp->bigmac_op = op; |
1103 | 1103 | ||
1104 | SET_NETDEV_DEV(dev, &bp->bigmac_sdev->ofdev.dev); | 1104 | SET_NETDEV_DEV(dev, &op->dev); |
1105 | 1105 | ||
1106 | spin_lock_init(&bp->lock); | 1106 | spin_lock_init(&bp->lock); |
1107 | 1107 | ||
1108 | /* Verify the registers we expect, are actually there. */ | ||
1109 | if ((bp->bigmac_sdev->num_registers != 3) || | ||
1110 | (bp->qec_sdev->num_registers != 2)) { | ||
1111 | printk(KERN_ERR "BIGMAC: Device does not have 2 and 3 regs, it has %d and %d.\n", | ||
1112 | bp->qec_sdev->num_registers, | ||
1113 | bp->bigmac_sdev->num_registers); | ||
1114 | printk(KERN_ERR "BIGMAC: Would you like that for here or to go?\n"); | ||
1115 | goto fail_and_cleanup; | ||
1116 | } | ||
1117 | |||
1118 | /* Map in QEC global control registers. */ | 1108 | /* Map in QEC global control registers. */ |
1119 | bp->gregs = sbus_ioremap(&bp->qec_sdev->resource[0], 0, | 1109 | bp->gregs = of_ioremap(&qec_op->resource[0], 0, |
1120 | GLOB_REG_SIZE, "BigMAC QEC GLobal Regs"); | 1110 | GLOB_REG_SIZE, "BigMAC QEC GLobal Regs"); |
1121 | if (!bp->gregs) { | 1111 | if (!bp->gregs) { |
1122 | printk(KERN_ERR "BIGMAC: Cannot map QEC global registers.\n"); | 1112 | printk(KERN_ERR "BIGMAC: Cannot map QEC global registers.\n"); |
1123 | goto fail_and_cleanup; | 1113 | goto fail_and_cleanup; |
@@ -1134,13 +1124,8 @@ static int __devinit bigmac_ether_init(struct sbus_dev *qec_sdev) | |||
1134 | goto fail_and_cleanup; | 1124 | goto fail_and_cleanup; |
1135 | 1125 | ||
1136 | /* Get supported SBUS burst sizes. */ | 1126 | /* Get supported SBUS burst sizes. */ |
1137 | bsizes = prom_getintdefault(bp->qec_sdev->prom_node, | 1127 | bsizes = of_getintprop_default(qec_op->node, "burst-sizes", 0xff); |
1138 | "burst-sizes", | 1128 | bsizes_more = of_getintprop_default(qec_op->node, "burst-sizes", 0xff); |
1139 | 0xff); | ||
1140 | |||
1141 | bsizes_more = prom_getintdefault(bp->qec_sdev->bus->prom_node, | ||
1142 | "burst-sizes", | ||
1143 | 0xff); | ||
1144 | 1129 | ||
1145 | bsizes &= 0xff; | 1130 | bsizes &= 0xff; |
1146 | if (bsizes_more != 0xff) | 1131 | if (bsizes_more != 0xff) |
@@ -1154,16 +1139,16 @@ static int __devinit bigmac_ether_init(struct sbus_dev *qec_sdev) | |||
1154 | qec_init(bp); | 1139 | qec_init(bp); |
1155 | 1140 | ||
1156 | /* Map in the BigMAC channel registers. */ | 1141 | /* Map in the BigMAC channel registers. */ |
1157 | bp->creg = sbus_ioremap(&bp->bigmac_sdev->resource[0], 0, | 1142 | bp->creg = of_ioremap(&op->resource[0], 0, |
1158 | CREG_REG_SIZE, "BigMAC QEC Channel Regs"); | 1143 | CREG_REG_SIZE, "BigMAC QEC Channel Regs"); |
1159 | if (!bp->creg) { | 1144 | if (!bp->creg) { |
1160 | printk(KERN_ERR "BIGMAC: Cannot map QEC channel registers.\n"); | 1145 | printk(KERN_ERR "BIGMAC: Cannot map QEC channel registers.\n"); |
1161 | goto fail_and_cleanup; | 1146 | goto fail_and_cleanup; |
1162 | } | 1147 | } |
1163 | 1148 | ||
1164 | /* Map in the BigMAC control registers. */ | 1149 | /* Map in the BigMAC control registers. */ |
1165 | bp->bregs = sbus_ioremap(&bp->bigmac_sdev->resource[1], 0, | 1150 | bp->bregs = of_ioremap(&op->resource[1], 0, |
1166 | BMAC_REG_SIZE, "BigMAC Primary Regs"); | 1151 | BMAC_REG_SIZE, "BigMAC Primary Regs"); |
1167 | if (!bp->bregs) { | 1152 | if (!bp->bregs) { |
1168 | printk(KERN_ERR "BIGMAC: Cannot map BigMAC primary registers.\n"); | 1153 | printk(KERN_ERR "BIGMAC: Cannot map BigMAC primary registers.\n"); |
1169 | goto fail_and_cleanup; | 1154 | goto fail_and_cleanup; |
@@ -1172,8 +1157,8 @@ static int __devinit bigmac_ether_init(struct sbus_dev *qec_sdev) | |||
1172 | /* Map in the BigMAC transceiver registers, this is how you poke at | 1157 | /* Map in the BigMAC transceiver registers, this is how you poke at |
1173 | * the BigMAC's PHY. | 1158 | * the BigMAC's PHY. |
1174 | */ | 1159 | */ |
1175 | bp->tregs = sbus_ioremap(&bp->bigmac_sdev->resource[2], 0, | 1160 | bp->tregs = of_ioremap(&op->resource[2], 0, |
1176 | TCVR_REG_SIZE, "BigMAC Transceiver Regs"); | 1161 | TCVR_REG_SIZE, "BigMAC Transceiver Regs"); |
1177 | if (!bp->tregs) { | 1162 | if (!bp->tregs) { |
1178 | printk(KERN_ERR "BIGMAC: Cannot map BigMAC transceiver registers.\n"); | 1163 | printk(KERN_ERR "BIGMAC: Cannot map BigMAC transceiver registers.\n"); |
1179 | goto fail_and_cleanup; | 1164 | goto fail_and_cleanup; |
@@ -1183,17 +1168,17 @@ static int __devinit bigmac_ether_init(struct sbus_dev *qec_sdev) | |||
1183 | bigmac_stop(bp); | 1168 | bigmac_stop(bp); |
1184 | 1169 | ||
1185 | /* Allocate transmit/receive descriptor DVMA block. */ | 1170 | /* Allocate transmit/receive descriptor DVMA block. */ |
1186 | bp->bmac_block = sbus_alloc_consistent(bp->bigmac_sdev, | 1171 | bp->bmac_block = dma_alloc_coherent(&bp->bigmac_op->dev, |
1187 | PAGE_SIZE, | 1172 | PAGE_SIZE, |
1188 | &bp->bblock_dvma); | 1173 | &bp->bblock_dvma, GFP_ATOMIC); |
1189 | if (bp->bmac_block == NULL || bp->bblock_dvma == 0) { | 1174 | if (bp->bmac_block == NULL || bp->bblock_dvma == 0) { |
1190 | printk(KERN_ERR "BIGMAC: Cannot allocate consistent DMA.\n"); | 1175 | printk(KERN_ERR "BIGMAC: Cannot allocate consistent DMA.\n"); |
1191 | goto fail_and_cleanup; | 1176 | goto fail_and_cleanup; |
1192 | } | 1177 | } |
1193 | 1178 | ||
1194 | /* Get the board revision of this BigMAC. */ | 1179 | /* Get the board revision of this BigMAC. */ |
1195 | bp->board_rev = prom_getintdefault(bp->bigmac_sdev->prom_node, | 1180 | bp->board_rev = of_getintprop_default(bp->bigmac_op->node, |
1196 | "board-version", 1); | 1181 | "board-version", 1); |
1197 | 1182 | ||
1198 | /* Init auto-negotiation timer state. */ | 1183 | /* Init auto-negotiation timer state. */ |
1199 | init_timer(&bp->bigmac_timer); | 1184 | init_timer(&bp->bigmac_timer); |
@@ -1217,7 +1202,7 @@ static int __devinit bigmac_ether_init(struct sbus_dev *qec_sdev) | |||
1217 | dev->watchdog_timeo = 5*HZ; | 1202 | dev->watchdog_timeo = 5*HZ; |
1218 | 1203 | ||
1219 | /* Finish net device registration. */ | 1204 | /* Finish net device registration. */ |
1220 | dev->irq = bp->bigmac_sdev->irqs[0]; | 1205 | dev->irq = bp->bigmac_op->irqs[0]; |
1221 | dev->dma = 0; | 1206 | dev->dma = 0; |
1222 | 1207 | ||
1223 | if (register_netdev(dev)) { | 1208 | if (register_netdev(dev)) { |
@@ -1225,7 +1210,7 @@ static int __devinit bigmac_ether_init(struct sbus_dev *qec_sdev) | |||
1225 | goto fail_and_cleanup; | 1210 | goto fail_and_cleanup; |
1226 | } | 1211 | } |
1227 | 1212 | ||
1228 | dev_set_drvdata(&bp->bigmac_sdev->ofdev.dev, bp); | 1213 | dev_set_drvdata(&bp->bigmac_op->dev, bp); |
1229 | 1214 | ||
1230 | printk(KERN_INFO "%s: BigMAC 100baseT Ethernet %s\n", | 1215 | printk(KERN_INFO "%s: BigMAC 100baseT Ethernet %s\n", |
1231 | dev->name, print_mac(mac, dev->dev_addr)); | 1216 | dev->name, print_mac(mac, dev->dev_addr)); |
@@ -1236,66 +1221,67 @@ fail_and_cleanup: | |||
1236 | /* Something went wrong, undo whatever we did so far. */ | 1221 | /* Something went wrong, undo whatever we did so far. */ |
1237 | /* Free register mappings if any. */ | 1222 | /* Free register mappings if any. */ |
1238 | if (bp->gregs) | 1223 | if (bp->gregs) |
1239 | sbus_iounmap(bp->gregs, GLOB_REG_SIZE); | 1224 | of_iounmap(&qec_op->resource[0], bp->gregs, GLOB_REG_SIZE); |
1240 | if (bp->creg) | 1225 | if (bp->creg) |
1241 | sbus_iounmap(bp->creg, CREG_REG_SIZE); | 1226 | of_iounmap(&op->resource[0], bp->creg, CREG_REG_SIZE); |
1242 | if (bp->bregs) | 1227 | if (bp->bregs) |
1243 | sbus_iounmap(bp->bregs, BMAC_REG_SIZE); | 1228 | of_iounmap(&op->resource[1], bp->bregs, BMAC_REG_SIZE); |
1244 | if (bp->tregs) | 1229 | if (bp->tregs) |
1245 | sbus_iounmap(bp->tregs, TCVR_REG_SIZE); | 1230 | of_iounmap(&op->resource[2], bp->tregs, TCVR_REG_SIZE); |
1246 | 1231 | ||
1247 | if (bp->bmac_block) | 1232 | if (bp->bmac_block) |
1248 | sbus_free_consistent(bp->bigmac_sdev, | 1233 | dma_free_coherent(&bp->bigmac_op->dev, |
1249 | PAGE_SIZE, | 1234 | PAGE_SIZE, |
1250 | bp->bmac_block, | 1235 | bp->bmac_block, |
1251 | bp->bblock_dvma); | 1236 | bp->bblock_dvma); |
1252 | 1237 | ||
1253 | /* This also frees the co-located 'dev->priv' */ | 1238 | /* This also frees the co-located 'dev->priv' */ |
1254 | free_netdev(dev); | 1239 | free_netdev(dev); |
1255 | return -ENODEV; | 1240 | return -ENODEV; |
1256 | } | 1241 | } |
1257 | 1242 | ||
1258 | /* QEC can be the parent of either QuadEthernet or | 1243 | /* QEC can be the parent of either QuadEthernet or a BigMAC. We want |
1259 | * a BigMAC. We want the latter. | 1244 | * the latter. |
1260 | */ | 1245 | */ |
1261 | static int __devinit bigmac_sbus_probe(struct of_device *dev, const struct of_device_id *match) | 1246 | static int __devinit bigmac_sbus_probe(struct of_device *op, |
1247 | const struct of_device_id *match) | ||
1262 | { | 1248 | { |
1263 | struct sbus_dev *sdev = to_sbus_device(&dev->dev); | 1249 | struct device *parent = op->dev.parent; |
1264 | struct device_node *dp = dev->node; | 1250 | struct of_device *qec_op; |
1265 | 1251 | ||
1266 | if (!strcmp(dp->name, "be")) | 1252 | qec_op = to_of_device(parent); |
1267 | sdev = sdev->parent; | ||
1268 | 1253 | ||
1269 | return bigmac_ether_init(sdev); | 1254 | return bigmac_ether_init(op, qec_op); |
1270 | } | 1255 | } |
1271 | 1256 | ||
1272 | static int __devexit bigmac_sbus_remove(struct of_device *dev) | 1257 | static int __devexit bigmac_sbus_remove(struct of_device *op) |
1273 | { | 1258 | { |
1274 | struct bigmac *bp = dev_get_drvdata(&dev->dev); | 1259 | struct bigmac *bp = dev_get_drvdata(&op->dev); |
1260 | struct device *parent = op->dev.parent; | ||
1275 | struct net_device *net_dev = bp->dev; | 1261 | struct net_device *net_dev = bp->dev; |
1262 | struct of_device *qec_op; | ||
1263 | |||
1264 | qec_op = to_of_device(parent); | ||
1276 | 1265 | ||
1277 | unregister_netdev(net_dev); | 1266 | unregister_netdev(net_dev); |
1278 | 1267 | ||
1279 | sbus_iounmap(bp->gregs, GLOB_REG_SIZE); | 1268 | of_iounmap(&qec_op->resource[0], bp->gregs, GLOB_REG_SIZE); |
1280 | sbus_iounmap(bp->creg, CREG_REG_SIZE); | 1269 | of_iounmap(&op->resource[0], bp->creg, CREG_REG_SIZE); |
1281 | sbus_iounmap(bp->bregs, BMAC_REG_SIZE); | 1270 | of_iounmap(&op->resource[1], bp->bregs, BMAC_REG_SIZE); |
1282 | sbus_iounmap(bp->tregs, TCVR_REG_SIZE); | 1271 | of_iounmap(&op->resource[2], bp->tregs, TCVR_REG_SIZE); |
1283 | sbus_free_consistent(bp->bigmac_sdev, | 1272 | dma_free_coherent(&op->dev, |
1284 | PAGE_SIZE, | 1273 | PAGE_SIZE, |
1285 | bp->bmac_block, | 1274 | bp->bmac_block, |
1286 | bp->bblock_dvma); | 1275 | bp->bblock_dvma); |
1287 | 1276 | ||
1288 | free_netdev(net_dev); | 1277 | free_netdev(net_dev); |
1289 | 1278 | ||
1290 | dev_set_drvdata(&dev->dev, NULL); | 1279 | dev_set_drvdata(&op->dev, NULL); |
1291 | 1280 | ||
1292 | return 0; | 1281 | return 0; |
1293 | } | 1282 | } |
1294 | 1283 | ||
1295 | static struct of_device_id bigmac_sbus_match[] = { | 1284 | static const struct of_device_id bigmac_sbus_match[] = { |
1296 | { | ||
1297 | .name = "qec", | ||
1298 | }, | ||
1299 | { | 1285 | { |
1300 | .name = "be", | 1286 | .name = "be", |
1301 | }, | 1287 | }, |
@@ -1313,7 +1299,7 @@ static struct of_platform_driver bigmac_sbus_driver = { | |||
1313 | 1299 | ||
1314 | static int __init bigmac_init(void) | 1300 | static int __init bigmac_init(void) |
1315 | { | 1301 | { |
1316 | return of_register_driver(&bigmac_sbus_driver, &sbus_bus_type); | 1302 | return of_register_driver(&bigmac_sbus_driver, &of_bus_type); |
1317 | } | 1303 | } |
1318 | 1304 | ||
1319 | static void __exit bigmac_exit(void) | 1305 | static void __exit bigmac_exit(void) |
diff --git a/drivers/net/sunbmac.h b/drivers/net/sunbmac.h index b563d3c2993e..8840bc0b840b 100644 --- a/drivers/net/sunbmac.h +++ b/drivers/net/sunbmac.h | |||
@@ -329,8 +329,8 @@ struct bigmac { | |||
329 | unsigned int timer_ticks; | 329 | unsigned int timer_ticks; |
330 | 330 | ||
331 | struct net_device_stats enet_stats; | 331 | struct net_device_stats enet_stats; |
332 | struct sbus_dev *qec_sdev; | 332 | struct of_device *qec_op; |
333 | struct sbus_dev *bigmac_sdev; | 333 | struct of_device *bigmac_op; |
334 | struct net_device *dev; | 334 | struct net_device *dev; |
335 | }; | 335 | }; |
336 | 336 | ||
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c index b79d5f018f79..f1ebeb5f65b2 100644 --- a/drivers/net/sunhme.c +++ b/drivers/net/sunhme.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * "Happy Meal Ethernet" found on SunSwift SBUS cards. | 3 | * "Happy Meal Ethernet" found on SunSwift SBUS cards. |
4 | * | 4 | * |
5 | * Copyright (C) 1996, 1998, 1999, 2002, 2003, | 5 | * Copyright (C) 1996, 1998, 1999, 2002, 2003, |
6 | 2006 David S. Miller (davem@davemloft.net) | 6 | * 2006, 2008 David S. Miller (davem@davemloft.net) |
7 | * | 7 | * |
8 | * Changes : | 8 | * Changes : |
9 | * 2000/11/11 Willy Tarreau <willy AT meta-x.org> | 9 | * 2000/11/11 Willy Tarreau <willy AT meta-x.org> |
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/skbuff.h> | 34 | #include <linux/skbuff.h> |
35 | #include <linux/mm.h> | 35 | #include <linux/mm.h> |
36 | #include <linux/bitops.h> | 36 | #include <linux/bitops.h> |
37 | #include <linux/dma-mapping.h> | ||
37 | 38 | ||
38 | #include <asm/system.h> | 39 | #include <asm/system.h> |
39 | #include <asm/io.h> | 40 | #include <asm/io.h> |
@@ -41,8 +42,9 @@ | |||
41 | #include <asm/byteorder.h> | 42 | #include <asm/byteorder.h> |
42 | 43 | ||
43 | #ifdef CONFIG_SPARC | 44 | #ifdef CONFIG_SPARC |
45 | #include <linux/of.h> | ||
46 | #include <linux/of_device.h> | ||
44 | #include <asm/idprom.h> | 47 | #include <asm/idprom.h> |
45 | #include <asm/sbus.h> | ||
46 | #include <asm/openprom.h> | 48 | #include <asm/openprom.h> |
47 | #include <asm/oplib.h> | 49 | #include <asm/oplib.h> |
48 | #include <asm/prom.h> | 50 | #include <asm/prom.h> |
@@ -60,8 +62,8 @@ | |||
60 | #include "sunhme.h" | 62 | #include "sunhme.h" |
61 | 63 | ||
62 | #define DRV_NAME "sunhme" | 64 | #define DRV_NAME "sunhme" |
63 | #define DRV_VERSION "3.00" | 65 | #define DRV_VERSION "3.10" |
64 | #define DRV_RELDATE "June 23, 2006" | 66 | #define DRV_RELDATE "August 26, 2008" |
65 | #define DRV_AUTHOR "David S. Miller (davem@davemloft.net)" | 67 | #define DRV_AUTHOR "David S. Miller (davem@davemloft.net)" |
66 | 68 | ||
67 | static char version[] = | 69 | static char version[] = |
@@ -251,13 +253,13 @@ static u32 pci_hme_read_desc32(hme32 *p) | |||
251 | #define hme_read_desc32(__hp, __p) \ | 253 | #define hme_read_desc32(__hp, __p) \ |
252 | ((__hp)->read_desc32(__p)) | 254 | ((__hp)->read_desc32(__p)) |
253 | #define hme_dma_map(__hp, __ptr, __size, __dir) \ | 255 | #define hme_dma_map(__hp, __ptr, __size, __dir) \ |
254 | ((__hp)->dma_map((__hp)->happy_dev, (__ptr), (__size), (__dir))) | 256 | ((__hp)->dma_map((__hp)->dma_dev, (__ptr), (__size), (__dir))) |
255 | #define hme_dma_unmap(__hp, __addr, __size, __dir) \ | 257 | #define hme_dma_unmap(__hp, __addr, __size, __dir) \ |
256 | ((__hp)->dma_unmap((__hp)->happy_dev, (__addr), (__size), (__dir))) | 258 | ((__hp)->dma_unmap((__hp)->dma_dev, (__addr), (__size), (__dir))) |
257 | #define hme_dma_sync_for_cpu(__hp, __addr, __size, __dir) \ | 259 | #define hme_dma_sync_for_cpu(__hp, __addr, __size, __dir) \ |
258 | ((__hp)->dma_sync_for_cpu((__hp)->happy_dev, (__addr), (__size), (__dir))) | 260 | ((__hp)->dma_sync_for_cpu((__hp)->dma_dev, (__addr), (__size), (__dir))) |
259 | #define hme_dma_sync_for_device(__hp, __addr, __size, __dir) \ | 261 | #define hme_dma_sync_for_device(__hp, __addr, __size, __dir) \ |
260 | ((__hp)->dma_sync_for_device((__hp)->happy_dev, (__addr), (__size), (__dir))) | 262 | ((__hp)->dma_sync_for_device((__hp)->dma_dev, (__addr), (__size), (__dir))) |
261 | #else | 263 | #else |
262 | #ifdef CONFIG_SBUS | 264 | #ifdef CONFIG_SBUS |
263 | /* SBUS only compilation */ | 265 | /* SBUS only compilation */ |
@@ -277,13 +279,13 @@ do { (__txd)->tx_addr = (__force hme32)(u32)(__addr); \ | |||
277 | } while(0) | 279 | } while(0) |
278 | #define hme_read_desc32(__hp, __p) ((__force u32)(hme32)*(__p)) | 280 | #define hme_read_desc32(__hp, __p) ((__force u32)(hme32)*(__p)) |
279 | #define hme_dma_map(__hp, __ptr, __size, __dir) \ | 281 | #define hme_dma_map(__hp, __ptr, __size, __dir) \ |
280 | sbus_map_single((__hp)->happy_dev, (__ptr), (__size), (__dir)) | 282 | dma_map_single((__hp)->dma_dev, (__ptr), (__size), (__dir)) |
281 | #define hme_dma_unmap(__hp, __addr, __size, __dir) \ | 283 | #define hme_dma_unmap(__hp, __addr, __size, __dir) \ |
282 | sbus_unmap_single((__hp)->happy_dev, (__addr), (__size), (__dir)) | 284 | dma_unmap_single((__hp)->dma_dev, (__addr), (__size), (__dir)) |
283 | #define hme_dma_sync_for_cpu(__hp, __addr, __size, __dir) \ | 285 | #define hme_dma_sync_for_cpu(__hp, __addr, __size, __dir) \ |
284 | sbus_dma_sync_single_for_cpu((__hp)->happy_dev, (__addr), (__size), (__dir)) | 286 | dma_dma_sync_single_for_cpu((__hp)->dma_dev, (__addr), (__size), (__dir)) |
285 | #define hme_dma_sync_for_device(__hp, __addr, __size, __dir) \ | 287 | #define hme_dma_sync_for_device(__hp, __addr, __size, __dir) \ |
286 | sbus_dma_sync_single_for_device((__hp)->happy_dev, (__addr), (__size), (__dir)) | 288 | dma_dma_sync_single_for_device((__hp)->dma_dev, (__addr), (__size), (__dir)) |
287 | #else | 289 | #else |
288 | /* PCI only compilation */ | 290 | /* PCI only compilation */ |
289 | #define hme_write32(__hp, __reg, __val) \ | 291 | #define hme_write32(__hp, __reg, __val) \ |
@@ -305,36 +307,17 @@ static inline u32 hme_read_desc32(struct happy_meal *hp, hme32 *p) | |||
305 | return le32_to_cpup((__le32 *)p); | 307 | return le32_to_cpup((__le32 *)p); |
306 | } | 308 | } |
307 | #define hme_dma_map(__hp, __ptr, __size, __dir) \ | 309 | #define hme_dma_map(__hp, __ptr, __size, __dir) \ |
308 | pci_map_single((__hp)->happy_dev, (__ptr), (__size), (__dir)) | 310 | pci_map_single((__hp)->dma_dev, (__ptr), (__size), (__dir)) |
309 | #define hme_dma_unmap(__hp, __addr, __size, __dir) \ | 311 | #define hme_dma_unmap(__hp, __addr, __size, __dir) \ |
310 | pci_unmap_single((__hp)->happy_dev, (__addr), (__size), (__dir)) | 312 | pci_unmap_single((__hp)->dma_dev, (__addr), (__size), (__dir)) |
311 | #define hme_dma_sync_for_cpu(__hp, __addr, __size, __dir) \ | 313 | #define hme_dma_sync_for_cpu(__hp, __addr, __size, __dir) \ |
312 | pci_dma_sync_single_for_cpu((__hp)->happy_dev, (__addr), (__size), (__dir)) | 314 | pci_dma_sync_single_for_cpu((__hp)->dma_dev, (__addr), (__size), (__dir)) |
313 | #define hme_dma_sync_for_device(__hp, __addr, __size, __dir) \ | 315 | #define hme_dma_sync_for_device(__hp, __addr, __size, __dir) \ |
314 | pci_dma_sync_single_for_device((__hp)->happy_dev, (__addr), (__size), (__dir)) | 316 | pci_dma_sync_single_for_device((__hp)->dma_dev, (__addr), (__size), (__dir)) |
315 | #endif | 317 | #endif |
316 | #endif | 318 | #endif |
317 | 319 | ||
318 | 320 | ||
319 | #ifdef SBUS_DMA_BIDIRECTIONAL | ||
320 | # define DMA_BIDIRECTIONAL SBUS_DMA_BIDIRECTIONAL | ||
321 | #else | ||
322 | # define DMA_BIDIRECTIONAL 0 | ||
323 | #endif | ||
324 | |||
325 | #ifdef SBUS_DMA_FROMDEVICE | ||
326 | # define DMA_FROMDEVICE SBUS_DMA_FROMDEVICE | ||
327 | #else | ||
328 | # define DMA_TODEVICE 1 | ||
329 | #endif | ||
330 | |||
331 | #ifdef SBUS_DMA_TODEVICE | ||
332 | # define DMA_TODEVICE SBUS_DMA_TODEVICE | ||
333 | #else | ||
334 | # define DMA_FROMDEVICE 2 | ||
335 | #endif | ||
336 | |||
337 | |||
338 | /* Oh yes, the MIF BitBang is mighty fun to program. BitBucket is more like it. */ | 321 | /* Oh yes, the MIF BitBang is mighty fun to program. BitBucket is more like it. */ |
339 | static void BB_PUT_BIT(struct happy_meal *hp, void __iomem *tregs, int bit) | 322 | static void BB_PUT_BIT(struct happy_meal *hp, void __iomem *tregs, int bit) |
340 | { | 323 | { |
@@ -1224,7 +1207,8 @@ static void happy_meal_clean_rings(struct happy_meal *hp) | |||
1224 | 1207 | ||
1225 | rxd = &hp->happy_block->happy_meal_rxd[i]; | 1208 | rxd = &hp->happy_block->happy_meal_rxd[i]; |
1226 | dma_addr = hme_read_desc32(hp, &rxd->rx_addr); | 1209 | dma_addr = hme_read_desc32(hp, &rxd->rx_addr); |
1227 | hme_dma_unmap(hp, dma_addr, RX_BUF_ALLOC_SIZE, DMA_FROMDEVICE); | 1210 | dma_unmap_single(hp->dma_dev, dma_addr, |
1211 | RX_BUF_ALLOC_SIZE, DMA_FROM_DEVICE); | ||
1228 | dev_kfree_skb_any(skb); | 1212 | dev_kfree_skb_any(skb); |
1229 | hp->rx_skbs[i] = NULL; | 1213 | hp->rx_skbs[i] = NULL; |
1230 | } | 1214 | } |
@@ -1242,10 +1226,10 @@ static void happy_meal_clean_rings(struct happy_meal *hp) | |||
1242 | for (frag = 0; frag <= skb_shinfo(skb)->nr_frags; frag++) { | 1226 | for (frag = 0; frag <= skb_shinfo(skb)->nr_frags; frag++) { |
1243 | txd = &hp->happy_block->happy_meal_txd[i]; | 1227 | txd = &hp->happy_block->happy_meal_txd[i]; |
1244 | dma_addr = hme_read_desc32(hp, &txd->tx_addr); | 1228 | dma_addr = hme_read_desc32(hp, &txd->tx_addr); |
1245 | hme_dma_unmap(hp, dma_addr, | 1229 | dma_unmap_single(hp->dma_dev, dma_addr, |
1246 | (hme_read_desc32(hp, &txd->tx_flags) | 1230 | (hme_read_desc32(hp, &txd->tx_flags) |
1247 | & TXFLAG_SIZE), | 1231 | & TXFLAG_SIZE), |
1248 | DMA_TODEVICE); | 1232 | DMA_TO_DEVICE); |
1249 | 1233 | ||
1250 | if (frag != skb_shinfo(skb)->nr_frags) | 1234 | if (frag != skb_shinfo(skb)->nr_frags) |
1251 | i++; | 1235 | i++; |
@@ -1287,7 +1271,8 @@ static void happy_meal_init_rings(struct happy_meal *hp) | |||
1287 | skb_put(skb, (ETH_FRAME_LEN + RX_OFFSET + 4)); | 1271 | skb_put(skb, (ETH_FRAME_LEN + RX_OFFSET + 4)); |
1288 | hme_write_rxd(hp, &hb->happy_meal_rxd[i], | 1272 | hme_write_rxd(hp, &hb->happy_meal_rxd[i], |
1289 | (RXFLAG_OWN | ((RX_BUF_ALLOC_SIZE - RX_OFFSET) << 16)), | 1273 | (RXFLAG_OWN | ((RX_BUF_ALLOC_SIZE - RX_OFFSET) << 16)), |
1290 | hme_dma_map(hp, skb->data, RX_BUF_ALLOC_SIZE, DMA_FROMDEVICE)); | 1274 | dma_map_single(hp->dma_dev, skb->data, RX_BUF_ALLOC_SIZE, |
1275 | DMA_FROM_DEVICE)); | ||
1291 | skb_reserve(skb, RX_OFFSET); | 1276 | skb_reserve(skb, RX_OFFSET); |
1292 | } | 1277 | } |
1293 | 1278 | ||
@@ -1593,7 +1578,7 @@ static int happy_meal_init(struct happy_meal *hp) | |||
1593 | if ((hp->happy_bursts & DMA_BURST64) && | 1578 | if ((hp->happy_bursts & DMA_BURST64) && |
1594 | ((hp->happy_flags & HFLAG_PCI) != 0 | 1579 | ((hp->happy_flags & HFLAG_PCI) != 0 |
1595 | #ifdef CONFIG_SBUS | 1580 | #ifdef CONFIG_SBUS |
1596 | || sbus_can_burst64(hp->happy_dev) | 1581 | || sbus_can_burst64() |
1597 | #endif | 1582 | #endif |
1598 | || 0)) { | 1583 | || 0)) { |
1599 | u32 gcfg = GREG_CFG_BURST64; | 1584 | u32 gcfg = GREG_CFG_BURST64; |
@@ -1603,11 +1588,13 @@ static int happy_meal_init(struct happy_meal *hp) | |||
1603 | * do not. -DaveM | 1588 | * do not. -DaveM |
1604 | */ | 1589 | */ |
1605 | #ifdef CONFIG_SBUS | 1590 | #ifdef CONFIG_SBUS |
1606 | if ((hp->happy_flags & HFLAG_PCI) == 0 && | 1591 | if ((hp->happy_flags & HFLAG_PCI) == 0) { |
1607 | sbus_can_dma_64bit(hp->happy_dev)) { | 1592 | struct of_device *op = hp->happy_dev; |
1608 | sbus_set_sbus64(hp->happy_dev, | 1593 | if (sbus_can_dma_64bit()) { |
1609 | hp->happy_bursts); | 1594 | sbus_set_sbus64(&op->dev, |
1610 | gcfg |= GREG_CFG_64BIT; | 1595 | hp->happy_bursts); |
1596 | gcfg |= GREG_CFG_64BIT; | ||
1597 | } | ||
1611 | } | 1598 | } |
1612 | #endif | 1599 | #endif |
1613 | 1600 | ||
@@ -1966,7 +1953,7 @@ static void happy_meal_tx(struct happy_meal *hp) | |||
1966 | dma_len = hme_read_desc32(hp, &this->tx_flags); | 1953 | dma_len = hme_read_desc32(hp, &this->tx_flags); |
1967 | 1954 | ||
1968 | dma_len &= TXFLAG_SIZE; | 1955 | dma_len &= TXFLAG_SIZE; |
1969 | hme_dma_unmap(hp, dma_addr, dma_len, DMA_TODEVICE); | 1956 | dma_unmap_single(hp->dma_dev, dma_addr, dma_len, DMA_TO_DEVICE); |
1970 | 1957 | ||
1971 | elem = NEXT_TX(elem); | 1958 | elem = NEXT_TX(elem); |
1972 | this = &txbase[elem]; | 1959 | this = &txbase[elem]; |
@@ -2044,13 +2031,14 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev) | |||
2044 | drops++; | 2031 | drops++; |
2045 | goto drop_it; | 2032 | goto drop_it; |
2046 | } | 2033 | } |
2047 | hme_dma_unmap(hp, dma_addr, RX_BUF_ALLOC_SIZE, DMA_FROMDEVICE); | 2034 | dma_unmap_single(hp->dma_dev, dma_addr, RX_BUF_ALLOC_SIZE, DMA_FROM_DEVICE); |
2048 | hp->rx_skbs[elem] = new_skb; | 2035 | hp->rx_skbs[elem] = new_skb; |
2049 | new_skb->dev = dev; | 2036 | new_skb->dev = dev; |
2050 | skb_put(new_skb, (ETH_FRAME_LEN + RX_OFFSET + 4)); | 2037 | skb_put(new_skb, (ETH_FRAME_LEN + RX_OFFSET + 4)); |
2051 | hme_write_rxd(hp, this, | 2038 | hme_write_rxd(hp, this, |
2052 | (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)), | 2039 | (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)), |
2053 | hme_dma_map(hp, new_skb->data, RX_BUF_ALLOC_SIZE, DMA_FROMDEVICE)); | 2040 | dma_map_single(hp->dma_dev, new_skb->data, RX_BUF_ALLOC_SIZE, |
2041 | DMA_FROM_DEVICE)); | ||
2054 | skb_reserve(new_skb, RX_OFFSET); | 2042 | skb_reserve(new_skb, RX_OFFSET); |
2055 | 2043 | ||
2056 | /* Trim the original skb for the netif. */ | 2044 | /* Trim the original skb for the netif. */ |
@@ -2065,10 +2053,9 @@ static void happy_meal_rx(struct happy_meal *hp, struct net_device *dev) | |||
2065 | 2053 | ||
2066 | skb_reserve(copy_skb, 2); | 2054 | skb_reserve(copy_skb, 2); |
2067 | skb_put(copy_skb, len); | 2055 | skb_put(copy_skb, len); |
2068 | hme_dma_sync_for_cpu(hp, dma_addr, len, DMA_FROMDEVICE); | 2056 | dma_sync_single_for_cpu(hp->dma_dev, dma_addr, len, DMA_FROM_DEVICE); |
2069 | skb_copy_from_linear_data(skb, copy_skb->data, len); | 2057 | skb_copy_from_linear_data(skb, copy_skb->data, len); |
2070 | hme_dma_sync_for_device(hp, dma_addr, len, DMA_FROMDEVICE); | 2058 | dma_sync_single_for_device(hp->dma_dev, dma_addr, len, DMA_FROM_DEVICE); |
2071 | |||
2072 | /* Reuse original ring buffer. */ | 2059 | /* Reuse original ring buffer. */ |
2073 | hme_write_rxd(hp, this, | 2060 | hme_write_rxd(hp, this, |
2074 | (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)), | 2061 | (RXFLAG_OWN|((RX_BUF_ALLOC_SIZE-RX_OFFSET)<<16)), |
@@ -2300,7 +2287,7 @@ static int happy_meal_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2300 | u32 mapping, len; | 2287 | u32 mapping, len; |
2301 | 2288 | ||
2302 | len = skb->len; | 2289 | len = skb->len; |
2303 | mapping = hme_dma_map(hp, skb->data, len, DMA_TODEVICE); | 2290 | mapping = dma_map_single(hp->dma_dev, skb->data, len, DMA_TO_DEVICE); |
2304 | tx_flags |= (TXFLAG_SOP | TXFLAG_EOP); | 2291 | tx_flags |= (TXFLAG_SOP | TXFLAG_EOP); |
2305 | hme_write_txd(hp, &hp->happy_block->happy_meal_txd[entry], | 2292 | hme_write_txd(hp, &hp->happy_block->happy_meal_txd[entry], |
2306 | (tx_flags | (len & TXFLAG_SIZE)), | 2293 | (tx_flags | (len & TXFLAG_SIZE)), |
@@ -2314,7 +2301,8 @@ static int happy_meal_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2314 | * Otherwise we could race with the device. | 2301 | * Otherwise we could race with the device. |
2315 | */ | 2302 | */ |
2316 | first_len = skb_headlen(skb); | 2303 | first_len = skb_headlen(skb); |
2317 | first_mapping = hme_dma_map(hp, skb->data, first_len, DMA_TODEVICE); | 2304 | first_mapping = dma_map_single(hp->dma_dev, skb->data, first_len, |
2305 | DMA_TO_DEVICE); | ||
2318 | entry = NEXT_TX(entry); | 2306 | entry = NEXT_TX(entry); |
2319 | 2307 | ||
2320 | for (frag = 0; frag < skb_shinfo(skb)->nr_frags; frag++) { | 2308 | for (frag = 0; frag < skb_shinfo(skb)->nr_frags; frag++) { |
@@ -2322,10 +2310,9 @@ static int happy_meal_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2322 | u32 len, mapping, this_txflags; | 2310 | u32 len, mapping, this_txflags; |
2323 | 2311 | ||
2324 | len = this_frag->size; | 2312 | len = this_frag->size; |
2325 | mapping = hme_dma_map(hp, | 2313 | mapping = dma_map_page(hp->dma_dev, this_frag->page, |
2326 | ((void *) page_address(this_frag->page) + | 2314 | this_frag->page_offset, len, |
2327 | this_frag->page_offset), | 2315 | DMA_TO_DEVICE); |
2328 | len, DMA_TODEVICE); | ||
2329 | this_txflags = tx_flags; | 2316 | this_txflags = tx_flags; |
2330 | if (frag == skb_shinfo(skb)->nr_frags - 1) | 2317 | if (frag == skb_shinfo(skb)->nr_frags - 1) |
2331 | this_txflags |= TXFLAG_EOP; | 2318 | this_txflags |= TXFLAG_EOP; |
@@ -2493,9 +2480,12 @@ static void hme_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info | |||
2493 | } | 2480 | } |
2494 | #ifdef CONFIG_SBUS | 2481 | #ifdef CONFIG_SBUS |
2495 | else { | 2482 | else { |
2496 | struct sbus_dev *sdev = hp->happy_dev; | 2483 | const struct linux_prom_registers *regs; |
2497 | sprintf(info->bus_info, "SBUS:%d", | 2484 | struct of_device *op = hp->happy_dev; |
2498 | sdev->slot); | 2485 | regs = of_get_property(op->node, "regs", NULL); |
2486 | if (regs) | ||
2487 | sprintf(info->bus_info, "SBUS:%d", | ||
2488 | regs->which_io); | ||
2499 | } | 2489 | } |
2500 | #endif | 2490 | #endif |
2501 | } | 2491 | } |
@@ -2521,63 +2511,21 @@ static const struct ethtool_ops hme_ethtool_ops = { | |||
2521 | static int hme_version_printed; | 2511 | static int hme_version_printed; |
2522 | 2512 | ||
2523 | #ifdef CONFIG_SBUS | 2513 | #ifdef CONFIG_SBUS |
2524 | void __devinit quattro_get_ranges(struct quattro *qp) | ||
2525 | { | ||
2526 | struct sbus_dev *sdev = qp->quattro_dev; | ||
2527 | int err; | ||
2528 | |||
2529 | err = prom_getproperty(sdev->prom_node, | ||
2530 | "ranges", | ||
2531 | (char *)&qp->ranges[0], | ||
2532 | sizeof(qp->ranges)); | ||
2533 | if (err == 0 || err == -1) { | ||
2534 | qp->nranges = 0; | ||
2535 | return; | ||
2536 | } | ||
2537 | qp->nranges = (err / sizeof(struct linux_prom_ranges)); | ||
2538 | } | ||
2539 | |||
2540 | static void __devinit quattro_apply_ranges(struct quattro *qp, struct happy_meal *hp) | ||
2541 | { | ||
2542 | struct sbus_dev *sdev = hp->happy_dev; | ||
2543 | int rng; | ||
2544 | |||
2545 | for (rng = 0; rng < qp->nranges; rng++) { | ||
2546 | struct linux_prom_ranges *rngp = &qp->ranges[rng]; | ||
2547 | int reg; | ||
2548 | |||
2549 | for (reg = 0; reg < 5; reg++) { | ||
2550 | if (sdev->reg_addrs[reg].which_io == | ||
2551 | rngp->ot_child_space) | ||
2552 | break; | ||
2553 | } | ||
2554 | if (reg == 5) | ||
2555 | continue; | ||
2556 | |||
2557 | sdev->reg_addrs[reg].which_io = rngp->ot_parent_space; | ||
2558 | sdev->reg_addrs[reg].phys_addr += rngp->ot_parent_base; | ||
2559 | } | ||
2560 | } | ||
2561 | |||
2562 | /* Given a happy meal sbus device, find it's quattro parent. | 2514 | /* Given a happy meal sbus device, find it's quattro parent. |
2563 | * If none exist, allocate and return a new one. | 2515 | * If none exist, allocate and return a new one. |
2564 | * | 2516 | * |
2565 | * Return NULL on failure. | 2517 | * Return NULL on failure. |
2566 | */ | 2518 | */ |
2567 | static struct quattro * __devinit quattro_sbus_find(struct sbus_dev *goal_sdev) | 2519 | static struct quattro * __devinit quattro_sbus_find(struct of_device *child) |
2568 | { | 2520 | { |
2569 | struct sbus_dev *sdev; | 2521 | struct device *parent = child->dev.parent; |
2522 | struct of_device *op; | ||
2570 | struct quattro *qp; | 2523 | struct quattro *qp; |
2571 | int i; | ||
2572 | 2524 | ||
2573 | for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { | 2525 | op = to_of_device(parent); |
2574 | for (i = 0, sdev = qp->quattro_dev; | 2526 | qp = dev_get_drvdata(&op->dev); |
2575 | (sdev != NULL) && (i < 4); | 2527 | if (qp) |
2576 | sdev = sdev->next, i++) { | 2528 | return qp; |
2577 | if (sdev == goal_sdev) | ||
2578 | return qp; | ||
2579 | } | ||
2580 | } | ||
2581 | 2529 | ||
2582 | qp = kmalloc(sizeof(struct quattro), GFP_KERNEL); | 2530 | qp = kmalloc(sizeof(struct quattro), GFP_KERNEL); |
2583 | if (qp != NULL) { | 2531 | if (qp != NULL) { |
@@ -2586,10 +2534,11 @@ static struct quattro * __devinit quattro_sbus_find(struct sbus_dev *goal_sdev) | |||
2586 | for (i = 0; i < 4; i++) | 2534 | for (i = 0; i < 4; i++) |
2587 | qp->happy_meals[i] = NULL; | 2535 | qp->happy_meals[i] = NULL; |
2588 | 2536 | ||
2589 | qp->quattro_dev = goal_sdev; | 2537 | qp->quattro_dev = child; |
2590 | qp->next = qfe_sbus_list; | 2538 | qp->next = qfe_sbus_list; |
2591 | qfe_sbus_list = qp; | 2539 | qfe_sbus_list = qp; |
2592 | quattro_get_ranges(qp); | 2540 | |
2541 | dev_set_drvdata(&op->dev, qp); | ||
2593 | } | 2542 | } |
2594 | return qp; | 2543 | return qp; |
2595 | } | 2544 | } |
@@ -2602,10 +2551,10 @@ static void __init quattro_sbus_register_irqs(void) | |||
2602 | struct quattro *qp; | 2551 | struct quattro *qp; |
2603 | 2552 | ||
2604 | for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { | 2553 | for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { |
2605 | struct sbus_dev *sdev = qp->quattro_dev; | 2554 | struct of_device *op = qp->quattro_dev; |
2606 | int err; | 2555 | int err; |
2607 | 2556 | ||
2608 | err = request_irq(sdev->irqs[0], | 2557 | err = request_irq(op->irqs[0], |
2609 | quattro_sbus_interrupt, | 2558 | quattro_sbus_interrupt, |
2610 | IRQF_SHARED, "Quattro", | 2559 | IRQF_SHARED, "Quattro", |
2611 | qp); | 2560 | qp); |
@@ -2621,9 +2570,9 @@ static void quattro_sbus_free_irqs(void) | |||
2621 | struct quattro *qp; | 2570 | struct quattro *qp; |
2622 | 2571 | ||
2623 | for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { | 2572 | for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { |
2624 | struct sbus_dev *sdev = qp->quattro_dev; | 2573 | struct of_device *op = qp->quattro_dev; |
2625 | 2574 | ||
2626 | free_irq(sdev->irqs[0], qp); | 2575 | free_irq(op->irqs[0], qp); |
2627 | } | 2576 | } |
2628 | } | 2577 | } |
2629 | #endif /* CONFIG_SBUS */ | 2578 | #endif /* CONFIG_SBUS */ |
@@ -2660,9 +2609,9 @@ static struct quattro * __devinit quattro_pci_find(struct pci_dev *pdev) | |||
2660 | #endif /* CONFIG_PCI */ | 2609 | #endif /* CONFIG_PCI */ |
2661 | 2610 | ||
2662 | #ifdef CONFIG_SBUS | 2611 | #ifdef CONFIG_SBUS |
2663 | static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe) | 2612 | static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe) |
2664 | { | 2613 | { |
2665 | struct device_node *dp = sdev->ofdev.node; | 2614 | struct device_node *dp = op->node, *sbus_dp; |
2666 | struct quattro *qp = NULL; | 2615 | struct quattro *qp = NULL; |
2667 | struct happy_meal *hp; | 2616 | struct happy_meal *hp; |
2668 | struct net_device *dev; | 2617 | struct net_device *dev; |
@@ -2671,7 +2620,7 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe | |||
2671 | DECLARE_MAC_BUF(mac); | 2620 | DECLARE_MAC_BUF(mac); |
2672 | 2621 | ||
2673 | if (is_qfe) { | 2622 | if (is_qfe) { |
2674 | qp = quattro_sbus_find(sdev); | 2623 | qp = quattro_sbus_find(op); |
2675 | if (qp == NULL) | 2624 | if (qp == NULL) |
2676 | goto err_out; | 2625 | goto err_out; |
2677 | for (qfe_slot = 0; qfe_slot < 4; qfe_slot++) | 2626 | for (qfe_slot = 0; qfe_slot < 4; qfe_slot++) |
@@ -2685,7 +2634,7 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe | |||
2685 | dev = alloc_etherdev(sizeof(struct happy_meal)); | 2634 | dev = alloc_etherdev(sizeof(struct happy_meal)); |
2686 | if (!dev) | 2635 | if (!dev) |
2687 | goto err_out; | 2636 | goto err_out; |
2688 | SET_NETDEV_DEV(dev, &sdev->ofdev.dev); | 2637 | SET_NETDEV_DEV(dev, &op->dev); |
2689 | 2638 | ||
2690 | if (hme_version_printed++ == 0) | 2639 | if (hme_version_printed++ == 0) |
2691 | printk(KERN_INFO "%s", version); | 2640 | printk(KERN_INFO "%s", version); |
@@ -2713,56 +2662,50 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe | |||
2713 | memcpy(dev->dev_addr, idprom->id_ethaddr, 6); | 2662 | memcpy(dev->dev_addr, idprom->id_ethaddr, 6); |
2714 | } | 2663 | } |
2715 | 2664 | ||
2716 | hp = dev->priv; | 2665 | hp = netdev_priv(dev); |
2717 | 2666 | ||
2718 | hp->happy_dev = sdev; | 2667 | hp->happy_dev = op; |
2668 | hp->dma_dev = &op->dev; | ||
2719 | 2669 | ||
2720 | spin_lock_init(&hp->happy_lock); | 2670 | spin_lock_init(&hp->happy_lock); |
2721 | 2671 | ||
2722 | err = -ENODEV; | 2672 | err = -ENODEV; |
2723 | if (sdev->num_registers != 5) { | ||
2724 | printk(KERN_ERR "happymeal: Device needs 5 regs, has %d.\n", | ||
2725 | sdev->num_registers); | ||
2726 | goto err_out_free_netdev; | ||
2727 | } | ||
2728 | |||
2729 | if (qp != NULL) { | 2673 | if (qp != NULL) { |
2730 | hp->qfe_parent = qp; | 2674 | hp->qfe_parent = qp; |
2731 | hp->qfe_ent = qfe_slot; | 2675 | hp->qfe_ent = qfe_slot; |
2732 | qp->happy_meals[qfe_slot] = dev; | 2676 | qp->happy_meals[qfe_slot] = dev; |
2733 | quattro_apply_ranges(qp, hp); | ||
2734 | } | 2677 | } |
2735 | 2678 | ||
2736 | hp->gregs = sbus_ioremap(&sdev->resource[0], 0, | 2679 | hp->gregs = of_ioremap(&op->resource[0], 0, |
2737 | GREG_REG_SIZE, "HME Global Regs"); | 2680 | GREG_REG_SIZE, "HME Global Regs"); |
2738 | if (!hp->gregs) { | 2681 | if (!hp->gregs) { |
2739 | printk(KERN_ERR "happymeal: Cannot map global registers.\n"); | 2682 | printk(KERN_ERR "happymeal: Cannot map global registers.\n"); |
2740 | goto err_out_free_netdev; | 2683 | goto err_out_free_netdev; |
2741 | } | 2684 | } |
2742 | 2685 | ||
2743 | hp->etxregs = sbus_ioremap(&sdev->resource[1], 0, | 2686 | hp->etxregs = of_ioremap(&op->resource[1], 0, |
2744 | ETX_REG_SIZE, "HME TX Regs"); | 2687 | ETX_REG_SIZE, "HME TX Regs"); |
2745 | if (!hp->etxregs) { | 2688 | if (!hp->etxregs) { |
2746 | printk(KERN_ERR "happymeal: Cannot map MAC TX registers.\n"); | 2689 | printk(KERN_ERR "happymeal: Cannot map MAC TX registers.\n"); |
2747 | goto err_out_iounmap; | 2690 | goto err_out_iounmap; |
2748 | } | 2691 | } |
2749 | 2692 | ||
2750 | hp->erxregs = sbus_ioremap(&sdev->resource[2], 0, | 2693 | hp->erxregs = of_ioremap(&op->resource[2], 0, |
2751 | ERX_REG_SIZE, "HME RX Regs"); | 2694 | ERX_REG_SIZE, "HME RX Regs"); |
2752 | if (!hp->erxregs) { | 2695 | if (!hp->erxregs) { |
2753 | printk(KERN_ERR "happymeal: Cannot map MAC RX registers.\n"); | 2696 | printk(KERN_ERR "happymeal: Cannot map MAC RX registers.\n"); |
2754 | goto err_out_iounmap; | 2697 | goto err_out_iounmap; |
2755 | } | 2698 | } |
2756 | 2699 | ||
2757 | hp->bigmacregs = sbus_ioremap(&sdev->resource[3], 0, | 2700 | hp->bigmacregs = of_ioremap(&op->resource[3], 0, |
2758 | BMAC_REG_SIZE, "HME BIGMAC Regs"); | 2701 | BMAC_REG_SIZE, "HME BIGMAC Regs"); |
2759 | if (!hp->bigmacregs) { | 2702 | if (!hp->bigmacregs) { |
2760 | printk(KERN_ERR "happymeal: Cannot map BIGMAC registers.\n"); | 2703 | printk(KERN_ERR "happymeal: Cannot map BIGMAC registers.\n"); |
2761 | goto err_out_iounmap; | 2704 | goto err_out_iounmap; |
2762 | } | 2705 | } |
2763 | 2706 | ||
2764 | hp->tcvregs = sbus_ioremap(&sdev->resource[4], 0, | 2707 | hp->tcvregs = of_ioremap(&op->resource[4], 0, |
2765 | TCVR_REG_SIZE, "HME Tranceiver Regs"); | 2708 | TCVR_REG_SIZE, "HME Tranceiver Regs"); |
2766 | if (!hp->tcvregs) { | 2709 | if (!hp->tcvregs) { |
2767 | printk(KERN_ERR "happymeal: Cannot map TCVR registers.\n"); | 2710 | printk(KERN_ERR "happymeal: Cannot map TCVR registers.\n"); |
2768 | goto err_out_iounmap; | 2711 | goto err_out_iounmap; |
@@ -2781,13 +2724,18 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe | |||
2781 | if (qp != NULL) | 2724 | if (qp != NULL) |
2782 | hp->happy_flags |= HFLAG_QUATTRO; | 2725 | hp->happy_flags |= HFLAG_QUATTRO; |
2783 | 2726 | ||
2727 | sbus_dp = to_of_device(op->dev.parent)->node; | ||
2728 | if (is_qfe) | ||
2729 | sbus_dp = to_of_device(op->dev.parent->parent)->node; | ||
2730 | |||
2784 | /* Get the supported DVMA burst sizes from our Happy SBUS. */ | 2731 | /* Get the supported DVMA burst sizes from our Happy SBUS. */ |
2785 | hp->happy_bursts = of_getintprop_default(sdev->bus->ofdev.node, | 2732 | hp->happy_bursts = of_getintprop_default(sbus_dp, |
2786 | "burst-sizes", 0x00); | 2733 | "burst-sizes", 0x00); |
2787 | 2734 | ||
2788 | hp->happy_block = sbus_alloc_consistent(hp->happy_dev, | 2735 | hp->happy_block = dma_alloc_coherent(hp->dma_dev, |
2789 | PAGE_SIZE, | 2736 | PAGE_SIZE, |
2790 | &hp->hblock_dvma); | 2737 | &hp->hblock_dvma, |
2738 | GFP_ATOMIC); | ||
2791 | err = -ENOMEM; | 2739 | err = -ENOMEM; |
2792 | if (!hp->happy_block) { | 2740 | if (!hp->happy_block) { |
2793 | printk(KERN_ERR "happymeal: Cannot allocate descriptors.\n"); | 2741 | printk(KERN_ERR "happymeal: Cannot allocate descriptors.\n"); |
@@ -2816,19 +2764,13 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe | |||
2816 | /* Happy Meal can do it all... */ | 2764 | /* Happy Meal can do it all... */ |
2817 | dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; | 2765 | dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; |
2818 | 2766 | ||
2819 | dev->irq = sdev->irqs[0]; | 2767 | dev->irq = op->irqs[0]; |
2820 | 2768 | ||
2821 | #if defined(CONFIG_SBUS) && defined(CONFIG_PCI) | 2769 | #if defined(CONFIG_SBUS) && defined(CONFIG_PCI) |
2822 | /* Hook up PCI register/dma accessors. */ | 2770 | /* Hook up SBUS register/descriptor accessors. */ |
2823 | hp->read_desc32 = sbus_hme_read_desc32; | 2771 | hp->read_desc32 = sbus_hme_read_desc32; |
2824 | hp->write_txd = sbus_hme_write_txd; | 2772 | hp->write_txd = sbus_hme_write_txd; |
2825 | hp->write_rxd = sbus_hme_write_rxd; | 2773 | hp->write_rxd = sbus_hme_write_rxd; |
2826 | hp->dma_map = (u32 (*)(void *, void *, long, int))sbus_map_single; | ||
2827 | hp->dma_unmap = (void (*)(void *, u32, long, int))sbus_unmap_single; | ||
2828 | hp->dma_sync_for_cpu = (void (*)(void *, u32, long, int)) | ||
2829 | sbus_dma_sync_single_for_cpu; | ||
2830 | hp->dma_sync_for_device = (void (*)(void *, u32, long, int)) | ||
2831 | sbus_dma_sync_single_for_device; | ||
2832 | hp->read32 = sbus_hme_read32; | 2774 | hp->read32 = sbus_hme_read32; |
2833 | hp->write32 = sbus_hme_write32; | 2775 | hp->write32 = sbus_hme_write32; |
2834 | #endif | 2776 | #endif |
@@ -2843,10 +2785,10 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe | |||
2843 | if (register_netdev(hp->dev)) { | 2785 | if (register_netdev(hp->dev)) { |
2844 | printk(KERN_ERR "happymeal: Cannot register net device, " | 2786 | printk(KERN_ERR "happymeal: Cannot register net device, " |
2845 | "aborting.\n"); | 2787 | "aborting.\n"); |
2846 | goto err_out_free_consistent; | 2788 | goto err_out_free_coherent; |
2847 | } | 2789 | } |
2848 | 2790 | ||
2849 | dev_set_drvdata(&sdev->ofdev.dev, hp); | 2791 | dev_set_drvdata(&op->dev, hp); |
2850 | 2792 | ||
2851 | if (qfe_slot != -1) | 2793 | if (qfe_slot != -1) |
2852 | printk(KERN_INFO "%s: Quattro HME slot %d (SBUS) 10/100baseT Ethernet ", | 2794 | printk(KERN_INFO "%s: Quattro HME slot %d (SBUS) 10/100baseT Ethernet ", |
@@ -2859,23 +2801,23 @@ static int __devinit happy_meal_sbus_probe_one(struct sbus_dev *sdev, int is_qfe | |||
2859 | 2801 | ||
2860 | return 0; | 2802 | return 0; |
2861 | 2803 | ||
2862 | err_out_free_consistent: | 2804 | err_out_free_coherent: |
2863 | sbus_free_consistent(hp->happy_dev, | 2805 | dma_free_coherent(hp->dma_dev, |
2864 | PAGE_SIZE, | 2806 | PAGE_SIZE, |
2865 | hp->happy_block, | 2807 | hp->happy_block, |
2866 | hp->hblock_dvma); | 2808 | hp->hblock_dvma); |
2867 | 2809 | ||
2868 | err_out_iounmap: | 2810 | err_out_iounmap: |
2869 | if (hp->gregs) | 2811 | if (hp->gregs) |
2870 | sbus_iounmap(hp->gregs, GREG_REG_SIZE); | 2812 | of_iounmap(&op->resource[0], hp->gregs, GREG_REG_SIZE); |
2871 | if (hp->etxregs) | 2813 | if (hp->etxregs) |
2872 | sbus_iounmap(hp->etxregs, ETX_REG_SIZE); | 2814 | of_iounmap(&op->resource[1], hp->etxregs, ETX_REG_SIZE); |
2873 | if (hp->erxregs) | 2815 | if (hp->erxregs) |
2874 | sbus_iounmap(hp->erxregs, ERX_REG_SIZE); | 2816 | of_iounmap(&op->resource[2], hp->erxregs, ERX_REG_SIZE); |
2875 | if (hp->bigmacregs) | 2817 | if (hp->bigmacregs) |
2876 | sbus_iounmap(hp->bigmacregs, BMAC_REG_SIZE); | 2818 | of_iounmap(&op->resource[3], hp->bigmacregs, BMAC_REG_SIZE); |
2877 | if (hp->tcvregs) | 2819 | if (hp->tcvregs) |
2878 | sbus_iounmap(hp->tcvregs, TCVR_REG_SIZE); | 2820 | of_iounmap(&op->resource[4], hp->tcvregs, TCVR_REG_SIZE); |
2879 | 2821 | ||
2880 | err_out_free_netdev: | 2822 | err_out_free_netdev: |
2881 | free_netdev(dev); | 2823 | free_netdev(dev); |
@@ -3035,6 +2977,7 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev, | |||
3035 | memset(hp, 0, sizeof(*hp)); | 2977 | memset(hp, 0, sizeof(*hp)); |
3036 | 2978 | ||
3037 | hp->happy_dev = pdev; | 2979 | hp->happy_dev = pdev; |
2980 | hp->dma_dev = &pdev->dev; | ||
3038 | 2981 | ||
3039 | spin_lock_init(&hp->happy_lock); | 2982 | spin_lock_init(&hp->happy_lock); |
3040 | 2983 | ||
@@ -3121,7 +3064,7 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev, | |||
3121 | #endif | 3064 | #endif |
3122 | 3065 | ||
3123 | hp->happy_block = (struct hmeal_init_block *) | 3066 | hp->happy_block = (struct hmeal_init_block *) |
3124 | pci_alloc_consistent(pdev, PAGE_SIZE, &hp->hblock_dvma); | 3067 | dma_alloc_coherent(&pdev->dev, PAGE_SIZE, &hp->hblock_dvma, GFP_KERNEL); |
3125 | 3068 | ||
3126 | err = -ENODEV; | 3069 | err = -ENODEV; |
3127 | if (!hp->happy_block) { | 3070 | if (!hp->happy_block) { |
@@ -3151,16 +3094,10 @@ static int __devinit happy_meal_pci_probe(struct pci_dev *pdev, | |||
3151 | dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; | 3094 | dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM; |
3152 | 3095 | ||
3153 | #if defined(CONFIG_SBUS) && defined(CONFIG_PCI) | 3096 | #if defined(CONFIG_SBUS) && defined(CONFIG_PCI) |
3154 | /* Hook up PCI register/dma accessors. */ | 3097 | /* Hook up PCI register/descriptor accessors. */ |
3155 | hp->read_desc32 = pci_hme_read_desc32; | 3098 | hp->read_desc32 = pci_hme_read_desc32; |
3156 | hp->write_txd = pci_hme_write_txd; | 3099 | hp->write_txd = pci_hme_write_txd; |
3157 | hp->write_rxd = pci_hme_write_rxd; | 3100 | hp->write_rxd = pci_hme_write_rxd; |
3158 | hp->dma_map = (u32 (*)(void *, void *, long, int))pci_map_single; | ||
3159 | hp->dma_unmap = (void (*)(void *, u32, long, int))pci_unmap_single; | ||
3160 | hp->dma_sync_for_cpu = (void (*)(void *, u32, long, int)) | ||
3161 | pci_dma_sync_single_for_cpu; | ||
3162 | hp->dma_sync_for_device = (void (*)(void *, u32, long, int)) | ||
3163 | pci_dma_sync_single_for_device; | ||
3164 | hp->read32 = pci_hme_read32; | 3101 | hp->read32 = pci_hme_read32; |
3165 | hp->write32 = pci_hme_write32; | 3102 | hp->write32 = pci_hme_write32; |
3166 | #endif | 3103 | #endif |
@@ -3231,10 +3168,8 @@ static void __devexit happy_meal_pci_remove(struct pci_dev *pdev) | |||
3231 | 3168 | ||
3232 | unregister_netdev(net_dev); | 3169 | unregister_netdev(net_dev); |
3233 | 3170 | ||
3234 | pci_free_consistent(hp->happy_dev, | 3171 | dma_free_coherent(hp->dma_dev, PAGE_SIZE, |
3235 | PAGE_SIZE, | 3172 | hp->happy_block, hp->hblock_dvma); |
3236 | hp->happy_block, | ||
3237 | hp->hblock_dvma); | ||
3238 | iounmap(hp->gregs); | 3173 | iounmap(hp->gregs); |
3239 | pci_release_regions(hp->happy_dev); | 3174 | pci_release_regions(hp->happy_dev); |
3240 | 3175 | ||
@@ -3279,46 +3214,45 @@ static void happy_meal_pci_exit(void) | |||
3279 | #endif | 3214 | #endif |
3280 | 3215 | ||
3281 | #ifdef CONFIG_SBUS | 3216 | #ifdef CONFIG_SBUS |
3282 | static int __devinit hme_sbus_probe(struct of_device *dev, const struct of_device_id *match) | 3217 | static int __devinit hme_sbus_probe(struct of_device *op, const struct of_device_id *match) |
3283 | { | 3218 | { |
3284 | struct sbus_dev *sdev = to_sbus_device(&dev->dev); | 3219 | struct device_node *dp = op->node; |
3285 | struct device_node *dp = dev->node; | ||
3286 | const char *model = of_get_property(dp, "model", NULL); | 3220 | const char *model = of_get_property(dp, "model", NULL); |
3287 | int is_qfe = (match->data != NULL); | 3221 | int is_qfe = (match->data != NULL); |
3288 | 3222 | ||
3289 | if (!is_qfe && model && !strcmp(model, "SUNW,sbus-qfe")) | 3223 | if (!is_qfe && model && !strcmp(model, "SUNW,sbus-qfe")) |
3290 | is_qfe = 1; | 3224 | is_qfe = 1; |
3291 | 3225 | ||
3292 | return happy_meal_sbus_probe_one(sdev, is_qfe); | 3226 | return happy_meal_sbus_probe_one(op, is_qfe); |
3293 | } | 3227 | } |
3294 | 3228 | ||
3295 | static int __devexit hme_sbus_remove(struct of_device *dev) | 3229 | static int __devexit hme_sbus_remove(struct of_device *op) |
3296 | { | 3230 | { |
3297 | struct happy_meal *hp = dev_get_drvdata(&dev->dev); | 3231 | struct happy_meal *hp = dev_get_drvdata(&op->dev); |
3298 | struct net_device *net_dev = hp->dev; | 3232 | struct net_device *net_dev = hp->dev; |
3299 | 3233 | ||
3300 | unregister_netdev(net_dev); | 3234 | unregister_netdev(net_dev); |
3301 | 3235 | ||
3302 | /* XXX qfe parent interrupt... */ | 3236 | /* XXX qfe parent interrupt... */ |
3303 | 3237 | ||
3304 | sbus_iounmap(hp->gregs, GREG_REG_SIZE); | 3238 | of_iounmap(&op->resource[0], hp->gregs, GREG_REG_SIZE); |
3305 | sbus_iounmap(hp->etxregs, ETX_REG_SIZE); | 3239 | of_iounmap(&op->resource[1], hp->etxregs, ETX_REG_SIZE); |
3306 | sbus_iounmap(hp->erxregs, ERX_REG_SIZE); | 3240 | of_iounmap(&op->resource[2], hp->erxregs, ERX_REG_SIZE); |
3307 | sbus_iounmap(hp->bigmacregs, BMAC_REG_SIZE); | 3241 | of_iounmap(&op->resource[3], hp->bigmacregs, BMAC_REG_SIZE); |
3308 | sbus_iounmap(hp->tcvregs, TCVR_REG_SIZE); | 3242 | of_iounmap(&op->resource[4], hp->tcvregs, TCVR_REG_SIZE); |
3309 | sbus_free_consistent(hp->happy_dev, | 3243 | dma_free_coherent(hp->dma_dev, |
3310 | PAGE_SIZE, | 3244 | PAGE_SIZE, |
3311 | hp->happy_block, | 3245 | hp->happy_block, |
3312 | hp->hblock_dvma); | 3246 | hp->hblock_dvma); |
3313 | 3247 | ||
3314 | free_netdev(net_dev); | 3248 | free_netdev(net_dev); |
3315 | 3249 | ||
3316 | dev_set_drvdata(&dev->dev, NULL); | 3250 | dev_set_drvdata(&op->dev, NULL); |
3317 | 3251 | ||
3318 | return 0; | 3252 | return 0; |
3319 | } | 3253 | } |
3320 | 3254 | ||
3321 | static struct of_device_id hme_sbus_match[] = { | 3255 | static const struct of_device_id hme_sbus_match[] = { |
3322 | { | 3256 | { |
3323 | .name = "SUNW,hme", | 3257 | .name = "SUNW,hme", |
3324 | }, | 3258 | }, |
@@ -3346,7 +3280,7 @@ static int __init happy_meal_sbus_init(void) | |||
3346 | { | 3280 | { |
3347 | int err; | 3281 | int err; |
3348 | 3282 | ||
3349 | err = of_register_driver(&hme_sbus_driver, &sbus_bus_type); | 3283 | err = of_register_driver(&hme_sbus_driver, &of_bus_type); |
3350 | if (!err) | 3284 | if (!err) |
3351 | quattro_sbus_register_irqs(); | 3285 | quattro_sbus_register_irqs(); |
3352 | 3286 | ||
diff --git a/drivers/net/sunhme.h b/drivers/net/sunhme.h index 4da5539fac7b..efd2ca0fcad3 100644 --- a/drivers/net/sunhme.h +++ b/drivers/net/sunhme.h | |||
@@ -405,14 +405,11 @@ struct happy_meal { | |||
405 | u32 (*read_desc32)(hme32 *); | 405 | u32 (*read_desc32)(hme32 *); |
406 | void (*write_txd)(struct happy_meal_txd *, u32, u32); | 406 | void (*write_txd)(struct happy_meal_txd *, u32, u32); |
407 | void (*write_rxd)(struct happy_meal_rxd *, u32, u32); | 407 | void (*write_rxd)(struct happy_meal_rxd *, u32, u32); |
408 | u32 (*dma_map)(void *, void *, long, int); | ||
409 | void (*dma_unmap)(void *, u32, long, int); | ||
410 | void (*dma_sync_for_cpu)(void *, u32, long, int); | ||
411 | void (*dma_sync_for_device)(void *, u32, long, int); | ||
412 | #endif | 408 | #endif |
413 | 409 | ||
414 | /* This is either a sbus_dev or a pci_dev. */ | 410 | /* This is either an of_device or a pci_dev. */ |
415 | void *happy_dev; | 411 | void *happy_dev; |
412 | struct device *dma_dev; | ||
416 | 413 | ||
417 | spinlock_t happy_lock; | 414 | spinlock_t happy_lock; |
418 | 415 | ||
diff --git a/drivers/net/sunlance.c b/drivers/net/sunlance.c index 4e994f87469e..704301a5a7ff 100644 --- a/drivers/net/sunlance.c +++ b/drivers/net/sunlance.c | |||
@@ -91,6 +91,9 @@ static char lancestr[] = "LANCE"; | |||
91 | #include <linux/skbuff.h> | 91 | #include <linux/skbuff.h> |
92 | #include <linux/ethtool.h> | 92 | #include <linux/ethtool.h> |
93 | #include <linux/bitops.h> | 93 | #include <linux/bitops.h> |
94 | #include <linux/dma-mapping.h> | ||
95 | #include <linux/of.h> | ||
96 | #include <linux/of_device.h> | ||
94 | 97 | ||
95 | #include <asm/system.h> | 98 | #include <asm/system.h> |
96 | #include <asm/io.h> | 99 | #include <asm/io.h> |
@@ -98,7 +101,6 @@ static char lancestr[] = "LANCE"; | |||
98 | #include <asm/pgtable.h> | 101 | #include <asm/pgtable.h> |
99 | #include <asm/byteorder.h> /* Used by the checksum routines */ | 102 | #include <asm/byteorder.h> /* Used by the checksum routines */ |
100 | #include <asm/idprom.h> | 103 | #include <asm/idprom.h> |
101 | #include <asm/sbus.h> | ||
102 | #include <asm/prom.h> | 104 | #include <asm/prom.h> |
103 | #include <asm/auxio.h> /* For tpe-link-test? setting */ | 105 | #include <asm/auxio.h> /* For tpe-link-test? setting */ |
104 | #include <asm/irq.h> | 106 | #include <asm/irq.h> |
@@ -248,7 +250,7 @@ struct lance_private { | |||
248 | int rx_new, tx_new; | 250 | int rx_new, tx_new; |
249 | int rx_old, tx_old; | 251 | int rx_old, tx_old; |
250 | 252 | ||
251 | struct sbus_dma *ledma; /* If set this points to ledma */ | 253 | struct of_device *ledma; /* If set this points to ledma */ |
252 | char tpe; /* cable-selection is TPE */ | 254 | char tpe; /* cable-selection is TPE */ |
253 | char auto_select; /* cable-selection by carrier */ | 255 | char auto_select; /* cable-selection by carrier */ |
254 | char burst_sizes; /* ledma SBus burst sizes */ | 256 | char burst_sizes; /* ledma SBus burst sizes */ |
@@ -263,7 +265,8 @@ struct lance_private { | |||
263 | char *name; | 265 | char *name; |
264 | dma_addr_t init_block_dvma; | 266 | dma_addr_t init_block_dvma; |
265 | struct net_device *dev; /* Backpointer */ | 267 | struct net_device *dev; /* Backpointer */ |
266 | struct sbus_dev *sdev; | 268 | struct of_device *op; |
269 | struct of_device *lebuffer; | ||
267 | struct timer_list multicast_timer; | 270 | struct timer_list multicast_timer; |
268 | }; | 271 | }; |
269 | 272 | ||
@@ -1272,27 +1275,29 @@ static void lance_set_multicast_retry(unsigned long _opaque) | |||
1272 | static void lance_free_hwresources(struct lance_private *lp) | 1275 | static void lance_free_hwresources(struct lance_private *lp) |
1273 | { | 1276 | { |
1274 | if (lp->lregs) | 1277 | if (lp->lregs) |
1275 | sbus_iounmap(lp->lregs, LANCE_REG_SIZE); | 1278 | of_iounmap(&lp->op->resource[0], lp->lregs, LANCE_REG_SIZE); |
1279 | if (lp->dregs) { | ||
1280 | struct of_device *ledma = lp->ledma; | ||
1281 | |||
1282 | of_iounmap(&ledma->resource[0], lp->dregs, | ||
1283 | resource_size(&ledma->resource[0])); | ||
1284 | } | ||
1276 | if (lp->init_block_iomem) { | 1285 | if (lp->init_block_iomem) { |
1277 | sbus_iounmap(lp->init_block_iomem, | 1286 | of_iounmap(&lp->lebuffer->resource[0], lp->init_block_iomem, |
1278 | sizeof(struct lance_init_block)); | 1287 | sizeof(struct lance_init_block)); |
1279 | } else if (lp->init_block_mem) { | 1288 | } else if (lp->init_block_mem) { |
1280 | sbus_free_consistent(lp->sdev, | 1289 | dma_free_coherent(&lp->op->dev, |
1281 | sizeof(struct lance_init_block), | 1290 | sizeof(struct lance_init_block), |
1282 | lp->init_block_mem, | 1291 | lp->init_block_mem, |
1283 | lp->init_block_dvma); | 1292 | lp->init_block_dvma); |
1284 | } | 1293 | } |
1285 | } | 1294 | } |
1286 | 1295 | ||
1287 | /* Ethtool support... */ | 1296 | /* Ethtool support... */ |
1288 | static void sparc_lance_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 1297 | static void sparc_lance_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
1289 | { | 1298 | { |
1290 | struct lance_private *lp = netdev_priv(dev); | ||
1291 | |||
1292 | strcpy(info->driver, "sunlance"); | 1299 | strcpy(info->driver, "sunlance"); |
1293 | strcpy(info->version, "2.02"); | 1300 | strcpy(info->version, "2.02"); |
1294 | sprintf(info->bus_info, "SBUS:%d", | ||
1295 | lp->sdev->slot); | ||
1296 | } | 1301 | } |
1297 | 1302 | ||
1298 | static u32 sparc_lance_get_link(struct net_device *dev) | 1303 | static u32 sparc_lance_get_link(struct net_device *dev) |
@@ -1308,16 +1313,16 @@ static const struct ethtool_ops sparc_lance_ethtool_ops = { | |||
1308 | .get_link = sparc_lance_get_link, | 1313 | .get_link = sparc_lance_get_link, |
1309 | }; | 1314 | }; |
1310 | 1315 | ||
1311 | static int __devinit sparc_lance_probe_one(struct sbus_dev *sdev, | 1316 | static int __devinit sparc_lance_probe_one(struct of_device *op, |
1312 | struct sbus_dma *ledma, | 1317 | struct of_device *ledma, |
1313 | struct sbus_dev *lebuffer) | 1318 | struct of_device *lebuffer) |
1314 | { | 1319 | { |
1320 | struct device_node *dp = op->node; | ||
1315 | static unsigned version_printed; | 1321 | static unsigned version_printed; |
1316 | struct device_node *dp = sdev->ofdev.node; | ||
1317 | struct net_device *dev; | ||
1318 | struct lance_private *lp; | 1322 | struct lance_private *lp; |
1319 | int i; | 1323 | struct net_device *dev; |
1320 | DECLARE_MAC_BUF(mac); | 1324 | DECLARE_MAC_BUF(mac); |
1325 | int i; | ||
1321 | 1326 | ||
1322 | dev = alloc_etherdev(sizeof(struct lance_private) + 8); | 1327 | dev = alloc_etherdev(sizeof(struct lance_private) + 8); |
1323 | if (!dev) | 1328 | if (!dev) |
@@ -1338,14 +1343,27 @@ static int __devinit sparc_lance_probe_one(struct sbus_dev *sdev, | |||
1338 | dev->dev_addr[i] = idprom->id_ethaddr[i]; | 1343 | dev->dev_addr[i] = idprom->id_ethaddr[i]; |
1339 | 1344 | ||
1340 | /* Get the IO region */ | 1345 | /* Get the IO region */ |
1341 | lp->lregs = sbus_ioremap(&sdev->resource[0], 0, | 1346 | lp->lregs = of_ioremap(&op->resource[0], 0, |
1342 | LANCE_REG_SIZE, lancestr); | 1347 | LANCE_REG_SIZE, lancestr); |
1343 | if (!lp->lregs) { | 1348 | if (!lp->lregs) { |
1344 | printk(KERN_ERR "SunLance: Cannot map registers.\n"); | 1349 | printk(KERN_ERR "SunLance: Cannot map registers.\n"); |
1345 | goto fail; | 1350 | goto fail; |
1346 | } | 1351 | } |
1347 | 1352 | ||
1348 | lp->sdev = sdev; | 1353 | lp->ledma = ledma; |
1354 | if (lp->ledma) { | ||
1355 | lp->dregs = of_ioremap(&ledma->resource[0], 0, | ||
1356 | resource_size(&ledma->resource[0]), | ||
1357 | "ledma"); | ||
1358 | if (!lp->dregs) { | ||
1359 | printk(KERN_ERR "SunLance: Cannot map " | ||
1360 | "ledma registers.\n"); | ||
1361 | goto fail; | ||
1362 | } | ||
1363 | } | ||
1364 | |||
1365 | lp->op = op; | ||
1366 | lp->lebuffer = lebuffer; | ||
1349 | if (lebuffer) { | 1367 | if (lebuffer) { |
1350 | /* sanity check */ | 1368 | /* sanity check */ |
1351 | if (lebuffer->resource[0].start & 7) { | 1369 | if (lebuffer->resource[0].start & 7) { |
@@ -1353,8 +1371,8 @@ static int __devinit sparc_lance_probe_one(struct sbus_dev *sdev, | |||
1353 | goto fail; | 1371 | goto fail; |
1354 | } | 1372 | } |
1355 | lp->init_block_iomem = | 1373 | lp->init_block_iomem = |
1356 | sbus_ioremap(&lebuffer->resource[0], 0, | 1374 | of_ioremap(&lebuffer->resource[0], 0, |
1357 | sizeof(struct lance_init_block), "lebuffer"); | 1375 | sizeof(struct lance_init_block), "lebuffer"); |
1358 | if (!lp->init_block_iomem) { | 1376 | if (!lp->init_block_iomem) { |
1359 | printk(KERN_ERR "SunLance: Cannot map PIO buffer.\n"); | 1377 | printk(KERN_ERR "SunLance: Cannot map PIO buffer.\n"); |
1360 | goto fail; | 1378 | goto fail; |
@@ -1366,9 +1384,10 @@ static int __devinit sparc_lance_probe_one(struct sbus_dev *sdev, | |||
1366 | lp->tx = lance_tx_pio; | 1384 | lp->tx = lance_tx_pio; |
1367 | } else { | 1385 | } else { |
1368 | lp->init_block_mem = | 1386 | lp->init_block_mem = |
1369 | sbus_alloc_consistent(sdev, sizeof(struct lance_init_block), | 1387 | dma_alloc_coherent(&op->dev, |
1370 | &lp->init_block_dvma); | 1388 | sizeof(struct lance_init_block), |
1371 | if (!lp->init_block_mem || lp->init_block_dvma == 0) { | 1389 | &lp->init_block_dvma, GFP_ATOMIC); |
1390 | if (!lp->init_block_mem) { | ||
1372 | printk(KERN_ERR "SunLance: Cannot allocate consistent DMA memory.\n"); | 1391 | printk(KERN_ERR "SunLance: Cannot allocate consistent DMA memory.\n"); |
1373 | goto fail; | 1392 | goto fail; |
1374 | } | 1393 | } |
@@ -1383,13 +1402,13 @@ static int __devinit sparc_lance_probe_one(struct sbus_dev *sdev, | |||
1383 | LE_C3_BCON)); | 1402 | LE_C3_BCON)); |
1384 | 1403 | ||
1385 | lp->name = lancestr; | 1404 | lp->name = lancestr; |
1386 | lp->ledma = ledma; | ||
1387 | 1405 | ||
1388 | lp->burst_sizes = 0; | 1406 | lp->burst_sizes = 0; |
1389 | if (lp->ledma) { | 1407 | if (lp->ledma) { |
1390 | struct device_node *ledma_dp = ledma->sdev->ofdev.node; | 1408 | struct device_node *ledma_dp = ledma->node; |
1391 | const char *prop; | 1409 | struct device_node *sbus_dp; |
1392 | unsigned int sbmask; | 1410 | unsigned int sbmask; |
1411 | const char *prop; | ||
1393 | u32 csr; | 1412 | u32 csr; |
1394 | 1413 | ||
1395 | /* Find burst-size property for ledma */ | 1414 | /* Find burst-size property for ledma */ |
@@ -1397,7 +1416,8 @@ static int __devinit sparc_lance_probe_one(struct sbus_dev *sdev, | |||
1397 | "burst-sizes", 0); | 1416 | "burst-sizes", 0); |
1398 | 1417 | ||
1399 | /* ledma may be capable of fast bursts, but sbus may not. */ | 1418 | /* ledma may be capable of fast bursts, but sbus may not. */ |
1400 | sbmask = of_getintprop_default(ledma_dp, "burst-sizes", | 1419 | sbus_dp = ledma_dp->parent; |
1420 | sbmask = of_getintprop_default(sbus_dp, "burst-sizes", | ||
1401 | DMA_BURSTBITS); | 1421 | DMA_BURSTBITS); |
1402 | lp->burst_sizes &= sbmask; | 1422 | lp->burst_sizes &= sbmask; |
1403 | 1423 | ||
@@ -1435,8 +1455,6 @@ no_link_test: | |||
1435 | lp->tpe = 1; | 1455 | lp->tpe = 1; |
1436 | } | 1456 | } |
1437 | 1457 | ||
1438 | lp->dregs = ledma->regs; | ||
1439 | |||
1440 | /* Reset ledma */ | 1458 | /* Reset ledma */ |
1441 | csr = sbus_readl(lp->dregs + DMA_CSR); | 1459 | csr = sbus_readl(lp->dregs + DMA_CSR); |
1442 | sbus_writel(csr | DMA_RST_ENET, lp->dregs + DMA_CSR); | 1460 | sbus_writel(csr | DMA_RST_ENET, lp->dregs + DMA_CSR); |
@@ -1446,7 +1464,7 @@ no_link_test: | |||
1446 | lp->dregs = NULL; | 1464 | lp->dregs = NULL; |
1447 | 1465 | ||
1448 | lp->dev = dev; | 1466 | lp->dev = dev; |
1449 | SET_NETDEV_DEV(dev, &sdev->ofdev.dev); | 1467 | SET_NETDEV_DEV(dev, &op->dev); |
1450 | dev->open = &lance_open; | 1468 | dev->open = &lance_open; |
1451 | dev->stop = &lance_close; | 1469 | dev->stop = &lance_close; |
1452 | dev->hard_start_xmit = &lance_start_xmit; | 1470 | dev->hard_start_xmit = &lance_start_xmit; |
@@ -1455,9 +1473,7 @@ no_link_test: | |||
1455 | dev->set_multicast_list = &lance_set_multicast; | 1473 | dev->set_multicast_list = &lance_set_multicast; |
1456 | dev->ethtool_ops = &sparc_lance_ethtool_ops; | 1474 | dev->ethtool_ops = &sparc_lance_ethtool_ops; |
1457 | 1475 | ||
1458 | dev->irq = sdev->irqs[0]; | 1476 | dev->irq = op->irqs[0]; |
1459 | |||
1460 | dev->dma = 0; | ||
1461 | 1477 | ||
1462 | /* We cannot sleep if the chip is busy during a | 1478 | /* We cannot sleep if the chip is busy during a |
1463 | * multicast list update event, because such events | 1479 | * multicast list update event, because such events |
@@ -1473,7 +1489,7 @@ no_link_test: | |||
1473 | goto fail; | 1489 | goto fail; |
1474 | } | 1490 | } |
1475 | 1491 | ||
1476 | dev_set_drvdata(&sdev->ofdev.dev, lp); | 1492 | dev_set_drvdata(&op->dev, lp); |
1477 | 1493 | ||
1478 | printk(KERN_INFO "%s: LANCE %s\n", | 1494 | printk(KERN_INFO "%s: LANCE %s\n", |
1479 | dev->name, print_mac(mac, dev->dev_addr)); | 1495 | dev->name, print_mac(mac, dev->dev_addr)); |
@@ -1486,80 +1502,25 @@ fail: | |||
1486 | return -ENODEV; | 1502 | return -ENODEV; |
1487 | } | 1503 | } |
1488 | 1504 | ||
1489 | /* On 4m, find the associated dma for the lance chip */ | 1505 | static int __devinit sunlance_sbus_probe(struct of_device *op, const struct of_device_id *match) |
1490 | static struct sbus_dma * __devinit find_ledma(struct sbus_dev *sdev) | ||
1491 | { | ||
1492 | struct sbus_dma *p; | ||
1493 | |||
1494 | for_each_dvma(p) { | ||
1495 | if (p->sdev == sdev) | ||
1496 | return p; | ||
1497 | } | ||
1498 | return NULL; | ||
1499 | } | ||
1500 | |||
1501 | #ifdef CONFIG_SUN4 | ||
1502 | |||
1503 | #include <asm/sun4paddr.h> | ||
1504 | #include <asm/machines.h> | ||
1505 | |||
1506 | /* Find all the lance cards on the system and initialize them */ | ||
1507 | static struct sbus_dev sun4_sdev; | ||
1508 | static int __devinit sparc_lance_init(void) | ||
1509 | { | ||
1510 | if ((idprom->id_machtype == (SM_SUN4|SM_4_330)) || | ||
1511 | (idprom->id_machtype == (SM_SUN4|SM_4_470))) { | ||
1512 | memset(&sun4_sdev, 0, sizeof(struct sbus_dev)); | ||
1513 | sun4_sdev.reg_addrs[0].phys_addr = sun4_eth_physaddr; | ||
1514 | sun4_sdev.irqs[0] = 6; | ||
1515 | return sparc_lance_probe_one(&sun4_sdev, NULL, NULL); | ||
1516 | } | ||
1517 | return -ENODEV; | ||
1518 | } | ||
1519 | |||
1520 | static int __exit sunlance_sun4_remove(void) | ||
1521 | { | 1506 | { |
1522 | struct lance_private *lp = dev_get_drvdata(&sun4_sdev.ofdev.dev); | 1507 | struct of_device *parent = to_of_device(op->dev.parent); |
1523 | struct net_device *net_dev = lp->dev; | 1508 | struct device_node *parent_dp = parent->node; |
1524 | |||
1525 | unregister_netdev(net_dev); | ||
1526 | |||
1527 | lance_free_hwresources(lp); | ||
1528 | |||
1529 | free_netdev(net_dev); | ||
1530 | |||
1531 | dev_set_drvdata(&sun4_sdev.ofdev.dev, NULL); | ||
1532 | |||
1533 | return 0; | ||
1534 | } | ||
1535 | |||
1536 | #else /* !CONFIG_SUN4 */ | ||
1537 | |||
1538 | static int __devinit sunlance_sbus_probe(struct of_device *dev, const struct of_device_id *match) | ||
1539 | { | ||
1540 | struct sbus_dev *sdev = to_sbus_device(&dev->dev); | ||
1541 | int err; | 1509 | int err; |
1542 | 1510 | ||
1543 | if (sdev->parent) { | 1511 | if (!strcmp(parent_dp->name, "ledma")) { |
1544 | struct of_device *parent = &sdev->parent->ofdev; | 1512 | err = sparc_lance_probe_one(op, parent, NULL); |
1545 | 1513 | } else if (!strcmp(parent_dp->name, "lebuffer")) { | |
1546 | if (!strcmp(parent->node->name, "ledma")) { | 1514 | err = sparc_lance_probe_one(op, NULL, parent); |
1547 | struct sbus_dma *ledma = find_ledma(to_sbus_device(&parent->dev)); | ||
1548 | |||
1549 | err = sparc_lance_probe_one(sdev, ledma, NULL); | ||
1550 | } else if (!strcmp(parent->node->name, "lebuffer")) { | ||
1551 | err = sparc_lance_probe_one(sdev, NULL, to_sbus_device(&parent->dev)); | ||
1552 | } else | ||
1553 | err = sparc_lance_probe_one(sdev, NULL, NULL); | ||
1554 | } else | 1515 | } else |
1555 | err = sparc_lance_probe_one(sdev, NULL, NULL); | 1516 | err = sparc_lance_probe_one(op, NULL, NULL); |
1556 | 1517 | ||
1557 | return err; | 1518 | return err; |
1558 | } | 1519 | } |
1559 | 1520 | ||
1560 | static int __devexit sunlance_sbus_remove(struct of_device *dev) | 1521 | static int __devexit sunlance_sbus_remove(struct of_device *op) |
1561 | { | 1522 | { |
1562 | struct lance_private *lp = dev_get_drvdata(&dev->dev); | 1523 | struct lance_private *lp = dev_get_drvdata(&op->dev); |
1563 | struct net_device *net_dev = lp->dev; | 1524 | struct net_device *net_dev = lp->dev; |
1564 | 1525 | ||
1565 | unregister_netdev(net_dev); | 1526 | unregister_netdev(net_dev); |
@@ -1568,12 +1529,12 @@ static int __devexit sunlance_sbus_remove(struct of_device *dev) | |||
1568 | 1529 | ||
1569 | free_netdev(net_dev); | 1530 | free_netdev(net_dev); |
1570 | 1531 | ||
1571 | dev_set_drvdata(&dev->dev, NULL); | 1532 | dev_set_drvdata(&op->dev, NULL); |
1572 | 1533 | ||
1573 | return 0; | 1534 | return 0; |
1574 | } | 1535 | } |
1575 | 1536 | ||
1576 | static struct of_device_id sunlance_sbus_match[] = { | 1537 | static const struct of_device_id sunlance_sbus_match[] = { |
1577 | { | 1538 | { |
1578 | .name = "le", | 1539 | .name = "le", |
1579 | }, | 1540 | }, |
@@ -1593,17 +1554,12 @@ static struct of_platform_driver sunlance_sbus_driver = { | |||
1593 | /* Find all the lance cards on the system and initialize them */ | 1554 | /* Find all the lance cards on the system and initialize them */ |
1594 | static int __init sparc_lance_init(void) | 1555 | static int __init sparc_lance_init(void) |
1595 | { | 1556 | { |
1596 | return of_register_driver(&sunlance_sbus_driver, &sbus_bus_type); | 1557 | return of_register_driver(&sunlance_sbus_driver, &of_bus_type); |
1597 | } | 1558 | } |
1598 | #endif /* !CONFIG_SUN4 */ | ||
1599 | 1559 | ||
1600 | static void __exit sparc_lance_exit(void) | 1560 | static void __exit sparc_lance_exit(void) |
1601 | { | 1561 | { |
1602 | #ifdef CONFIG_SUN4 | ||
1603 | sunlance_sun4_remove(); | ||
1604 | #else | ||
1605 | of_unregister_driver(&sunlance_sbus_driver); | 1562 | of_unregister_driver(&sunlance_sbus_driver); |
1606 | #endif | ||
1607 | } | 1563 | } |
1608 | 1564 | ||
1609 | module_init(sparc_lance_init); | 1565 | module_init(sparc_lance_init); |
diff --git a/drivers/net/sunqe.c b/drivers/net/sunqe.c index e811331d4608..f63644744ff9 100644 --- a/drivers/net/sunqe.c +++ b/drivers/net/sunqe.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * controller out there can be most efficiently programmed | 3 | * controller out there can be most efficiently programmed |
4 | * if you make it look like a LANCE. | 4 | * if you make it look like a LANCE. |
5 | * | 5 | * |
6 | * Copyright (C) 1996, 1999, 2003, 2006 David S. Miller (davem@davemloft.net) | 6 | * Copyright (C) 1996, 1999, 2003, 2006, 2008 David S. Miller (davem@davemloft.net) |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
@@ -24,13 +24,15 @@ | |||
24 | #include <linux/skbuff.h> | 24 | #include <linux/skbuff.h> |
25 | #include <linux/ethtool.h> | 25 | #include <linux/ethtool.h> |
26 | #include <linux/bitops.h> | 26 | #include <linux/bitops.h> |
27 | #include <linux/dma-mapping.h> | ||
28 | #include <linux/of.h> | ||
29 | #include <linux/of_device.h> | ||
27 | 30 | ||
28 | #include <asm/system.h> | 31 | #include <asm/system.h> |
29 | #include <asm/io.h> | 32 | #include <asm/io.h> |
30 | #include <asm/dma.h> | 33 | #include <asm/dma.h> |
31 | #include <asm/byteorder.h> | 34 | #include <asm/byteorder.h> |
32 | #include <asm/idprom.h> | 35 | #include <asm/idprom.h> |
33 | #include <asm/sbus.h> | ||
34 | #include <asm/openprom.h> | 36 | #include <asm/openprom.h> |
35 | #include <asm/oplib.h> | 37 | #include <asm/oplib.h> |
36 | #include <asm/auxio.h> | 38 | #include <asm/auxio.h> |
@@ -40,8 +42,8 @@ | |||
40 | #include "sunqe.h" | 42 | #include "sunqe.h" |
41 | 43 | ||
42 | #define DRV_NAME "sunqe" | 44 | #define DRV_NAME "sunqe" |
43 | #define DRV_VERSION "4.0" | 45 | #define DRV_VERSION "4.1" |
44 | #define DRV_RELDATE "June 23, 2006" | 46 | #define DRV_RELDATE "August 27, 2008" |
45 | #define DRV_AUTHOR "David S. Miller (davem@davemloft.net)" | 47 | #define DRV_AUTHOR "David S. Miller (davem@davemloft.net)" |
46 | 48 | ||
47 | static char version[] = | 49 | static char version[] = |
@@ -690,12 +692,18 @@ static void qe_set_multicast(struct net_device *dev) | |||
690 | /* Ethtool support... */ | 692 | /* Ethtool support... */ |
691 | static void qe_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 693 | static void qe_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
692 | { | 694 | { |
695 | const struct linux_prom_registers *regs; | ||
693 | struct sunqe *qep = dev->priv; | 696 | struct sunqe *qep = dev->priv; |
697 | struct of_device *op; | ||
694 | 698 | ||
695 | strcpy(info->driver, "sunqe"); | 699 | strcpy(info->driver, "sunqe"); |
696 | strcpy(info->version, "3.0"); | 700 | strcpy(info->version, "3.0"); |
697 | sprintf(info->bus_info, "SBUS:%d", | 701 | |
698 | qep->qe_sdev->slot); | 702 | op = qep->op; |
703 | regs = of_get_property(op->node, "reg", NULL); | ||
704 | if (regs) | ||
705 | sprintf(info->bus_info, "SBUS:%d", regs->which_io); | ||
706 | |||
699 | } | 707 | } |
700 | 708 | ||
701 | static u32 qe_get_link(struct net_device *dev) | 709 | static u32 qe_get_link(struct net_device *dev) |
@@ -717,11 +725,11 @@ static const struct ethtool_ops qe_ethtool_ops = { | |||
717 | }; | 725 | }; |
718 | 726 | ||
719 | /* This is only called once at boot time for each card probed. */ | 727 | /* This is only called once at boot time for each card probed. */ |
720 | static inline void qec_init_once(struct sunqec *qecp, struct sbus_dev *qsdev) | 728 | static void qec_init_once(struct sunqec *qecp, struct of_device *op) |
721 | { | 729 | { |
722 | u8 bsizes = qecp->qec_bursts; | 730 | u8 bsizes = qecp->qec_bursts; |
723 | 731 | ||
724 | if (sbus_can_burst64(qsdev) && (bsizes & DMA_BURST64)) { | 732 | if (sbus_can_burst64() && (bsizes & DMA_BURST64)) { |
725 | sbus_writel(GLOB_CTRL_B64, qecp->gregs + GLOB_CTRL); | 733 | sbus_writel(GLOB_CTRL_B64, qecp->gregs + GLOB_CTRL); |
726 | } else if (bsizes & DMA_BURST32) { | 734 | } else if (bsizes & DMA_BURST32) { |
727 | sbus_writel(GLOB_CTRL_B32, qecp->gregs + GLOB_CTRL); | 735 | sbus_writel(GLOB_CTRL_B32, qecp->gregs + GLOB_CTRL); |
@@ -735,15 +743,15 @@ static inline void qec_init_once(struct sunqec *qecp, struct sbus_dev *qsdev) | |||
735 | sbus_writel(GLOB_PSIZE_2048, qecp->gregs + GLOB_PSIZE); | 743 | sbus_writel(GLOB_PSIZE_2048, qecp->gregs + GLOB_PSIZE); |
736 | 744 | ||
737 | /* Set the local memsize register, divided up to one piece per QE channel. */ | 745 | /* Set the local memsize register, divided up to one piece per QE channel. */ |
738 | sbus_writel((qsdev->reg_addrs[1].reg_size >> 2), | 746 | sbus_writel((resource_size(&op->resource[1]) >> 2), |
739 | qecp->gregs + GLOB_MSIZE); | 747 | qecp->gregs + GLOB_MSIZE); |
740 | 748 | ||
741 | /* Divide up the local QEC memory amongst the 4 QE receiver and | 749 | /* Divide up the local QEC memory amongst the 4 QE receiver and |
742 | * transmitter FIFOs. Basically it is (total / 2 / num_channels). | 750 | * transmitter FIFOs. Basically it is (total / 2 / num_channels). |
743 | */ | 751 | */ |
744 | sbus_writel((qsdev->reg_addrs[1].reg_size >> 2) >> 1, | 752 | sbus_writel((resource_size(&op->resource[1]) >> 2) >> 1, |
745 | qecp->gregs + GLOB_TSIZE); | 753 | qecp->gregs + GLOB_TSIZE); |
746 | sbus_writel((qsdev->reg_addrs[1].reg_size >> 2) >> 1, | 754 | sbus_writel((resource_size(&op->resource[1]) >> 2) >> 1, |
747 | qecp->gregs + GLOB_RSIZE); | 755 | qecp->gregs + GLOB_RSIZE); |
748 | } | 756 | } |
749 | 757 | ||
@@ -767,24 +775,21 @@ static u8 __devinit qec_get_burst(struct device_node *dp) | |||
767 | return bsizes; | 775 | return bsizes; |
768 | } | 776 | } |
769 | 777 | ||
770 | static struct sunqec * __devinit get_qec(struct sbus_dev *child_sdev) | 778 | static struct sunqec * __devinit get_qec(struct of_device *child) |
771 | { | 779 | { |
772 | struct sbus_dev *qec_sdev = child_sdev->parent; | 780 | struct of_device *op = to_of_device(child->dev.parent); |
773 | struct sunqec *qecp; | 781 | struct sunqec *qecp; |
774 | 782 | ||
775 | for (qecp = root_qec_dev; qecp; qecp = qecp->next_module) { | 783 | qecp = dev_get_drvdata(&op->dev); |
776 | if (qecp->qec_sdev == qec_sdev) | ||
777 | break; | ||
778 | } | ||
779 | if (!qecp) { | 784 | if (!qecp) { |
780 | qecp = kzalloc(sizeof(struct sunqec), GFP_KERNEL); | 785 | qecp = kzalloc(sizeof(struct sunqec), GFP_KERNEL); |
781 | if (qecp) { | 786 | if (qecp) { |
782 | u32 ctrl; | 787 | u32 ctrl; |
783 | 788 | ||
784 | qecp->qec_sdev = qec_sdev; | 789 | qecp->op = op; |
785 | qecp->gregs = sbus_ioremap(&qec_sdev->resource[0], 0, | 790 | qecp->gregs = of_ioremap(&op->resource[0], 0, |
786 | GLOB_REG_SIZE, | 791 | GLOB_REG_SIZE, |
787 | "QEC Global Registers"); | 792 | "QEC Global Registers"); |
788 | if (!qecp->gregs) | 793 | if (!qecp->gregs) |
789 | goto fail; | 794 | goto fail; |
790 | 795 | ||
@@ -799,16 +804,18 @@ static struct sunqec * __devinit get_qec(struct sbus_dev *child_sdev) | |||
799 | if (qec_global_reset(qecp->gregs)) | 804 | if (qec_global_reset(qecp->gregs)) |
800 | goto fail; | 805 | goto fail; |
801 | 806 | ||
802 | qecp->qec_bursts = qec_get_burst(qec_sdev->ofdev.node); | 807 | qecp->qec_bursts = qec_get_burst(op->node); |
803 | 808 | ||
804 | qec_init_once(qecp, qec_sdev); | 809 | qec_init_once(qecp, op); |
805 | 810 | ||
806 | if (request_irq(qec_sdev->irqs[0], &qec_interrupt, | 811 | if (request_irq(op->irqs[0], &qec_interrupt, |
807 | IRQF_SHARED, "qec", (void *) qecp)) { | 812 | IRQF_SHARED, "qec", (void *) qecp)) { |
808 | printk(KERN_ERR "qec: Can't register irq.\n"); | 813 | printk(KERN_ERR "qec: Can't register irq.\n"); |
809 | goto fail; | 814 | goto fail; |
810 | } | 815 | } |
811 | 816 | ||
817 | dev_set_drvdata(&op->dev, qecp); | ||
818 | |||
812 | qecp->next_module = root_qec_dev; | 819 | qecp->next_module = root_qec_dev; |
813 | root_qec_dev = qecp; | 820 | root_qec_dev = qecp; |
814 | } | 821 | } |
@@ -818,17 +825,17 @@ static struct sunqec * __devinit get_qec(struct sbus_dev *child_sdev) | |||
818 | 825 | ||
819 | fail: | 826 | fail: |
820 | if (qecp->gregs) | 827 | if (qecp->gregs) |
821 | sbus_iounmap(qecp->gregs, GLOB_REG_SIZE); | 828 | of_iounmap(&op->resource[0], qecp->gregs, GLOB_REG_SIZE); |
822 | kfree(qecp); | 829 | kfree(qecp); |
823 | return NULL; | 830 | return NULL; |
824 | } | 831 | } |
825 | 832 | ||
826 | static int __devinit qec_ether_init(struct sbus_dev *sdev) | 833 | static int __devinit qec_ether_init(struct of_device *op) |
827 | { | 834 | { |
828 | static unsigned version_printed; | 835 | static unsigned version_printed; |
829 | struct net_device *dev; | 836 | struct net_device *dev; |
830 | struct sunqe *qe; | ||
831 | struct sunqec *qecp; | 837 | struct sunqec *qecp; |
838 | struct sunqe *qe; | ||
832 | int i, res; | 839 | int i, res; |
833 | 840 | ||
834 | if (version_printed++ == 0) | 841 | if (version_printed++ == 0) |
@@ -842,49 +849,42 @@ static int __devinit qec_ether_init(struct sbus_dev *sdev) | |||
842 | 849 | ||
843 | qe = netdev_priv(dev); | 850 | qe = netdev_priv(dev); |
844 | 851 | ||
845 | i = of_getintprop_default(sdev->ofdev.node, "channel#", -1); | 852 | res = -ENODEV; |
846 | if (i == -1) { | 853 | |
847 | struct sbus_dev *td = sdev->parent->child; | 854 | i = of_getintprop_default(op->node, "channel#", -1); |
848 | i = 0; | 855 | if (i == -1) |
849 | while (td != sdev) { | 856 | goto fail; |
850 | td = td->next; | ||
851 | i++; | ||
852 | } | ||
853 | } | ||
854 | qe->channel = i; | 857 | qe->channel = i; |
855 | spin_lock_init(&qe->lock); | 858 | spin_lock_init(&qe->lock); |
856 | 859 | ||
857 | res = -ENODEV; | 860 | qecp = get_qec(op); |
858 | qecp = get_qec(sdev); | ||
859 | if (!qecp) | 861 | if (!qecp) |
860 | goto fail; | 862 | goto fail; |
861 | 863 | ||
862 | qecp->qes[qe->channel] = qe; | 864 | qecp->qes[qe->channel] = qe; |
863 | qe->dev = dev; | 865 | qe->dev = dev; |
864 | qe->parent = qecp; | 866 | qe->parent = qecp; |
865 | qe->qe_sdev = sdev; | 867 | qe->op = op; |
866 | 868 | ||
867 | res = -ENOMEM; | 869 | res = -ENOMEM; |
868 | qe->qcregs = sbus_ioremap(&qe->qe_sdev->resource[0], 0, | 870 | qe->qcregs = of_ioremap(&op->resource[0], 0, |
869 | CREG_REG_SIZE, "QEC Channel Registers"); | 871 | CREG_REG_SIZE, "QEC Channel Registers"); |
870 | if (!qe->qcregs) { | 872 | if (!qe->qcregs) { |
871 | printk(KERN_ERR "qe: Cannot map channel registers.\n"); | 873 | printk(KERN_ERR "qe: Cannot map channel registers.\n"); |
872 | goto fail; | 874 | goto fail; |
873 | } | 875 | } |
874 | 876 | ||
875 | qe->mregs = sbus_ioremap(&qe->qe_sdev->resource[1], 0, | 877 | qe->mregs = of_ioremap(&op->resource[1], 0, |
876 | MREGS_REG_SIZE, "QE MACE Registers"); | 878 | MREGS_REG_SIZE, "QE MACE Registers"); |
877 | if (!qe->mregs) { | 879 | if (!qe->mregs) { |
878 | printk(KERN_ERR "qe: Cannot map MACE registers.\n"); | 880 | printk(KERN_ERR "qe: Cannot map MACE registers.\n"); |
879 | goto fail; | 881 | goto fail; |
880 | } | 882 | } |
881 | 883 | ||
882 | qe->qe_block = sbus_alloc_consistent(qe->qe_sdev, | 884 | qe->qe_block = dma_alloc_coherent(&op->dev, PAGE_SIZE, |
883 | PAGE_SIZE, | 885 | &qe->qblock_dvma, GFP_ATOMIC); |
884 | &qe->qblock_dvma); | 886 | qe->buffers = dma_alloc_coherent(&op->dev, sizeof(struct sunqe_buffers), |
885 | qe->buffers = sbus_alloc_consistent(qe->qe_sdev, | 887 | &qe->buffers_dvma, GFP_ATOMIC); |
886 | sizeof(struct sunqe_buffers), | ||
887 | &qe->buffers_dvma); | ||
888 | if (qe->qe_block == NULL || qe->qblock_dvma == 0 || | 888 | if (qe->qe_block == NULL || qe->qblock_dvma == 0 || |
889 | qe->buffers == NULL || qe->buffers_dvma == 0) | 889 | qe->buffers == NULL || qe->buffers_dvma == 0) |
890 | goto fail; | 890 | goto fail; |
@@ -892,7 +892,7 @@ static int __devinit qec_ether_init(struct sbus_dev *sdev) | |||
892 | /* Stop this QE. */ | 892 | /* Stop this QE. */ |
893 | qe_stop(qe); | 893 | qe_stop(qe); |
894 | 894 | ||
895 | SET_NETDEV_DEV(dev, &sdev->ofdev.dev); | 895 | SET_NETDEV_DEV(dev, &op->dev); |
896 | 896 | ||
897 | dev->open = qe_open; | 897 | dev->open = qe_open; |
898 | dev->stop = qe_close; | 898 | dev->stop = qe_close; |
@@ -900,7 +900,7 @@ static int __devinit qec_ether_init(struct sbus_dev *sdev) | |||
900 | dev->set_multicast_list = qe_set_multicast; | 900 | dev->set_multicast_list = qe_set_multicast; |
901 | dev->tx_timeout = qe_tx_timeout; | 901 | dev->tx_timeout = qe_tx_timeout; |
902 | dev->watchdog_timeo = 5*HZ; | 902 | dev->watchdog_timeo = 5*HZ; |
903 | dev->irq = sdev->irqs[0]; | 903 | dev->irq = op->irqs[0]; |
904 | dev->dma = 0; | 904 | dev->dma = 0; |
905 | dev->ethtool_ops = &qe_ethtool_ops; | 905 | dev->ethtool_ops = &qe_ethtool_ops; |
906 | 906 | ||
@@ -908,7 +908,7 @@ static int __devinit qec_ether_init(struct sbus_dev *sdev) | |||
908 | if (res) | 908 | if (res) |
909 | goto fail; | 909 | goto fail; |
910 | 910 | ||
911 | dev_set_drvdata(&sdev->ofdev.dev, qe); | 911 | dev_set_drvdata(&op->dev, qe); |
912 | 912 | ||
913 | printk(KERN_INFO "%s: qe channel[%d] ", dev->name, qe->channel); | 913 | printk(KERN_INFO "%s: qe channel[%d] ", dev->name, qe->channel); |
914 | for (i = 0; i < 6; i++) | 914 | for (i = 0; i < 6; i++) |
@@ -922,58 +922,50 @@ static int __devinit qec_ether_init(struct sbus_dev *sdev) | |||
922 | 922 | ||
923 | fail: | 923 | fail: |
924 | if (qe->qcregs) | 924 | if (qe->qcregs) |
925 | sbus_iounmap(qe->qcregs, CREG_REG_SIZE); | 925 | of_iounmap(&op->resource[0], qe->qcregs, CREG_REG_SIZE); |
926 | if (qe->mregs) | 926 | if (qe->mregs) |
927 | sbus_iounmap(qe->mregs, MREGS_REG_SIZE); | 927 | of_iounmap(&op->resource[1], qe->mregs, MREGS_REG_SIZE); |
928 | if (qe->qe_block) | 928 | if (qe->qe_block) |
929 | sbus_free_consistent(qe->qe_sdev, | 929 | dma_free_coherent(&op->dev, PAGE_SIZE, |
930 | PAGE_SIZE, | 930 | qe->qe_block, qe->qblock_dvma); |
931 | qe->qe_block, | ||
932 | qe->qblock_dvma); | ||
933 | if (qe->buffers) | 931 | if (qe->buffers) |
934 | sbus_free_consistent(qe->qe_sdev, | 932 | dma_free_coherent(&op->dev, |
935 | sizeof(struct sunqe_buffers), | 933 | sizeof(struct sunqe_buffers), |
936 | qe->buffers, | 934 | qe->buffers, |
937 | qe->buffers_dvma); | 935 | qe->buffers_dvma); |
938 | 936 | ||
939 | free_netdev(dev); | 937 | free_netdev(dev); |
940 | 938 | ||
941 | return res; | 939 | return res; |
942 | } | 940 | } |
943 | 941 | ||
944 | static int __devinit qec_sbus_probe(struct of_device *dev, const struct of_device_id *match) | 942 | static int __devinit qec_sbus_probe(struct of_device *op, const struct of_device_id *match) |
945 | { | 943 | { |
946 | struct sbus_dev *sdev = to_sbus_device(&dev->dev); | 944 | return qec_ether_init(op); |
947 | |||
948 | return qec_ether_init(sdev); | ||
949 | } | 945 | } |
950 | 946 | ||
951 | static int __devexit qec_sbus_remove(struct of_device *dev) | 947 | static int __devexit qec_sbus_remove(struct of_device *op) |
952 | { | 948 | { |
953 | struct sunqe *qp = dev_get_drvdata(&dev->dev); | 949 | struct sunqe *qp = dev_get_drvdata(&op->dev); |
954 | struct net_device *net_dev = qp->dev; | 950 | struct net_device *net_dev = qp->dev; |
955 | 951 | ||
956 | unregister_netdev(net_dev); | 952 | unregister_netdev(net_dev); |
957 | 953 | ||
958 | sbus_iounmap(qp->qcregs, CREG_REG_SIZE); | 954 | of_iounmap(&op->resource[0], qp->qcregs, CREG_REG_SIZE); |
959 | sbus_iounmap(qp->mregs, MREGS_REG_SIZE); | 955 | of_iounmap(&op->resource[1], qp->mregs, MREGS_REG_SIZE); |
960 | sbus_free_consistent(qp->qe_sdev, | 956 | dma_free_coherent(&op->dev, PAGE_SIZE, |
961 | PAGE_SIZE, | 957 | qp->qe_block, qp->qblock_dvma); |
962 | qp->qe_block, | 958 | dma_free_coherent(&op->dev, sizeof(struct sunqe_buffers), |
963 | qp->qblock_dvma); | 959 | qp->buffers, qp->buffers_dvma); |
964 | sbus_free_consistent(qp->qe_sdev, | ||
965 | sizeof(struct sunqe_buffers), | ||
966 | qp->buffers, | ||
967 | qp->buffers_dvma); | ||
968 | 960 | ||
969 | free_netdev(net_dev); | 961 | free_netdev(net_dev); |
970 | 962 | ||
971 | dev_set_drvdata(&dev->dev, NULL); | 963 | dev_set_drvdata(&op->dev, NULL); |
972 | 964 | ||
973 | return 0; | 965 | return 0; |
974 | } | 966 | } |
975 | 967 | ||
976 | static struct of_device_id qec_sbus_match[] = { | 968 | static const struct of_device_id qec_sbus_match[] = { |
977 | { | 969 | { |
978 | .name = "qe", | 970 | .name = "qe", |
979 | }, | 971 | }, |
@@ -991,7 +983,7 @@ static struct of_platform_driver qec_sbus_driver = { | |||
991 | 983 | ||
992 | static int __init qec_init(void) | 984 | static int __init qec_init(void) |
993 | { | 985 | { |
994 | return of_register_driver(&qec_sbus_driver, &sbus_bus_type); | 986 | return of_register_driver(&qec_sbus_driver, &of_bus_type); |
995 | } | 987 | } |
996 | 988 | ||
997 | static void __exit qec_exit(void) | 989 | static void __exit qec_exit(void) |
@@ -1000,11 +992,11 @@ static void __exit qec_exit(void) | |||
1000 | 992 | ||
1001 | while (root_qec_dev) { | 993 | while (root_qec_dev) { |
1002 | struct sunqec *next = root_qec_dev->next_module; | 994 | struct sunqec *next = root_qec_dev->next_module; |
995 | struct of_device *op = root_qec_dev->op; | ||
1003 | 996 | ||
1004 | free_irq(root_qec_dev->qec_sdev->irqs[0], | 997 | free_irq(op->irqs[0], (void *) root_qec_dev); |
1005 | (void *) root_qec_dev); | 998 | of_iounmap(&op->resource[0], root_qec_dev->gregs, |
1006 | sbus_iounmap(root_qec_dev->gregs, GLOB_REG_SIZE); | 999 | GLOB_REG_SIZE); |
1007 | |||
1008 | kfree(root_qec_dev); | 1000 | kfree(root_qec_dev); |
1009 | 1001 | ||
1010 | root_qec_dev = next; | 1002 | root_qec_dev = next; |
diff --git a/drivers/net/sunqe.h b/drivers/net/sunqe.h index 347c8ddc1592..5813a7b2faa5 100644 --- a/drivers/net/sunqe.h +++ b/drivers/net/sunqe.h | |||
@@ -314,7 +314,7 @@ struct sunqec { | |||
314 | void __iomem *gregs; /* QEC Global Registers */ | 314 | void __iomem *gregs; /* QEC Global Registers */ |
315 | struct sunqe *qes[4]; /* Each child MACE */ | 315 | struct sunqe *qes[4]; /* Each child MACE */ |
316 | unsigned int qec_bursts; /* Support burst sizes */ | 316 | unsigned int qec_bursts; /* Support burst sizes */ |
317 | struct sbus_dev *qec_sdev; /* QEC's SBUS device */ | 317 | struct of_device *op; /* QEC's OF device */ |
318 | struct sunqec *next_module; /* List of all QECs in system */ | 318 | struct sunqec *next_module; /* List of all QECs in system */ |
319 | }; | 319 | }; |
320 | 320 | ||
@@ -342,7 +342,7 @@ struct sunqe { | |||
342 | __u32 buffers_dvma; /* DVMA visible address. */ | 342 | __u32 buffers_dvma; /* DVMA visible address. */ |
343 | struct sunqec *parent; | 343 | struct sunqec *parent; |
344 | u8 mconfig; /* Base MACE mconfig value */ | 344 | u8 mconfig; /* Base MACE mconfig value */ |
345 | struct sbus_dev *qe_sdev; /* QE's SBUS device struct */ | 345 | struct of_device *op; /* QE's OF device struct */ |
346 | struct net_device *dev; /* QE's netdevice struct */ | 346 | struct net_device *dev; /* QE's netdevice struct */ |
347 | int channel; /* Who am I? */ | 347 | int channel; /* Who am I? */ |
348 | }; | 348 | }; |
diff --git a/drivers/net/sunvnet.c b/drivers/net/sunvnet.c index 6415ce15c2ef..a720065553df 100644 --- a/drivers/net/sunvnet.c +++ b/drivers/net/sunvnet.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* sunvnet.c: Sun LDOM Virtual Network Driver. | 1 | /* sunvnet.c: Sun LDOM Virtual Network Driver. |
2 | * | 2 | * |
3 | * Copyright (C) 2007 David S. Miller <davem@davemloft.net> | 3 | * Copyright (C) 2007, 2008 David S. Miller <davem@davemloft.net> |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <linux/module.h> | 6 | #include <linux/module.h> |
@@ -1260,7 +1260,7 @@ static int vnet_port_remove(struct vio_dev *vdev) | |||
1260 | return 0; | 1260 | return 0; |
1261 | } | 1261 | } |
1262 | 1262 | ||
1263 | static struct vio_device_id vnet_port_match[] = { | 1263 | static const struct vio_device_id vnet_port_match[] = { |
1264 | { | 1264 | { |
1265 | .type = "vnet-port", | 1265 | .type = "vnet-port", |
1266 | }, | 1266 | }, |
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig index 2ae2ec40015d..21efd99b9294 100644 --- a/drivers/net/wan/Kconfig +++ b/drivers/net/wan/Kconfig | |||
@@ -205,7 +205,7 @@ config WANXL_BUILD_FIRMWARE | |||
205 | 205 | ||
206 | config PC300 | 206 | config PC300 |
207 | tristate "Cyclades-PC300 support (RS-232/V.35, X.21, T1/E1 boards)" | 207 | tristate "Cyclades-PC300 support (RS-232/V.35, X.21, T1/E1 boards)" |
208 | depends on HDLC && PCI | 208 | depends on HDLC && PCI && BROKEN |
209 | ---help--- | 209 | ---help--- |
210 | Driver for the Cyclades-PC300 synchronous communication boards. | 210 | Driver for the Cyclades-PC300 synchronous communication boards. |
211 | 211 | ||
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c index fd72e427cb28..27696c20f4c2 100644 --- a/drivers/net/wireless/airo_cs.c +++ b/drivers/net/wireless/airo_cs.c | |||
@@ -206,126 +206,123 @@ static void airo_detach(struct pcmcia_device *link) | |||
206 | #define CS_CHECK(fn, ret) \ | 206 | #define CS_CHECK(fn, ret) \ |
207 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 207 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
208 | 208 | ||
209 | static int airo_cs_config_check(struct pcmcia_device *p_dev, | ||
210 | cistpl_cftable_entry_t *cfg, | ||
211 | cistpl_cftable_entry_t *dflt, | ||
212 | unsigned int vcc, | ||
213 | void *priv_data) | ||
214 | { | ||
215 | win_req_t *req = priv_data; | ||
216 | |||
217 | if (cfg->index == 0) | ||
218 | return -ENODEV; | ||
219 | |||
220 | /* Does this card need audio output? */ | ||
221 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { | ||
222 | p_dev->conf.Attributes |= CONF_ENABLE_SPKR; | ||
223 | p_dev->conf.Status = CCSR_AUDIO_ENA; | ||
224 | } | ||
225 | |||
226 | /* Use power settings for Vcc and Vpp if present */ | ||
227 | /* Note that the CIS values need to be rescaled */ | ||
228 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
229 | p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
230 | else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
231 | p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
232 | |||
233 | /* Do we need to allocate an interrupt? */ | ||
234 | if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1) | ||
235 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; | ||
236 | |||
237 | /* IO window settings */ | ||
238 | p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; | ||
239 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { | ||
240 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | ||
241 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
242 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
243 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
244 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
245 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
246 | p_dev->io.BasePort1 = io->win[0].base; | ||
247 | p_dev->io.NumPorts1 = io->win[0].len; | ||
248 | if (io->nwin > 1) { | ||
249 | p_dev->io.Attributes2 = p_dev->io.Attributes1; | ||
250 | p_dev->io.BasePort2 = io->win[1].base; | ||
251 | p_dev->io.NumPorts2 = io->win[1].len; | ||
252 | } | ||
253 | } | ||
254 | |||
255 | /* This reserves IO space but doesn't actually enable it */ | ||
256 | if (pcmcia_request_io(p_dev, &p_dev->io) != 0) | ||
257 | return -ENODEV; | ||
258 | |||
259 | /* | ||
260 | Now set up a common memory window, if needed. There is room | ||
261 | in the struct pcmcia_device structure for one memory window handle, | ||
262 | but if the base addresses need to be saved, or if multiple | ||
263 | windows are needed, the info should go in the private data | ||
264 | structure for this device. | ||
265 | |||
266 | Note that the memory window base is a physical address, and | ||
267 | needs to be mapped to virtual space with ioremap() before it | ||
268 | is used. | ||
269 | */ | ||
270 | if ((cfg->mem.nwin > 0) || (dflt->mem.nwin > 0)) { | ||
271 | cistpl_mem_t *mem = (cfg->mem.nwin) ? &cfg->mem : &dflt->mem; | ||
272 | memreq_t map; | ||
273 | req->Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; | ||
274 | req->Base = mem->win[0].host_addr; | ||
275 | req->Size = mem->win[0].len; | ||
276 | req->AccessSpeed = 0; | ||
277 | if (pcmcia_request_window(&p_dev, req, &p_dev->win) != 0) | ||
278 | return -ENODEV; | ||
279 | map.Page = 0; | ||
280 | map.CardOffset = mem->win[0].card_addr; | ||
281 | if (pcmcia_map_mem_page(p_dev->win, &map) != 0) | ||
282 | return -ENODEV; | ||
283 | } | ||
284 | /* If we got this far, we're cool! */ | ||
285 | return 0; | ||
286 | } | ||
287 | |||
288 | |||
209 | static int airo_config(struct pcmcia_device *link) | 289 | static int airo_config(struct pcmcia_device *link) |
210 | { | 290 | { |
211 | tuple_t tuple; | ||
212 | cisparse_t parse; | ||
213 | local_info_t *dev; | 291 | local_info_t *dev; |
292 | win_req_t *req; | ||
214 | int last_fn, last_ret; | 293 | int last_fn, last_ret; |
215 | u_char buf[64]; | ||
216 | win_req_t req; | ||
217 | memreq_t map; | ||
218 | 294 | ||
219 | dev = link->priv; | 295 | dev = link->priv; |
220 | 296 | ||
221 | DEBUG(0, "airo_config(0x%p)\n", link); | 297 | DEBUG(0, "airo_config(0x%p)\n", link); |
222 | 298 | ||
299 | req = kzalloc(sizeof(win_req_t), GFP_KERNEL); | ||
300 | if (!req) | ||
301 | return -ENOMEM; | ||
302 | |||
303 | /* | ||
304 | * In this loop, we scan the CIS for configuration table | ||
305 | * entries, each of which describes a valid card | ||
306 | * configuration, including voltage, IO window, memory window, | ||
307 | * and interrupt settings. | ||
308 | * | ||
309 | * We make no assumptions about the card to be configured: we | ||
310 | * use just the information available in the CIS. In an ideal | ||
311 | * world, this would work for any PCMCIA card, but it requires | ||
312 | * a complete and accurate CIS. In practice, a driver usually | ||
313 | * "knows" most of these things without consulting the CIS, | ||
314 | * and most client drivers will only use the CIS to fill in | ||
315 | * implementation-defined details. | ||
316 | */ | ||
317 | last_ret = pcmcia_loop_config(link, airo_cs_config_check, req); | ||
318 | if (last_ret) | ||
319 | goto failed; | ||
320 | |||
223 | /* | 321 | /* |
224 | In this loop, we scan the CIS for configuration table entries, | 322 | Allocate an interrupt line. Note that this does not assign a |
225 | each of which describes a valid card configuration, including | 323 | handler to the interrupt, unless the 'Handler' member of the |
226 | voltage, IO window, memory window, and interrupt settings. | 324 | irq structure is initialized. |
227 | |||
228 | We make no assumptions about the card to be configured: we use | ||
229 | just the information available in the CIS. In an ideal world, | ||
230 | this would work for any PCMCIA card, but it requires a complete | ||
231 | and accurate CIS. In practice, a driver usually "knows" most of | ||
232 | these things without consulting the CIS, and most client drivers | ||
233 | will only use the CIS to fill in implementation-defined details. | ||
234 | */ | 325 | */ |
235 | tuple.Attributes = 0; | ||
236 | tuple.TupleData = buf; | ||
237 | tuple.TupleDataMax = sizeof(buf); | ||
238 | tuple.TupleOffset = 0; | ||
239 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
240 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
241 | while (1) { | ||
242 | cistpl_cftable_entry_t dflt = { 0 }; | ||
243 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | ||
244 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
245 | pcmcia_parse_tuple(link, &tuple, &parse) != 0) | ||
246 | goto next_entry; | ||
247 | |||
248 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; | ||
249 | if (cfg->index == 0) goto next_entry; | ||
250 | link->conf.ConfigIndex = cfg->index; | ||
251 | |||
252 | /* Does this card need audio output? */ | ||
253 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { | ||
254 | link->conf.Attributes |= CONF_ENABLE_SPKR; | ||
255 | link->conf.Status = CCSR_AUDIO_ENA; | ||
256 | } | ||
257 | |||
258 | /* Use power settings for Vcc and Vpp if present */ | ||
259 | /* Note that the CIS values need to be rescaled */ | ||
260 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
261 | link->conf.Vpp = | ||
262 | cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
263 | else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
264 | link->conf.Vpp = | ||
265 | dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
266 | |||
267 | /* Do we need to allocate an interrupt? */ | ||
268 | if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) | ||
269 | link->conf.Attributes |= CONF_ENABLE_IRQ; | ||
270 | |||
271 | /* IO window settings */ | ||
272 | link->io.NumPorts1 = link->io.NumPorts2 = 0; | ||
273 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | ||
274 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; | ||
275 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
276 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
277 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
278 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
279 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
280 | link->io.BasePort1 = io->win[0].base; | ||
281 | link->io.NumPorts1 = io->win[0].len; | ||
282 | if (io->nwin > 1) { | ||
283 | link->io.Attributes2 = link->io.Attributes1; | ||
284 | link->io.BasePort2 = io->win[1].base; | ||
285 | link->io.NumPorts2 = io->win[1].len; | ||
286 | } | ||
287 | } | ||
288 | |||
289 | /* This reserves IO space but doesn't actually enable it */ | ||
290 | if (pcmcia_request_io(link, &link->io) != 0) | ||
291 | goto next_entry; | ||
292 | |||
293 | /* | ||
294 | Now set up a common memory window, if needed. There is room | ||
295 | in the struct pcmcia_device structure for one memory window handle, | ||
296 | but if the base addresses need to be saved, or if multiple | ||
297 | windows are needed, the info should go in the private data | ||
298 | structure for this device. | ||
299 | |||
300 | Note that the memory window base is a physical address, and | ||
301 | needs to be mapped to virtual space with ioremap() before it | ||
302 | is used. | ||
303 | */ | ||
304 | if ((cfg->mem.nwin > 0) || (dflt.mem.nwin > 0)) { | ||
305 | cistpl_mem_t *mem = | ||
306 | (cfg->mem.nwin) ? &cfg->mem : &dflt.mem; | ||
307 | req.Attributes = WIN_DATA_WIDTH_16|WIN_MEMORY_TYPE_CM; | ||
308 | req.Base = mem->win[0].host_addr; | ||
309 | req.Size = mem->win[0].len; | ||
310 | req.AccessSpeed = 0; | ||
311 | if (pcmcia_request_window(&link, &req, &link->win) != 0) | ||
312 | goto next_entry; | ||
313 | map.Page = 0; map.CardOffset = mem->win[0].card_addr; | ||
314 | if (pcmcia_map_mem_page(link->win, &map) != 0) | ||
315 | goto next_entry; | ||
316 | } | ||
317 | /* If we got this far, we're cool! */ | ||
318 | break; | ||
319 | |||
320 | next_entry: | ||
321 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); | ||
322 | } | ||
323 | |||
324 | /* | ||
325 | Allocate an interrupt line. Note that this does not assign a | ||
326 | handler to the interrupt, unless the 'Handler' member of the | ||
327 | irq structure is initialized. | ||
328 | */ | ||
329 | if (link->conf.Attributes & CONF_ENABLE_IRQ) | 326 | if (link->conf.Attributes & CONF_ENABLE_IRQ) |
330 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); | 327 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
331 | 328 | ||
@@ -362,14 +359,17 @@ static int airo_config(struct pcmcia_device *link) | |||
362 | printk(" & 0x%04x-0x%04x", link->io.BasePort2, | 359 | printk(" & 0x%04x-0x%04x", link->io.BasePort2, |
363 | link->io.BasePort2+link->io.NumPorts2-1); | 360 | link->io.BasePort2+link->io.NumPorts2-1); |
364 | if (link->win) | 361 | if (link->win) |
365 | printk(", mem 0x%06lx-0x%06lx", req.Base, | 362 | printk(", mem 0x%06lx-0x%06lx", req->Base, |
366 | req.Base+req.Size-1); | 363 | req->Base+req->Size-1); |
367 | printk("\n"); | 364 | printk("\n"); |
365 | kfree(req); | ||
368 | return 0; | 366 | return 0; |
369 | 367 | ||
370 | cs_failed: | 368 | cs_failed: |
371 | cs_error(link, last_fn, last_ret); | 369 | cs_error(link, last_fn, last_ret); |
370 | failed: | ||
372 | airo_release(link); | 371 | airo_release(link); |
372 | kfree(req); | ||
373 | return -ENODEV; | 373 | return -ENODEV; |
374 | } /* airo_config */ | 374 | } /* airo_config */ |
375 | 375 | ||
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c index d2388e8d179a..77406245dc7b 100644 --- a/drivers/net/wireless/atmel_cs.c +++ b/drivers/net/wireless/atmel_cs.c | |||
@@ -224,13 +224,58 @@ static int card_present(void *arg) | |||
224 | return 0; | 224 | return 0; |
225 | } | 225 | } |
226 | 226 | ||
227 | static int atmel_config_check(struct pcmcia_device *p_dev, | ||
228 | cistpl_cftable_entry_t *cfg, | ||
229 | cistpl_cftable_entry_t *dflt, | ||
230 | unsigned int vcc, | ||
231 | void *priv_data) | ||
232 | { | ||
233 | if (cfg->index == 0) | ||
234 | return -ENODEV; | ||
235 | |||
236 | /* Does this card need audio output? */ | ||
237 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { | ||
238 | p_dev->conf.Attributes |= CONF_ENABLE_SPKR; | ||
239 | p_dev->conf.Status = CCSR_AUDIO_ENA; | ||
240 | } | ||
241 | |||
242 | /* Use power settings for Vcc and Vpp if present */ | ||
243 | /* Note that the CIS values need to be rescaled */ | ||
244 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
245 | p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
246 | else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
247 | p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
248 | |||
249 | /* Do we need to allocate an interrupt? */ | ||
250 | if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1) | ||
251 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; | ||
252 | |||
253 | /* IO window settings */ | ||
254 | p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; | ||
255 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { | ||
256 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | ||
257 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
258 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
259 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
260 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
261 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
262 | p_dev->io.BasePort1 = io->win[0].base; | ||
263 | p_dev->io.NumPorts1 = io->win[0].len; | ||
264 | if (io->nwin > 1) { | ||
265 | p_dev->io.Attributes2 = p_dev->io.Attributes1; | ||
266 | p_dev->io.BasePort2 = io->win[1].base; | ||
267 | p_dev->io.NumPorts2 = io->win[1].len; | ||
268 | } | ||
269 | } | ||
270 | |||
271 | /* This reserves IO space but doesn't actually enable it */ | ||
272 | return pcmcia_request_io(p_dev, &p_dev->io); | ||
273 | } | ||
274 | |||
227 | static int atmel_config(struct pcmcia_device *link) | 275 | static int atmel_config(struct pcmcia_device *link) |
228 | { | 276 | { |
229 | tuple_t tuple; | ||
230 | cisparse_t parse; | ||
231 | local_info_t *dev; | 277 | local_info_t *dev; |
232 | int last_fn, last_ret; | 278 | int last_fn, last_ret; |
233 | u_char buf[64]; | ||
234 | struct pcmcia_device_id *did; | 279 | struct pcmcia_device_id *did; |
235 | 280 | ||
236 | dev = link->priv; | 281 | dev = link->priv; |
@@ -238,11 +283,6 @@ static int atmel_config(struct pcmcia_device *link) | |||
238 | 283 | ||
239 | DEBUG(0, "atmel_config(0x%p)\n", link); | 284 | DEBUG(0, "atmel_config(0x%p)\n", link); |
240 | 285 | ||
241 | tuple.Attributes = 0; | ||
242 | tuple.TupleData = buf; | ||
243 | tuple.TupleDataMax = sizeof(buf); | ||
244 | tuple.TupleOffset = 0; | ||
245 | |||
246 | /* | 286 | /* |
247 | In this loop, we scan the CIS for configuration table entries, | 287 | In this loop, we scan the CIS for configuration table entries, |
248 | each of which describes a valid card configuration, including | 288 | each of which describes a valid card configuration, including |
@@ -255,66 +295,8 @@ static int atmel_config(struct pcmcia_device *link) | |||
255 | these things without consulting the CIS, and most client drivers | 295 | these things without consulting the CIS, and most client drivers |
256 | will only use the CIS to fill in implementation-defined details. | 296 | will only use the CIS to fill in implementation-defined details. |
257 | */ | 297 | */ |
258 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 298 | if (pcmcia_loop_config(link, atmel_config_check, NULL)) |
259 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | 299 | goto failed; |
260 | while (1) { | ||
261 | cistpl_cftable_entry_t dflt = { 0 }; | ||
262 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | ||
263 | if (pcmcia_get_tuple_data(link, &tuple) != 0 || | ||
264 | pcmcia_parse_tuple(link, &tuple, &parse) != 0) | ||
265 | goto next_entry; | ||
266 | |||
267 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; | ||
268 | if (cfg->index == 0) goto next_entry; | ||
269 | link->conf.ConfigIndex = cfg->index; | ||
270 | |||
271 | /* Does this card need audio output? */ | ||
272 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { | ||
273 | link->conf.Attributes |= CONF_ENABLE_SPKR; | ||
274 | link->conf.Status = CCSR_AUDIO_ENA; | ||
275 | } | ||
276 | |||
277 | /* Use power settings for Vcc and Vpp if present */ | ||
278 | /* Note that the CIS values need to be rescaled */ | ||
279 | if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
280 | link->conf.Vpp = | ||
281 | cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
282 | else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) | ||
283 | link->conf.Vpp = | ||
284 | dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; | ||
285 | |||
286 | /* Do we need to allocate an interrupt? */ | ||
287 | if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) | ||
288 | link->conf.Attributes |= CONF_ENABLE_IRQ; | ||
289 | |||
290 | /* IO window settings */ | ||
291 | link->io.NumPorts1 = link->io.NumPorts2 = 0; | ||
292 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | ||
293 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; | ||
294 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
295 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
296 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
297 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
298 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
299 | link->io.BasePort1 = io->win[0].base; | ||
300 | link->io.NumPorts1 = io->win[0].len; | ||
301 | if (io->nwin > 1) { | ||
302 | link->io.Attributes2 = link->io.Attributes1; | ||
303 | link->io.BasePort2 = io->win[1].base; | ||
304 | link->io.NumPorts2 = io->win[1].len; | ||
305 | } | ||
306 | } | ||
307 | |||
308 | /* This reserves IO space but doesn't actually enable it */ | ||
309 | if (pcmcia_request_io(link, &link->io) != 0) | ||
310 | goto next_entry; | ||
311 | |||
312 | /* If we got this far, we're cool! */ | ||
313 | break; | ||
314 | |||
315 | next_entry: | ||
316 | CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); | ||
317 | } | ||
318 | 300 | ||
319 | /* | 301 | /* |
320 | Allocate an interrupt line. Note that this does not assign a | 302 | Allocate an interrupt line. Note that this does not assign a |
@@ -360,6 +342,7 @@ static int atmel_config(struct pcmcia_device *link) | |||
360 | 342 | ||
361 | cs_failed: | 343 | cs_failed: |
362 | cs_error(link, last_fn, last_ret); | 344 | cs_error(link, last_fn, last_ret); |
345 | failed: | ||
363 | atmel_release(link); | 346 | atmel_release(link); |
364 | return -ENODEV; | 347 | return -ENODEV; |
365 | } | 348 | } |
diff --git a/drivers/net/wireless/b43/pcmcia.c b/drivers/net/wireless/b43/pcmcia.c index b8aa16307f79..3cfc30307a27 100644 --- a/drivers/net/wireless/b43/pcmcia.c +++ b/drivers/net/wireless/b43/pcmcia.c | |||
@@ -82,13 +82,13 @@ static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev) | |||
82 | tuple.TupleOffset = 0; | 82 | tuple.TupleOffset = 0; |
83 | 83 | ||
84 | res = pcmcia_get_first_tuple(dev, &tuple); | 84 | res = pcmcia_get_first_tuple(dev, &tuple); |
85 | if (res != CS_SUCCESS) | 85 | if (res != 0) |
86 | goto err_kfree_ssb; | 86 | goto err_kfree_ssb; |
87 | res = pcmcia_get_tuple_data(dev, &tuple); | 87 | res = pcmcia_get_tuple_data(dev, &tuple); |
88 | if (res != CS_SUCCESS) | 88 | if (res != 0) |
89 | goto err_kfree_ssb; | 89 | goto err_kfree_ssb; |
90 | res = pcmcia_parse_tuple(dev, &tuple, &parse); | 90 | res = pcmcia_parse_tuple(&tuple, &parse); |
91 | if (res != CS_SUCCESS) | 91 | if (res != 0) |
92 | goto err_kfree_ssb; | 92 | goto err_kfree_ssb; |
93 | 93 | ||
94 | dev->conf.ConfigBase = parse.config.base; | 94 | dev->conf.ConfigBase = parse.config.base; |
@@ -107,13 +107,13 @@ static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev) | |||
107 | win.Size = SSB_CORE_SIZE; | 107 | win.Size = SSB_CORE_SIZE; |
108 | win.AccessSpeed = 250; | 108 | win.AccessSpeed = 250; |
109 | res = pcmcia_request_window(&dev, &win, &dev->win); | 109 | res = pcmcia_request_window(&dev, &win, &dev->win); |
110 | if (res != CS_SUCCESS) | 110 | if (res != 0) |
111 | goto err_kfree_ssb; | 111 | goto err_kfree_ssb; |
112 | 112 | ||
113 | mem.CardOffset = 0; | 113 | mem.CardOffset = 0; |
114 | mem.Page = 0; | 114 | mem.Page = 0; |
115 | res = pcmcia_map_mem_page(dev->win, &mem); | 115 | res = pcmcia_map_mem_page(dev->win, &mem); |
116 | if (res != CS_SUCCESS) | 116 | if (res != 0) |
117 | goto err_disable; | 117 | goto err_disable; |
118 | 118 | ||
119 | dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; | 119 | dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; |
@@ -121,11 +121,11 @@ static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev) | |||
121 | dev->irq.Handler = NULL; /* The handler is registered later. */ | 121 | dev->irq.Handler = NULL; /* The handler is registered later. */ |
122 | dev->irq.Instance = NULL; | 122 | dev->irq.Instance = NULL; |
123 | res = pcmcia_request_irq(dev, &dev->irq); | 123 | res = pcmcia_request_irq(dev, &dev->irq); |
124 | if (res != CS_SUCCESS) | 124 | if (res != 0) |
125 | goto err_disable; | 125 | goto err_disable; |
126 | 126 | ||
127 | res = pcmcia_request_configuration(dev, &dev->conf); | 127 | res = pcmcia_request_configuration(dev, &dev->conf); |
128 | if (res != CS_SUCCESS) | 128 | if (res != 0) |
129 | goto err_disable; | 129 | goto err_disable; |
130 | 130 | ||
131 | err = ssb_bus_pcmciabus_register(ssb, dev, win.Base); | 131 | err = ssb_bus_pcmciabus_register(ssb, dev, win.Base); |
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c index 3b4e55cf33cd..633740277352 100644 --- a/drivers/net/wireless/hostap/hostap_cs.c +++ b/drivers/net/wireless/hostap/hostap_cs.c | |||
@@ -234,7 +234,7 @@ static void sandisk_set_iobase(local_info_t *local) | |||
234 | reg.Value = hw_priv->link->io.BasePort1 & 0x00ff; | 234 | reg.Value = hw_priv->link->io.BasePort1 & 0x00ff; |
235 | res = pcmcia_access_configuration_register(hw_priv->link, | 235 | res = pcmcia_access_configuration_register(hw_priv->link, |
236 | ®); | 236 | ®); |
237 | if (res != CS_SUCCESS) { | 237 | if (res != 0) { |
238 | printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -" | 238 | printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -" |
239 | " res=%d\n", res); | 239 | " res=%d\n", res); |
240 | } | 240 | } |
@@ -246,7 +246,7 @@ static void sandisk_set_iobase(local_info_t *local) | |||
246 | reg.Value = (hw_priv->link->io.BasePort1 & 0xff00) >> 8; | 246 | reg.Value = (hw_priv->link->io.BasePort1 & 0xff00) >> 8; |
247 | res = pcmcia_access_configuration_register(hw_priv->link, | 247 | res = pcmcia_access_configuration_register(hw_priv->link, |
248 | ®); | 248 | ®); |
249 | if (res != CS_SUCCESS) { | 249 | if (res != 0) { |
250 | printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -" | 250 | printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -" |
251 | " res=%d\n", res); | 251 | " res=%d\n", res); |
252 | } | 252 | } |
@@ -305,7 +305,7 @@ static int sandisk_enable_wireless(struct net_device *dev) | |||
305 | tuple.DesiredTuple = CISTPL_LONGLINK_MFC; | 305 | tuple.DesiredTuple = CISTPL_LONGLINK_MFC; |
306 | if (pcmcia_get_first_tuple(hw_priv->link, &tuple) || | 306 | if (pcmcia_get_first_tuple(hw_priv->link, &tuple) || |
307 | pcmcia_get_tuple_data(hw_priv->link, &tuple) || | 307 | pcmcia_get_tuple_data(hw_priv->link, &tuple) || |
308 | pcmcia_parse_tuple(hw_priv->link, &tuple, parse) || | 308 | pcmcia_parse_tuple(&tuple, parse) || |
309 | parse->longlink_mfc.nfn < 2) { | 309 | parse->longlink_mfc.nfn < 2) { |
310 | /* No multi-function links found */ | 310 | /* No multi-function links found */ |
311 | ret = -ENODEV; | 311 | ret = -ENODEV; |
@@ -322,7 +322,7 @@ static int sandisk_enable_wireless(struct net_device *dev) | |||
322 | reg.Value = COR_SOFT_RESET; | 322 | reg.Value = COR_SOFT_RESET; |
323 | res = pcmcia_access_configuration_register(hw_priv->link, | 323 | res = pcmcia_access_configuration_register(hw_priv->link, |
324 | ®); | 324 | ®); |
325 | if (res != CS_SUCCESS) { | 325 | if (res != 0) { |
326 | printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", | 326 | printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", |
327 | dev->name, res); | 327 | dev->name, res); |
328 | goto done; | 328 | goto done; |
@@ -339,7 +339,7 @@ static int sandisk_enable_wireless(struct net_device *dev) | |||
339 | reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA; | 339 | reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA; |
340 | res = pcmcia_access_configuration_register(hw_priv->link, | 340 | res = pcmcia_access_configuration_register(hw_priv->link, |
341 | ®); | 341 | ®); |
342 | if (res != CS_SUCCESS) { | 342 | if (res != 0) { |
343 | printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", | 343 | printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", |
344 | dev->name, res); | 344 | dev->name, res); |
345 | goto done; | 345 | goto done; |
@@ -374,7 +374,7 @@ static void prism2_pccard_cor_sreset(local_info_t *local) | |||
374 | reg.Value = 0; | 374 | reg.Value = 0; |
375 | res = pcmcia_access_configuration_register(hw_priv->link, | 375 | res = pcmcia_access_configuration_register(hw_priv->link, |
376 | ®); | 376 | ®); |
377 | if (res != CS_SUCCESS) { | 377 | if (res != 0) { |
378 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n", | 378 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n", |
379 | res); | 379 | res); |
380 | return; | 380 | return; |
@@ -386,7 +386,7 @@ static void prism2_pccard_cor_sreset(local_info_t *local) | |||
386 | reg.Value |= COR_SOFT_RESET; | 386 | reg.Value |= COR_SOFT_RESET; |
387 | res = pcmcia_access_configuration_register(hw_priv->link, | 387 | res = pcmcia_access_configuration_register(hw_priv->link, |
388 | ®); | 388 | ®); |
389 | if (res != CS_SUCCESS) { | 389 | if (res != 0) { |
390 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n", | 390 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n", |
391 | res); | 391 | res); |
392 | return; | 392 | return; |
@@ -399,7 +399,7 @@ static void prism2_pccard_cor_sreset(local_info_t *local) | |||
399 | reg.Value |= COR_IREQ_ENA; | 399 | reg.Value |= COR_IREQ_ENA; |
400 | res = pcmcia_access_configuration_register(hw_priv->link, | 400 | res = pcmcia_access_configuration_register(hw_priv->link, |
401 | ®); | 401 | ®); |
402 | if (res != CS_SUCCESS) { | 402 | if (res != 0) { |
403 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n", | 403 | printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n", |
404 | res); | 404 | res); |
405 | return; | 405 | return; |
@@ -433,7 +433,7 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr) | |||
433 | reg.Value = 0; | 433 | reg.Value = 0; |
434 | res = pcmcia_access_configuration_register(hw_priv->link, | 434 | res = pcmcia_access_configuration_register(hw_priv->link, |
435 | ®); | 435 | ®); |
436 | if (res != CS_SUCCESS) { | 436 | if (res != 0) { |
437 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 " | 437 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 " |
438 | "(%d)\n", res); | 438 | "(%d)\n", res); |
439 | return; | 439 | return; |
@@ -446,7 +446,7 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr) | |||
446 | reg.Value |= COR_SOFT_RESET; | 446 | reg.Value |= COR_SOFT_RESET; |
447 | res = pcmcia_access_configuration_register(hw_priv->link, | 447 | res = pcmcia_access_configuration_register(hw_priv->link, |
448 | ®); | 448 | ®); |
449 | if (res != CS_SUCCESS) { | 449 | if (res != 0) { |
450 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 " | 450 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 " |
451 | "(%d)\n", res); | 451 | "(%d)\n", res); |
452 | return; | 452 | return; |
@@ -460,7 +460,7 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr) | |||
460 | reg.Offset = CISREG_CCSR; | 460 | reg.Offset = CISREG_CCSR; |
461 | res = pcmcia_access_configuration_register(hw_priv->link, | 461 | res = pcmcia_access_configuration_register(hw_priv->link, |
462 | ®); | 462 | ®); |
463 | if (res != CS_SUCCESS) { | 463 | if (res != 0) { |
464 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 " | 464 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 " |
465 | "(%d)\n", res); | 465 | "(%d)\n", res); |
466 | return; | 466 | return; |
@@ -472,7 +472,7 @@ static void prism2_pccard_genesis_reset(local_info_t *local, int hcr) | |||
472 | reg.Value = old_cor & ~COR_SOFT_RESET; | 472 | reg.Value = old_cor & ~COR_SOFT_RESET; |
473 | res = pcmcia_access_configuration_register(hw_priv->link, | 473 | res = pcmcia_access_configuration_register(hw_priv->link, |
474 | ®); | 474 | ®); |
475 | if (res != CS_SUCCESS) { | 475 | if (res != 0) { |
476 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 " | 476 | printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 " |
477 | "(%d)\n", res); | 477 | "(%d)\n", res); |
478 | return; | 478 | return; |
@@ -532,145 +532,118 @@ static void prism2_detach(struct pcmcia_device *link) | |||
532 | #define CS_CHECK(fn, ret) \ | 532 | #define CS_CHECK(fn, ret) \ |
533 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 533 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
534 | 534 | ||
535 | #define CFG_CHECK2(fn, retf) \ | ||
536 | do { int _ret = (retf); \ | ||
537 | if (_ret != 0) { \ | ||
538 | PDEBUG(DEBUG_EXTRA, "CardServices(" #fn ") returned %d\n", _ret); \ | ||
539 | cs_error(link, fn, _ret); \ | ||
540 | goto next_entry; \ | ||
541 | } \ | ||
542 | } while (0) | ||
543 | |||
544 | 535 | ||
545 | /* run after a CARD_INSERTION event is received to configure the PCMCIA | 536 | /* run after a CARD_INSERTION event is received to configure the PCMCIA |
546 | * socket and make the device available to the system */ | 537 | * socket and make the device available to the system */ |
538 | |||
539 | static int prism2_config_check(struct pcmcia_device *p_dev, | ||
540 | cistpl_cftable_entry_t *cfg, | ||
541 | cistpl_cftable_entry_t *dflt, | ||
542 | unsigned int vcc, | ||
543 | void *priv_data) | ||
544 | { | ||
545 | if (cfg->index == 0) | ||
546 | return -ENODEV; | ||
547 | |||
548 | PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X " | ||
549 | "(default 0x%02X)\n", cfg->index, dflt->index); | ||
550 | |||
551 | /* Does this card need audio output? */ | ||
552 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { | ||
553 | p_dev->conf.Attributes |= CONF_ENABLE_SPKR; | ||
554 | p_dev->conf.Status = CCSR_AUDIO_ENA; | ||
555 | } | ||
556 | |||
557 | /* Use power settings for Vcc and Vpp if present */ | ||
558 | /* Note that the CIS values need to be rescaled */ | ||
559 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
560 | if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / | ||
561 | 10000 && !ignore_cis_vcc) { | ||
562 | PDEBUG(DEBUG_EXTRA, " Vcc mismatch - skipping" | ||
563 | " this entry\n"); | ||
564 | return -ENODEV; | ||
565 | } | ||
566 | } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
567 | if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / | ||
568 | 10000 && !ignore_cis_vcc) { | ||
569 | PDEBUG(DEBUG_EXTRA, " Vcc (default) mismatch " | ||
570 | "- skipping this entry\n"); | ||
571 | return -ENODEV; | ||
572 | } | ||
573 | } | ||
574 | |||
575 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
576 | p_dev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
577 | else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
578 | p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
579 | |||
580 | /* Do we need to allocate an interrupt? */ | ||
581 | if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1) | ||
582 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; | ||
583 | else if (!(p_dev->conf.Attributes & CONF_ENABLE_IRQ)) { | ||
584 | /* At least Compaq WL200 does not have IRQInfo1 set, | ||
585 | * but it does not work without interrupts.. */ | ||
586 | printk(KERN_WARNING "Config has no IRQ info, but trying to " | ||
587 | "enable IRQ anyway..\n"); | ||
588 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; | ||
589 | } | ||
590 | |||
591 | /* IO window settings */ | ||
592 | PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d " | ||
593 | "dflt->io.nwin=%d\n", | ||
594 | cfg->io.nwin, dflt->io.nwin); | ||
595 | p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; | ||
596 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { | ||
597 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | ||
598 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
599 | PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, " | ||
600 | "io.base=0x%04x, len=%d\n", io->flags, | ||
601 | io->win[0].base, io->win[0].len); | ||
602 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
603 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
604 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
605 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
606 | p_dev->io.IOAddrLines = io->flags & | ||
607 | CISTPL_IO_LINES_MASK; | ||
608 | p_dev->io.BasePort1 = io->win[0].base; | ||
609 | p_dev->io.NumPorts1 = io->win[0].len; | ||
610 | if (io->nwin > 1) { | ||
611 | p_dev->io.Attributes2 = p_dev->io.Attributes1; | ||
612 | p_dev->io.BasePort2 = io->win[1].base; | ||
613 | p_dev->io.NumPorts2 = io->win[1].len; | ||
614 | } | ||
615 | } | ||
616 | |||
617 | /* This reserves IO space but doesn't actually enable it */ | ||
618 | return pcmcia_request_io(p_dev, &p_dev->io); | ||
619 | } | ||
620 | |||
547 | static int prism2_config(struct pcmcia_device *link) | 621 | static int prism2_config(struct pcmcia_device *link) |
548 | { | 622 | { |
549 | struct net_device *dev; | 623 | struct net_device *dev; |
550 | struct hostap_interface *iface; | 624 | struct hostap_interface *iface; |
551 | local_info_t *local; | 625 | local_info_t *local; |
552 | int ret = 1; | 626 | int ret = 1; |
553 | tuple_t tuple; | ||
554 | cisparse_t *parse; | ||
555 | int last_fn, last_ret; | 627 | int last_fn, last_ret; |
556 | u_char buf[64]; | ||
557 | config_info_t conf; | ||
558 | cistpl_cftable_entry_t dflt = { 0 }; | ||
559 | struct hostap_cs_priv *hw_priv; | 628 | struct hostap_cs_priv *hw_priv; |
560 | 629 | ||
561 | PDEBUG(DEBUG_FLOW, "prism2_config()\n"); | 630 | PDEBUG(DEBUG_FLOW, "prism2_config()\n"); |
562 | 631 | ||
563 | parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL); | ||
564 | hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL); | 632 | hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL); |
565 | if (parse == NULL || hw_priv == NULL) { | 633 | if (hw_priv == NULL) { |
566 | ret = -ENOMEM; | 634 | ret = -ENOMEM; |
567 | goto failed; | 635 | goto failed; |
568 | } | 636 | } |
569 | 637 | ||
570 | tuple.Attributes = 0; | ||
571 | tuple.TupleData = buf; | ||
572 | tuple.TupleDataMax = sizeof(buf); | ||
573 | tuple.TupleOffset = 0; | ||
574 | |||
575 | CS_CHECK(GetConfigurationInfo, | ||
576 | pcmcia_get_configuration_info(link, &conf)); | ||
577 | |||
578 | /* Look for an appropriate configuration table entry in the CIS */ | 638 | /* Look for an appropriate configuration table entry in the CIS */ |
579 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 639 | last_ret = pcmcia_loop_config(link, prism2_config_check, NULL); |
580 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | 640 | if (last_ret) { |
581 | for (;;) { | 641 | if (!ignore_cis_vcc) |
582 | cistpl_cftable_entry_t *cfg = &(parse->cftable_entry); | 642 | printk(KERN_ERR "GetNextTuple(): No matching " |
583 | CFG_CHECK2(GetTupleData, | 643 | "CIS configuration. Maybe you need the " |
584 | pcmcia_get_tuple_data(link, &tuple)); | 644 | "ignore_cis_vcc=1 parameter.\n"); |
585 | CFG_CHECK2(ParseTuple, | 645 | cs_error(link, RequestIO, last_ret); |
586 | pcmcia_parse_tuple(link, &tuple, parse)); | 646 | goto failed; |
587 | |||
588 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) | ||
589 | dflt = *cfg; | ||
590 | if (cfg->index == 0) | ||
591 | goto next_entry; | ||
592 | link->conf.ConfigIndex = cfg->index; | ||
593 | PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X " | ||
594 | "(default 0x%02X)\n", cfg->index, dflt.index); | ||
595 | |||
596 | /* Does this card need audio output? */ | ||
597 | if (cfg->flags & CISTPL_CFTABLE_AUDIO) { | ||
598 | link->conf.Attributes |= CONF_ENABLE_SPKR; | ||
599 | link->conf.Status = CCSR_AUDIO_ENA; | ||
600 | } | ||
601 | |||
602 | /* Use power settings for Vcc and Vpp if present */ | ||
603 | /* Note that the CIS values need to be rescaled */ | ||
604 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
605 | if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / | ||
606 | 10000 && !ignore_cis_vcc) { | ||
607 | PDEBUG(DEBUG_EXTRA, " Vcc mismatch - skipping" | ||
608 | " this entry\n"); | ||
609 | goto next_entry; | ||
610 | } | ||
611 | } else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
612 | if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] / | ||
613 | 10000 && !ignore_cis_vcc) { | ||
614 | PDEBUG(DEBUG_EXTRA, " Vcc (default) mismatch " | ||
615 | "- skipping this entry\n"); | ||
616 | goto next_entry; | ||
617 | } | ||
618 | } | ||
619 | |||
620 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
621 | link->conf.Vpp = | ||
622 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
623 | else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
624 | link->conf.Vpp = | ||
625 | dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
626 | |||
627 | /* Do we need to allocate an interrupt? */ | ||
628 | if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1) | ||
629 | link->conf.Attributes |= CONF_ENABLE_IRQ; | ||
630 | else if (!(link->conf.Attributes & CONF_ENABLE_IRQ)) { | ||
631 | /* At least Compaq WL200 does not have IRQInfo1 set, | ||
632 | * but it does not work without interrupts.. */ | ||
633 | printk("Config has no IRQ info, but trying to enable " | ||
634 | "IRQ anyway..\n"); | ||
635 | link->conf.Attributes |= CONF_ENABLE_IRQ; | ||
636 | } | ||
637 | |||
638 | /* IO window settings */ | ||
639 | PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d " | ||
640 | "dflt.io.nwin=%d\n", | ||
641 | cfg->io.nwin, dflt.io.nwin); | ||
642 | link->io.NumPorts1 = link->io.NumPorts2 = 0; | ||
643 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | ||
644 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; | ||
645 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
646 | PDEBUG(DEBUG_EXTRA, "io->flags = 0x%04X, " | ||
647 | "io.base=0x%04x, len=%d\n", io->flags, | ||
648 | io->win[0].base, io->win[0].len); | ||
649 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
650 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
651 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
652 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
653 | link->io.IOAddrLines = io->flags & | ||
654 | CISTPL_IO_LINES_MASK; | ||
655 | link->io.BasePort1 = io->win[0].base; | ||
656 | link->io.NumPorts1 = io->win[0].len; | ||
657 | if (io->nwin > 1) { | ||
658 | link->io.Attributes2 = link->io.Attributes1; | ||
659 | link->io.BasePort2 = io->win[1].base; | ||
660 | link->io.NumPorts2 = io->win[1].len; | ||
661 | } | ||
662 | } | ||
663 | |||
664 | /* This reserves IO space but doesn't actually enable it */ | ||
665 | CFG_CHECK2(RequestIO, | ||
666 | pcmcia_request_io(link, &link->io)); | ||
667 | |||
668 | /* This configuration table entry is OK */ | ||
669 | break; | ||
670 | |||
671 | next_entry: | ||
672 | CS_CHECK(GetNextTuple, | ||
673 | pcmcia_get_next_tuple(link, &tuple)); | ||
674 | } | 647 | } |
675 | 648 | ||
676 | /* Need to allocate net_device before requesting IRQ handler */ | 649 | /* Need to allocate net_device before requesting IRQ handler */ |
@@ -738,14 +711,12 @@ static int prism2_config(struct pcmcia_device *link) | |||
738 | if (ret == 0 && local->ddev) | 711 | if (ret == 0 && local->ddev) |
739 | strcpy(hw_priv->node.dev_name, local->ddev->name); | 712 | strcpy(hw_priv->node.dev_name, local->ddev->name); |
740 | } | 713 | } |
741 | kfree(parse); | ||
742 | return ret; | 714 | return ret; |
743 | 715 | ||
744 | cs_failed: | 716 | cs_failed: |
745 | cs_error(link, last_fn, last_ret); | 717 | cs_error(link, last_fn, last_ret); |
746 | 718 | ||
747 | failed: | 719 | failed: |
748 | kfree(parse); | ||
749 | kfree(hw_priv); | 720 | kfree(hw_priv); |
750 | prism2_release((u_long)link); | 721 | prism2_release((u_long)link); |
751 | return ret; | 722 | return ret; |
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c index e3505c110af6..842a08d1f106 100644 --- a/drivers/net/wireless/libertas/if_cs.c +++ b/drivers/net/wireless/libertas/if_cs.c | |||
@@ -791,7 +791,7 @@ static int if_cs_probe(struct pcmcia_device *p_dev) | |||
791 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 791 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; |
792 | if ((ret = pcmcia_get_first_tuple(p_dev, &tuple)) != 0 || | 792 | if ((ret = pcmcia_get_first_tuple(p_dev, &tuple)) != 0 || |
793 | (ret = pcmcia_get_tuple_data(p_dev, &tuple)) != 0 || | 793 | (ret = pcmcia_get_tuple_data(p_dev, &tuple)) != 0 || |
794 | (ret = pcmcia_parse_tuple(p_dev, &tuple, &parse)) != 0) | 794 | (ret = pcmcia_parse_tuple(&tuple, &parse)) != 0) |
795 | { | 795 | { |
796 | lbs_pr_err("error in pcmcia_get_first_tuple etc\n"); | 796 | lbs_pr_err("error in pcmcia_get_first_tuple etc\n"); |
797 | goto out1; | 797 | goto out1; |
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c index 25bae7933aa5..a670f36b5f3f 100644 --- a/drivers/net/wireless/netwave_cs.c +++ b/drivers/net/wireless/netwave_cs.c | |||
@@ -749,9 +749,10 @@ static int netwave_pcmcia_config(struct pcmcia_device *link) { | |||
749 | for (i = j = 0x0; j < 0x400; j += 0x20) { | 749 | for (i = j = 0x0; j < 0x400; j += 0x20) { |
750 | link->io.BasePort1 = j ^ 0x300; | 750 | link->io.BasePort1 = j ^ 0x300; |
751 | i = pcmcia_request_io(link, &link->io); | 751 | i = pcmcia_request_io(link, &link->io); |
752 | if (i == CS_SUCCESS) break; | 752 | if (i == 0) |
753 | break; | ||
753 | } | 754 | } |
754 | if (i != CS_SUCCESS) { | 755 | if (i != 0) { |
755 | cs_error(link, RequestIO, i); | 756 | cs_error(link, RequestIO, i); |
756 | goto failed; | 757 | goto failed; |
757 | } | 758 | } |
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c index 9eaa252c2430..e585684e59a0 100644 --- a/drivers/net/wireless/orinoco_cs.c +++ b/drivers/net/wireless/orinoco_cs.c | |||
@@ -80,7 +80,7 @@ orinoco_cs_hard_reset(struct orinoco_private *priv) | |||
80 | /* We need atomic ops here, because we're not holding the lock */ | 80 | /* We need atomic ops here, because we're not holding the lock */ |
81 | set_bit(0, &card->hard_reset_in_progress); | 81 | set_bit(0, &card->hard_reset_in_progress); |
82 | 82 | ||
83 | err = pcmcia_reset_card(link, NULL); | 83 | err = pcmcia_reset_card(link->socket); |
84 | if (err) | 84 | if (err) |
85 | return err; | 85 | return err; |
86 | 86 | ||
@@ -165,6 +165,70 @@ static void orinoco_cs_detach(struct pcmcia_device *link) | |||
165 | last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; \ | 165 | last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; \ |
166 | } while (0) | 166 | } while (0) |
167 | 167 | ||
168 | static int orinoco_cs_config_check(struct pcmcia_device *p_dev, | ||
169 | cistpl_cftable_entry_t *cfg, | ||
170 | cistpl_cftable_entry_t *dflt, | ||
171 | unsigned int vcc, | ||
172 | void *priv_data) | ||
173 | { | ||
174 | if (cfg->index == 0) | ||
175 | goto next_entry; | ||
176 | |||
177 | /* Use power settings for Vcc and Vpp if present */ | ||
178 | /* Note that the CIS values need to be rescaled */ | ||
179 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
180 | if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) { | ||
181 | DEBUG(2, "spectrum_cs_config: Vcc mismatch (vcc = %d, CIS = %d)\n", vcc, cfg->vcc.param[CISTPL_POWER_VNOM] / 10000); | ||
182 | if (!ignore_cis_vcc) | ||
183 | goto next_entry; | ||
184 | } | ||
185 | } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
186 | if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) { | ||
187 | DEBUG(2, "spectrum_cs_config: Vcc mismatch (vcc = %d, CIS = %d)\n", vcc, dflt->vcc.param[CISTPL_POWER_VNOM] / 10000); | ||
188 | if (!ignore_cis_vcc) | ||
189 | goto next_entry; | ||
190 | } | ||
191 | } | ||
192 | |||
193 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
194 | p_dev->conf.Vpp = | ||
195 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
196 | else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
197 | p_dev->conf.Vpp = | ||
198 | dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
199 | |||
200 | /* Do we need to allocate an interrupt? */ | ||
201 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; | ||
202 | |||
203 | /* IO window settings */ | ||
204 | p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; | ||
205 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { | ||
206 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | ||
207 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
208 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
209 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
210 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
211 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
212 | p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
213 | p_dev->io.BasePort1 = io->win[0].base; | ||
214 | p_dev->io.NumPorts1 = io->win[0].len; | ||
215 | if (io->nwin > 1) { | ||
216 | p_dev->io.Attributes2 = p_dev->io.Attributes1; | ||
217 | p_dev->io.BasePort2 = io->win[1].base; | ||
218 | p_dev->io.NumPorts2 = io->win[1].len; | ||
219 | } | ||
220 | |||
221 | /* This reserves IO space but doesn't actually enable it */ | ||
222 | if (pcmcia_request_io(p_dev, &p_dev->io) != 0) | ||
223 | goto next_entry; | ||
224 | } | ||
225 | return 0; | ||
226 | |||
227 | next_entry: | ||
228 | pcmcia_disable_device(p_dev); | ||
229 | return -ENODEV; | ||
230 | }; | ||
231 | |||
168 | static int | 232 | static int |
169 | orinoco_cs_config(struct pcmcia_device *link) | 233 | orinoco_cs_config(struct pcmcia_device *link) |
170 | { | 234 | { |
@@ -173,16 +237,8 @@ orinoco_cs_config(struct pcmcia_device *link) | |||
173 | struct orinoco_pccard *card = priv->card; | 237 | struct orinoco_pccard *card = priv->card; |
174 | hermes_t *hw = &priv->hw; | 238 | hermes_t *hw = &priv->hw; |
175 | int last_fn, last_ret; | 239 | int last_fn, last_ret; |
176 | u_char buf[64]; | ||
177 | config_info_t conf; | ||
178 | tuple_t tuple; | ||
179 | cisparse_t parse; | ||
180 | void __iomem *mem; | 240 | void __iomem *mem; |
181 | 241 | ||
182 | /* Look up the current Vcc */ | ||
183 | CS_CHECK(GetConfigurationInfo, | ||
184 | pcmcia_get_configuration_info(link, &conf)); | ||
185 | |||
186 | /* | 242 | /* |
187 | * In this loop, we scan the CIS for configuration table | 243 | * In this loop, we scan the CIS for configuration table |
188 | * entries, each of which describes a valid card | 244 | * entries, each of which describes a valid card |
@@ -197,94 +253,14 @@ orinoco_cs_config(struct pcmcia_device *link) | |||
197 | * and most client drivers will only use the CIS to fill in | 253 | * and most client drivers will only use the CIS to fill in |
198 | * implementation-defined details. | 254 | * implementation-defined details. |
199 | */ | 255 | */ |
200 | tuple.Attributes = 0; | 256 | last_ret = pcmcia_loop_config(link, orinoco_cs_config_check, NULL); |
201 | tuple.TupleData = buf; | 257 | if (last_ret) { |
202 | tuple.TupleDataMax = sizeof(buf); | 258 | if (!ignore_cis_vcc) |
203 | tuple.TupleOffset = 0; | ||
204 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | ||
205 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
206 | while (1) { | ||
207 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | ||
208 | cistpl_cftable_entry_t dflt = { .index = 0 }; | ||
209 | |||
210 | if ( (pcmcia_get_tuple_data(link, &tuple) != 0) | ||
211 | || (pcmcia_parse_tuple(link, &tuple, &parse) != 0)) | ||
212 | goto next_entry; | ||
213 | |||
214 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) | ||
215 | dflt = *cfg; | ||
216 | if (cfg->index == 0) | ||
217 | goto next_entry; | ||
218 | link->conf.ConfigIndex = cfg->index; | ||
219 | |||
220 | /* Use power settings for Vcc and Vpp if present */ | ||
221 | /* Note that the CIS values need to be rescaled */ | ||
222 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
223 | if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) { | ||
224 | DEBUG(2, "orinoco_cs_config: Vcc mismatch (conf.Vcc = %d, cfg CIS = %d)\n", conf.Vcc, cfg->vcc.param[CISTPL_POWER_VNOM] / 10000); | ||
225 | if (!ignore_cis_vcc) | ||
226 | goto next_entry; | ||
227 | } | ||
228 | } else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
229 | if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) { | ||
230 | DEBUG(2, "orinoco_cs_config: Vcc mismatch (conf.Vcc = %d, dflt CIS = %d)\n", conf.Vcc, dflt.vcc.param[CISTPL_POWER_VNOM] / 10000); | ||
231 | if(!ignore_cis_vcc) | ||
232 | goto next_entry; | ||
233 | } | ||
234 | } | ||
235 | |||
236 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
237 | link->conf.Vpp = | ||
238 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
239 | else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
240 | link->conf.Vpp = | ||
241 | dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
242 | |||
243 | /* Do we need to allocate an interrupt? */ | ||
244 | link->conf.Attributes |= CONF_ENABLE_IRQ; | ||
245 | |||
246 | /* IO window settings */ | ||
247 | link->io.NumPorts1 = link->io.NumPorts2 = 0; | ||
248 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | ||
249 | cistpl_io_t *io = | ||
250 | (cfg->io.nwin) ? &cfg->io : &dflt.io; | ||
251 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
252 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
253 | link->io.Attributes1 = | ||
254 | IO_DATA_PATH_WIDTH_16; | ||
255 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
256 | link->io.Attributes1 = | ||
257 | IO_DATA_PATH_WIDTH_8; | ||
258 | link->io.IOAddrLines = | ||
259 | io->flags & CISTPL_IO_LINES_MASK; | ||
260 | link->io.BasePort1 = io->win[0].base; | ||
261 | link->io.NumPorts1 = io->win[0].len; | ||
262 | if (io->nwin > 1) { | ||
263 | link->io.Attributes2 = | ||
264 | link->io.Attributes1; | ||
265 | link->io.BasePort2 = io->win[1].base; | ||
266 | link->io.NumPorts2 = io->win[1].len; | ||
267 | } | ||
268 | |||
269 | /* This reserves IO space but doesn't actually enable it */ | ||
270 | if (pcmcia_request_io(link, &link->io) != 0) | ||
271 | goto next_entry; | ||
272 | } | ||
273 | |||
274 | |||
275 | /* If we got this far, we're cool! */ | ||
276 | |||
277 | break; | ||
278 | |||
279 | next_entry: | ||
280 | pcmcia_disable_device(link); | ||
281 | last_ret = pcmcia_get_next_tuple(link, &tuple); | ||
282 | if (last_ret == CS_NO_MORE_ITEMS) { | ||
283 | printk(KERN_ERR PFX "GetNextTuple(): No matching " | 259 | printk(KERN_ERR PFX "GetNextTuple(): No matching " |
284 | "CIS configuration. Maybe you need the " | 260 | "CIS configuration. Maybe you need the " |
285 | "ignore_cis_vcc=1 parameter.\n"); | 261 | "ignore_cis_vcc=1 parameter.\n"); |
286 | goto cs_failed; | 262 | cs_error(link, RequestIO, last_ret); |
287 | } | 263 | goto failed; |
288 | } | 264 | } |
289 | 265 | ||
290 | /* | 266 | /* |
@@ -335,7 +311,6 @@ orinoco_cs_config(struct pcmcia_device *link) | |||
335 | "0x%04x-0x%04x\n", dev->name, dev->dev.parent->bus_id, | 311 | "0x%04x-0x%04x\n", dev->name, dev->dev.parent->bus_id, |
336 | link->irq.AssignedIRQ, link->io.BasePort1, | 312 | link->irq.AssignedIRQ, link->io.BasePort1, |
337 | link->io.BasePort1 + link->io.NumPorts1 - 1); | 313 | link->io.BasePort1 + link->io.NumPorts1 - 1); |
338 | |||
339 | return 0; | 314 | return 0; |
340 | 315 | ||
341 | cs_failed: | 316 | cs_failed: |
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c index 44da0d19b5c8..1404a5717520 100644 --- a/drivers/net/wireless/ray_cs.c +++ b/drivers/net/wireless/ray_cs.c | |||
@@ -798,9 +798,9 @@ static void ray_release(struct pcmcia_device *link) | |||
798 | iounmap(local->amem); | 798 | iounmap(local->amem); |
799 | /* Do bother checking to see if these succeed or not */ | 799 | /* Do bother checking to see if these succeed or not */ |
800 | i = pcmcia_release_window(local->amem_handle); | 800 | i = pcmcia_release_window(local->amem_handle); |
801 | if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseWindow(local->amem) ret = %x\n",i); | 801 | if ( i != 0 ) DEBUG(0,"ReleaseWindow(local->amem) ret = %x\n",i); |
802 | i = pcmcia_release_window(local->rmem_handle); | 802 | i = pcmcia_release_window(local->rmem_handle); |
803 | if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseWindow(local->rmem) ret = %x\n",i); | 803 | if ( i != 0 ) DEBUG(0,"ReleaseWindow(local->rmem) ret = %x\n",i); |
804 | pcmcia_disable_device(link); | 804 | pcmcia_disable_device(link); |
805 | 805 | ||
806 | DEBUG(2,"ray_release ending\n"); | 806 | DEBUG(2,"ray_release ending\n"); |
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c index 67b26d3c3cd5..b0c71c3be467 100644 --- a/drivers/net/wireless/spectrum_cs.c +++ b/drivers/net/wireless/spectrum_cs.c | |||
@@ -235,6 +235,70 @@ static void spectrum_cs_detach(struct pcmcia_device *link) | |||
235 | * device available to the system. | 235 | * device available to the system. |
236 | */ | 236 | */ |
237 | 237 | ||
238 | static int spectrum_cs_config_check(struct pcmcia_device *p_dev, | ||
239 | cistpl_cftable_entry_t *cfg, | ||
240 | cistpl_cftable_entry_t *dflt, | ||
241 | unsigned int vcc, | ||
242 | void *priv_data) | ||
243 | { | ||
244 | if (cfg->index == 0) | ||
245 | goto next_entry; | ||
246 | |||
247 | /* Use power settings for Vcc and Vpp if present */ | ||
248 | /* Note that the CIS values need to be rescaled */ | ||
249 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
250 | if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) { | ||
251 | DEBUG(2, "spectrum_cs_config: Vcc mismatch (vcc = %d, CIS = %d)\n", vcc, cfg->vcc.param[CISTPL_POWER_VNOM] / 10000); | ||
252 | if (!ignore_cis_vcc) | ||
253 | goto next_entry; | ||
254 | } | ||
255 | } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
256 | if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000) { | ||
257 | DEBUG(2, "spectrum_cs_config: Vcc mismatch (vcc = %d, CIS = %d)\n", vcc, dflt->vcc.param[CISTPL_POWER_VNOM] / 10000); | ||
258 | if (!ignore_cis_vcc) | ||
259 | goto next_entry; | ||
260 | } | ||
261 | } | ||
262 | |||
263 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
264 | p_dev->conf.Vpp = | ||
265 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
266 | else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
267 | p_dev->conf.Vpp = | ||
268 | dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
269 | |||
270 | /* Do we need to allocate an interrupt? */ | ||
271 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; | ||
272 | |||
273 | /* IO window settings */ | ||
274 | p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0; | ||
275 | if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { | ||
276 | cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; | ||
277 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
278 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
279 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | ||
280 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
281 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; | ||
282 | p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; | ||
283 | p_dev->io.BasePort1 = io->win[0].base; | ||
284 | p_dev->io.NumPorts1 = io->win[0].len; | ||
285 | if (io->nwin > 1) { | ||
286 | p_dev->io.Attributes2 = p_dev->io.Attributes1; | ||
287 | p_dev->io.BasePort2 = io->win[1].base; | ||
288 | p_dev->io.NumPorts2 = io->win[1].len; | ||
289 | } | ||
290 | |||
291 | /* This reserves IO space but doesn't actually enable it */ | ||
292 | if (pcmcia_request_io(p_dev, &p_dev->io) != 0) | ||
293 | goto next_entry; | ||
294 | } | ||
295 | return 0; | ||
296 | |||
297 | next_entry: | ||
298 | pcmcia_disable_device(p_dev); | ||
299 | return -ENODEV; | ||
300 | }; | ||
301 | |||
238 | static int | 302 | static int |
239 | spectrum_cs_config(struct pcmcia_device *link) | 303 | spectrum_cs_config(struct pcmcia_device *link) |
240 | { | 304 | { |
@@ -243,16 +307,8 @@ spectrum_cs_config(struct pcmcia_device *link) | |||
243 | struct orinoco_pccard *card = priv->card; | 307 | struct orinoco_pccard *card = priv->card; |
244 | hermes_t *hw = &priv->hw; | 308 | hermes_t *hw = &priv->hw; |
245 | int last_fn, last_ret; | 309 | int last_fn, last_ret; |
246 | u_char buf[64]; | ||
247 | config_info_t conf; | ||
248 | tuple_t tuple; | ||
249 | cisparse_t parse; | ||
250 | void __iomem *mem; | 310 | void __iomem *mem; |
251 | 311 | ||
252 | /* Look up the current Vcc */ | ||
253 | CS_CHECK(GetConfigurationInfo, | ||
254 | pcmcia_get_configuration_info(link, &conf)); | ||
255 | |||
256 | /* | 312 | /* |
257 | * In this loop, we scan the CIS for configuration table | 313 | * In this loop, we scan the CIS for configuration table |
258 | * entries, each of which describes a valid card | 314 | * entries, each of which describes a valid card |
@@ -267,94 +323,14 @@ spectrum_cs_config(struct pcmcia_device *link) | |||
267 | * and most client drivers will only use the CIS to fill in | 323 | * and most client drivers will only use the CIS to fill in |
268 | * implementation-defined details. | 324 | * implementation-defined details. |
269 | */ | 325 | */ |
270 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 326 | last_ret = pcmcia_loop_config(link, spectrum_cs_config_check, NULL); |
271 | tuple.Attributes = 0; | 327 | if (last_ret) { |
272 | tuple.TupleData = buf; | 328 | if (!ignore_cis_vcc) |
273 | tuple.TupleDataMax = sizeof(buf); | ||
274 | tuple.TupleOffset = 0; | ||
275 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); | ||
276 | while (1) { | ||
277 | cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); | ||
278 | cistpl_cftable_entry_t dflt = { .index = 0 }; | ||
279 | |||
280 | if ( (pcmcia_get_tuple_data(link, &tuple) != 0) | ||
281 | || (pcmcia_parse_tuple(link, &tuple, &parse) != 0)) | ||
282 | goto next_entry; | ||
283 | |||
284 | if (cfg->flags & CISTPL_CFTABLE_DEFAULT) | ||
285 | dflt = *cfg; | ||
286 | if (cfg->index == 0) | ||
287 | goto next_entry; | ||
288 | link->conf.ConfigIndex = cfg->index; | ||
289 | |||
290 | /* Use power settings for Vcc and Vpp if present */ | ||
291 | /* Note that the CIS values need to be rescaled */ | ||
292 | if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
293 | if (conf.Vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000) { | ||
294 | DEBUG(2, "spectrum_cs_config: Vcc mismatch (conf.Vcc = %d, CIS = %d)\n", conf.Vcc, cfg->vcc.param[CISTPL_POWER_VNOM] / 10000); | ||
295 | if (!ignore_cis_vcc) | ||
296 | goto next_entry; | ||
297 | } | ||
298 | } else if (dflt.vcc.present & (1 << CISTPL_POWER_VNOM)) { | ||
299 | if (conf.Vcc != dflt.vcc.param[CISTPL_POWER_VNOM] / 10000) { | ||
300 | DEBUG(2, "spectrum_cs_config: Vcc mismatch (conf.Vcc = %d, CIS = %d)\n", conf.Vcc, dflt.vcc.param[CISTPL_POWER_VNOM] / 10000); | ||
301 | if(!ignore_cis_vcc) | ||
302 | goto next_entry; | ||
303 | } | ||
304 | } | ||
305 | |||
306 | if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
307 | link->conf.Vpp = | ||
308 | cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
309 | else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) | ||
310 | link->conf.Vpp = | ||
311 | dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; | ||
312 | |||
313 | /* Do we need to allocate an interrupt? */ | ||
314 | link->conf.Attributes |= CONF_ENABLE_IRQ; | ||
315 | |||
316 | /* IO window settings */ | ||
317 | link->io.NumPorts1 = link->io.NumPorts2 = 0; | ||
318 | if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { | ||
319 | cistpl_io_t *io = | ||
320 | (cfg->io.nwin) ? &cfg->io : &dflt.io; | ||
321 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | ||
322 | if (!(io->flags & CISTPL_IO_8BIT)) | ||
323 | link->io.Attributes1 = | ||
324 | IO_DATA_PATH_WIDTH_16; | ||
325 | if (!(io->flags & CISTPL_IO_16BIT)) | ||
326 | link->io.Attributes1 = | ||
327 | IO_DATA_PATH_WIDTH_8; | ||
328 | link->io.IOAddrLines = | ||
329 | io->flags & CISTPL_IO_LINES_MASK; | ||
330 | link->io.BasePort1 = io->win[0].base; | ||
331 | link->io.NumPorts1 = io->win[0].len; | ||
332 | if (io->nwin > 1) { | ||
333 | link->io.Attributes2 = | ||
334 | link->io.Attributes1; | ||
335 | link->io.BasePort2 = io->win[1].base; | ||
336 | link->io.NumPorts2 = io->win[1].len; | ||
337 | } | ||
338 | |||
339 | /* This reserves IO space but doesn't actually enable it */ | ||
340 | if (pcmcia_request_io(link, &link->io) != 0) | ||
341 | goto next_entry; | ||
342 | } | ||
343 | |||
344 | |||
345 | /* If we got this far, we're cool! */ | ||
346 | |||
347 | break; | ||
348 | |||
349 | next_entry: | ||
350 | pcmcia_disable_device(link); | ||
351 | last_ret = pcmcia_get_next_tuple(link, &tuple); | ||
352 | if (last_ret == CS_NO_MORE_ITEMS) { | ||
353 | printk(KERN_ERR PFX "GetNextTuple(): No matching " | 329 | printk(KERN_ERR PFX "GetNextTuple(): No matching " |
354 | "CIS configuration. Maybe you need the " | 330 | "CIS configuration. Maybe you need the " |
355 | "ignore_cis_vcc=1 parameter.\n"); | 331 | "ignore_cis_vcc=1 parameter.\n"); |
356 | goto cs_failed; | 332 | cs_error(link, RequestIO, last_ret); |
357 | } | 333 | goto failed; |
358 | } | 334 | } |
359 | 335 | ||
360 | /* | 336 | /* |
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c index b5de38a9b791..e124b1d6267a 100644 --- a/drivers/net/wireless/wavelan_cs.c +++ b/drivers/net/wireless/wavelan_cs.c | |||
@@ -3702,7 +3702,7 @@ wv_pcmcia_reset(struct net_device * dev) | |||
3702 | #endif | 3702 | #endif |
3703 | 3703 | ||
3704 | i = pcmcia_access_configuration_register(link, ®); | 3704 | i = pcmcia_access_configuration_register(link, ®); |
3705 | if(i != CS_SUCCESS) | 3705 | if (i != 0) |
3706 | { | 3706 | { |
3707 | cs_error(link, AccessConfigurationRegister, i); | 3707 | cs_error(link, AccessConfigurationRegister, i); |
3708 | return FALSE; | 3708 | return FALSE; |
@@ -3716,7 +3716,7 @@ wv_pcmcia_reset(struct net_device * dev) | |||
3716 | reg.Action = CS_WRITE; | 3716 | reg.Action = CS_WRITE; |
3717 | reg.Value = reg.Value | COR_SW_RESET; | 3717 | reg.Value = reg.Value | COR_SW_RESET; |
3718 | i = pcmcia_access_configuration_register(link, ®); | 3718 | i = pcmcia_access_configuration_register(link, ®); |
3719 | if(i != CS_SUCCESS) | 3719 | if (i != 0) |
3720 | { | 3720 | { |
3721 | cs_error(link, AccessConfigurationRegister, i); | 3721 | cs_error(link, AccessConfigurationRegister, i); |
3722 | return FALSE; | 3722 | return FALSE; |
@@ -3725,7 +3725,7 @@ wv_pcmcia_reset(struct net_device * dev) | |||
3725 | reg.Action = CS_WRITE; | 3725 | reg.Action = CS_WRITE; |
3726 | reg.Value = COR_LEVEL_IRQ | COR_CONFIG; | 3726 | reg.Value = COR_LEVEL_IRQ | COR_CONFIG; |
3727 | i = pcmcia_access_configuration_register(link, ®); | 3727 | i = pcmcia_access_configuration_register(link, ®); |
3728 | if(i != CS_SUCCESS) | 3728 | if (i != 0) |
3729 | { | 3729 | { |
3730 | cs_error(link, AccessConfigurationRegister, i); | 3730 | cs_error(link, AccessConfigurationRegister, i); |
3731 | return FALSE; | 3731 | return FALSE; |
@@ -3903,7 +3903,7 @@ wv_pcmcia_config(struct pcmcia_device * link) | |||
3903 | do | 3903 | do |
3904 | { | 3904 | { |
3905 | i = pcmcia_request_io(link, &link->io); | 3905 | i = pcmcia_request_io(link, &link->io); |
3906 | if(i != CS_SUCCESS) | 3906 | if (i != 0) |
3907 | { | 3907 | { |
3908 | cs_error(link, RequestIO, i); | 3908 | cs_error(link, RequestIO, i); |
3909 | break; | 3909 | break; |
@@ -3914,7 +3914,7 @@ wv_pcmcia_config(struct pcmcia_device * link) | |||
3914 | * actually assign a handler to the interrupt. | 3914 | * actually assign a handler to the interrupt. |
3915 | */ | 3915 | */ |
3916 | i = pcmcia_request_irq(link, &link->irq); | 3916 | i = pcmcia_request_irq(link, &link->irq); |
3917 | if(i != CS_SUCCESS) | 3917 | if (i != 0) |
3918 | { | 3918 | { |
3919 | cs_error(link, RequestIRQ, i); | 3919 | cs_error(link, RequestIRQ, i); |
3920 | break; | 3920 | break; |
@@ -3926,7 +3926,7 @@ wv_pcmcia_config(struct pcmcia_device * link) | |||
3926 | */ | 3926 | */ |
3927 | link->conf.ConfigIndex = 1; | 3927 | link->conf.ConfigIndex = 1; |
3928 | i = pcmcia_request_configuration(link, &link->conf); | 3928 | i = pcmcia_request_configuration(link, &link->conf); |
3929 | if(i != CS_SUCCESS) | 3929 | if (i != 0) |
3930 | { | 3930 | { |
3931 | cs_error(link, RequestConfiguration, i); | 3931 | cs_error(link, RequestConfiguration, i); |
3932 | break; | 3932 | break; |
@@ -3942,7 +3942,7 @@ wv_pcmcia_config(struct pcmcia_device * link) | |||
3942 | req.Base = req.Size = 0; | 3942 | req.Base = req.Size = 0; |
3943 | req.AccessSpeed = mem_speed; | 3943 | req.AccessSpeed = mem_speed; |
3944 | i = pcmcia_request_window(&link, &req, &link->win); | 3944 | i = pcmcia_request_window(&link, &req, &link->win); |
3945 | if(i != CS_SUCCESS) | 3945 | if (i != 0) |
3946 | { | 3946 | { |
3947 | cs_error(link, RequestWindow, i); | 3947 | cs_error(link, RequestWindow, i); |
3948 | break; | 3948 | break; |
@@ -3954,7 +3954,7 @@ wv_pcmcia_config(struct pcmcia_device * link) | |||
3954 | 3954 | ||
3955 | mem.CardOffset = 0; mem.Page = 0; | 3955 | mem.CardOffset = 0; mem.Page = 0; |
3956 | i = pcmcia_map_mem_page(link->win, &mem); | 3956 | i = pcmcia_map_mem_page(link->win, &mem); |
3957 | if(i != CS_SUCCESS) | 3957 | if (i != 0) |
3958 | { | 3958 | { |
3959 | cs_error(link, MapMemPage, i); | 3959 | cs_error(link, MapMemPage, i); |
3960 | break; | 3960 | break; |
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c index 74a5ad2f1223..68789c6e1ce9 100644 --- a/drivers/net/wireless/wl3501_cs.c +++ b/drivers/net/wireless/wl3501_cs.c | |||
@@ -1977,10 +1977,10 @@ static int wl3501_config(struct pcmcia_device *link) | |||
1977 | link->io.BasePort1 = j; | 1977 | link->io.BasePort1 = j; |
1978 | link->io.BasePort2 = link->io.BasePort1 + 0x10; | 1978 | link->io.BasePort2 = link->io.BasePort1 + 0x10; |
1979 | i = pcmcia_request_io(link, &link->io); | 1979 | i = pcmcia_request_io(link, &link->io); |
1980 | if (i == CS_SUCCESS) | 1980 | if (i == 0) |
1981 | break; | 1981 | break; |
1982 | } | 1982 | } |
1983 | if (i != CS_SUCCESS) { | 1983 | if (i != 0) { |
1984 | cs_error(link, RequestIO, i); | 1984 | cs_error(link, RequestIO, i); |
1985 | goto failed; | 1985 | goto failed; |
1986 | } | 1986 | } |
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index c749bdba214c..3c3dd403f5dd 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c | |||
@@ -1794,10 +1794,10 @@ static struct xenbus_driver netfront = { | |||
1794 | 1794 | ||
1795 | static int __init netif_init(void) | 1795 | static int __init netif_init(void) |
1796 | { | 1796 | { |
1797 | if (!is_running_on_xen()) | 1797 | if (!xen_domain()) |
1798 | return -ENODEV; | 1798 | return -ENODEV; |
1799 | 1799 | ||
1800 | if (is_initial_xendomain()) | 1800 | if (xen_initial_domain()) |
1801 | return 0; | 1801 | return 0; |
1802 | 1802 | ||
1803 | printk(KERN_INFO "Initialising Xen virtual ethernet driver.\n"); | 1803 | printk(KERN_INFO "Initialising Xen virtual ethernet driver.\n"); |
@@ -1809,7 +1809,7 @@ module_init(netif_init); | |||
1809 | 1809 | ||
1810 | static void __exit netif_exit(void) | 1810 | static void __exit netif_exit(void) |
1811 | { | 1811 | { |
1812 | if (is_initial_xendomain()) | 1812 | if (xen_initial_domain()) |
1813 | return; | 1813 | return; |
1814 | 1814 | ||
1815 | xenbus_unregister_driver(&netfront); | 1815 | xenbus_unregister_driver(&netfront); |