diff options
Diffstat (limited to 'drivers/net/wireless/netwave_cs.c')
-rw-r--r-- | drivers/net/wireless/netwave_cs.c | 127 |
1 files changed, 48 insertions, 79 deletions
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c index 75ce6ddb0cf5..9343d970537b 100644 --- a/drivers/net/wireless/netwave_cs.c +++ b/drivers/net/wireless/netwave_cs.c | |||
@@ -190,8 +190,8 @@ module_param(mem_speed, int, 0); | |||
190 | /*====================================================================*/ | 190 | /*====================================================================*/ |
191 | 191 | ||
192 | /* PCMCIA (Card Services) related functions */ | 192 | /* PCMCIA (Card Services) related functions */ |
193 | static void netwave_release(dev_link_t *link); /* Card removal */ | 193 | static void netwave_release(struct pcmcia_device *link); /* Card removal */ |
194 | static void netwave_pcmcia_config(dev_link_t *arg); /* Runs after card | 194 | static int netwave_pcmcia_config(struct pcmcia_device *arg); /* Runs after card |
195 | insertion */ | 195 | insertion */ |
196 | static void netwave_detach(struct pcmcia_device *p_dev); /* Destroy instance */ | 196 | static void netwave_detach(struct pcmcia_device *p_dev); /* Destroy instance */ |
197 | 197 | ||
@@ -221,10 +221,10 @@ static struct iw_statistics* netwave_get_wireless_stats(struct net_device *dev); | |||
221 | static void set_multicast_list(struct net_device *dev); | 221 | static void set_multicast_list(struct net_device *dev); |
222 | 222 | ||
223 | /* | 223 | /* |
224 | A dev_link_t structure has fields for most things that are needed | 224 | A struct pcmcia_device structure has fields for most things that are needed |
225 | to keep track of a socket, but there will usually be some device | 225 | to keep track of a socket, but there will usually be some device |
226 | specific information that also needs to be kept track of. The | 226 | specific information that also needs to be kept track of. The |
227 | 'priv' pointer in a dev_link_t structure can be used to point to | 227 | 'priv' pointer in a struct pcmcia_device structure can be used to point to |
228 | a device-specific private data structure, like this. | 228 | a device-specific private data structure, like this. |
229 | 229 | ||
230 | A driver needs to provide a dev_node_t structure for each device | 230 | A driver needs to provide a dev_node_t structure for each device |
@@ -232,7 +232,7 @@ static void set_multicast_list(struct net_device *dev); | |||
232 | example, ethernet cards, modems). In other cases, there may be | 232 | example, ethernet cards, modems). In other cases, there may be |
233 | many actual or logical devices (SCSI adapters, memory cards with | 233 | many actual or logical devices (SCSI adapters, memory cards with |
234 | multiple partitions). The dev_node_t structures need to be kept | 234 | multiple partitions). The dev_node_t structures need to be kept |
235 | in a linked list starting at the 'dev' field of a dev_link_t | 235 | in a linked list starting at the 'dev' field of a struct pcmcia_device |
236 | structure. We allocate them in the card's private data structure, | 236 | structure. We allocate them in the card's private data structure, |
237 | because they generally can't be allocated dynamically. | 237 | because they generally can't be allocated dynamically. |
238 | */ | 238 | */ |
@@ -268,7 +268,7 @@ struct site_survey { | |||
268 | }; | 268 | }; |
269 | 269 | ||
270 | typedef struct netwave_private { | 270 | typedef struct netwave_private { |
271 | dev_link_t link; | 271 | struct pcmcia_device *p_dev; |
272 | spinlock_t spinlock; /* Serialize access to the hardware (SMP) */ | 272 | spinlock_t spinlock; /* Serialize access to the hardware (SMP) */ |
273 | dev_node_t node; | 273 | dev_node_t node; |
274 | u_char __iomem *ramBase; | 274 | u_char __iomem *ramBase; |
@@ -376,20 +376,19 @@ static struct iw_statistics *netwave_get_wireless_stats(struct net_device *dev) | |||
376 | * configure the card at this point -- we wait until we receive a | 376 | * configure the card at this point -- we wait until we receive a |
377 | * card insertion event. | 377 | * card insertion event. |
378 | */ | 378 | */ |
379 | static int netwave_attach(struct pcmcia_device *p_dev) | 379 | static int netwave_probe(struct pcmcia_device *link) |
380 | { | 380 | { |
381 | dev_link_t *link; | ||
382 | struct net_device *dev; | 381 | struct net_device *dev; |
383 | netwave_private *priv; | 382 | netwave_private *priv; |
384 | 383 | ||
385 | DEBUG(0, "netwave_attach()\n"); | 384 | DEBUG(0, "netwave_attach()\n"); |
386 | 385 | ||
387 | /* Initialize the dev_link_t structure */ | 386 | /* Initialize the struct pcmcia_device structure */ |
388 | dev = alloc_etherdev(sizeof(netwave_private)); | 387 | dev = alloc_etherdev(sizeof(netwave_private)); |
389 | if (!dev) | 388 | if (!dev) |
390 | return -ENOMEM; | 389 | return -ENOMEM; |
391 | priv = netdev_priv(dev); | 390 | priv = netdev_priv(dev); |
392 | link = &priv->link; | 391 | priv->p_dev = link; |
393 | link->priv = dev; | 392 | link->priv = dev; |
394 | 393 | ||
395 | /* The io structure describes IO port mapping */ | 394 | /* The io structure describes IO port mapping */ |
@@ -406,7 +405,6 @@ static int netwave_attach(struct pcmcia_device *p_dev) | |||
406 | 405 | ||
407 | /* General socket configuration */ | 406 | /* General socket configuration */ |
408 | link->conf.Attributes = CONF_ENABLE_IRQ; | 407 | link->conf.Attributes = CONF_ENABLE_IRQ; |
409 | link->conf.Vcc = 50; | ||
410 | link->conf.IntType = INT_MEMORY_AND_IO; | 408 | link->conf.IntType = INT_MEMORY_AND_IO; |
411 | link->conf.ConfigIndex = 1; | 409 | link->conf.ConfigIndex = 1; |
412 | link->conf.Present = PRESENT_OPTION; | 410 | link->conf.Present = PRESENT_OPTION; |
@@ -430,13 +428,7 @@ static int netwave_attach(struct pcmcia_device *p_dev) | |||
430 | dev->stop = &netwave_close; | 428 | dev->stop = &netwave_close; |
431 | link->irq.Instance = dev; | 429 | link->irq.Instance = dev; |
432 | 430 | ||
433 | link->handle = p_dev; | 431 | return netwave_pcmcia_config( link); |
434 | p_dev->instance = link; | ||
435 | |||
436 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
437 | netwave_pcmcia_config( link); | ||
438 | |||
439 | return 0; | ||
440 | } /* netwave_attach */ | 432 | } /* netwave_attach */ |
441 | 433 | ||
442 | /* | 434 | /* |
@@ -447,17 +439,15 @@ static int netwave_attach(struct pcmcia_device *p_dev) | |||
447 | * structures are freed. Otherwise, the structures will be freed | 439 | * structures are freed. Otherwise, the structures will be freed |
448 | * when the device is released. | 440 | * when the device is released. |
449 | */ | 441 | */ |
450 | static void netwave_detach(struct pcmcia_device *p_dev) | 442 | static void netwave_detach(struct pcmcia_device *link) |
451 | { | 443 | { |
452 | dev_link_t *link = dev_to_instance(p_dev); | ||
453 | struct net_device *dev = link->priv; | 444 | struct net_device *dev = link->priv; |
454 | 445 | ||
455 | DEBUG(0, "netwave_detach(0x%p)\n", link); | 446 | DEBUG(0, "netwave_detach(0x%p)\n", link); |
456 | 447 | ||
457 | if (link->state & DEV_CONFIG) | 448 | netwave_release(link); |
458 | netwave_release(link); | ||
459 | 449 | ||
460 | if (link->dev) | 450 | if (link->dev_node) |
461 | unregister_netdev(dev); | 451 | unregister_netdev(dev); |
462 | 452 | ||
463 | free_netdev(dev); | 453 | free_netdev(dev); |
@@ -743,8 +733,7 @@ static const struct iw_handler_def netwave_handler_def = | |||
743 | #define CS_CHECK(fn, ret) \ | 733 | #define CS_CHECK(fn, ret) \ |
744 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 734 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
745 | 735 | ||
746 | static void netwave_pcmcia_config(dev_link_t *link) { | 736 | static int netwave_pcmcia_config(struct pcmcia_device *link) { |
747 | client_handle_t handle = link->handle; | ||
748 | struct net_device *dev = link->priv; | 737 | struct net_device *dev = link->priv; |
749 | netwave_private *priv = netdev_priv(dev); | 738 | netwave_private *priv = netdev_priv(dev); |
750 | tuple_t tuple; | 739 | tuple_t tuple; |
@@ -766,15 +755,12 @@ static void netwave_pcmcia_config(dev_link_t *link) { | |||
766 | tuple.TupleDataMax = 64; | 755 | tuple.TupleDataMax = 64; |
767 | tuple.TupleOffset = 0; | 756 | tuple.TupleOffset = 0; |
768 | tuple.DesiredTuple = CISTPL_CONFIG; | 757 | tuple.DesiredTuple = CISTPL_CONFIG; |
769 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | 758 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
770 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); | 759 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); |
771 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); | 760 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); |
772 | link->conf.ConfigBase = parse.config.base; | 761 | link->conf.ConfigBase = parse.config.base; |
773 | link->conf.Present = parse.config.rmask[0]; | 762 | link->conf.Present = parse.config.rmask[0]; |
774 | 763 | ||
775 | /* Configure card */ | ||
776 | link->state |= DEV_CONFIG; | ||
777 | |||
778 | /* | 764 | /* |
779 | * Try allocating IO ports. This tries a few fixed addresses. | 765 | * Try allocating IO ports. This tries a few fixed addresses. |
780 | * If you want, you can also read the card's config table to | 766 | * If you want, you can also read the card's config table to |
@@ -782,11 +768,11 @@ static void netwave_pcmcia_config(dev_link_t *link) { | |||
782 | */ | 768 | */ |
783 | for (i = j = 0x0; j < 0x400; j += 0x20) { | 769 | for (i = j = 0x0; j < 0x400; j += 0x20) { |
784 | link->io.BasePort1 = j ^ 0x300; | 770 | link->io.BasePort1 = j ^ 0x300; |
785 | i = pcmcia_request_io(link->handle, &link->io); | 771 | i = pcmcia_request_io(link, &link->io); |
786 | if (i == CS_SUCCESS) break; | 772 | if (i == CS_SUCCESS) break; |
787 | } | 773 | } |
788 | if (i != CS_SUCCESS) { | 774 | if (i != CS_SUCCESS) { |
789 | cs_error(link->handle, RequestIO, i); | 775 | cs_error(link, RequestIO, i); |
790 | goto failed; | 776 | goto failed; |
791 | } | 777 | } |
792 | 778 | ||
@@ -794,16 +780,16 @@ static void netwave_pcmcia_config(dev_link_t *link) { | |||
794 | * Now allocate an interrupt line. Note that this does not | 780 | * Now allocate an interrupt line. Note that this does not |
795 | * actually assign a handler to the interrupt. | 781 | * actually assign a handler to the interrupt. |
796 | */ | 782 | */ |
797 | CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq)); | 783 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
798 | 784 | ||
799 | /* | 785 | /* |
800 | * This actually configures the PCMCIA socket -- setting up | 786 | * This actually configures the PCMCIA socket -- setting up |
801 | * the I/O windows and the interrupt mapping. | 787 | * the I/O windows and the interrupt mapping. |
802 | */ | 788 | */ |
803 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); | 789 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); |
804 | 790 | ||
805 | /* | 791 | /* |
806 | * Allocate a 32K memory window. Note that the dev_link_t | 792 | * Allocate a 32K memory window. Note that the struct pcmcia_device |
807 | * structure provides space for one window handle -- if your | 793 | * structure provides space for one window handle -- if your |
808 | * device needs several windows, you'll need to keep track of | 794 | * device needs several windows, you'll need to keep track of |
809 | * the handles in your private data structure, dev->priv. | 795 | * the handles in your private data structure, dev->priv. |
@@ -813,7 +799,7 @@ static void netwave_pcmcia_config(dev_link_t *link) { | |||
813 | req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_CM|WIN_ENABLE; | 799 | req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_CM|WIN_ENABLE; |
814 | req.Base = 0; req.Size = 0x8000; | 800 | req.Base = 0; req.Size = 0x8000; |
815 | req.AccessSpeed = mem_speed; | 801 | req.AccessSpeed = mem_speed; |
816 | CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &link->win)); | 802 | CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win)); |
817 | mem.CardOffset = 0x20000; mem.Page = 0; | 803 | mem.CardOffset = 0x20000; mem.Page = 0; |
818 | CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem)); | 804 | CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem)); |
819 | 805 | ||
@@ -823,7 +809,7 @@ static void netwave_pcmcia_config(dev_link_t *link) { | |||
823 | 809 | ||
824 | dev->irq = link->irq.AssignedIRQ; | 810 | dev->irq = link->irq.AssignedIRQ; |
825 | dev->base_addr = link->io.BasePort1; | 811 | dev->base_addr = link->io.BasePort1; |
826 | SET_NETDEV_DEV(dev, &handle_to_dev(handle)); | 812 | SET_NETDEV_DEV(dev, &handle_to_dev(link)); |
827 | 813 | ||
828 | if (register_netdev(dev) != 0) { | 814 | if (register_netdev(dev) != 0) { |
829 | printk(KERN_DEBUG "netwave_cs: register_netdev() failed\n"); | 815 | printk(KERN_DEBUG "netwave_cs: register_netdev() failed\n"); |
@@ -831,8 +817,7 @@ static void netwave_pcmcia_config(dev_link_t *link) { | |||
831 | } | 817 | } |
832 | 818 | ||
833 | strcpy(priv->node.dev_name, dev->name); | 819 | strcpy(priv->node.dev_name, dev->name); |
834 | link->dev = &priv->node; | 820 | link->dev_node = &priv->node; |
835 | link->state &= ~DEV_CONFIG_PENDING; | ||
836 | 821 | ||
837 | /* Reset card before reading physical address */ | 822 | /* Reset card before reading physical address */ |
838 | netwave_doreset(dev->base_addr, ramBase); | 823 | netwave_doreset(dev->base_addr, ramBase); |
@@ -852,12 +837,13 @@ static void netwave_pcmcia_config(dev_link_t *link) { | |||
852 | printk(KERN_DEBUG "Netwave_reset: revision %04x %04x\n", | 837 | printk(KERN_DEBUG "Netwave_reset: revision %04x %04x\n", |
853 | get_uint16(ramBase + NETWAVE_EREG_ARW), | 838 | get_uint16(ramBase + NETWAVE_EREG_ARW), |
854 | get_uint16(ramBase + NETWAVE_EREG_ARW+2)); | 839 | get_uint16(ramBase + NETWAVE_EREG_ARW+2)); |
855 | return; | 840 | return 0; |
856 | 841 | ||
857 | cs_failed: | 842 | cs_failed: |
858 | cs_error(link->handle, last_fn, last_ret); | 843 | cs_error(link, last_fn, last_ret); |
859 | failed: | 844 | failed: |
860 | netwave_release(link); | 845 | netwave_release(link); |
846 | return -ENODEV; | ||
861 | } /* netwave_pcmcia_config */ | 847 | } /* netwave_pcmcia_config */ |
862 | 848 | ||
863 | /* | 849 | /* |
@@ -867,52 +853,35 @@ failed: | |||
867 | * device, and release the PCMCIA configuration. If the device is | 853 | * device, and release the PCMCIA configuration. If the device is |
868 | * still open, this will be postponed until it is closed. | 854 | * still open, this will be postponed until it is closed. |
869 | */ | 855 | */ |
870 | static void netwave_release(dev_link_t *link) | 856 | static void netwave_release(struct pcmcia_device *link) |
871 | { | 857 | { |
872 | struct net_device *dev = link->priv; | 858 | struct net_device *dev = link->priv; |
873 | netwave_private *priv = netdev_priv(dev); | 859 | netwave_private *priv = netdev_priv(dev); |
874 | |||
875 | DEBUG(0, "netwave_release(0x%p)\n", link); | ||
876 | 860 | ||
877 | /* Don't bother checking to see if these succeed or not */ | 861 | DEBUG(0, "netwave_release(0x%p)\n", link); |
878 | if (link->win) { | ||
879 | iounmap(priv->ramBase); | ||
880 | pcmcia_release_window(link->win); | ||
881 | } | ||
882 | pcmcia_release_configuration(link->handle); | ||
883 | pcmcia_release_io(link->handle, &link->io); | ||
884 | pcmcia_release_irq(link->handle, &link->irq); | ||
885 | 862 | ||
886 | link->state &= ~DEV_CONFIG; | 863 | pcmcia_disable_device(link); |
864 | if (link->win) | ||
865 | iounmap(priv->ramBase); | ||
887 | } | 866 | } |
888 | 867 | ||
889 | static int netwave_suspend(struct pcmcia_device *p_dev) | 868 | static int netwave_suspend(struct pcmcia_device *link) |
890 | { | 869 | { |
891 | dev_link_t *link = dev_to_instance(p_dev); | ||
892 | struct net_device *dev = link->priv; | 870 | struct net_device *dev = link->priv; |
893 | 871 | ||
894 | link->state |= DEV_SUSPEND; | 872 | if (link->open) |
895 | if (link->state & DEV_CONFIG) { | 873 | netif_device_detach(dev); |
896 | if (link->open) | ||
897 | netif_device_detach(dev); | ||
898 | pcmcia_release_configuration(link->handle); | ||
899 | } | ||
900 | 874 | ||
901 | return 0; | 875 | return 0; |
902 | } | 876 | } |
903 | 877 | ||
904 | static int netwave_resume(struct pcmcia_device *p_dev) | 878 | static int netwave_resume(struct pcmcia_device *link) |
905 | { | 879 | { |
906 | dev_link_t *link = dev_to_instance(p_dev); | ||
907 | struct net_device *dev = link->priv; | 880 | struct net_device *dev = link->priv; |
908 | 881 | ||
909 | link->state &= ~DEV_SUSPEND; | 882 | if (link->open) { |
910 | if (link->state & DEV_CONFIG) { | 883 | netwave_reset(dev); |
911 | pcmcia_request_configuration(link->handle, &link->conf); | 884 | netif_device_attach(dev); |
912 | if (link->open) { | ||
913 | netwave_reset(dev); | ||
914 | netif_device_attach(dev); | ||
915 | } | ||
916 | } | 885 | } |
917 | 886 | ||
918 | return 0; | 887 | return 0; |
@@ -1119,7 +1088,7 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id, struct pt_regs *regs | |||
1119 | u_char __iomem *ramBase; | 1088 | u_char __iomem *ramBase; |
1120 | struct net_device *dev = (struct net_device *)dev_id; | 1089 | struct net_device *dev = (struct net_device *)dev_id; |
1121 | struct netwave_private *priv = netdev_priv(dev); | 1090 | struct netwave_private *priv = netdev_priv(dev); |
1122 | dev_link_t *link = &priv->link; | 1091 | struct pcmcia_device *link = priv->p_dev; |
1123 | int i; | 1092 | int i; |
1124 | 1093 | ||
1125 | if (!netif_device_present(dev)) | 1094 | if (!netif_device_present(dev)) |
@@ -1138,7 +1107,7 @@ static irqreturn_t netwave_interrupt(int irq, void* dev_id, struct pt_regs *regs | |||
1138 | 1107 | ||
1139 | status = inb(iobase + NETWAVE_REG_ASR); | 1108 | status = inb(iobase + NETWAVE_REG_ASR); |
1140 | 1109 | ||
1141 | if (!DEV_OK(link)) { | 1110 | if (!pcmcia_dev_present(link)) { |
1142 | DEBUG(1, "netwave_interrupt: Interrupt with status 0x%x " | 1111 | DEBUG(1, "netwave_interrupt: Interrupt with status 0x%x " |
1143 | "from removed or suspended card!\n", status); | 1112 | "from removed or suspended card!\n", status); |
1144 | break; | 1113 | break; |
@@ -1373,11 +1342,11 @@ static int netwave_rx(struct net_device *dev) | |||
1373 | 1342 | ||
1374 | static int netwave_open(struct net_device *dev) { | 1343 | static int netwave_open(struct net_device *dev) { |
1375 | netwave_private *priv = netdev_priv(dev); | 1344 | netwave_private *priv = netdev_priv(dev); |
1376 | dev_link_t *link = &priv->link; | 1345 | struct pcmcia_device *link = priv->p_dev; |
1377 | 1346 | ||
1378 | DEBUG(1, "netwave_open: starting.\n"); | 1347 | DEBUG(1, "netwave_open: starting.\n"); |
1379 | 1348 | ||
1380 | if (!DEV_OK(link)) | 1349 | if (!pcmcia_dev_present(link)) |
1381 | return -ENODEV; | 1350 | return -ENODEV; |
1382 | 1351 | ||
1383 | link->open++; | 1352 | link->open++; |
@@ -1390,7 +1359,7 @@ static int netwave_open(struct net_device *dev) { | |||
1390 | 1359 | ||
1391 | static int netwave_close(struct net_device *dev) { | 1360 | static int netwave_close(struct net_device *dev) { |
1392 | netwave_private *priv = netdev_priv(dev); | 1361 | netwave_private *priv = netdev_priv(dev); |
1393 | dev_link_t *link = &priv->link; | 1362 | struct pcmcia_device *link = priv->p_dev; |
1394 | 1363 | ||
1395 | DEBUG(1, "netwave_close: finishing.\n"); | 1364 | DEBUG(1, "netwave_close: finishing.\n"); |
1396 | 1365 | ||
@@ -1411,7 +1380,7 @@ static struct pcmcia_driver netwave_driver = { | |||
1411 | .drv = { | 1380 | .drv = { |
1412 | .name = "netwave_cs", | 1381 | .name = "netwave_cs", |
1413 | }, | 1382 | }, |
1414 | .probe = netwave_attach, | 1383 | .probe = netwave_probe, |
1415 | .remove = netwave_detach, | 1384 | .remove = netwave_detach, |
1416 | .id_table = netwave_ids, | 1385 | .id_table = netwave_ids, |
1417 | .suspend = netwave_suspend, | 1386 | .suspend = netwave_suspend, |