diff options
Diffstat (limited to 'drivers/net/pcmcia/xirc2ps_cs.c')
-rw-r--r-- | drivers/net/pcmcia/xirc2ps_cs.c | 187 |
1 files changed, 77 insertions, 110 deletions
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index eed496803fe4..71f45056a70c 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c | |||
@@ -289,9 +289,9 @@ static void mii_wr(kio_addr_t ioaddr, u_char phyaddr, u_char phyreg, | |||
289 | * and ejection events. They are invoked from the event handler. | 289 | * and ejection events. They are invoked from the event handler. |
290 | */ | 290 | */ |
291 | 291 | ||
292 | static int has_ce2_string(dev_link_t * link); | 292 | static int has_ce2_string(struct pcmcia_device * link); |
293 | static void xirc2ps_config(dev_link_t * link); | 293 | static int xirc2ps_config(struct pcmcia_device * link); |
294 | static void xirc2ps_release(dev_link_t * link); | 294 | static void xirc2ps_release(struct pcmcia_device * link); |
295 | 295 | ||
296 | /**************** | 296 | /**************** |
297 | * The attach() and detach() entry points are used to create and destroy | 297 | * The attach() and detach() entry points are used to create and destroy |
@@ -313,10 +313,10 @@ static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id, struct pt_regs *regs | |||
313 | /**************** | 313 | /**************** |
314 | * A linked list of "instances" of the device. Each actual | 314 | * A linked list of "instances" of the device. Each actual |
315 | * PCMCIA card corresponds to one device instance, and is described | 315 | * PCMCIA card corresponds to one device instance, and is described |
316 | * by one dev_link_t structure (defined in ds.h). | 316 | * by one struct pcmcia_device structure (defined in ds.h). |
317 | * | 317 | * |
318 | * You may not want to use a linked list for this -- for example, the | 318 | * You may not want to use a linked list for this -- for example, the |
319 | * memory card driver uses an array of dev_link_t pointers, where minor | 319 | * memory card driver uses an array of struct pcmcia_device pointers, where minor |
320 | * device numbers are used to derive the corresponding array index. | 320 | * device numbers are used to derive the corresponding array index. |
321 | */ | 321 | */ |
322 | 322 | ||
@@ -326,13 +326,13 @@ static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id, struct pt_regs *regs | |||
326 | * example, ethernet cards, modems). In other cases, there may be | 326 | * example, ethernet cards, modems). In other cases, there may be |
327 | * many actual or logical devices (SCSI adapters, memory cards with | 327 | * many actual or logical devices (SCSI adapters, memory cards with |
328 | * multiple partitions). The dev_node_t structures need to be kept | 328 | * multiple partitions). The dev_node_t structures need to be kept |
329 | * in a linked list starting at the 'dev' field of a dev_link_t | 329 | * in a linked list starting at the 'dev' field of a struct pcmcia_device |
330 | * structure. We allocate them in the card's private data structure, | 330 | * structure. We allocate them in the card's private data structure, |
331 | * because they generally can't be allocated dynamically. | 331 | * because they generally can't be allocated dynamically. |
332 | */ | 332 | */ |
333 | 333 | ||
334 | typedef struct local_info_t { | 334 | typedef struct local_info_t { |
335 | dev_link_t link; | 335 | struct pcmcia_device *p_dev; |
336 | dev_node_t node; | 336 | dev_node_t node; |
337 | struct net_device_stats stats; | 337 | struct net_device_stats stats; |
338 | int card_type; | 338 | int card_type; |
@@ -355,7 +355,7 @@ static void do_tx_timeout(struct net_device *dev); | |||
355 | static struct net_device_stats *do_get_stats(struct net_device *dev); | 355 | static struct net_device_stats *do_get_stats(struct net_device *dev); |
356 | static void set_addresses(struct net_device *dev); | 356 | static void set_addresses(struct net_device *dev); |
357 | static void set_multicast_list(struct net_device *dev); | 357 | static void set_multicast_list(struct net_device *dev); |
358 | static int set_card_type(dev_link_t *link, const void *s); | 358 | static int set_card_type(struct pcmcia_device *link, const void *s); |
359 | static int do_config(struct net_device *dev, struct ifmap *map); | 359 | static int do_config(struct net_device *dev, struct ifmap *map); |
360 | static int do_open(struct net_device *dev); | 360 | static int do_open(struct net_device *dev); |
361 | static int do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); | 361 | static int do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); |
@@ -368,7 +368,7 @@ static int do_stop(struct net_device *dev); | |||
368 | 368 | ||
369 | /*=============== Helper functions =========================*/ | 369 | /*=============== Helper functions =========================*/ |
370 | static int | 370 | static int |
371 | first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) | 371 | first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) |
372 | { | 372 | { |
373 | int err; | 373 | int err; |
374 | 374 | ||
@@ -379,7 +379,7 @@ first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) | |||
379 | } | 379 | } |
380 | 380 | ||
381 | static int | 381 | static int |
382 | next_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) | 382 | next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) |
383 | { | 383 | { |
384 | int err; | 384 | int err; |
385 | 385 | ||
@@ -553,9 +553,8 @@ mii_wr(kio_addr_t ioaddr, u_char phyaddr, u_char phyreg, unsigned data, int len) | |||
553 | */ | 553 | */ |
554 | 554 | ||
555 | static int | 555 | static int |
556 | xirc2ps_attach(struct pcmcia_device *p_dev) | 556 | xirc2ps_probe(struct pcmcia_device *link) |
557 | { | 557 | { |
558 | dev_link_t *link; | ||
559 | struct net_device *dev; | 558 | struct net_device *dev; |
560 | local_info_t *local; | 559 | local_info_t *local; |
561 | 560 | ||
@@ -566,12 +565,11 @@ xirc2ps_attach(struct pcmcia_device *p_dev) | |||
566 | if (!dev) | 565 | if (!dev) |
567 | return -ENOMEM; | 566 | return -ENOMEM; |
568 | local = netdev_priv(dev); | 567 | local = netdev_priv(dev); |
569 | link = &local->link; | 568 | local->p_dev = link; |
570 | link->priv = dev; | 569 | link->priv = dev; |
571 | 570 | ||
572 | /* General socket configuration */ | 571 | /* General socket configuration */ |
573 | link->conf.Attributes = CONF_ENABLE_IRQ; | 572 | link->conf.Attributes = CONF_ENABLE_IRQ; |
574 | link->conf.Vcc = 50; | ||
575 | link->conf.IntType = INT_MEMORY_AND_IO; | 573 | link->conf.IntType = INT_MEMORY_AND_IO; |
576 | link->conf.ConfigIndex = 1; | 574 | link->conf.ConfigIndex = 1; |
577 | link->conf.Present = PRESENT_OPTION; | 575 | link->conf.Present = PRESENT_OPTION; |
@@ -593,13 +591,7 @@ xirc2ps_attach(struct pcmcia_device *p_dev) | |||
593 | dev->watchdog_timeo = TX_TIMEOUT; | 591 | dev->watchdog_timeo = TX_TIMEOUT; |
594 | #endif | 592 | #endif |
595 | 593 | ||
596 | link->handle = p_dev; | 594 | return xirc2ps_config(link); |
597 | p_dev->instance = link; | ||
598 | |||
599 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
600 | xirc2ps_config(link); | ||
601 | |||
602 | return 0; | ||
603 | } /* xirc2ps_attach */ | 595 | } /* xirc2ps_attach */ |
604 | 596 | ||
605 | /**************** | 597 | /**************** |
@@ -610,18 +602,16 @@ xirc2ps_attach(struct pcmcia_device *p_dev) | |||
610 | */ | 602 | */ |
611 | 603 | ||
612 | static void | 604 | static void |
613 | xirc2ps_detach(struct pcmcia_device *p_dev) | 605 | xirc2ps_detach(struct pcmcia_device *link) |
614 | { | 606 | { |
615 | dev_link_t *link = dev_to_instance(p_dev); | ||
616 | struct net_device *dev = link->priv; | 607 | struct net_device *dev = link->priv; |
617 | 608 | ||
618 | DEBUG(0, "detach(0x%p)\n", link); | 609 | DEBUG(0, "detach(0x%p)\n", link); |
619 | 610 | ||
620 | if (link->dev) | 611 | if (link->dev_node) |
621 | unregister_netdev(dev); | 612 | unregister_netdev(dev); |
622 | 613 | ||
623 | if (link->state & DEV_CONFIG) | 614 | xirc2ps_release(link); |
624 | xirc2ps_release(link); | ||
625 | 615 | ||
626 | free_netdev(dev); | 616 | free_netdev(dev); |
627 | } /* xirc2ps_detach */ | 617 | } /* xirc2ps_detach */ |
@@ -645,7 +635,7 @@ xirc2ps_detach(struct pcmcia_device *p_dev) | |||
645 | * | 635 | * |
646 | */ | 636 | */ |
647 | static int | 637 | static int |
648 | set_card_type(dev_link_t *link, const void *s) | 638 | set_card_type(struct pcmcia_device *link, const void *s) |
649 | { | 639 | { |
650 | struct net_device *dev = link->priv; | 640 | struct net_device *dev = link->priv; |
651 | local_info_t *local = netdev_priv(dev); | 641 | local_info_t *local = netdev_priv(dev); |
@@ -714,9 +704,8 @@ set_card_type(dev_link_t *link, const void *s) | |||
714 | * Returns: true if this is a CE2 | 704 | * Returns: true if this is a CE2 |
715 | */ | 705 | */ |
716 | static int | 706 | static int |
717 | has_ce2_string(dev_link_t * link) | 707 | has_ce2_string(struct pcmcia_device * link) |
718 | { | 708 | { |
719 | client_handle_t handle = link->handle; | ||
720 | tuple_t tuple; | 709 | tuple_t tuple; |
721 | cisparse_t parse; | 710 | cisparse_t parse; |
722 | u_char buf[256]; | 711 | u_char buf[256]; |
@@ -726,7 +715,7 @@ has_ce2_string(dev_link_t * link) | |||
726 | tuple.TupleDataMax = 254; | 715 | tuple.TupleDataMax = 254; |
727 | tuple.TupleOffset = 0; | 716 | tuple.TupleOffset = 0; |
728 | tuple.DesiredTuple = CISTPL_VERS_1; | 717 | tuple.DesiredTuple = CISTPL_VERS_1; |
729 | if (!first_tuple(handle, &tuple, &parse) && parse.version_1.ns > 2) { | 718 | if (!first_tuple(link, &tuple, &parse) && parse.version_1.ns > 2) { |
730 | if (strstr(parse.version_1.str + parse.version_1.ofs[2], "CE2")) | 719 | if (strstr(parse.version_1.str + parse.version_1.ofs[2], "CE2")) |
731 | return 1; | 720 | return 1; |
732 | } | 721 | } |
@@ -738,10 +727,9 @@ has_ce2_string(dev_link_t * link) | |||
738 | * is received, to configure the PCMCIA socket, and to make the | 727 | * is received, to configure the PCMCIA socket, and to make the |
739 | * ethernet device available to the system. | 728 | * ethernet device available to the system. |
740 | */ | 729 | */ |
741 | static void | 730 | static int |
742 | xirc2ps_config(dev_link_t * link) | 731 | xirc2ps_config(struct pcmcia_device * link) |
743 | { | 732 | { |
744 | client_handle_t handle = link->handle; | ||
745 | struct net_device *dev = link->priv; | 733 | struct net_device *dev = link->priv; |
746 | local_info_t *local = netdev_priv(dev); | 734 | local_info_t *local = netdev_priv(dev); |
747 | tuple_t tuple; | 735 | tuple_t tuple; |
@@ -767,7 +755,7 @@ xirc2ps_config(dev_link_t * link) | |||
767 | 755 | ||
768 | /* Is this a valid card */ | 756 | /* Is this a valid card */ |
769 | tuple.DesiredTuple = CISTPL_MANFID; | 757 | tuple.DesiredTuple = CISTPL_MANFID; |
770 | if ((err=first_tuple(handle, &tuple, &parse))) { | 758 | if ((err=first_tuple(link, &tuple, &parse))) { |
771 | printk(KNOT_XIRC "manfid not found in CIS\n"); | 759 | printk(KNOT_XIRC "manfid not found in CIS\n"); |
772 | goto failure; | 760 | goto failure; |
773 | } | 761 | } |
@@ -803,15 +791,15 @@ xirc2ps_config(dev_link_t * link) | |||
803 | 791 | ||
804 | /* get configuration stuff */ | 792 | /* get configuration stuff */ |
805 | tuple.DesiredTuple = CISTPL_CONFIG; | 793 | tuple.DesiredTuple = CISTPL_CONFIG; |
806 | if ((err=first_tuple(handle, &tuple, &parse))) | 794 | if ((err=first_tuple(link, &tuple, &parse))) |
807 | goto cis_error; | 795 | goto cis_error; |
808 | link->conf.ConfigBase = parse.config.base; | 796 | link->conf.ConfigBase = parse.config.base; |
809 | link->conf.Present = parse.config.rmask[0]; | 797 | link->conf.Present = parse.config.rmask[0]; |
810 | 798 | ||
811 | /* get the ethernet address from the CIS */ | 799 | /* get the ethernet address from the CIS */ |
812 | tuple.DesiredTuple = CISTPL_FUNCE; | 800 | tuple.DesiredTuple = CISTPL_FUNCE; |
813 | for (err = first_tuple(handle, &tuple, &parse); !err; | 801 | for (err = first_tuple(link, &tuple, &parse); !err; |
814 | err = next_tuple(handle, &tuple, &parse)) { | 802 | err = next_tuple(link, &tuple, &parse)) { |
815 | /* Once I saw two CISTPL_FUNCE_LAN_NODE_ID entries: | 803 | /* Once I saw two CISTPL_FUNCE_LAN_NODE_ID entries: |
816 | * the first one with a length of zero the second correct - | 804 | * the first one with a length of zero the second correct - |
817 | * so I skip all entries with length 0 */ | 805 | * so I skip all entries with length 0 */ |
@@ -821,8 +809,8 @@ xirc2ps_config(dev_link_t * link) | |||
821 | } | 809 | } |
822 | if (err) { /* not found: try to get the node-id from tuple 0x89 */ | 810 | if (err) { /* not found: try to get the node-id from tuple 0x89 */ |
823 | tuple.DesiredTuple = 0x89; /* data layout looks like tuple 0x22 */ | 811 | tuple.DesiredTuple = 0x89; /* data layout looks like tuple 0x22 */ |
824 | if ((err = pcmcia_get_first_tuple(handle, &tuple)) == 0 && | 812 | if ((err = pcmcia_get_first_tuple(link, &tuple)) == 0 && |
825 | (err = pcmcia_get_tuple_data(handle, &tuple)) == 0) { | 813 | (err = pcmcia_get_tuple_data(link, &tuple)) == 0) { |
826 | if (tuple.TupleDataLen == 8 && *buf == CISTPL_FUNCE_LAN_NODE_ID) | 814 | if (tuple.TupleDataLen == 8 && *buf == CISTPL_FUNCE_LAN_NODE_ID) |
827 | memcpy(&parse, buf, 8); | 815 | memcpy(&parse, buf, 8); |
828 | else | 816 | else |
@@ -831,8 +819,8 @@ xirc2ps_config(dev_link_t * link) | |||
831 | } | 819 | } |
832 | if (err) { /* another try (James Lehmer's CE2 version 4.1)*/ | 820 | if (err) { /* another try (James Lehmer's CE2 version 4.1)*/ |
833 | tuple.DesiredTuple = CISTPL_FUNCE; | 821 | tuple.DesiredTuple = CISTPL_FUNCE; |
834 | for (err = first_tuple(handle, &tuple, &parse); !err; | 822 | for (err = first_tuple(link, &tuple, &parse); !err; |
835 | err = next_tuple(handle, &tuple, &parse)) { | 823 | err = next_tuple(link, &tuple, &parse)) { |
836 | if (parse.funce.type == 0x02 && parse.funce.data[0] == 1 | 824 | if (parse.funce.type == 0x02 && parse.funce.data[0] == 1 |
837 | && parse.funce.data[1] == 6 && tuple.TupleDataLen == 13) { | 825 | && parse.funce.data[1] == 6 && tuple.TupleDataLen == 13) { |
838 | buf[1] = 4; | 826 | buf[1] = 4; |
@@ -853,9 +841,6 @@ xirc2ps_config(dev_link_t * link) | |||
853 | for (i=0; i < 6; i++) | 841 | for (i=0; i < 6; i++) |
854 | dev->dev_addr[i] = node_id->id[i]; | 842 | dev->dev_addr[i] = node_id->id[i]; |
855 | 843 | ||
856 | /* Configure card */ | ||
857 | link->state |= DEV_CONFIG; | ||
858 | |||
859 | link->io.IOAddrLines =10; | 844 | link->io.IOAddrLines =10; |
860 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; | 845 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; |
861 | link->irq.Attributes = IRQ_HANDLE_PRESENT; | 846 | link->irq.Attributes = IRQ_HANDLE_PRESENT; |
@@ -875,14 +860,14 @@ xirc2ps_config(dev_link_t * link) | |||
875 | * Ethernet port */ | 860 | * Ethernet port */ |
876 | link->io.NumPorts1 = 16; /* no Mako stuff anymore */ | 861 | link->io.NumPorts1 = 16; /* no Mako stuff anymore */ |
877 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 862 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; |
878 | for (err = first_tuple(handle, &tuple, &parse); !err; | 863 | for (err = first_tuple(link, &tuple, &parse); !err; |
879 | err = next_tuple(handle, &tuple, &parse)) { | 864 | err = next_tuple(link, &tuple, &parse)) { |
880 | if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { | 865 | if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { |
881 | for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { | 866 | for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { |
882 | link->conf.ConfigIndex = cf->index ; | 867 | link->conf.ConfigIndex = cf->index ; |
883 | link->io.BasePort2 = cf->io.win[0].base; | 868 | link->io.BasePort2 = cf->io.win[0].base; |
884 | link->io.BasePort1 = ioaddr; | 869 | link->io.BasePort1 = ioaddr; |
885 | if (!(err=pcmcia_request_io(link->handle, &link->io))) | 870 | if (!(err=pcmcia_request_io(link, &link->io))) |
886 | goto port_found; | 871 | goto port_found; |
887 | } | 872 | } |
888 | } | 873 | } |
@@ -896,15 +881,15 @@ xirc2ps_config(dev_link_t * link) | |||
896 | */ | 881 | */ |
897 | for (pass=0; pass < 2; pass++) { | 882 | for (pass=0; pass < 2; pass++) { |
898 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 883 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; |
899 | for (err = first_tuple(handle, &tuple, &parse); !err; | 884 | for (err = first_tuple(link, &tuple, &parse); !err; |
900 | err = next_tuple(handle, &tuple, &parse)){ | 885 | err = next_tuple(link, &tuple, &parse)){ |
901 | if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8){ | 886 | if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8){ |
902 | link->conf.ConfigIndex = cf->index ; | 887 | link->conf.ConfigIndex = cf->index ; |
903 | link->io.BasePort2 = cf->io.win[0].base; | 888 | link->io.BasePort2 = cf->io.win[0].base; |
904 | link->io.BasePort1 = link->io.BasePort2 | 889 | link->io.BasePort1 = link->io.BasePort2 |
905 | + (pass ? (cf->index & 0x20 ? -24:8) | 890 | + (pass ? (cf->index & 0x20 ? -24:8) |
906 | : (cf->index & 0x20 ? 8:-24)); | 891 | : (cf->index & 0x20 ? 8:-24)); |
907 | if (!(err=pcmcia_request_io(link->handle, &link->io))) | 892 | if (!(err=pcmcia_request_io(link, &link->io))) |
908 | goto port_found; | 893 | goto port_found; |
909 | } | 894 | } |
910 | } | 895 | } |
@@ -919,12 +904,12 @@ xirc2ps_config(dev_link_t * link) | |||
919 | link->io.NumPorts1 = 16; | 904 | link->io.NumPorts1 = 16; |
920 | for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { | 905 | for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { |
921 | link->io.BasePort1 = ioaddr; | 906 | link->io.BasePort1 = ioaddr; |
922 | if (!(err=pcmcia_request_io(link->handle, &link->io))) | 907 | if (!(err=pcmcia_request_io(link, &link->io))) |
923 | goto port_found; | 908 | goto port_found; |
924 | } | 909 | } |
925 | link->io.BasePort1 = 0; /* let CS decide */ | 910 | link->io.BasePort1 = 0; /* let CS decide */ |
926 | if ((err=pcmcia_request_io(link->handle, &link->io))) { | 911 | if ((err=pcmcia_request_io(link, &link->io))) { |
927 | cs_error(link->handle, RequestIO, err); | 912 | cs_error(link, RequestIO, err); |
928 | goto config_error; | 913 | goto config_error; |
929 | } | 914 | } |
930 | } | 915 | } |
@@ -936,8 +921,8 @@ xirc2ps_config(dev_link_t * link) | |||
936 | * Now allocate an interrupt line. Note that this does not | 921 | * Now allocate an interrupt line. Note that this does not |
937 | * actually assign a handler to the interrupt. | 922 | * actually assign a handler to the interrupt. |
938 | */ | 923 | */ |
939 | if ((err=pcmcia_request_irq(link->handle, &link->irq))) { | 924 | if ((err=pcmcia_request_irq(link, &link->irq))) { |
940 | cs_error(link->handle, RequestIRQ, err); | 925 | cs_error(link, RequestIRQ, err); |
941 | goto config_error; | 926 | goto config_error; |
942 | } | 927 | } |
943 | 928 | ||
@@ -945,8 +930,8 @@ xirc2ps_config(dev_link_t * link) | |||
945 | * This actually configures the PCMCIA socket -- setting up | 930 | * This actually configures the PCMCIA socket -- setting up |
946 | * the I/O windows and the interrupt mapping. | 931 | * the I/O windows and the interrupt mapping. |
947 | */ | 932 | */ |
948 | if ((err=pcmcia_request_configuration(link->handle, &link->conf))) { | 933 | if ((err=pcmcia_request_configuration(link, &link->conf))) { |
949 | cs_error(link->handle, RequestConfiguration, err); | 934 | cs_error(link, RequestConfiguration, err); |
950 | goto config_error; | 935 | goto config_error; |
951 | } | 936 | } |
952 | 937 | ||
@@ -963,15 +948,15 @@ xirc2ps_config(dev_link_t * link) | |||
963 | reg.Action = CS_WRITE; | 948 | reg.Action = CS_WRITE; |
964 | reg.Offset = CISREG_IOBASE_0; | 949 | reg.Offset = CISREG_IOBASE_0; |
965 | reg.Value = link->io.BasePort2 & 0xff; | 950 | reg.Value = link->io.BasePort2 & 0xff; |
966 | if ((err = pcmcia_access_configuration_register(link->handle, ®))) { | 951 | if ((err = pcmcia_access_configuration_register(link, ®))) { |
967 | cs_error(link->handle, AccessConfigurationRegister, err); | 952 | cs_error(link, AccessConfigurationRegister, err); |
968 | goto config_error; | 953 | goto config_error; |
969 | } | 954 | } |
970 | reg.Action = CS_WRITE; | 955 | reg.Action = CS_WRITE; |
971 | reg.Offset = CISREG_IOBASE_1; | 956 | reg.Offset = CISREG_IOBASE_1; |
972 | reg.Value = (link->io.BasePort2 >> 8) & 0xff; | 957 | reg.Value = (link->io.BasePort2 >> 8) & 0xff; |
973 | if ((err = pcmcia_access_configuration_register(link->handle, ®))) { | 958 | if ((err = pcmcia_access_configuration_register(link, ®))) { |
974 | cs_error(link->handle, AccessConfigurationRegister, err); | 959 | cs_error(link, AccessConfigurationRegister, err); |
975 | goto config_error; | 960 | goto config_error; |
976 | } | 961 | } |
977 | 962 | ||
@@ -982,15 +967,15 @@ xirc2ps_config(dev_link_t * link) | |||
982 | req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; | 967 | req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; |
983 | req.Base = req.Size = 0; | 968 | req.Base = req.Size = 0; |
984 | req.AccessSpeed = 0; | 969 | req.AccessSpeed = 0; |
985 | if ((err = pcmcia_request_window(&link->handle, &req, &link->win))) { | 970 | if ((err = pcmcia_request_window(&link, &req, &link->win))) { |
986 | cs_error(link->handle, RequestWindow, err); | 971 | cs_error(link, RequestWindow, err); |
987 | goto config_error; | 972 | goto config_error; |
988 | } | 973 | } |
989 | local->dingo_ccr = ioremap(req.Base,0x1000) + 0x0800; | 974 | local->dingo_ccr = ioremap(req.Base,0x1000) + 0x0800; |
990 | mem.CardOffset = 0x0; | 975 | mem.CardOffset = 0x0; |
991 | mem.Page = 0; | 976 | mem.Page = 0; |
992 | if ((err = pcmcia_map_mem_page(link->win, &mem))) { | 977 | if ((err = pcmcia_map_mem_page(link->win, &mem))) { |
993 | cs_error(link->handle, MapMemPage, err); | 978 | cs_error(link, MapMemPage, err); |
994 | goto config_error; | 979 | goto config_error; |
995 | } | 980 | } |
996 | 981 | ||
@@ -1050,13 +1035,12 @@ xirc2ps_config(dev_link_t * link) | |||
1050 | if (local->dingo) | 1035 | if (local->dingo) |
1051 | do_reset(dev, 1); /* a kludge to make the cem56 work */ | 1036 | do_reset(dev, 1); /* a kludge to make the cem56 work */ |
1052 | 1037 | ||
1053 | link->dev = &local->node; | 1038 | link->dev_node = &local->node; |
1054 | link->state &= ~DEV_CONFIG_PENDING; | 1039 | SET_NETDEV_DEV(dev, &handle_to_dev(link)); |
1055 | SET_NETDEV_DEV(dev, &handle_to_dev(handle)); | ||
1056 | 1040 | ||
1057 | if ((err=register_netdev(dev))) { | 1041 | if ((err=register_netdev(dev))) { |
1058 | printk(KNOT_XIRC "register_netdev() failed\n"); | 1042 | printk(KNOT_XIRC "register_netdev() failed\n"); |
1059 | link->dev = NULL; | 1043 | link->dev_node = NULL; |
1060 | goto config_error; | 1044 | goto config_error; |
1061 | } | 1045 | } |
1062 | 1046 | ||
@@ -1069,17 +1053,16 @@ xirc2ps_config(dev_link_t * link) | |||
1069 | printk("%c%02X", i?':':' ', dev->dev_addr[i]); | 1053 | printk("%c%02X", i?':':' ', dev->dev_addr[i]); |
1070 | printk("\n"); | 1054 | printk("\n"); |
1071 | 1055 | ||
1072 | return; | 1056 | return 0; |
1073 | 1057 | ||
1074 | config_error: | 1058 | config_error: |
1075 | link->state &= ~DEV_CONFIG_PENDING; | ||
1076 | xirc2ps_release(link); | 1059 | xirc2ps_release(link); |
1077 | return; | 1060 | return -ENODEV; |
1078 | 1061 | ||
1079 | cis_error: | 1062 | cis_error: |
1080 | printk(KNOT_XIRC "unable to parse CIS\n"); | 1063 | printk(KNOT_XIRC "unable to parse CIS\n"); |
1081 | failure: | 1064 | failure: |
1082 | link->state &= ~DEV_CONFIG_PENDING; | 1065 | return -ENODEV; |
1083 | } /* xirc2ps_config */ | 1066 | } /* xirc2ps_config */ |
1084 | 1067 | ||
1085 | /**************** | 1068 | /**************** |
@@ -1088,57 +1071,41 @@ xirc2ps_config(dev_link_t * link) | |||
1088 | * still open, this will be postponed until it is closed. | 1071 | * still open, this will be postponed until it is closed. |
1089 | */ | 1072 | */ |
1090 | static void | 1073 | static void |
1091 | xirc2ps_release(dev_link_t *link) | 1074 | xirc2ps_release(struct pcmcia_device *link) |
1092 | { | 1075 | { |
1076 | DEBUG(0, "release(0x%p)\n", link); | ||
1093 | 1077 | ||
1094 | DEBUG(0, "release(0x%p)\n", link); | 1078 | if (link->win) { |
1095 | 1079 | struct net_device *dev = link->priv; | |
1096 | if (link->win) { | 1080 | local_info_t *local = netdev_priv(dev); |
1097 | struct net_device *dev = link->priv; | 1081 | if (local->dingo) |
1098 | local_info_t *local = netdev_priv(dev); | 1082 | iounmap(local->dingo_ccr - 0x0800); |
1099 | if (local->dingo) | 1083 | } |
1100 | iounmap(local->dingo_ccr - 0x0800); | 1084 | pcmcia_disable_device(link); |
1101 | pcmcia_release_window(link->win); | ||
1102 | } | ||
1103 | pcmcia_release_configuration(link->handle); | ||
1104 | pcmcia_release_io(link->handle, &link->io); | ||
1105 | pcmcia_release_irq(link->handle, &link->irq); | ||
1106 | link->state &= ~DEV_CONFIG; | ||
1107 | |||
1108 | } /* xirc2ps_release */ | 1085 | } /* xirc2ps_release */ |
1109 | 1086 | ||
1110 | /*====================================================================*/ | 1087 | /*====================================================================*/ |
1111 | 1088 | ||
1112 | 1089 | ||
1113 | static int xirc2ps_suspend(struct pcmcia_device *p_dev) | 1090 | static int xirc2ps_suspend(struct pcmcia_device *link) |
1114 | { | 1091 | { |
1115 | dev_link_t *link = dev_to_instance(p_dev); | ||
1116 | struct net_device *dev = link->priv; | 1092 | struct net_device *dev = link->priv; |
1117 | 1093 | ||
1118 | link->state |= DEV_SUSPEND; | 1094 | if (link->open) { |
1119 | if (link->state & DEV_CONFIG) { | 1095 | netif_device_detach(dev); |
1120 | if (link->open) { | 1096 | do_powerdown(dev); |
1121 | netif_device_detach(dev); | ||
1122 | do_powerdown(dev); | ||
1123 | } | ||
1124 | pcmcia_release_configuration(link->handle); | ||
1125 | } | 1097 | } |
1126 | 1098 | ||
1127 | return 0; | 1099 | return 0; |
1128 | } | 1100 | } |
1129 | 1101 | ||
1130 | static int xirc2ps_resume(struct pcmcia_device *p_dev) | 1102 | static int xirc2ps_resume(struct pcmcia_device *link) |
1131 | { | 1103 | { |
1132 | dev_link_t *link = dev_to_instance(p_dev); | ||
1133 | struct net_device *dev = link->priv; | 1104 | struct net_device *dev = link->priv; |
1134 | 1105 | ||
1135 | link->state &= ~DEV_SUSPEND; | 1106 | if (link->open) { |
1136 | if (link->state & DEV_CONFIG) { | 1107 | do_reset(dev,1); |
1137 | pcmcia_request_configuration(link->handle, &link->conf); | 1108 | netif_device_attach(dev); |
1138 | if (link->open) { | ||
1139 | do_reset(dev,1); | ||
1140 | netif_device_attach(dev); | ||
1141 | } | ||
1142 | } | 1109 | } |
1143 | 1110 | ||
1144 | return 0; | 1111 | return 0; |
@@ -1552,13 +1519,13 @@ static int | |||
1552 | do_open(struct net_device *dev) | 1519 | do_open(struct net_device *dev) |
1553 | { | 1520 | { |
1554 | local_info_t *lp = netdev_priv(dev); | 1521 | local_info_t *lp = netdev_priv(dev); |
1555 | dev_link_t *link = &lp->link; | 1522 | struct pcmcia_device *link = lp->p_dev; |
1556 | 1523 | ||
1557 | DEBUG(0, "do_open(%p)\n", dev); | 1524 | DEBUG(0, "do_open(%p)\n", dev); |
1558 | 1525 | ||
1559 | /* Check that the PCMCIA card is still here. */ | 1526 | /* Check that the PCMCIA card is still here. */ |
1560 | /* Physical device present signature. */ | 1527 | /* Physical device present signature. */ |
1561 | if (!DEV_OK(link)) | 1528 | if (!pcmcia_dev_present(link)) |
1562 | return -ENODEV; | 1529 | return -ENODEV; |
1563 | 1530 | ||
1564 | /* okay */ | 1531 | /* okay */ |
@@ -1882,7 +1849,7 @@ do_stop(struct net_device *dev) | |||
1882 | { | 1849 | { |
1883 | kio_addr_t ioaddr = dev->base_addr; | 1850 | kio_addr_t ioaddr = dev->base_addr; |
1884 | local_info_t *lp = netdev_priv(dev); | 1851 | local_info_t *lp = netdev_priv(dev); |
1885 | dev_link_t *link = &lp->link; | 1852 | struct pcmcia_device *link = lp->p_dev; |
1886 | 1853 | ||
1887 | DEBUG(0, "do_stop(%p)\n", dev); | 1854 | DEBUG(0, "do_stop(%p)\n", dev); |
1888 | 1855 | ||
@@ -1935,7 +1902,7 @@ static struct pcmcia_driver xirc2ps_cs_driver = { | |||
1935 | .drv = { | 1902 | .drv = { |
1936 | .name = "xirc2ps_cs", | 1903 | .name = "xirc2ps_cs", |
1937 | }, | 1904 | }, |
1938 | .probe = xirc2ps_attach, | 1905 | .probe = xirc2ps_probe, |
1939 | .remove = xirc2ps_detach, | 1906 | .remove = xirc2ps_detach, |
1940 | .id_table = xirc2ps_ids, | 1907 | .id_table = xirc2ps_ids, |
1941 | .suspend = xirc2ps_suspend, | 1908 | .suspend = xirc2ps_suspend, |
@@ -1973,7 +1940,7 @@ static int __init setup_xirc2ps_cs(char *str) | |||
1973 | MAYBE_SET(lockup_hack, 6); | 1940 | MAYBE_SET(lockup_hack, 6); |
1974 | #undef MAYBE_SET | 1941 | #undef MAYBE_SET |
1975 | 1942 | ||
1976 | return 0; | 1943 | return 1; |
1977 | } | 1944 | } |
1978 | 1945 | ||
1979 | __setup("xirc2ps_cs=", setup_xirc2ps_cs); | 1946 | __setup("xirc2ps_cs=", setup_xirc2ps_cs); |