Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge master.kernel.org:/pub/scm/linux/kernel/git/brodo/pcmcia-2.6

* master.kernel.org:/pub/scm/linux/kernel/git/brodo/pcmcia-2.6: (33 commits)
[PATCH] pcmcia: declare pccard_iodyn_ops (fix m8xx_pcmcia.c compilation error)
[PATCH] pcmcia: fix pcmcia_device_remove oops
[PATCH] pcmcia: Add support for Possio GCC AKA PCMCIA Siemens MC45
[PATCH] pcmcia: pseudo device handling update
[PATCH] pcmcia: convert DEV_OK to pcmcia_dev_present
[PATCH] pcmcia: use bitfield instead of p_state and state
[PATCH] pcmcia: remove unused p_dev->state flags
[PATCH] pcmcia: make pcmcia_release_{io,irq} static
[PATCH] pcmcia: add return value to _config() functions
[PATCH] pcmcia: remove dev_link_t and client_handle_t indirection
[PATCH] pcmcia: embed dev_link_t into struct pcmcia_device
[PATCH] pcmcia: rename pcmcia_device.state
[PATCH] pcmcia: remove unneeded Vcc pseudo setting
[PATCH] pcmcia: remove export of pcmcia_release_configuration
[PATCH] pcmcia: default suspend and resume handling
[PATCH] pcmcia: convert remaining users of pcmcia_release_io and _irq
[PATCH] pcmcia: add pcmcia_disable_device
[PATCH] serial_cs: add Merlin U630 IDs
[PATCH] pcmcia: AT91RM9200 Compact Flash driver
[PATCH] pcmcia: socket.functions starts with 1
...

+3156 -4574
+6
Documentation/pcmcia/driver-changes.txt
··· 1 1 This file details changes in 2.6 which affect PCMCIA card driver authors: 2 2 3 + * New release helper (as of 2.6.17) 4 + Instead of calling pcmcia_release_{configuration,io,irq,win}, all that's 5 + necessary now is calling pcmcia_disable_device. As there is no valid 6 + reason left to call pcmcia_release_io and pcmcia_release_irq, the 7 + exports for them were removed. 8 + 3 9 * Unify detach and REMOVAL event code, as well as attach and INSERTION 4 10 code (as of 2.6.16) 5 11 void (*remove) (struct pcmcia_device *dev);
+35 -84
drivers/bluetooth/bluecard_cs.c
··· 65 65 66 66 67 67 typedef struct bluecard_info_t { 68 - dev_link_t link; 68 + struct pcmcia_device *p_dev; 69 69 dev_node_t node; 70 70 71 71 struct hci_dev *hdev; ··· 85 85 } bluecard_info_t; 86 86 87 87 88 - static void bluecard_config(dev_link_t *link); 89 - static void bluecard_release(dev_link_t *link); 88 + static int bluecard_config(struct pcmcia_device *link); 89 + static void bluecard_release(struct pcmcia_device *link); 90 90 91 91 static void bluecard_detach(struct pcmcia_device *p_dev); 92 92 ··· 162 162 static void bluecard_activity_led_timeout(u_long arg) 163 163 { 164 164 bluecard_info_t *info = (bluecard_info_t *)arg; 165 - unsigned int iobase = info->link.io.BasePort1; 165 + unsigned int iobase = info->p_dev->io.BasePort1; 166 166 167 167 if (!test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) 168 168 return; ··· 179 179 180 180 static void bluecard_enable_activity_led(bluecard_info_t *info) 181 181 { 182 - unsigned int iobase = info->link.io.BasePort1; 182 + unsigned int iobase = info->p_dev->io.BasePort1; 183 183 184 184 if (!test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) 185 185 return; ··· 235 235 } 236 236 237 237 do { 238 - register unsigned int iobase = info->link.io.BasePort1; 238 + register unsigned int iobase = info->p_dev->io.BasePort1; 239 239 register unsigned int offset; 240 240 register unsigned char command; 241 241 register unsigned long ready_bit; ··· 244 244 245 245 clear_bit(XMIT_WAKEUP, &(info->tx_state)); 246 246 247 - if (!(info->link.state & DEV_PRESENT)) 247 + if (!pcmcia_dev_present(info->p_dev)) 248 248 return; 249 249 250 250 if (test_bit(XMIT_BUFFER_NUMBER, &(info->tx_state))) { ··· 382 382 return; 383 383 } 384 384 385 - iobase = info->link.io.BasePort1; 385 + iobase = info->p_dev->io.BasePort1; 386 386 387 387 if (test_bit(XMIT_SENDING_READY, &(info->tx_state))) 388 388 bluecard_enable_activity_led(info); ··· 512 512 if (!test_bit(CARD_READY, &(info->hw_state))) 513 513 return IRQ_HANDLED; 514 514 515 - iobase = info->link.io.BasePort1; 515 + iobase = info->p_dev->io.BasePort1; 516 516 517 517 spin_lock(&(info->lock)); 518 518 ··· 626 626 static int bluecard_hci_open(struct hci_dev *hdev) 627 627 { 628 628 bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data); 629 - unsigned int iobase = info->link.io.BasePort1; 629 + unsigned int iobase = info->p_dev->io.BasePort1; 630 630 631 631 if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) 632 632 bluecard_hci_set_baud_rate(hdev, DEFAULT_BAUD_RATE); ··· 646 646 static int bluecard_hci_close(struct hci_dev *hdev) 647 647 { 648 648 bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data); 649 - unsigned int iobase = info->link.io.BasePort1; 649 + unsigned int iobase = info->p_dev->io.BasePort1; 650 650 651 651 if (!test_and_clear_bit(HCI_RUNNING, &(hdev->flags))) 652 652 return 0; ··· 713 713 714 714 static int bluecard_open(bluecard_info_t *info) 715 715 { 716 - unsigned int iobase = info->link.io.BasePort1; 716 + unsigned int iobase = info->p_dev->io.BasePort1; 717 717 struct hci_dev *hdev; 718 718 unsigned char id; 719 719 ··· 831 831 832 832 static int bluecard_close(bluecard_info_t *info) 833 833 { 834 - unsigned int iobase = info->link.io.BasePort1; 834 + unsigned int iobase = info->p_dev->io.BasePort1; 835 835 struct hci_dev *hdev = info->hdev; 836 836 837 837 if (!hdev) ··· 856 856 return 0; 857 857 } 858 858 859 - static int bluecard_attach(struct pcmcia_device *p_dev) 859 + static int bluecard_probe(struct pcmcia_device *link) 860 860 { 861 861 bluecard_info_t *info; 862 - dev_link_t *link; 863 862 864 863 /* Create new info device */ 865 864 info = kzalloc(sizeof(*info), GFP_KERNEL); 866 865 if (!info) 867 866 return -ENOMEM; 868 867 869 - link = &info->link; 868 + info->p_dev = link; 870 869 link->priv = info; 871 870 872 871 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; ··· 877 878 link->irq.Instance = info; 878 879 879 880 link->conf.Attributes = CONF_ENABLE_IRQ; 880 - link->conf.Vcc = 50; 881 881 link->conf.IntType = INT_MEMORY_AND_IO; 882 882 883 - link->handle = p_dev; 884 - p_dev->instance = link; 885 - 886 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 887 - bluecard_config(link); 888 - 889 - return 0; 883 + return bluecard_config(link); 890 884 } 891 885 892 886 893 - static void bluecard_detach(struct pcmcia_device *p_dev) 887 + static void bluecard_detach(struct pcmcia_device *link) 894 888 { 895 - dev_link_t *link = dev_to_instance(p_dev); 896 889 bluecard_info_t *info = link->priv; 897 890 898 - if (link->state & DEV_CONFIG) 899 - bluecard_release(link); 900 - 891 + bluecard_release(link); 901 892 kfree(info); 902 893 } 903 894 904 895 905 - static int first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) 896 + static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) 906 897 { 907 898 int i; 908 899 ··· 907 918 return pcmcia_parse_tuple(handle, tuple, parse); 908 919 } 909 920 910 - static void bluecard_config(dev_link_t *link) 921 + static int bluecard_config(struct pcmcia_device *link) 911 922 { 912 - client_handle_t handle = link->handle; 913 923 bluecard_info_t *info = link->priv; 914 924 tuple_t tuple; 915 925 u_short buf[256]; 916 926 cisparse_t parse; 917 - config_info_t config; 918 927 int i, n, last_ret, last_fn; 919 928 920 929 tuple.TupleData = (cisdata_t *)buf; ··· 922 935 923 936 /* Get configuration register information */ 924 937 tuple.DesiredTuple = CISTPL_CONFIG; 925 - last_ret = first_tuple(handle, &tuple, &parse); 938 + last_ret = first_tuple(link, &tuple, &parse); 926 939 if (last_ret != CS_SUCCESS) { 927 940 last_fn = ParseTuple; 928 941 goto cs_failed; ··· 930 943 link->conf.ConfigBase = parse.config.base; 931 944 link->conf.Present = parse.config.rmask[0]; 932 945 933 - /* Configure card */ 934 - link->state |= DEV_CONFIG; 935 - i = pcmcia_get_configuration_info(handle, &config); 936 - link->conf.Vcc = config.Vcc; 937 - 938 946 link->conf.ConfigIndex = 0x20; 939 947 link->io.NumPorts1 = 64; 940 948 link->io.IOAddrLines = 6; 941 949 942 950 for (n = 0; n < 0x400; n += 0x40) { 943 951 link->io.BasePort1 = n ^ 0x300; 944 - i = pcmcia_request_io(link->handle, &link->io); 952 + i = pcmcia_request_io(link, &link->io); 945 953 if (i == CS_SUCCESS) 946 954 break; 947 955 } 948 956 949 957 if (i != CS_SUCCESS) { 950 - cs_error(link->handle, RequestIO, i); 958 + cs_error(link, RequestIO, i); 951 959 goto failed; 952 960 } 953 961 954 - i = pcmcia_request_irq(link->handle, &link->irq); 962 + i = pcmcia_request_irq(link, &link->irq); 955 963 if (i != CS_SUCCESS) { 956 - cs_error(link->handle, RequestIRQ, i); 964 + cs_error(link, RequestIRQ, i); 957 965 link->irq.AssignedIRQ = 0; 958 966 } 959 967 960 - i = pcmcia_request_configuration(link->handle, &link->conf); 968 + i = pcmcia_request_configuration(link, &link->conf); 961 969 if (i != CS_SUCCESS) { 962 - cs_error(link->handle, RequestConfiguration, i); 970 + cs_error(link, RequestConfiguration, i); 963 971 goto failed; 964 972 } 965 973 ··· 962 980 goto failed; 963 981 964 982 strcpy(info->node.dev_name, info->hdev->name); 965 - link->dev = &info->node; 966 - link->state &= ~DEV_CONFIG_PENDING; 983 + link->dev_node = &info->node; 967 984 968 - return; 985 + return 0; 969 986 970 987 cs_failed: 971 - cs_error(link->handle, last_fn, last_ret); 988 + cs_error(link, last_fn, last_ret); 972 989 973 990 failed: 974 991 bluecard_release(link); 992 + return -ENODEV; 975 993 } 976 994 977 995 978 - static void bluecard_release(dev_link_t *link) 996 + static void bluecard_release(struct pcmcia_device *link) 979 997 { 980 998 bluecard_info_t *info = link->priv; 981 999 982 - if (link->state & DEV_PRESENT) 983 - bluecard_close(info); 1000 + bluecard_close(info); 984 1001 985 1002 del_timer(&(info->timer)); 986 1003 987 - link->dev = NULL; 988 - 989 - pcmcia_release_configuration(link->handle); 990 - pcmcia_release_io(link->handle, &link->io); 991 - pcmcia_release_irq(link->handle, &link->irq); 992 - 993 - link->state &= ~DEV_CONFIG; 994 - } 995 - 996 - static int bluecard_suspend(struct pcmcia_device *dev) 997 - { 998 - dev_link_t *link = dev_to_instance(dev); 999 - 1000 - link->state |= DEV_SUSPEND; 1001 - if (link->state & DEV_CONFIG) 1002 - pcmcia_release_configuration(link->handle); 1003 - 1004 - return 0; 1005 - } 1006 - 1007 - static int bluecard_resume(struct pcmcia_device *dev) 1008 - { 1009 - dev_link_t *link = dev_to_instance(dev); 1010 - 1011 - link->state &= ~DEV_SUSPEND; 1012 - if (DEV_OK(link)) 1013 - pcmcia_request_configuration(link->handle, &link->conf); 1014 - 1015 - return 0; 1004 + pcmcia_disable_device(link); 1016 1005 } 1017 1006 1018 1007 static struct pcmcia_device_id bluecard_ids[] = { ··· 999 1046 .drv = { 1000 1047 .name = "bluecard_cs", 1001 1048 }, 1002 - .probe = bluecard_attach, 1049 + .probe = bluecard_probe, 1003 1050 .remove = bluecard_detach, 1004 1051 .id_table = bluecard_ids, 1005 - .suspend = bluecard_suspend, 1006 - .resume = bluecard_resume, 1007 1052 }; 1008 1053 1009 1054 static int __init init_bluecard_cs(void)
+39 -91
drivers/bluetooth/bt3c_cs.c
··· 72 72 73 73 74 74 typedef struct bt3c_info_t { 75 - dev_link_t link; 75 + struct pcmcia_device *p_dev; 76 76 dev_node_t node; 77 77 78 78 struct hci_dev *hdev; ··· 88 88 } bt3c_info_t; 89 89 90 90 91 - static void bt3c_config(dev_link_t *link); 92 - static void bt3c_release(dev_link_t *link); 91 + static int bt3c_config(struct pcmcia_device *link); 92 + static void bt3c_release(struct pcmcia_device *link); 93 93 94 94 static void bt3c_detach(struct pcmcia_device *p_dev); 95 95 ··· 191 191 return; 192 192 193 193 do { 194 - register unsigned int iobase = info->link.io.BasePort1; 194 + register unsigned int iobase = info->p_dev->io.BasePort1; 195 195 register struct sk_buff *skb; 196 196 register int len; 197 197 198 - if (!(info->link.state & DEV_PRESENT)) 198 + if (!pcmcia_dev_present(info->p_dev)) 199 199 break; 200 200 201 201 ··· 229 229 return; 230 230 } 231 231 232 - iobase = info->link.io.BasePort1; 232 + iobase = info->p_dev->io.BasePort1; 233 233 234 234 avail = bt3c_read(iobase, 0x7006); 235 235 //printk("bt3c_cs: receiving %d bytes\n", avail); ··· 350 350 return IRQ_NONE; 351 351 } 352 352 353 - iobase = info->link.io.BasePort1; 353 + iobase = info->p_dev->io.BasePort1; 354 354 355 355 spin_lock(&(info->lock)); 356 356 ··· 481 481 unsigned int iobase, size, addr, fcs, tmp; 482 482 int i, err = 0; 483 483 484 - iobase = info->link.io.BasePort1; 484 + iobase = info->p_dev->io.BasePort1; 485 485 486 486 /* Reset */ 487 487 bt3c_io_write(iobase, 0x8040, 0x0404); ··· 562 562 { 563 563 const struct firmware *firmware; 564 564 struct hci_dev *hdev; 565 - client_handle_t handle; 566 565 int err; 567 566 568 567 spin_lock_init(&(info->lock)); ··· 593 594 594 595 hdev->owner = THIS_MODULE; 595 596 596 - handle = info->link.handle; 597 - 598 597 /* Load firmware */ 599 - err = request_firmware(&firmware, "BT3CPCC.bin", &handle_to_dev(handle)); 598 + err = request_firmware(&firmware, "BT3CPCC.bin", &info->p_dev->dev); 600 599 if (err < 0) { 601 600 BT_ERR("Firmware request failed"); 602 601 goto error; ··· 645 648 return 0; 646 649 } 647 650 648 - static int bt3c_attach(struct pcmcia_device *p_dev) 651 + static int bt3c_probe(struct pcmcia_device *link) 649 652 { 650 653 bt3c_info_t *info; 651 - dev_link_t *link; 652 654 653 655 /* Create new info device */ 654 656 info = kzalloc(sizeof(*info), GFP_KERNEL); 655 657 if (!info) 656 658 return -ENOMEM; 657 659 658 - link = &info->link; 660 + info->p_dev = link; 659 661 link->priv = info; 660 662 661 663 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; ··· 666 670 link->irq.Instance = info; 667 671 668 672 link->conf.Attributes = CONF_ENABLE_IRQ; 669 - link->conf.Vcc = 50; 670 673 link->conf.IntType = INT_MEMORY_AND_IO; 671 674 672 - link->handle = p_dev; 673 - p_dev->instance = link; 674 - 675 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 676 - bt3c_config(link); 677 - 678 - return 0; 675 + return bt3c_config(link); 679 676 } 680 677 681 678 682 - static void bt3c_detach(struct pcmcia_device *p_dev) 679 + static void bt3c_detach(struct pcmcia_device *link) 683 680 { 684 - dev_link_t *link = dev_to_instance(p_dev); 685 681 bt3c_info_t *info = link->priv; 686 682 687 - if (link->state & DEV_CONFIG) 688 - bt3c_release(link); 689 - 683 + bt3c_release(link); 690 684 kfree(info); 691 685 } 692 686 693 - static int get_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) 687 + static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) 694 688 { 695 689 int i; 696 690 ··· 691 705 return pcmcia_parse_tuple(handle, tuple, parse); 692 706 } 693 707 694 - static int first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) 708 + static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) 695 709 { 696 710 if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS) 697 711 return CS_NO_MORE_ITEMS; 698 712 return get_tuple(handle, tuple, parse); 699 713 } 700 714 701 - static int next_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) 715 + static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) 702 716 { 703 717 if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS) 704 718 return CS_NO_MORE_ITEMS; 705 719 return get_tuple(handle, tuple, parse); 706 720 } 707 721 708 - static void bt3c_config(dev_link_t *link) 722 + static int bt3c_config(struct pcmcia_device *link) 709 723 { 710 724 static kio_addr_t base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 711 - client_handle_t handle = link->handle; 712 725 bt3c_info_t *info = link->priv; 713 726 tuple_t tuple; 714 727 u_short buf[256]; 715 728 cisparse_t parse; 716 729 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 717 - config_info_t config; 718 730 int i, j, try, last_ret, last_fn; 719 731 720 732 tuple.TupleData = (cisdata_t *)buf; ··· 722 738 723 739 /* Get configuration register information */ 724 740 tuple.DesiredTuple = CISTPL_CONFIG; 725 - last_ret = first_tuple(handle, &tuple, &parse); 741 + last_ret = first_tuple(link, &tuple, &parse); 726 742 if (last_ret != CS_SUCCESS) { 727 743 last_fn = ParseTuple; 728 744 goto cs_failed; 729 745 } 730 746 link->conf.ConfigBase = parse.config.base; 731 747 link->conf.Present = parse.config.rmask[0]; 732 - 733 - /* Configure card */ 734 - link->state |= DEV_CONFIG; 735 - i = pcmcia_get_configuration_info(handle, &config); 736 - link->conf.Vcc = config.Vcc; 737 748 738 749 /* First pass: look for a config entry that looks normal. */ 739 750 tuple.TupleData = (cisdata_t *)buf; ··· 738 759 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 739 760 /* Two tries: without IO aliases, then with aliases */ 740 761 for (try = 0; try < 2; try++) { 741 - i = first_tuple(handle, &tuple, &parse); 762 + i = first_tuple(link, &tuple, &parse); 742 763 while (i != CS_NO_MORE_ITEMS) { 743 764 if (i != CS_SUCCESS) 744 765 goto next_entry; 745 766 if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) 746 - link->conf.Vpp1 = link->conf.Vpp2 = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; 767 + link->conf.Vpp = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; 747 768 if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && (cf->io.win[0].base != 0)) { 748 769 link->conf.ConfigIndex = cf->index; 749 770 link->io.BasePort1 = cf->io.win[0].base; 750 771 link->io.IOAddrLines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK; 751 - i = pcmcia_request_io(link->handle, &link->io); 772 + i = pcmcia_request_io(link, &link->io); 752 773 if (i == CS_SUCCESS) 753 774 goto found_port; 754 775 } 755 776 next_entry: 756 - i = next_tuple(handle, &tuple, &parse); 777 + i = next_tuple(link, &tuple, &parse); 757 778 } 758 779 } 759 780 760 781 /* Second pass: try to find an entry that isn't picky about 761 782 its base address, then try to grab any standard serial port 762 783 address, and finally try to get any free port. */ 763 - i = first_tuple(handle, &tuple, &parse); 784 + i = first_tuple(link, &tuple, &parse); 764 785 while (i != CS_NO_MORE_ITEMS) { 765 786 if ((i == CS_SUCCESS) && (cf->io.nwin > 0) && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { 766 787 link->conf.ConfigIndex = cf->index; 767 788 for (j = 0; j < 5; j++) { 768 789 link->io.BasePort1 = base[j]; 769 790 link->io.IOAddrLines = base[j] ? 16 : 3; 770 - i = pcmcia_request_io(link->handle, &link->io); 791 + i = pcmcia_request_io(link, &link->io); 771 792 if (i == CS_SUCCESS) 772 793 goto found_port; 773 794 } 774 795 } 775 - i = next_tuple(handle, &tuple, &parse); 796 + i = next_tuple(link, &tuple, &parse); 776 797 } 777 798 778 799 found_port: 779 800 if (i != CS_SUCCESS) { 780 801 BT_ERR("No usable port range found"); 781 - cs_error(link->handle, RequestIO, i); 802 + cs_error(link, RequestIO, i); 782 803 goto failed; 783 804 } 784 805 785 - i = pcmcia_request_irq(link->handle, &link->irq); 806 + i = pcmcia_request_irq(link, &link->irq); 786 807 if (i != CS_SUCCESS) { 787 - cs_error(link->handle, RequestIRQ, i); 808 + cs_error(link, RequestIRQ, i); 788 809 link->irq.AssignedIRQ = 0; 789 810 } 790 811 791 - i = pcmcia_request_configuration(link->handle, &link->conf); 812 + i = pcmcia_request_configuration(link, &link->conf); 792 813 if (i != CS_SUCCESS) { 793 - cs_error(link->handle, RequestConfiguration, i); 814 + cs_error(link, RequestConfiguration, i); 794 815 goto failed; 795 816 } 796 817 ··· 798 819 goto failed; 799 820 800 821 strcpy(info->node.dev_name, info->hdev->name); 801 - link->dev = &info->node; 802 - link->state &= ~DEV_CONFIG_PENDING; 822 + link->dev_node = &info->node; 803 823 804 - return; 824 + return 0; 805 825 806 826 cs_failed: 807 - cs_error(link->handle, last_fn, last_ret); 827 + cs_error(link, last_fn, last_ret); 808 828 809 829 failed: 810 830 bt3c_release(link); 831 + return -ENODEV; 811 832 } 812 833 813 834 814 - static void bt3c_release(dev_link_t *link) 835 + static void bt3c_release(struct pcmcia_device *link) 815 836 { 816 837 bt3c_info_t *info = link->priv; 817 838 818 - if (link->state & DEV_PRESENT) 819 - bt3c_close(info); 839 + bt3c_close(info); 820 840 821 - link->dev = NULL; 822 - 823 - pcmcia_release_configuration(link->handle); 824 - pcmcia_release_io(link->handle, &link->io); 825 - pcmcia_release_irq(link->handle, &link->irq); 826 - 827 - link->state &= ~DEV_CONFIG; 828 - } 829 - 830 - static int bt3c_suspend(struct pcmcia_device *dev) 831 - { 832 - dev_link_t *link = dev_to_instance(dev); 833 - 834 - link->state |= DEV_SUSPEND; 835 - if (link->state & DEV_CONFIG) 836 - pcmcia_release_configuration(link->handle); 837 - 838 - return 0; 839 - } 840 - 841 - static int bt3c_resume(struct pcmcia_device *dev) 842 - { 843 - dev_link_t *link = dev_to_instance(dev); 844 - 845 - link->state &= ~DEV_SUSPEND; 846 - if (DEV_OK(link)) 847 - pcmcia_request_configuration(link->handle, &link->conf); 848 - 849 - return 0; 841 + pcmcia_disable_device(link); 850 842 } 851 843 852 844 ··· 832 882 .drv = { 833 883 .name = "bt3c_cs", 834 884 }, 835 - .probe = bt3c_attach, 885 + .probe = bt3c_probe, 836 886 .remove = bt3c_detach, 837 887 .id_table = bt3c_ids, 838 - .suspend = bt3c_suspend, 839 - .resume = bt3c_resume, 840 888 }; 841 889 842 890 static int __init init_bt3c_cs(void)
+40 -90
drivers/bluetooth/btuart_cs.c
··· 68 68 69 69 70 70 typedef struct btuart_info_t { 71 - dev_link_t link; 71 + struct pcmcia_device *p_dev; 72 72 dev_node_t node; 73 73 74 74 struct hci_dev *hdev; ··· 84 84 } btuart_info_t; 85 85 86 86 87 - static void btuart_config(dev_link_t *link); 88 - static void btuart_release(dev_link_t *link); 87 + static int btuart_config(struct pcmcia_device *link); 88 + static void btuart_release(struct pcmcia_device *link); 89 89 90 90 static void btuart_detach(struct pcmcia_device *p_dev); 91 91 ··· 146 146 } 147 147 148 148 do { 149 - register unsigned int iobase = info->link.io.BasePort1; 149 + register unsigned int iobase = info->p_dev->io.BasePort1; 150 150 register struct sk_buff *skb; 151 151 register int len; 152 152 153 153 clear_bit(XMIT_WAKEUP, &(info->tx_state)); 154 154 155 - if (!(info->link.state & DEV_PRESENT)) 155 + if (!pcmcia_dev_present(info->p_dev)) 156 156 return; 157 157 158 158 if (!(skb = skb_dequeue(&(info->txq)))) ··· 187 187 return; 188 188 } 189 189 190 - iobase = info->link.io.BasePort1; 190 + iobase = info->p_dev->io.BasePort1; 191 191 192 192 do { 193 193 info->hdev->stat.byte_rx++; ··· 301 301 return IRQ_NONE; 302 302 } 303 303 304 - iobase = info->link.io.BasePort1; 304 + iobase = info->p_dev->io.BasePort1; 305 305 306 306 spin_lock(&(info->lock)); 307 307 ··· 357 357 return; 358 358 } 359 359 360 - iobase = info->link.io.BasePort1; 360 + iobase = info->p_dev->io.BasePort1; 361 361 362 362 spin_lock_irqsave(&(info->lock), flags); 363 363 ··· 481 481 static int btuart_open(btuart_info_t *info) 482 482 { 483 483 unsigned long flags; 484 - unsigned int iobase = info->link.io.BasePort1; 484 + unsigned int iobase = info->p_dev->io.BasePort1; 485 485 struct hci_dev *hdev; 486 486 487 487 spin_lock_init(&(info->lock)); ··· 550 550 static int btuart_close(btuart_info_t *info) 551 551 { 552 552 unsigned long flags; 553 - unsigned int iobase = info->link.io.BasePort1; 553 + unsigned int iobase = info->p_dev->io.BasePort1; 554 554 struct hci_dev *hdev = info->hdev; 555 555 556 556 if (!hdev) ··· 576 576 return 0; 577 577 } 578 578 579 - static int btuart_attach(struct pcmcia_device *p_dev) 579 + static int btuart_probe(struct pcmcia_device *link) 580 580 { 581 581 btuart_info_t *info; 582 - dev_link_t *link; 583 582 584 583 /* Create new info device */ 585 584 info = kzalloc(sizeof(*info), GFP_KERNEL); 586 585 if (!info) 587 586 return -ENOMEM; 588 587 589 - link = &info->link; 588 + info->p_dev = link; 590 589 link->priv = info; 591 590 592 591 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; ··· 597 598 link->irq.Instance = info; 598 599 599 600 link->conf.Attributes = CONF_ENABLE_IRQ; 600 - link->conf.Vcc = 50; 601 601 link->conf.IntType = INT_MEMORY_AND_IO; 602 602 603 - link->handle = p_dev; 604 - p_dev->instance = link; 605 - 606 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 607 - btuart_config(link); 608 - 609 - return 0; 603 + return btuart_config(link); 610 604 } 611 605 612 606 613 - static void btuart_detach(struct pcmcia_device *p_dev) 607 + static void btuart_detach(struct pcmcia_device *link) 614 608 { 615 - dev_link_t *link = dev_to_instance(p_dev); 616 609 btuart_info_t *info = link->priv; 617 610 618 - if (link->state & DEV_CONFIG) 619 - btuart_release(link); 620 - 611 + btuart_release(link); 621 612 kfree(info); 622 613 } 623 614 624 - static int get_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) 615 + static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) 625 616 { 626 617 int i; 627 618 ··· 622 633 return pcmcia_parse_tuple(handle, tuple, parse); 623 634 } 624 635 625 - static int first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) 636 + static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) 626 637 { 627 638 if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS) 628 639 return CS_NO_MORE_ITEMS; 629 640 return get_tuple(handle, tuple, parse); 630 641 } 631 642 632 - static int next_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) 643 + static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) 633 644 { 634 645 if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS) 635 646 return CS_NO_MORE_ITEMS; 636 647 return get_tuple(handle, tuple, parse); 637 648 } 638 649 639 - static void btuart_config(dev_link_t *link) 650 + static int btuart_config(struct pcmcia_device *link) 640 651 { 641 652 static kio_addr_t base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 642 - client_handle_t handle = link->handle; 643 653 btuart_info_t *info = link->priv; 644 654 tuple_t tuple; 645 655 u_short buf[256]; 646 656 cisparse_t parse; 647 657 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 648 - config_info_t config; 649 658 int i, j, try, last_ret, last_fn; 650 659 651 660 tuple.TupleData = (cisdata_t *)buf; ··· 653 666 654 667 /* Get configuration register information */ 655 668 tuple.DesiredTuple = CISTPL_CONFIG; 656 - last_ret = first_tuple(handle, &tuple, &parse); 669 + last_ret = first_tuple(link, &tuple, &parse); 657 670 if (last_ret != CS_SUCCESS) { 658 671 last_fn = ParseTuple; 659 672 goto cs_failed; 660 673 } 661 674 link->conf.ConfigBase = parse.config.base; 662 675 link->conf.Present = parse.config.rmask[0]; 663 - 664 - /* Configure card */ 665 - link->state |= DEV_CONFIG; 666 - i = pcmcia_get_configuration_info(handle, &config); 667 - link->conf.Vcc = config.Vcc; 668 676 669 677 /* First pass: look for a config entry that looks normal. */ 670 678 tuple.TupleData = (cisdata_t *) buf; ··· 669 687 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 670 688 /* Two tries: without IO aliases, then with aliases */ 671 689 for (try = 0; try < 2; try++) { 672 - i = first_tuple(handle, &tuple, &parse); 690 + i = first_tuple(link, &tuple, &parse); 673 691 while (i != CS_NO_MORE_ITEMS) { 674 692 if (i != CS_SUCCESS) 675 693 goto next_entry; 676 694 if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) 677 - link->conf.Vpp1 = link->conf.Vpp2 = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; 695 + link->conf.Vpp = cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; 678 696 if ((cf->io.nwin > 0) && (cf->io.win[0].len == 8) && (cf->io.win[0].base != 0)) { 679 697 link->conf.ConfigIndex = cf->index; 680 698 link->io.BasePort1 = cf->io.win[0].base; 681 699 link->io.IOAddrLines = (try == 0) ? 16 : cf->io.flags & CISTPL_IO_LINES_MASK; 682 - i = pcmcia_request_io(link->handle, &link->io); 700 + i = pcmcia_request_io(link, &link->io); 683 701 if (i == CS_SUCCESS) 684 702 goto found_port; 685 703 } 686 704 next_entry: 687 - i = next_tuple(handle, &tuple, &parse); 705 + i = next_tuple(link, &tuple, &parse); 688 706 } 689 707 } 690 708 691 709 /* Second pass: try to find an entry that isn't picky about 692 710 its base address, then try to grab any standard serial port 693 711 address, and finally try to get any free port. */ 694 - i = first_tuple(handle, &tuple, &parse); 712 + i = first_tuple(link, &tuple, &parse); 695 713 while (i != CS_NO_MORE_ITEMS) { 696 714 if ((i == CS_SUCCESS) && (cf->io.nwin > 0) 697 715 && ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { ··· 699 717 for (j = 0; j < 5; j++) { 700 718 link->io.BasePort1 = base[j]; 701 719 link->io.IOAddrLines = base[j] ? 16 : 3; 702 - i = pcmcia_request_io(link->handle, &link->io); 720 + i = pcmcia_request_io(link, &link->io); 703 721 if (i == CS_SUCCESS) 704 722 goto found_port; 705 723 } 706 724 } 707 - i = next_tuple(handle, &tuple, &parse); 725 + i = next_tuple(link, &tuple, &parse); 708 726 } 709 727 710 728 found_port: 711 729 if (i != CS_SUCCESS) { 712 730 BT_ERR("No usable port range found"); 713 - cs_error(link->handle, RequestIO, i); 731 + cs_error(link, RequestIO, i); 714 732 goto failed; 715 733 } 716 734 717 - i = pcmcia_request_irq(link->handle, &link->irq); 735 + i = pcmcia_request_irq(link, &link->irq); 718 736 if (i != CS_SUCCESS) { 719 - cs_error(link->handle, RequestIRQ, i); 737 + cs_error(link, RequestIRQ, i); 720 738 link->irq.AssignedIRQ = 0; 721 739 } 722 740 723 - i = pcmcia_request_configuration(link->handle, &link->conf); 741 + i = pcmcia_request_configuration(link, &link->conf); 724 742 if (i != CS_SUCCESS) { 725 - cs_error(link->handle, RequestConfiguration, i); 743 + cs_error(link, RequestConfiguration, i); 726 744 goto failed; 727 745 } 728 746 ··· 730 748 goto failed; 731 749 732 750 strcpy(info->node.dev_name, info->hdev->name); 733 - link->dev = &info->node; 734 - link->state &= ~DEV_CONFIG_PENDING; 751 + link->dev_node = &info->node; 735 752 736 - return; 753 + return 0; 737 754 738 755 cs_failed: 739 - cs_error(link->handle, last_fn, last_ret); 756 + cs_error(link, last_fn, last_ret); 740 757 741 758 failed: 742 759 btuart_release(link); 760 + return -ENODEV; 743 761 } 744 762 745 763 746 - static void btuart_release(dev_link_t *link) 764 + static void btuart_release(struct pcmcia_device *link) 747 765 { 748 766 btuart_info_t *info = link->priv; 749 767 750 - if (link->state & DEV_PRESENT) 751 - btuart_close(info); 768 + btuart_close(info); 752 769 753 - link->dev = NULL; 754 - 755 - pcmcia_release_configuration(link->handle); 756 - pcmcia_release_io(link->handle, &link->io); 757 - pcmcia_release_irq(link->handle, &link->irq); 758 - 759 - link->state &= ~DEV_CONFIG; 770 + pcmcia_disable_device(link); 760 771 } 761 - 762 - static int btuart_suspend(struct pcmcia_device *dev) 763 - { 764 - dev_link_t *link = dev_to_instance(dev); 765 - 766 - link->state |= DEV_SUSPEND; 767 - if (link->state & DEV_CONFIG) 768 - pcmcia_release_configuration(link->handle); 769 - 770 - return 0; 771 - } 772 - 773 - static int btuart_resume(struct pcmcia_device *dev) 774 - { 775 - dev_link_t *link = dev_to_instance(dev); 776 - 777 - link->state &= ~DEV_SUSPEND; 778 - if (DEV_OK(link)) 779 - pcmcia_request_configuration(link->handle, &link->conf); 780 - 781 - return 0; 782 - } 783 - 784 772 785 773 static struct pcmcia_device_id btuart_ids[] = { 786 774 /* don't use this driver. Use serial_cs + hci_uart instead */ ··· 763 811 .drv = { 764 812 .name = "btuart_cs", 765 813 }, 766 - .probe = btuart_attach, 814 + .probe = btuart_probe, 767 815 .remove = btuart_detach, 768 816 .id_table = btuart_ids, 769 - .suspend = btuart_suspend, 770 - .resume = btuart_resume, 771 817 }; 772 818 773 819 static int __init init_btuart_cs(void)
+36 -84
drivers/bluetooth/dtl1_cs.c
··· 68 68 69 69 70 70 typedef struct dtl1_info_t { 71 - dev_link_t link; 71 + struct pcmcia_device *p_dev; 72 72 dev_node_t node; 73 73 74 74 struct hci_dev *hdev; ··· 87 87 } dtl1_info_t; 88 88 89 89 90 - static void dtl1_config(dev_link_t *link); 91 - static void dtl1_release(dev_link_t *link); 90 + static int dtl1_config(struct pcmcia_device *link); 91 + static void dtl1_release(struct pcmcia_device *link); 92 92 93 93 static void dtl1_detach(struct pcmcia_device *p_dev); 94 94 ··· 153 153 } 154 154 155 155 do { 156 - register unsigned int iobase = info->link.io.BasePort1; 156 + register unsigned int iobase = info->p_dev->io.BasePort1; 157 157 register struct sk_buff *skb; 158 158 register int len; 159 159 160 160 clear_bit(XMIT_WAKEUP, &(info->tx_state)); 161 161 162 - if (!(info->link.state & DEV_PRESENT)) 162 + if (!pcmcia_dev_present(info->p_dev)) 163 163 return; 164 164 165 165 if (!(skb = skb_dequeue(&(info->txq)))) ··· 218 218 return; 219 219 } 220 220 221 - iobase = info->link.io.BasePort1; 221 + iobase = info->p_dev->io.BasePort1; 222 222 223 223 do { 224 224 info->hdev->stat.byte_rx++; ··· 305 305 return IRQ_NONE; 306 306 } 307 307 308 - iobase = info->link.io.BasePort1; 308 + iobase = info->p_dev->io.BasePort1; 309 309 310 310 spin_lock(&(info->lock)); 311 311 ··· 458 458 static int dtl1_open(dtl1_info_t *info) 459 459 { 460 460 unsigned long flags; 461 - unsigned int iobase = info->link.io.BasePort1; 461 + unsigned int iobase = info->p_dev->io.BasePort1; 462 462 struct hci_dev *hdev; 463 463 464 464 spin_lock_init(&(info->lock)); ··· 504 504 outb(UART_LCR_WLEN8, iobase + UART_LCR); /* Reset DLAB */ 505 505 outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), iobase + UART_MCR); 506 506 507 - info->ri_latch = inb(info->link.io.BasePort1 + UART_MSR) & UART_MSR_RI; 507 + info->ri_latch = inb(info->p_dev->io.BasePort1 + UART_MSR) & UART_MSR_RI; 508 508 509 509 /* Turn on interrupts */ 510 510 outb(UART_IER_RLSI | UART_IER_RDI | UART_IER_THRI, iobase + UART_IER); ··· 529 529 static int dtl1_close(dtl1_info_t *info) 530 530 { 531 531 unsigned long flags; 532 - unsigned int iobase = info->link.io.BasePort1; 532 + unsigned int iobase = info->p_dev->io.BasePort1; 533 533 struct hci_dev *hdev = info->hdev; 534 534 535 535 if (!hdev) ··· 555 555 return 0; 556 556 } 557 557 558 - static int dtl1_attach(struct pcmcia_device *p_dev) 558 + static int dtl1_probe(struct pcmcia_device *link) 559 559 { 560 560 dtl1_info_t *info; 561 - dev_link_t *link; 562 561 563 562 /* Create new info device */ 564 563 info = kzalloc(sizeof(*info), GFP_KERNEL); 565 564 if (!info) 566 565 return -ENOMEM; 567 566 568 - link = &info->link; 567 + info->p_dev = link; 569 568 link->priv = info; 570 569 571 570 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; ··· 576 577 link->irq.Instance = info; 577 578 578 579 link->conf.Attributes = CONF_ENABLE_IRQ; 579 - link->conf.Vcc = 50; 580 580 link->conf.IntType = INT_MEMORY_AND_IO; 581 581 582 - link->handle = p_dev; 583 - p_dev->instance = link; 584 - 585 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 586 - dtl1_config(link); 587 - 588 - return 0; 582 + return dtl1_config(link); 589 583 } 590 584 591 585 592 - static void dtl1_detach(struct pcmcia_device *p_dev) 586 + static void dtl1_detach(struct pcmcia_device *link) 593 587 { 594 - dev_link_t *link = dev_to_instance(p_dev); 595 588 dtl1_info_t *info = link->priv; 596 589 597 - if (link->state & DEV_CONFIG) 598 - dtl1_release(link); 590 + dtl1_release(link); 599 591 600 592 kfree(info); 601 593 } 602 594 603 - static int get_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) 595 + static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) 604 596 { 605 597 int i; 606 598 ··· 602 612 return pcmcia_parse_tuple(handle, tuple, parse); 603 613 } 604 614 605 - static int first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) 615 + static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) 606 616 { 607 617 if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS) 608 618 return CS_NO_MORE_ITEMS; 609 619 return get_tuple(handle, tuple, parse); 610 620 } 611 621 612 - static int next_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse) 622 + static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, cisparse_t *parse) 613 623 { 614 624 if (pcmcia_get_next_tuple(handle, tuple) != CS_SUCCESS) 615 625 return CS_NO_MORE_ITEMS; 616 626 return get_tuple(handle, tuple, parse); 617 627 } 618 628 619 - static void dtl1_config(dev_link_t *link) 629 + static int dtl1_config(struct pcmcia_device *link) 620 630 { 621 - client_handle_t handle = link->handle; 622 631 dtl1_info_t *info = link->priv; 623 632 tuple_t tuple; 624 633 u_short buf[256]; 625 634 cisparse_t parse; 626 635 cistpl_cftable_entry_t *cf = &parse.cftable_entry; 627 - config_info_t config; 628 636 int i, last_ret, last_fn; 629 637 630 638 tuple.TupleData = (cisdata_t *)buf; ··· 632 644 633 645 /* Get configuration register information */ 634 646 tuple.DesiredTuple = CISTPL_CONFIG; 635 - last_ret = first_tuple(handle, &tuple, &parse); 647 + last_ret = first_tuple(link, &tuple, &parse); 636 648 if (last_ret != CS_SUCCESS) { 637 649 last_fn = ParseTuple; 638 650 goto cs_failed; 639 651 } 640 652 link->conf.ConfigBase = parse.config.base; 641 653 link->conf.Present = parse.config.rmask[0]; 642 - 643 - /* Configure card */ 644 - link->state |= DEV_CONFIG; 645 - i = pcmcia_get_configuration_info(handle, &config); 646 - link->conf.Vcc = config.Vcc; 647 654 648 655 tuple.TupleData = (cisdata_t *)buf; 649 656 tuple.TupleOffset = 0; ··· 648 665 649 666 /* Look for a generic full-sized window */ 650 667 link->io.NumPorts1 = 8; 651 - i = first_tuple(handle, &tuple, &parse); 668 + i = first_tuple(link, &tuple, &parse); 652 669 while (i != CS_NO_MORE_ITEMS) { 653 670 if ((i == CS_SUCCESS) && (cf->io.nwin == 1) && (cf->io.win[0].len > 8)) { 654 671 link->conf.ConfigIndex = cf->index; 655 672 link->io.BasePort1 = cf->io.win[0].base; 656 673 link->io.NumPorts1 = cf->io.win[0].len; /*yo */ 657 674 link->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; 658 - i = pcmcia_request_io(link->handle, &link->io); 675 + i = pcmcia_request_io(link, &link->io); 659 676 if (i == CS_SUCCESS) 660 677 break; 661 678 } 662 - i = next_tuple(handle, &tuple, &parse); 679 + i = next_tuple(link, &tuple, &parse); 663 680 } 664 681 665 682 if (i != CS_SUCCESS) { 666 - cs_error(link->handle, RequestIO, i); 683 + cs_error(link, RequestIO, i); 667 684 goto failed; 668 685 } 669 686 670 - i = pcmcia_request_irq(link->handle, &link->irq); 687 + i = pcmcia_request_irq(link, &link->irq); 671 688 if (i != CS_SUCCESS) { 672 - cs_error(link->handle, RequestIRQ, i); 689 + cs_error(link, RequestIRQ, i); 673 690 link->irq.AssignedIRQ = 0; 674 691 } 675 692 676 - i = pcmcia_request_configuration(link->handle, &link->conf); 693 + i = pcmcia_request_configuration(link, &link->conf); 677 694 if (i != CS_SUCCESS) { 678 - cs_error(link->handle, RequestConfiguration, i); 695 + cs_error(link, RequestConfiguration, i); 679 696 goto failed; 680 697 } 681 698 ··· 683 700 goto failed; 684 701 685 702 strcpy(info->node.dev_name, info->hdev->name); 686 - link->dev = &info->node; 687 - link->state &= ~DEV_CONFIG_PENDING; 703 + link->dev_node = &info->node; 688 704 689 - return; 705 + return 0; 690 706 691 707 cs_failed: 692 - cs_error(link->handle, last_fn, last_ret); 708 + cs_error(link, last_fn, last_ret); 693 709 694 710 failed: 695 711 dtl1_release(link); 712 + return -ENODEV; 696 713 } 697 714 698 715 699 - static void dtl1_release(dev_link_t *link) 716 + static void dtl1_release(struct pcmcia_device *link) 700 717 { 701 718 dtl1_info_t *info = link->priv; 702 719 703 - if (link->state & DEV_PRESENT) 704 - dtl1_close(info); 720 + dtl1_close(info); 705 721 706 - link->dev = NULL; 707 - 708 - pcmcia_release_configuration(link->handle); 709 - pcmcia_release_io(link->handle, &link->io); 710 - pcmcia_release_irq(link->handle, &link->irq); 711 - 712 - link->state &= ~DEV_CONFIG; 713 - } 714 - 715 - static int dtl1_suspend(struct pcmcia_device *dev) 716 - { 717 - dev_link_t *link = dev_to_instance(dev); 718 - 719 - link->state |= DEV_SUSPEND; 720 - if (link->state & DEV_CONFIG) 721 - pcmcia_release_configuration(link->handle); 722 - 723 - return 0; 724 - } 725 - 726 - static int dtl1_resume(struct pcmcia_device *dev) 727 - { 728 - dev_link_t *link = dev_to_instance(dev); 729 - 730 - link->state &= ~DEV_SUSPEND; 731 - if (DEV_OK(link)) 732 - pcmcia_request_configuration(link->handle, &link->conf); 733 - 734 - return 0; 722 + pcmcia_disable_device(link); 735 723 } 736 724 737 725 ··· 719 765 .drv = { 720 766 .name = "dtl1_cs", 721 767 }, 722 - .probe = dtl1_attach, 768 + .probe = dtl1_probe, 723 769 .remove = dtl1_detach, 724 770 .id_table = dtl1_ids, 725 - .suspend = dtl1_suspend, 726 - .resume = dtl1_resume, 727 771 }; 728 772 729 773 static int __init init_dtl1_cs(void)
+46 -75
drivers/char/pcmcia/cm4000_cs.c
··· 46 46 /* #define ATR_CSUM */ 47 47 48 48 #ifdef PCMCIA_DEBUG 49 - #define reader_to_dev(x) (&handle_to_dev(x->link.handle)) 49 + #define reader_to_dev(x) (&handle_to_dev(x->p_dev->handle)) 50 50 static int pc_debug = PCMCIA_DEBUG; 51 51 module_param(pc_debug, int, 0600); 52 52 #define DEBUGP(n, rdr, x, args...) do { \ ··· 67 67 #define T_100MSEC msecs_to_jiffies(100) 68 68 #define T_500MSEC msecs_to_jiffies(500) 69 69 70 - static void cm4000_release(dev_link_t *link); 70 + static void cm4000_release(struct pcmcia_device *link); 71 71 72 72 static int major; /* major number we get from the kernel */ 73 73 ··· 106 106 #define REG_STOPBITS(x) (x + 7) 107 107 108 108 struct cm4000_dev { 109 - dev_link_t link; /* pcmcia link */ 109 + struct pcmcia_device *p_dev; 110 110 dev_node_t node; /* OS node (major,minor) */ 111 111 112 112 unsigned char atr[MAX_ATR]; ··· 149 149 #define ZERO_DEV(dev) \ 150 150 memset(&dev->atr_csum,0, \ 151 151 sizeof(struct cm4000_dev) - \ 152 - /*link*/ sizeof(dev_link_t) - \ 152 + /*link*/ sizeof(struct pcmcia_device) - \ 153 153 /*node*/ sizeof(dev_node_t) - \ 154 154 /*atr*/ MAX_ATR*sizeof(char) - \ 155 155 /*rbuf*/ 512*sizeof(char) - \ 156 156 /*sbuf*/ 512*sizeof(char) - \ 157 157 /*queue*/ 4*sizeof(wait_queue_head_t)) 158 158 159 - static dev_link_t *dev_table[CM4000_MAX_DEV]; 159 + static struct pcmcia_device *dev_table[CM4000_MAX_DEV]; 160 160 static struct class *cmm_class; 161 161 162 162 /* This table doesn't use spaces after the comma between fields and thus ··· 454 454 static void set_cardparameter(struct cm4000_dev *dev) 455 455 { 456 456 int i; 457 - ioaddr_t iobase = dev->link.io.BasePort1; 457 + ioaddr_t iobase = dev->p_dev->io.BasePort1; 458 458 u_int8_t stopbits = 0x02; /* ISO default */ 459 459 460 460 DEBUGP(3, dev, "-> set_cardparameter\n"); ··· 487 487 unsigned short num_bytes_read; 488 488 unsigned char pts_reply[4]; 489 489 ssize_t rc; 490 - ioaddr_t iobase = dev->link.io.BasePort1; 490 + ioaddr_t iobase = dev->p_dev->io.BasePort1; 491 491 492 492 rc = 0; 493 493 ··· 699 699 static void monitor_card(unsigned long p) 700 700 { 701 701 struct cm4000_dev *dev = (struct cm4000_dev *) p; 702 - ioaddr_t iobase = dev->link.io.BasePort1; 702 + ioaddr_t iobase = dev->p_dev->io.BasePort1; 703 703 unsigned short s; 704 704 struct ptsreq ptsreq; 705 705 int i, atrc; ··· 962 962 loff_t *ppos) 963 963 { 964 964 struct cm4000_dev *dev = filp->private_data; 965 - ioaddr_t iobase = dev->link.io.BasePort1; 965 + ioaddr_t iobase = dev->p_dev->io.BasePort1; 966 966 ssize_t rc; 967 967 int i, j, k; 968 968 ··· 971 971 if (count == 0) /* according to manpage */ 972 972 return 0; 973 973 974 - if ((dev->link.state & DEV_PRESENT) == 0 || /* socket removed */ 974 + if (!pcmcia_dev_present(dev->p_dev) || /* device removed */ 975 975 test_bit(IS_CMM_ABSENT, &dev->flags)) 976 976 return -ENODEV; 977 977 ··· 1083 1083 size_t count, loff_t *ppos) 1084 1084 { 1085 1085 struct cm4000_dev *dev = (struct cm4000_dev *) filp->private_data; 1086 - ioaddr_t iobase = dev->link.io.BasePort1; 1086 + ioaddr_t iobase = dev->p_dev->io.BasePort1; 1087 1087 unsigned short s; 1088 1088 unsigned char tmp; 1089 1089 unsigned char infolen; ··· 1108 1108 1109 1109 sendT0 = dev->proto ? 0 : nr > 5 ? 0x08 : 0; 1110 1110 1111 - if ((dev->link.state & DEV_PRESENT) == 0 || /* socket removed */ 1111 + if (!pcmcia_dev_present(dev->p_dev) || /* device removed */ 1112 1112 test_bit(IS_CMM_ABSENT, &dev->flags)) 1113 1113 return -ENODEV; 1114 1114 ··· 1440 1440 unsigned long arg) 1441 1441 { 1442 1442 struct cm4000_dev *dev = filp->private_data; 1443 - ioaddr_t iobase = dev->link.io.BasePort1; 1444 - dev_link_t *link; 1443 + ioaddr_t iobase = dev->p_dev->io.BasePort1; 1444 + struct pcmcia_device *link; 1445 1445 int size; 1446 1446 int rc; 1447 1447 void __user *argp = (void __user *)arg; ··· 1458 1458 iminor(inode), ioctl_names[_IOC_NR(cmd)]); 1459 1459 1460 1460 link = dev_table[iminor(inode)]; 1461 - if (!(DEV_OK(link))) { 1461 + if (!pcmcia_dev_present(link)) { 1462 1462 DEBUGP(4, dev, "DEV_OK false\n"); 1463 1463 return -ENODEV; 1464 1464 } ··· 1660 1660 static int cmm_open(struct inode *inode, struct file *filp) 1661 1661 { 1662 1662 struct cm4000_dev *dev; 1663 - dev_link_t *link; 1663 + struct pcmcia_device *link; 1664 1664 int rc, minor = iminor(inode); 1665 1665 1666 1666 if (minor >= CM4000_MAX_DEV) 1667 1667 return -ENODEV; 1668 1668 1669 1669 link = dev_table[minor]; 1670 - if (link == NULL || !(DEV_OK(link))) 1670 + if (link == NULL || !pcmcia_dev_present(link)) 1671 1671 return -ENODEV; 1672 1672 1673 1673 if (link->open) ··· 1709 1709 static int cmm_close(struct inode *inode, struct file *filp) 1710 1710 { 1711 1711 struct cm4000_dev *dev; 1712 - dev_link_t *link; 1712 + struct pcmcia_device *link; 1713 1713 int minor = iminor(inode); 1714 1714 1715 1715 if (minor >= CM4000_MAX_DEV) ··· 1735 1735 return 0; 1736 1736 } 1737 1737 1738 - static void cmm_cm4000_release(dev_link_t * link) 1738 + static void cmm_cm4000_release(struct pcmcia_device * link) 1739 1739 { 1740 1740 struct cm4000_dev *dev = link->priv; 1741 1741 ··· 1759 1759 1760 1760 /*==== Interface to PCMCIA Layer =======================================*/ 1761 1761 1762 - static void cm4000_config(dev_link_t * link, int devno) 1762 + static int cm4000_config(struct pcmcia_device * link, int devno) 1763 1763 { 1764 - client_handle_t handle = link->handle; 1765 1764 struct cm4000_dev *dev; 1766 1765 tuple_t tuple; 1767 1766 cisparse_t parse; 1768 - config_info_t conf; 1769 1767 u_char buf[64]; 1770 1768 int fail_fn, fail_rc; 1771 1769 int rc; ··· 1775 1777 tuple.TupleDataMax = sizeof(buf); 1776 1778 tuple.TupleOffset = 0; 1777 1779 1778 - if ((fail_rc = pcmcia_get_first_tuple(handle, &tuple)) != CS_SUCCESS) { 1780 + if ((fail_rc = pcmcia_get_first_tuple(link, &tuple)) != CS_SUCCESS) { 1779 1781 fail_fn = GetFirstTuple; 1780 1782 goto cs_failed; 1781 1783 } 1782 - if ((fail_rc = pcmcia_get_tuple_data(handle, &tuple)) != CS_SUCCESS) { 1784 + if ((fail_rc = pcmcia_get_tuple_data(link, &tuple)) != CS_SUCCESS) { 1783 1785 fail_fn = GetTupleData; 1784 1786 goto cs_failed; 1785 1787 } 1786 1788 if ((fail_rc = 1787 - pcmcia_parse_tuple(handle, &tuple, &parse)) != CS_SUCCESS) { 1789 + pcmcia_parse_tuple(link, &tuple, &parse)) != CS_SUCCESS) { 1788 1790 fail_fn = ParseTuple; 1789 1791 goto cs_failed; 1790 1792 } 1791 - if ((fail_rc = 1792 - pcmcia_get_configuration_info(handle, &conf)) != CS_SUCCESS) { 1793 - fail_fn = GetConfigurationInfo; 1794 - goto cs_failed; 1795 - } 1796 1793 1797 - link->state |= DEV_CONFIG; 1798 1794 link->conf.ConfigBase = parse.config.base; 1799 1795 link->conf.Present = parse.config.rmask[0]; 1800 - link->conf.Vcc = conf.Vcc; 1801 1796 1802 1797 link->io.BasePort2 = 0; 1803 1798 link->io.NumPorts2 = 0; 1804 1799 link->io.Attributes2 = 0; 1805 1800 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 1806 - for (rc = pcmcia_get_first_tuple(handle, &tuple); 1807 - rc == CS_SUCCESS; rc = pcmcia_get_next_tuple(handle, &tuple)) { 1801 + for (rc = pcmcia_get_first_tuple(link, &tuple); 1802 + rc == CS_SUCCESS; rc = pcmcia_get_next_tuple(link, &tuple)) { 1808 1803 1809 - rc = pcmcia_get_tuple_data(handle, &tuple); 1804 + rc = pcmcia_get_tuple_data(link, &tuple); 1810 1805 if (rc != CS_SUCCESS) 1811 1806 continue; 1812 - rc = pcmcia_parse_tuple(handle, &tuple, &parse); 1807 + rc = pcmcia_parse_tuple(link, &tuple, &parse); 1813 1808 if (rc != CS_SUCCESS) 1814 1809 continue; 1815 1810 ··· 1822 1831 link->io.IOAddrLines = parse.cftable_entry.io.flags 1823 1832 & CISTPL_IO_LINES_MASK; 1824 1833 1825 - rc = pcmcia_request_io(handle, &link->io); 1834 + rc = pcmcia_request_io(link, &link->io); 1826 1835 if (rc == CS_SUCCESS) 1827 1836 break; /* we are done */ 1828 1837 } ··· 1832 1841 link->conf.IntType = 00000002; 1833 1842 1834 1843 if ((fail_rc = 1835 - pcmcia_request_configuration(handle, &link->conf)) != CS_SUCCESS) { 1844 + pcmcia_request_configuration(link, &link->conf)) != CS_SUCCESS) { 1836 1845 fail_fn = RequestConfiguration; 1837 1846 goto cs_release; 1838 1847 } ··· 1842 1851 dev->node.major = major; 1843 1852 dev->node.minor = devno; 1844 1853 dev->node.next = NULL; 1845 - link->dev = &dev->node; 1846 - link->state &= ~DEV_CONFIG_PENDING; 1854 + link->dev_node = &dev->node; 1847 1855 1848 - return; 1856 + return 0; 1849 1857 1850 1858 cs_failed: 1851 - cs_error(handle, fail_fn, fail_rc); 1859 + cs_error(link, fail_fn, fail_rc); 1852 1860 cs_release: 1853 1861 cm4000_release(link); 1854 - 1855 - link->state &= ~DEV_CONFIG_PENDING; 1862 + return -ENODEV; 1856 1863 } 1857 1864 1858 - static int cm4000_suspend(struct pcmcia_device *p_dev) 1865 + static int cm4000_suspend(struct pcmcia_device *link) 1859 1866 { 1860 - dev_link_t *link = dev_to_instance(p_dev); 1861 1867 struct cm4000_dev *dev; 1862 1868 1863 1869 dev = link->priv; 1864 - 1865 - link->state |= DEV_SUSPEND; 1866 - if (link->state & DEV_CONFIG) 1867 - pcmcia_release_configuration(link->handle); 1868 1870 stop_monitor(dev); 1869 1871 1870 1872 return 0; 1871 1873 } 1872 1874 1873 - static int cm4000_resume(struct pcmcia_device *p_dev) 1875 + static int cm4000_resume(struct pcmcia_device *link) 1874 1876 { 1875 - dev_link_t *link = dev_to_instance(p_dev); 1876 1877 struct cm4000_dev *dev; 1877 1878 1878 1879 dev = link->priv; 1879 - 1880 - link->state &= ~DEV_SUSPEND; 1881 - if (link->state & DEV_CONFIG) 1882 - pcmcia_request_configuration(link->handle, &link->conf); 1883 - 1884 1880 if (link->open) 1885 1881 start_monitor(dev); 1886 1882 1887 1883 return 0; 1888 1884 } 1889 1885 1890 - static void cm4000_release(dev_link_t *link) 1886 + static void cm4000_release(struct pcmcia_device *link) 1891 1887 { 1892 1888 cmm_cm4000_release(link->priv); /* delay release until device closed */ 1893 - pcmcia_release_configuration(link->handle); 1894 - pcmcia_release_io(link->handle, &link->io); 1889 + pcmcia_disable_device(link); 1895 1890 } 1896 1891 1897 - static int cm4000_attach(struct pcmcia_device *p_dev) 1892 + static int cm4000_probe(struct pcmcia_device *link) 1898 1893 { 1899 1894 struct cm4000_dev *dev; 1900 - dev_link_t *link; 1901 - int i; 1895 + int i, ret; 1902 1896 1903 1897 for (i = 0; i < CM4000_MAX_DEV; i++) 1904 1898 if (dev_table[i] == NULL) ··· 1899 1923 if (dev == NULL) 1900 1924 return -ENOMEM; 1901 1925 1902 - link = &dev->link; 1926 + dev->p_dev = link; 1903 1927 link->priv = dev; 1904 1928 link->conf.IntType = INT_MEMORY_AND_IO; 1905 1929 dev_table[i] = link; ··· 1909 1933 init_waitqueue_head(&dev->atrq); 1910 1934 init_waitqueue_head(&dev->readq); 1911 1935 1912 - link->handle = p_dev; 1913 - p_dev->instance = link; 1914 - 1915 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 1916 - cm4000_config(link, i); 1936 + ret = cm4000_config(link, i); 1937 + if (ret) 1938 + return ret; 1917 1939 1918 1940 class_device_create(cmm_class, NULL, MKDEV(major, i), NULL, 1919 1941 "cmm%d", i); ··· 1919 1945 return 0; 1920 1946 } 1921 1947 1922 - static void cm4000_detach(struct pcmcia_device *p_dev) 1948 + static void cm4000_detach(struct pcmcia_device *link) 1923 1949 { 1924 - dev_link_t *link = dev_to_instance(p_dev); 1925 1950 struct cm4000_dev *dev = link->priv; 1926 1951 int devno; 1927 1952 ··· 1931 1958 if (devno == CM4000_MAX_DEV) 1932 1959 return; 1933 1960 1934 - link->state &= ~DEV_PRESENT; 1935 1961 stop_monitor(dev); 1936 1962 1937 - if (link->state & DEV_CONFIG) 1938 - cm4000_release(link); 1963 + cm4000_release(link); 1939 1964 1940 1965 dev_table[devno] = NULL; 1941 1966 kfree(dev); ··· 1964 1993 .drv = { 1965 1994 .name = "cm4000_cs", 1966 1995 }, 1967 - .probe = cm4000_attach, 1996 + .probe = cm4000_probe, 1968 1997 .remove = cm4000_detach, 1969 1998 .suspend = cm4000_suspend, 1970 1999 .resume = cm4000_resume,
+44 -89
drivers/char/pcmcia/cm4040_cs.c
··· 41 41 42 42 43 43 #ifdef PCMCIA_DEBUG 44 - #define reader_to_dev(x) (&handle_to_dev(x->link.handle)) 44 + #define reader_to_dev(x) (&handle_to_dev(x->p_dev->handle)) 45 45 static int pc_debug = PCMCIA_DEBUG; 46 46 module_param(pc_debug, int, 0600); 47 47 #define DEBUGP(n, rdr, x, args...) do { \ ··· 65 65 /* how often to poll for fifo status change */ 66 66 #define POLL_PERIOD msecs_to_jiffies(10) 67 67 68 - static void reader_release(dev_link_t *link); 68 + static void reader_release(struct pcmcia_device *link); 69 69 70 70 static int major; 71 71 static struct class *cmx_class; ··· 74 74 #define BS_WRITABLE 0x02 75 75 76 76 struct reader_dev { 77 - dev_link_t link; 77 + struct pcmcia_device *p_dev; 78 78 dev_node_t node; 79 79 wait_queue_head_t devq; 80 80 wait_queue_head_t poll_wait; ··· 87 87 struct timer_list poll_timer; 88 88 }; 89 89 90 - static dev_link_t *dev_table[CM_MAX_DEV]; 90 + static struct pcmcia_device *dev_table[CM_MAX_DEV]; 91 91 92 92 #ifndef PCMCIA_DEBUG 93 93 #define xoutb outb ··· 116 116 static void cm4040_do_poll(unsigned long dummy) 117 117 { 118 118 struct reader_dev *dev = (struct reader_dev *) dummy; 119 - unsigned int obs = xinb(dev->link.io.BasePort1 119 + unsigned int obs = xinb(dev->p_dev->io.BasePort1 120 120 + REG_OFFSET_BUFFER_STATUS); 121 121 122 122 if ((obs & BSR_BULK_IN_FULL)) { ··· 147 147 static int wait_for_bulk_out_ready(struct reader_dev *dev) 148 148 { 149 149 int i, rc; 150 - int iobase = dev->link.io.BasePort1; 150 + int iobase = dev->p_dev->io.BasePort1; 151 151 152 152 for (i = 0; i < POLL_LOOP_COUNT; i++) { 153 153 if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS) ··· 177 177 /* Write to Sync Control Register */ 178 178 static int write_sync_reg(unsigned char val, struct reader_dev *dev) 179 179 { 180 - int iobase = dev->link.io.BasePort1; 180 + int iobase = dev->p_dev->io.BasePort1; 181 181 int rc; 182 182 183 183 rc = wait_for_bulk_out_ready(dev); ··· 195 195 static int wait_for_bulk_in_ready(struct reader_dev *dev) 196 196 { 197 197 int i, rc; 198 - int iobase = dev->link.io.BasePort1; 198 + int iobase = dev->p_dev->io.BasePort1; 199 199 200 200 for (i = 0; i < POLL_LOOP_COUNT; i++) { 201 201 if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS) ··· 225 225 size_t count, loff_t *ppos) 226 226 { 227 227 struct reader_dev *dev = filp->private_data; 228 - int iobase = dev->link.io.BasePort1; 228 + int iobase = dev->p_dev->io.BasePort1; 229 229 size_t bytes_to_read; 230 230 unsigned long i; 231 231 size_t min_bytes_to_read; ··· 246 246 return -EAGAIN; 247 247 } 248 248 249 - if ((dev->link.state & DEV_PRESENT)==0) 249 + if (!pcmcia_dev_present(dev->p_dev)) 250 250 return -ENODEV; 251 251 252 252 for (i = 0; i < 5; i++) { ··· 328 328 size_t count, loff_t *ppos) 329 329 { 330 330 struct reader_dev *dev = filp->private_data; 331 - int iobase = dev->link.io.BasePort1; 331 + int iobase = dev->p_dev->io.BasePort1; 332 332 ssize_t rc; 333 333 int i; 334 334 unsigned int bytes_to_write; ··· 351 351 return -EAGAIN; 352 352 } 353 353 354 - if ((dev->link.state & DEV_PRESENT) == 0) 354 + if (!pcmcia_dev_present(dev->p_dev)) 355 355 return -ENODEV; 356 356 357 357 bytes_to_write = count; ··· 445 445 static int cm4040_open(struct inode *inode, struct file *filp) 446 446 { 447 447 struct reader_dev *dev; 448 - dev_link_t *link; 448 + struct pcmcia_device *link; 449 449 int minor = iminor(inode); 450 450 451 451 if (minor >= CM_MAX_DEV) 452 452 return -ENODEV; 453 453 454 454 link = dev_table[minor]; 455 - if (link == NULL || !(DEV_OK(link))) 455 + if (link == NULL || !pcmcia_dev_present(link)) 456 456 return -ENODEV; 457 457 458 458 if (link->open) ··· 478 478 static int cm4040_close(struct inode *inode, struct file *filp) 479 479 { 480 480 struct reader_dev *dev = filp->private_data; 481 - dev_link_t *link; 481 + struct pcmcia_device *link; 482 482 int minor = iminor(inode); 483 483 484 484 DEBUGP(2, dev, "-> cm4040_close(maj/min=%d.%d)\n", imajor(inode), ··· 500 500 return 0; 501 501 } 502 502 503 - static void cm4040_reader_release(dev_link_t *link) 503 + static void cm4040_reader_release(struct pcmcia_device *link) 504 504 { 505 505 struct reader_dev *dev = link->priv; 506 506 ··· 514 514 return; 515 515 } 516 516 517 - static void reader_config(dev_link_t *link, int devno) 517 + static int reader_config(struct pcmcia_device *link, int devno) 518 518 { 519 - client_handle_t handle; 520 519 struct reader_dev *dev; 521 520 tuple_t tuple; 522 521 cisparse_t parse; 523 - config_info_t conf; 524 522 u_char buf[64]; 525 523 int fail_fn, fail_rc; 526 524 int rc; 527 - 528 - handle = link->handle; 529 525 530 526 tuple.DesiredTuple = CISTPL_CONFIG; 531 527 tuple.Attributes = 0; ··· 529 533 tuple.TupleDataMax = sizeof(buf); 530 534 tuple.TupleOffset = 0; 531 535 532 - if ((fail_rc = pcmcia_get_first_tuple(handle, &tuple)) != CS_SUCCESS) { 536 + if ((fail_rc = pcmcia_get_first_tuple(link, &tuple)) != CS_SUCCESS) { 533 537 fail_fn = GetFirstTuple; 534 538 goto cs_failed; 535 539 } 536 - if ((fail_rc = pcmcia_get_tuple_data(handle, &tuple)) != CS_SUCCESS) { 540 + if ((fail_rc = pcmcia_get_tuple_data(link, &tuple)) != CS_SUCCESS) { 537 541 fail_fn = GetTupleData; 538 542 goto cs_failed; 539 543 } 540 - if ((fail_rc = pcmcia_parse_tuple(handle, &tuple, &parse)) 544 + if ((fail_rc = pcmcia_parse_tuple(link, &tuple, &parse)) 541 545 != CS_SUCCESS) { 542 546 fail_fn = ParseTuple; 543 547 goto cs_failed; 544 548 } 545 - if ((fail_rc = pcmcia_get_configuration_info(handle, &conf)) 546 - != CS_SUCCESS) { 547 - fail_fn = GetConfigurationInfo; 548 - goto cs_failed; 549 - } 550 549 551 - link->state |= DEV_CONFIG; 552 550 link->conf.ConfigBase = parse.config.base; 553 551 link->conf.Present = parse.config.rmask[0]; 554 - link->conf.Vcc = conf.Vcc; 555 552 556 553 link->io.BasePort2 = 0; 557 554 link->io.NumPorts2 = 0; 558 555 link->io.Attributes2 = 0; 559 556 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 560 - for (rc = pcmcia_get_first_tuple(handle, &tuple); 557 + for (rc = pcmcia_get_first_tuple(link, &tuple); 561 558 rc == CS_SUCCESS; 562 - rc = pcmcia_get_next_tuple(handle, &tuple)) { 563 - rc = pcmcia_get_tuple_data(handle, &tuple); 559 + rc = pcmcia_get_next_tuple(link, &tuple)) { 560 + rc = pcmcia_get_tuple_data(link, &tuple); 564 561 if (rc != CS_SUCCESS) 565 562 continue; 566 - rc = pcmcia_parse_tuple(handle, &tuple, &parse); 563 + rc = pcmcia_parse_tuple(link, &tuple, &parse); 567 564 if (rc != CS_SUCCESS) 568 565 continue; 569 566 ··· 574 585 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 575 586 link->io.IOAddrLines = parse.cftable_entry.io.flags 576 587 & CISTPL_IO_LINES_MASK; 577 - rc = pcmcia_request_io(handle, &link->io); 588 + rc = pcmcia_request_io(link, &link->io); 578 589 579 - dev_printk(KERN_INFO, &handle_to_dev(handle), "foo"); 590 + dev_printk(KERN_INFO, &handle_to_dev(link), "foo"); 580 591 if (rc == CS_SUCCESS) 581 592 break; 582 593 else 583 - dev_printk(KERN_INFO, &handle_to_dev(handle), 594 + dev_printk(KERN_INFO, &handle_to_dev(link), 584 595 "pcmcia_request_io failed 0x%x\n", rc); 585 596 } 586 597 if (rc != CS_SUCCESS) ··· 588 599 589 600 link->conf.IntType = 00000002; 590 601 591 - if ((fail_rc = pcmcia_request_configuration(handle,&link->conf)) 602 + if ((fail_rc = pcmcia_request_configuration(link,&link->conf)) 592 603 !=CS_SUCCESS) { 593 604 fail_fn = RequestConfiguration; 594 - dev_printk(KERN_INFO, &handle_to_dev(handle), 605 + dev_printk(KERN_INFO, &handle_to_dev(link), 595 606 "pcmcia_request_configuration failed 0x%x\n", 596 607 fail_rc); 597 608 goto cs_release; ··· 601 612 sprintf(dev->node.dev_name, DEVICE_NAME "%d", devno); 602 613 dev->node.major = major; 603 614 dev->node.minor = devno; 604 - dev->node.next = NULL; 605 - link->dev = &dev->node; 606 - link->state &= ~DEV_CONFIG_PENDING; 615 + dev->node.next = &dev->node; 607 616 608 617 DEBUGP(2, dev, "device " DEVICE_NAME "%d at 0x%.4x-0x%.4x\n", devno, 609 618 link->io.BasePort1, link->io.BasePort1+link->io.NumPorts1); 610 619 DEBUGP(2, dev, "<- reader_config (succ)\n"); 611 620 612 - return; 621 + return 0; 613 622 614 623 cs_failed: 615 - cs_error(handle, fail_fn, fail_rc); 624 + cs_error(link, fail_fn, fail_rc); 616 625 cs_release: 617 626 reader_release(link); 618 - link->state &= ~DEV_CONFIG_PENDING; 627 + return -ENODEV; 619 628 } 620 629 621 - static int reader_suspend(struct pcmcia_device *p_dev) 622 - { 623 - dev_link_t *link = dev_to_instance(p_dev); 624 - 625 - link->state |= DEV_SUSPEND; 626 - if (link->state & DEV_CONFIG) 627 - pcmcia_release_configuration(link->handle); 628 - 629 - return 0; 630 - } 631 - 632 - static int reader_resume(struct pcmcia_device *p_dev) 633 - { 634 - dev_link_t *link = dev_to_instance(p_dev); 635 - 636 - link->state &= ~DEV_SUSPEND; 637 - if (link->state & DEV_CONFIG) 638 - pcmcia_request_configuration(link->handle, &link->conf); 639 - 640 - return 0; 641 - } 642 - 643 - static void reader_release(dev_link_t *link) 630 + static void reader_release(struct pcmcia_device *link) 644 631 { 645 632 cm4040_reader_release(link->priv); 646 - pcmcia_release_configuration(link->handle); 647 - pcmcia_release_io(link->handle, &link->io); 633 + pcmcia_disable_device(link); 648 634 } 649 635 650 - static int reader_attach(struct pcmcia_device *p_dev) 636 + static int reader_probe(struct pcmcia_device *link) 651 637 { 652 638 struct reader_dev *dev; 653 - dev_link_t *link; 654 - int i; 639 + int i, ret; 655 640 656 641 for (i = 0; i < CM_MAX_DEV; i++) { 657 642 if (dev_table[i] == NULL) ··· 642 679 dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT; 643 680 dev->buffer_status = 0; 644 681 645 - link = &dev->link; 646 682 link->priv = dev; 683 + dev->p_dev = link; 647 684 648 685 link->conf.IntType = INT_MEMORY_AND_IO; 649 686 dev_table[i] = link; ··· 655 692 init_timer(&dev->poll_timer); 656 693 dev->poll_timer.function = &cm4040_do_poll; 657 694 658 - link->handle = p_dev; 659 - p_dev->instance = link; 660 - 661 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 662 - reader_config(link, i); 695 + ret = reader_config(link, i); 696 + if (ret) 697 + return ret; 663 698 664 699 class_device_create(cmx_class, NULL, MKDEV(major, i), NULL, 665 700 "cmx%d", i); ··· 665 704 return 0; 666 705 } 667 706 668 - static void reader_detach(struct pcmcia_device *p_dev) 707 + static void reader_detach(struct pcmcia_device *link) 669 708 { 670 - dev_link_t *link = dev_to_instance(p_dev); 671 709 struct reader_dev *dev = link->priv; 672 710 int devno; 673 711 ··· 678 718 if (devno == CM_MAX_DEV) 679 719 return; 680 720 681 - link->state &= ~DEV_PRESENT; 682 - 683 - if (link->state & DEV_CONFIG) 684 - reader_release(link); 721 + reader_release(link); 685 722 686 723 dev_table[devno] = NULL; 687 724 kfree(dev); ··· 710 753 .drv = { 711 754 .name = "cm4040_cs", 712 755 }, 713 - .probe = reader_attach, 756 + .probe = reader_probe, 714 757 .remove = reader_detach, 715 - .suspend = reader_suspend, 716 - .resume = reader_resume, 717 758 .id_table = cm4040_ids, 718 759 }; 719 760
+41 -86
drivers/ide/legacy/ide-cs.c
··· 81 81 }; 82 82 83 83 typedef struct ide_info_t { 84 - dev_link_t link; 84 + struct pcmcia_device *p_dev; 85 85 int ndev; 86 86 dev_node_t node; 87 87 int hd; 88 88 } ide_info_t; 89 89 90 - static void ide_release(dev_link_t *); 91 - static void ide_config(dev_link_t *); 90 + static void ide_release(struct pcmcia_device *); 91 + static int ide_config(struct pcmcia_device *); 92 92 93 93 static void ide_detach(struct pcmcia_device *p_dev); 94 94 ··· 103 103 104 104 ======================================================================*/ 105 105 106 - static int ide_attach(struct pcmcia_device *p_dev) 106 + static int ide_probe(struct pcmcia_device *link) 107 107 { 108 108 ide_info_t *info; 109 - dev_link_t *link; 110 109 111 110 DEBUG(0, "ide_attach()\n"); 112 111 ··· 113 114 info = kzalloc(sizeof(*info), GFP_KERNEL); 114 115 if (!info) 115 116 return -ENOMEM; 116 - link = &info->link; link->priv = info; 117 + 118 + info->p_dev = link; 119 + link->priv = info; 117 120 118 121 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 119 122 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; ··· 123 122 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 124 123 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 125 124 link->conf.Attributes = CONF_ENABLE_IRQ; 126 - link->conf.Vcc = 50; 127 125 link->conf.IntType = INT_MEMORY_AND_IO; 128 126 129 - link->handle = p_dev; 130 - p_dev->instance = link; 131 - 132 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 133 - ide_config(link); 134 - 135 - return 0; 127 + return ide_config(link); 136 128 } /* ide_attach */ 137 129 138 130 /*====================================================================== ··· 137 143 138 144 ======================================================================*/ 139 145 140 - static void ide_detach(struct pcmcia_device *p_dev) 146 + static void ide_detach(struct pcmcia_device *link) 141 147 { 142 - dev_link_t *link = dev_to_instance(p_dev); 143 - 144 148 DEBUG(0, "ide_detach(0x%p)\n", link); 145 149 146 - if (link->state & DEV_CONFIG) 147 - ide_release(link); 150 + ide_release(link); 148 151 149 152 kfree(link->priv); 150 153 } /* ide_detach */ ··· 168 177 #define CS_CHECK(fn, ret) \ 169 178 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 170 179 171 - static void ide_config(dev_link_t *link) 180 + static int ide_config(struct pcmcia_device *link) 172 181 { 173 - client_handle_t handle = link->handle; 174 182 ide_info_t *info = link->priv; 175 183 tuple_t tuple; 176 184 struct { ··· 193 203 tuple.TupleDataMax = 255; 194 204 tuple.Attributes = 0; 195 205 tuple.DesiredTuple = CISTPL_CONFIG; 196 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 197 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 198 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &stk->parse)); 206 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 207 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 208 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &stk->parse)); 199 209 link->conf.ConfigBase = stk->parse.config.base; 200 210 link->conf.Present = stk->parse.config.rmask[0]; 201 211 202 212 tuple.DesiredTuple = CISTPL_MANFID; 203 - if (!pcmcia_get_first_tuple(handle, &tuple) && 204 - !pcmcia_get_tuple_data(handle, &tuple) && 205 - !pcmcia_parse_tuple(handle, &tuple, &stk->parse)) 213 + if (!pcmcia_get_first_tuple(link, &tuple) && 214 + !pcmcia_get_tuple_data(link, &tuple) && 215 + !pcmcia_parse_tuple(link, &tuple, &stk->parse)) 206 216 is_kme = ((stk->parse.manfid.manf == MANFID_KME) && 207 217 ((stk->parse.manfid.card == PRODID_KME_KXLC005_A) || 208 218 (stk->parse.manfid.card == PRODID_KME_KXLC005_B))); 209 219 210 - /* Configure card */ 211 - link->state |= DEV_CONFIG; 212 - 213 220 /* Not sure if this is right... look up the current Vcc */ 214 - CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &stk->conf)); 215 - link->conf.Vcc = stk->conf.Vcc; 221 + CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &stk->conf)); 216 222 217 223 pass = io_base = ctl_base = 0; 218 224 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 219 225 tuple.Attributes = 0; 220 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 226 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 221 227 while (1) { 222 - if (pcmcia_get_tuple_data(handle, &tuple) != 0) goto next_entry; 223 - if (pcmcia_parse_tuple(handle, &tuple, &stk->parse) != 0) goto next_entry; 228 + if (pcmcia_get_tuple_data(link, &tuple) != 0) goto next_entry; 229 + if (pcmcia_parse_tuple(link, &tuple, &stk->parse) != 0) goto next_entry; 224 230 225 231 /* Check for matching Vcc, unless we're desperate */ 226 232 if (!pass) { ··· 230 244 } 231 245 232 246 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 233 - link->conf.Vpp1 = link->conf.Vpp2 = 247 + link->conf.Vpp = 234 248 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 235 249 else if (stk->dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) 236 - link->conf.Vpp1 = link->conf.Vpp2 = 250 + link->conf.Vpp = 237 251 stk->dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; 238 252 239 253 if ((cfg->io.nwin > 0) || (stk->dflt.io.nwin > 0)) { ··· 247 261 link->io.NumPorts1 = 8; 248 262 link->io.BasePort2 = io->win[1].base; 249 263 link->io.NumPorts2 = (is_kme) ? 2 : 1; 250 - if (pcmcia_request_io(link->handle, &link->io) != 0) 264 + if (pcmcia_request_io(link, &link->io) != 0) 251 265 goto next_entry; 252 266 io_base = link->io.BasePort1; 253 267 ctl_base = link->io.BasePort2; 254 268 } else if ((io->nwin == 1) && (io->win[0].len >= 16)) { 255 269 link->io.NumPorts1 = io->win[0].len; 256 270 link->io.NumPorts2 = 0; 257 - if (pcmcia_request_io(link->handle, &link->io) != 0) 271 + if (pcmcia_request_io(link, &link->io) != 0) 258 272 goto next_entry; 259 273 io_base = link->io.BasePort1; 260 274 ctl_base = link->io.BasePort1 + 0x0e; ··· 267 281 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) 268 282 memcpy(&stk->dflt, cfg, sizeof(stk->dflt)); 269 283 if (pass) { 270 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); 271 - } else if (pcmcia_get_next_tuple(handle, &tuple) != 0) { 272 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 284 + CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 285 + } else if (pcmcia_get_next_tuple(link, &tuple) != 0) { 286 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 273 287 memset(&stk->dflt, 0, sizeof(stk->dflt)); 274 288 pass++; 275 289 } 276 290 } 277 291 278 - CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq)); 279 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); 292 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 293 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 280 294 281 295 /* disable drive interrupts during IDE probe */ 282 296 outb(0x02, ctl_base); ··· 287 301 288 302 /* retry registration in case device is still spinning up */ 289 303 for (hd = -1, i = 0; i < 10; i++) { 290 - hd = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, handle); 304 + hd = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, link); 291 305 if (hd >= 0) break; 292 306 if (link->io.NumPorts1 == 0x20) { 293 307 outb(0x02, ctl_base + 0x10); 294 308 hd = idecs_register(io_base + 0x10, ctl_base + 0x10, 295 - link->irq.AssignedIRQ, handle); 309 + link->irq.AssignedIRQ, link); 296 310 if (hd >= 0) { 297 311 io_base += 0x10; 298 312 ctl_base += 0x10; ··· 314 328 info->node.major = ide_major[hd]; 315 329 info->node.minor = 0; 316 330 info->hd = hd; 317 - link->dev = &info->node; 318 - printk(KERN_INFO "ide-cs: %s: Vcc = %d.%d, Vpp = %d.%d\n", 319 - info->node.dev_name, link->conf.Vcc / 10, link->conf.Vcc % 10, 320 - link->conf.Vpp1 / 10, link->conf.Vpp1 % 10); 331 + link->dev_node = &info->node; 332 + printk(KERN_INFO "ide-cs: %s: Vpp = %d.%d\n", 333 + info->node.dev_name, link->conf.Vpp / 10, link->conf.Vpp % 10); 321 334 322 - link->state &= ~DEV_CONFIG_PENDING; 323 335 kfree(stk); 324 - return; 336 + return 0; 325 337 326 338 err_mem: 327 339 printk(KERN_NOTICE "ide-cs: ide_config failed memory allocation\n"); 328 340 goto failed; 329 341 330 342 cs_failed: 331 - cs_error(link->handle, last_fn, last_ret); 343 + cs_error(link, last_fn, last_ret); 332 344 failed: 333 345 kfree(stk); 334 346 ide_release(link); 335 - link->state &= ~DEV_CONFIG_PENDING; 347 + return -ENODEV; 336 348 } /* ide_config */ 337 349 338 350 /*====================================================================== ··· 341 357 342 358 ======================================================================*/ 343 359 344 - void ide_release(dev_link_t *link) 360 + void ide_release(struct pcmcia_device *link) 345 361 { 346 362 ide_info_t *info = link->priv; 347 363 ··· 353 369 ide_unregister(info->hd); 354 370 } 355 371 info->ndev = 0; 356 - link->dev = NULL; 357 - 358 - pcmcia_release_configuration(link->handle); 359 - pcmcia_release_io(link->handle, &link->io); 360 - pcmcia_release_irq(link->handle, &link->irq); 361 - 362 - link->state &= ~DEV_CONFIG; 363 372 373 + pcmcia_disable_device(link); 364 374 } /* ide_release */ 365 375 366 - static int ide_suspend(struct pcmcia_device *dev) 367 - { 368 - dev_link_t *link = dev_to_instance(dev); 369 - 370 - link->state |= DEV_SUSPEND; 371 - if (link->state & DEV_CONFIG) 372 - pcmcia_release_configuration(link->handle); 373 - 374 - return 0; 375 - } 376 - 377 - static int ide_resume(struct pcmcia_device *dev) 378 - { 379 - dev_link_t *link = dev_to_instance(dev); 380 - 381 - link->state &= ~DEV_SUSPEND; 382 - if (DEV_OK(link)) 383 - pcmcia_request_configuration(link->handle, &link->conf); 384 - 385 - return 0; 386 - } 387 376 388 377 /*====================================================================== 389 378 ··· 416 459 .drv = { 417 460 .name = "ide-cs", 418 461 }, 419 - .probe = ide_attach, 462 + .probe = ide_probe, 420 463 .remove = ide_detach, 421 464 .id_table = ide_ids, 422 - .suspend = ide_suspend, 423 - .resume = ide_resume, 424 465 }; 425 466 426 467 static int __init init_ide_cs(void)
+56 -129
drivers/isdn/hardware/avm/avm_cs.c
··· 51 51 handler. 52 52 */ 53 53 54 - static void avmcs_config(dev_link_t *link); 55 - static void avmcs_release(dev_link_t *link); 54 + static int avmcs_config(struct pcmcia_device *link); 55 + static void avmcs_release(struct pcmcia_device *link); 56 56 57 57 /* 58 58 The attach() and detach() entry points are used to create and destroy ··· 65 65 /* 66 66 A linked list of "instances" of the skeleton device. Each actual 67 67 PCMCIA card corresponds to one device instance, and is described 68 - by one dev_link_t structure (defined in ds.h). 68 + by one struct pcmcia_device structure (defined in ds.h). 69 69 70 70 You may not want to use a linked list for this -- for example, the 71 - memory card driver uses an array of dev_link_t pointers, where minor 71 + memory card driver uses an array of struct pcmcia_device pointers, where minor 72 72 device numbers are used to derive the corresponding array index. 73 73 */ 74 74 ··· 78 78 example, ethernet cards, modems). In other cases, there may be 79 79 many actual or logical devices (SCSI adapters, memory cards with 80 80 multiple partitions). The dev_node_t structures need to be kept 81 - in a linked list starting at the 'dev' field of a dev_link_t 81 + in a linked list starting at the 'dev' field of a struct pcmcia_device 82 82 structure. We allocate them in the card's private data structure, 83 83 because they generally can't be allocated dynamically. 84 84 */ ··· 99 99 100 100 ======================================================================*/ 101 101 102 - static int avmcs_attach(struct pcmcia_device *p_dev) 102 + static int avmcs_probe(struct pcmcia_device *p_dev) 103 103 { 104 - dev_link_t *link; 105 104 local_info_t *local; 106 105 107 - /* Initialize the dev_link_t structure */ 108 - link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); 109 - if (!link) 110 - goto err; 111 - memset(link, 0, sizeof(struct dev_link_t)); 112 - 113 106 /* The io structure describes IO port mapping */ 114 - link->io.NumPorts1 = 16; 115 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 116 - link->io.NumPorts2 = 0; 107 + p_dev->io.NumPorts1 = 16; 108 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 109 + p_dev->io.NumPorts2 = 0; 117 110 118 111 /* Interrupt setup */ 119 - link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 120 - link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; 112 + p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 113 + p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; 121 114 122 - link->irq.IRQInfo1 = IRQ_LEVEL_ID; 123 - 115 + p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; 116 + 124 117 /* General socket configuration */ 125 - link->conf.Attributes = CONF_ENABLE_IRQ; 126 - link->conf.Vcc = 50; 127 - link->conf.IntType = INT_MEMORY_AND_IO; 128 - link->conf.ConfigIndex = 1; 129 - link->conf.Present = PRESENT_OPTION; 118 + p_dev->conf.Attributes = CONF_ENABLE_IRQ; 119 + p_dev->conf.IntType = INT_MEMORY_AND_IO; 120 + p_dev->conf.ConfigIndex = 1; 121 + p_dev->conf.Present = PRESENT_OPTION; 130 122 131 123 /* Allocate space for private device-specific data */ 132 124 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 133 125 if (!local) 134 - goto err_kfree; 126 + goto err; 135 127 memset(local, 0, sizeof(local_info_t)); 136 - link->priv = local; 128 + p_dev->priv = local; 137 129 138 - link->handle = p_dev; 139 - p_dev->instance = link; 130 + return avmcs_config(p_dev); 140 131 141 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 142 - avmcs_config(link); 143 - 144 - return 0; 145 - 146 - err_kfree: 147 - kfree(link); 148 132 err: 149 - return -EINVAL; 133 + return -ENOMEM; 150 134 } /* avmcs_attach */ 151 135 152 136 /*====================================================================== ··· 142 158 143 159 ======================================================================*/ 144 160 145 - static void avmcs_detach(struct pcmcia_device *p_dev) 161 + static void avmcs_detach(struct pcmcia_device *link) 146 162 { 147 - dev_link_t *link = dev_to_instance(p_dev); 148 - 149 - if (link->state & DEV_CONFIG) 150 163 avmcs_release(link); 151 - 152 - kfree(link->priv); 153 - kfree(link); 164 + kfree(link->priv); 154 165 } /* avmcs_detach */ 155 166 156 167 /*====================================================================== ··· 156 177 157 178 ======================================================================*/ 158 179 159 - static int get_tuple(client_handle_t handle, tuple_t *tuple, 180 + static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, 160 181 cisparse_t *parse) 161 182 { 162 183 int i = pcmcia_get_tuple_data(handle, tuple); ··· 164 185 return pcmcia_parse_tuple(handle, tuple, parse); 165 186 } 166 187 167 - static int first_tuple(client_handle_t handle, tuple_t *tuple, 188 + static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, 168 189 cisparse_t *parse) 169 190 { 170 191 int i = pcmcia_get_first_tuple(handle, tuple); ··· 172 193 return get_tuple(handle, tuple, parse); 173 194 } 174 195 175 - static int next_tuple(client_handle_t handle, tuple_t *tuple, 196 + static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, 176 197 cisparse_t *parse) 177 198 { 178 199 int i = pcmcia_get_next_tuple(handle, tuple); ··· 180 201 return get_tuple(handle, tuple, parse); 181 202 } 182 203 183 - static void avmcs_config(dev_link_t *link) 204 + static int avmcs_config(struct pcmcia_device *link) 184 205 { 185 - client_handle_t handle; 186 206 tuple_t tuple; 187 207 cisparse_t parse; 188 208 cistpl_cftable_entry_t *cf = &parse.cftable_entry; ··· 191 213 char devname[128]; 192 214 int cardtype; 193 215 int (*addcard)(unsigned int port, unsigned irq); 194 - 195 - handle = link->handle; 216 + 196 217 dev = link->priv; 197 218 198 219 /* ··· 200 223 */ 201 224 do { 202 225 tuple.DesiredTuple = CISTPL_CONFIG; 203 - i = pcmcia_get_first_tuple(handle, &tuple); 226 + i = pcmcia_get_first_tuple(link, &tuple); 204 227 if (i != CS_SUCCESS) break; 205 228 tuple.TupleData = buf; 206 229 tuple.TupleDataMax = 64; 207 230 tuple.TupleOffset = 0; 208 - i = pcmcia_get_tuple_data(handle, &tuple); 231 + i = pcmcia_get_tuple_data(link, &tuple); 209 232 if (i != CS_SUCCESS) break; 210 - i = pcmcia_parse_tuple(handle, &tuple, &parse); 233 + i = pcmcia_parse_tuple(link, &tuple, &parse); 211 234 if (i != CS_SUCCESS) break; 212 235 link->conf.ConfigBase = parse.config.base; 213 236 } while (0); 214 237 if (i != CS_SUCCESS) { 215 - cs_error(link->handle, ParseTuple, i); 216 - link->state &= ~DEV_CONFIG_PENDING; 217 - return; 238 + cs_error(link, ParseTuple, i); 239 + return -ENODEV; 218 240 } 219 - 220 - /* Configure card */ 221 - link->state |= DEV_CONFIG; 222 241 223 242 do { 224 243 ··· 225 252 tuple.DesiredTuple = CISTPL_VERS_1; 226 253 227 254 devname[0] = 0; 228 - if( !first_tuple(handle, &tuple, &parse) && parse.version_1.ns > 1 ) { 255 + if( !first_tuple(link, &tuple, &parse) && parse.version_1.ns > 1 ) { 229 256 strlcpy(devname,parse.version_1.str + parse.version_1.ofs[1], 230 257 sizeof(devname)); 231 258 } ··· 236 263 tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 237 264 tuple.Attributes = 0; 238 265 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 239 - i = first_tuple(handle, &tuple, &parse); 266 + i = first_tuple(link, &tuple, &parse); 240 267 while (i == CS_SUCCESS) { 241 268 if (cf->io.nwin > 0) { 242 269 link->conf.ConfigIndex = cf->index; ··· 246 273 printk(KERN_INFO "avm_cs: testing i/o %#x-%#x\n", 247 274 link->io.BasePort1, 248 275 link->io.BasePort1+link->io.NumPorts1-1); 249 - i = pcmcia_request_io(link->handle, &link->io); 276 + i = pcmcia_request_io(link, &link->io); 250 277 if (i == CS_SUCCESS) goto found_port; 251 278 } 252 - i = next_tuple(handle, &tuple, &parse); 279 + i = next_tuple(link, &tuple, &parse); 253 280 } 254 281 255 282 found_port: 256 283 if (i != CS_SUCCESS) { 257 - cs_error(link->handle, RequestIO, i); 284 + cs_error(link, RequestIO, i); 258 285 break; 259 286 } 260 - 287 + 261 288 /* 262 289 * allocate an interrupt line 263 290 */ 264 - i = pcmcia_request_irq(link->handle, &link->irq); 291 + i = pcmcia_request_irq(link, &link->irq); 265 292 if (i != CS_SUCCESS) { 266 - cs_error(link->handle, RequestIRQ, i); 267 - pcmcia_release_io(link->handle, &link->io); 293 + cs_error(link, RequestIRQ, i); 294 + /* undo */ 295 + pcmcia_disable_device(link); 268 296 break; 269 297 } 270 - 298 + 271 299 /* 272 300 * configure the PCMCIA socket 273 301 */ 274 - i = pcmcia_request_configuration(link->handle, &link->conf); 302 + i = pcmcia_request_configuration(link, &link->conf); 275 303 if (i != CS_SUCCESS) { 276 - cs_error(link->handle, RequestConfiguration, i); 277 - pcmcia_release_io(link->handle, &link->io); 278 - pcmcia_release_irq(link->handle, &link->irq); 304 + cs_error(link, RequestConfiguration, i); 305 + pcmcia_disable_device(link); 279 306 break; 280 307 } 281 308 ··· 304 331 305 332 dev->node.major = 64; 306 333 dev->node.minor = 0; 307 - link->dev = &dev->node; 308 - 309 - link->state &= ~DEV_CONFIG_PENDING; 334 + link->dev_node = &dev->node; 335 + 310 336 /* If any step failed, release any partially configured state */ 311 337 if (i != 0) { 312 338 avmcs_release(link); 313 - return; 339 + return -ENODEV; 314 340 } 315 341 316 342 ··· 323 351 printk(KERN_ERR "avm_cs: failed to add AVM-%s-Controller at i/o %#x, irq %d\n", 324 352 dev->node.dev_name, link->io.BasePort1, link->irq.AssignedIRQ); 325 353 avmcs_release(link); 326 - return; 354 + return -ENODEV; 327 355 } 328 356 dev->node.minor = i; 357 + return 0; 329 358 330 359 } /* avmcs_config */ 331 360 ··· 338 365 339 366 ======================================================================*/ 340 367 341 - static void avmcs_release(dev_link_t *link) 368 + static void avmcs_release(struct pcmcia_device *link) 342 369 { 343 - b1pcmcia_delcard(link->io.BasePort1, link->irq.AssignedIRQ); 344 - 345 - /* Unlink the device chain */ 346 - link->dev = NULL; 347 - 348 - /* Don't bother checking to see if these succeed or not */ 349 - pcmcia_release_configuration(link->handle); 350 - pcmcia_release_io(link->handle, &link->io); 351 - pcmcia_release_irq(link->handle, &link->irq); 352 - link->state &= ~DEV_CONFIG; 370 + b1pcmcia_delcard(link->io.BasePort1, link->irq.AssignedIRQ); 371 + pcmcia_disable_device(link); 353 372 } /* avmcs_release */ 354 - 355 - static int avmcs_suspend(struct pcmcia_device *dev) 356 - { 357 - dev_link_t *link = dev_to_instance(dev); 358 - 359 - link->state |= DEV_SUSPEND; 360 - if (link->state & DEV_CONFIG) 361 - pcmcia_release_configuration(link->handle); 362 - 363 - return 0; 364 - } 365 - 366 - static int avmcs_resume(struct pcmcia_device *dev) 367 - { 368 - dev_link_t *link = dev_to_instance(dev); 369 - 370 - link->state &= ~DEV_SUSPEND; 371 - if (link->state & DEV_CONFIG) 372 - pcmcia_request_configuration(link->handle, &link->conf); 373 - 374 - return 0; 375 - } 376 - 377 - /*====================================================================== 378 - 379 - The card status event handler. Mostly, this schedules other 380 - stuff to run after an event is received. A CARD_REMOVAL event 381 - also sets some flags to discourage the net drivers from trying 382 - to talk to the card any more. 383 - 384 - When a CARD_REMOVAL event is received, we immediately set a flag 385 - to block future accesses to this device. All the functions that 386 - actually access the device should check this flag to make sure 387 - the card is still present. 388 - 389 - ======================================================================*/ 390 373 391 374 392 375 static struct pcmcia_device_id avmcs_ids[] = { ··· 358 429 .drv = { 359 430 .name = "avm_cs", 360 431 }, 361 - .probe = avmcs_attach, 432 + .probe = avmcs_probe, 362 433 .remove = avmcs_detach, 363 434 .id_table = avmcs_ids, 364 - .suspend= avmcs_suspend, 365 - .resume = avmcs_resume, 366 435 }; 367 436 368 437 static int __init avmcs_init(void)
+62 -120
drivers/isdn/hisax/avma1_cs.c
··· 67 67 handler. 68 68 */ 69 69 70 - static void avma1cs_config(dev_link_t *link); 71 - static void avma1cs_release(dev_link_t *link); 70 + static int avma1cs_config(struct pcmcia_device *link); 71 + static void avma1cs_release(struct pcmcia_device *link); 72 72 73 73 /* 74 74 The attach() and detach() entry points are used to create and destroy ··· 82 82 /* 83 83 A linked list of "instances" of the skeleton device. Each actual 84 84 PCMCIA card corresponds to one device instance, and is described 85 - by one dev_link_t structure (defined in ds.h). 85 + by one struct pcmcia_device structure (defined in ds.h). 86 86 87 87 You may not want to use a linked list for this -- for example, the 88 - memory card driver uses an array of dev_link_t pointers, where minor 88 + memory card driver uses an array of struct pcmcia_device pointers, where minor 89 89 device numbers are used to derive the corresponding array index. 90 90 */ 91 91 ··· 95 95 example, ethernet cards, modems). In other cases, there may be 96 96 many actual or logical devices (SCSI adapters, memory cards with 97 97 multiple partitions). The dev_node_t structures need to be kept 98 - in a linked list starting at the 'dev' field of a dev_link_t 98 + in a linked list starting at the 'dev' field of a struct pcmcia_device 99 99 structure. We allocate them in the card's private data structure, 100 100 because they generally can't be allocated dynamically. 101 101 */ ··· 116 116 117 117 ======================================================================*/ 118 118 119 - static int avma1cs_attach(struct pcmcia_device *p_dev) 119 + static int avma1cs_probe(struct pcmcia_device *p_dev) 120 120 { 121 - dev_link_t *link; 122 121 local_info_t *local; 123 122 124 123 DEBUG(0, "avma1cs_attach()\n"); 125 124 126 - /* Initialize the dev_link_t structure */ 127 - link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); 128 - if (!link) 129 - return -ENOMEM; 130 - memset(link, 0, sizeof(struct dev_link_t)); 131 - 132 125 /* Allocate space for private device-specific data */ 133 126 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 134 - if (!local) { 135 - kfree(link); 127 + if (!local) 136 128 return -ENOMEM; 137 - } 129 + 138 130 memset(local, 0, sizeof(local_info_t)); 139 - link->priv = local; 131 + p_dev->priv = local; 140 132 141 133 /* The io structure describes IO port mapping */ 142 - link->io.NumPorts1 = 16; 143 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 144 - link->io.NumPorts2 = 16; 145 - link->io.Attributes2 = IO_DATA_PATH_WIDTH_16; 146 - link->io.IOAddrLines = 5; 134 + p_dev->io.NumPorts1 = 16; 135 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 136 + p_dev->io.NumPorts2 = 16; 137 + p_dev->io.Attributes2 = IO_DATA_PATH_WIDTH_16; 138 + p_dev->io.IOAddrLines = 5; 147 139 148 140 /* Interrupt setup */ 149 - link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 150 - link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; 141 + p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 142 + p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; 151 143 152 - link->irq.IRQInfo1 = IRQ_LEVEL_ID; 144 + p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; 153 145 154 146 /* General socket configuration */ 155 - link->conf.Attributes = CONF_ENABLE_IRQ; 156 - link->conf.Vcc = 50; 157 - link->conf.IntType = INT_MEMORY_AND_IO; 158 - link->conf.ConfigIndex = 1; 159 - link->conf.Present = PRESENT_OPTION; 147 + p_dev->conf.Attributes = CONF_ENABLE_IRQ; 148 + p_dev->conf.IntType = INT_MEMORY_AND_IO; 149 + p_dev->conf.ConfigIndex = 1; 150 + p_dev->conf.Present = PRESENT_OPTION; 160 151 161 - link->handle = p_dev; 162 - p_dev->instance = link; 163 - 164 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 165 - avma1cs_config(link); 166 - 167 - return 0; 152 + return avma1cs_config(p_dev); 168 153 } /* avma1cs_attach */ 169 154 170 155 /*====================================================================== ··· 161 176 162 177 ======================================================================*/ 163 178 164 - static void avma1cs_detach(struct pcmcia_device *p_dev) 179 + static void avma1cs_detach(struct pcmcia_device *link) 165 180 { 166 - dev_link_t *link = dev_to_instance(p_dev); 167 - 168 - DEBUG(0, "avma1cs_detach(0x%p)\n", link); 169 - 170 - if (link->state & DEV_CONFIG) 171 - avma1cs_release(link); 172 - 173 - kfree(link->priv); 174 - kfree(link); 181 + DEBUG(0, "avma1cs_detach(0x%p)\n", link); 182 + avma1cs_release(link); 183 + kfree(link->priv); 175 184 } /* avma1cs_detach */ 176 185 177 186 /*====================================================================== ··· 176 197 177 198 ======================================================================*/ 178 199 179 - static int get_tuple(client_handle_t handle, tuple_t *tuple, 200 + static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, 180 201 cisparse_t *parse) 181 202 { 182 203 int i = pcmcia_get_tuple_data(handle, tuple); ··· 184 205 return pcmcia_parse_tuple(handle, tuple, parse); 185 206 } 186 207 187 - static int first_tuple(client_handle_t handle, tuple_t *tuple, 208 + static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, 188 209 cisparse_t *parse) 189 210 { 190 211 int i = pcmcia_get_first_tuple(handle, tuple); ··· 192 213 return get_tuple(handle, tuple, parse); 193 214 } 194 215 195 - static int next_tuple(client_handle_t handle, tuple_t *tuple, 216 + static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, 196 217 cisparse_t *parse) 197 218 { 198 219 int i = pcmcia_get_next_tuple(handle, tuple); ··· 200 221 return get_tuple(handle, tuple, parse); 201 222 } 202 223 203 - static void avma1cs_config(dev_link_t *link) 224 + static int avma1cs_config(struct pcmcia_device *link) 204 225 { 205 - client_handle_t handle; 206 226 tuple_t tuple; 207 227 cisparse_t parse; 208 228 cistpl_cftable_entry_t *cf = &parse.cftable_entry; ··· 211 233 char devname[128]; 212 234 IsdnCard_t icard; 213 235 int busy = 0; 214 - 215 - handle = link->handle; 236 + 216 237 dev = link->priv; 217 238 218 239 DEBUG(0, "avma1cs_config(0x%p)\n", link); ··· 222 245 */ 223 246 do { 224 247 tuple.DesiredTuple = CISTPL_CONFIG; 225 - i = pcmcia_get_first_tuple(handle, &tuple); 248 + i = pcmcia_get_first_tuple(link, &tuple); 226 249 if (i != CS_SUCCESS) break; 227 250 tuple.TupleData = buf; 228 251 tuple.TupleDataMax = 64; 229 252 tuple.TupleOffset = 0; 230 - i = pcmcia_get_tuple_data(handle, &tuple); 253 + i = pcmcia_get_tuple_data(link, &tuple); 231 254 if (i != CS_SUCCESS) break; 232 - i = pcmcia_parse_tuple(handle, &tuple, &parse); 255 + i = pcmcia_parse_tuple(link, &tuple, &parse); 233 256 if (i != CS_SUCCESS) break; 234 257 link->conf.ConfigBase = parse.config.base; 235 258 } while (0); 236 259 if (i != CS_SUCCESS) { 237 - cs_error(link->handle, ParseTuple, i); 238 - link->state &= ~DEV_CONFIG_PENDING; 239 - return; 260 + cs_error(link, ParseTuple, i); 261 + return -ENODEV; 240 262 } 241 - 242 - /* Configure card */ 243 - link->state |= DEV_CONFIG; 244 263 245 264 do { 246 265 ··· 247 274 tuple.DesiredTuple = CISTPL_VERS_1; 248 275 249 276 devname[0] = 0; 250 - if( !first_tuple(handle, &tuple, &parse) && parse.version_1.ns > 1 ) { 277 + if( !first_tuple(link, &tuple, &parse) && parse.version_1.ns > 1 ) { 251 278 strlcpy(devname,parse.version_1.str + parse.version_1.ofs[1], 252 279 sizeof(devname)); 253 280 } ··· 258 285 tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 259 286 tuple.Attributes = 0; 260 287 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 261 - i = first_tuple(handle, &tuple, &parse); 288 + i = first_tuple(link, &tuple, &parse); 262 289 while (i == CS_SUCCESS) { 263 290 if (cf->io.nwin > 0) { 264 291 link->conf.ConfigIndex = cf->index; ··· 268 295 printk(KERN_INFO "avma1_cs: testing i/o %#x-%#x\n", 269 296 link->io.BasePort1, 270 297 link->io.BasePort1+link->io.NumPorts1 - 1); 271 - i = pcmcia_request_io(link->handle, &link->io); 298 + i = pcmcia_request_io(link, &link->io); 272 299 if (i == CS_SUCCESS) goto found_port; 273 300 } 274 - i = next_tuple(handle, &tuple, &parse); 301 + i = next_tuple(link, &tuple, &parse); 275 302 } 276 303 277 304 found_port: 278 305 if (i != CS_SUCCESS) { 279 - cs_error(link->handle, RequestIO, i); 306 + cs_error(link, RequestIO, i); 280 307 break; 281 308 } 282 309 283 310 /* 284 311 * allocate an interrupt line 285 312 */ 286 - i = pcmcia_request_irq(link->handle, &link->irq); 313 + i = pcmcia_request_irq(link, &link->irq); 287 314 if (i != CS_SUCCESS) { 288 - cs_error(link->handle, RequestIRQ, i); 289 - pcmcia_release_io(link->handle, &link->io); 315 + cs_error(link, RequestIRQ, i); 316 + /* undo */ 317 + pcmcia_disable_device(link); 290 318 break; 291 319 } 292 - 320 + 293 321 /* 294 322 * configure the PCMCIA socket 295 323 */ 296 - i = pcmcia_request_configuration(link->handle, &link->conf); 324 + i = pcmcia_request_configuration(link, &link->conf); 297 325 if (i != CS_SUCCESS) { 298 - cs_error(link->handle, RequestConfiguration, i); 299 - pcmcia_release_io(link->handle, &link->io); 300 - pcmcia_release_irq(link->handle, &link->irq); 326 + cs_error(link, RequestConfiguration, i); 327 + pcmcia_disable_device(link); 301 328 break; 302 329 } 303 330 ··· 309 336 strcpy(dev->node.dev_name, "A1"); 310 337 dev->node.major = 45; 311 338 dev->node.minor = 0; 312 - link->dev = &dev->node; 313 - 314 - link->state &= ~DEV_CONFIG_PENDING; 339 + link->dev_node = &dev->node; 340 + 315 341 /* If any step failed, release any partially configured state */ 316 342 if (i != 0) { 317 343 avma1cs_release(link); 318 - return; 344 + return -ENODEV; 319 345 } 320 346 321 347 printk(KERN_NOTICE "avma1_cs: checking at i/o %#x, irq %d\n", ··· 329 357 if (i < 0) { 330 358 printk(KERN_ERR "avma1_cs: failed to initialize AVM A1 PCMCIA %d at i/o %#x\n", i, link->io.BasePort1); 331 359 avma1cs_release(link); 332 - return; 360 + return -ENODEV; 333 361 } 334 362 dev->node.minor = i; 335 363 364 + return 0; 336 365 } /* avma1cs_config */ 337 366 338 367 /*====================================================================== ··· 344 371 345 372 ======================================================================*/ 346 373 347 - static void avma1cs_release(dev_link_t *link) 374 + static void avma1cs_release(struct pcmcia_device *link) 348 375 { 349 - local_info_t *local = link->priv; 376 + local_info_t *local = link->priv; 350 377 351 - DEBUG(0, "avma1cs_release(0x%p)\n", link); 378 + DEBUG(0, "avma1cs_release(0x%p)\n", link); 352 379 353 - /* no unregister function with hisax */ 354 - HiSax_closecard(local->node.minor); 380 + /* now unregister function with hisax */ 381 + HiSax_closecard(local->node.minor); 355 382 356 - /* Unlink the device chain */ 357 - link->dev = NULL; 358 - 359 - /* Don't bother checking to see if these succeed or not */ 360 - pcmcia_release_configuration(link->handle); 361 - pcmcia_release_io(link->handle, &link->io); 362 - pcmcia_release_irq(link->handle, &link->irq); 363 - link->state &= ~DEV_CONFIG; 383 + pcmcia_disable_device(link); 364 384 } /* avma1cs_release */ 365 - 366 - static int avma1cs_suspend(struct pcmcia_device *dev) 367 - { 368 - dev_link_t *link = dev_to_instance(dev); 369 - 370 - link->state |= DEV_SUSPEND; 371 - if (link->state & DEV_CONFIG) 372 - pcmcia_release_configuration(link->handle); 373 - 374 - return 0; 375 - } 376 - 377 - static int avma1cs_resume(struct pcmcia_device *dev) 378 - { 379 - dev_link_t *link = dev_to_instance(dev); 380 - 381 - link->state &= ~DEV_SUSPEND; 382 - if (link->state & DEV_CONFIG) 383 - pcmcia_request_configuration(link->handle, &link->conf); 384 - 385 - return 0; 386 - } 387 385 388 386 389 387 static struct pcmcia_device_id avma1cs_ids[] = { ··· 369 425 .drv = { 370 426 .name = "avma1_cs", 371 427 }, 372 - .probe = avma1cs_attach, 428 + .probe = avma1cs_probe, 373 429 .remove = avma1cs_detach, 374 430 .id_table = avma1cs_ids, 375 - .suspend = avma1cs_suspend, 376 - .resume = avma1cs_resume, 377 431 }; 378 - 432 + 379 433 /*====================================================================*/ 380 434 381 435 static int __init init_avma1_cs(void)
+38 -72
drivers/isdn/hisax/elsa_cs.c
··· 94 94 handler. 95 95 */ 96 96 97 - static void elsa_cs_config(dev_link_t *link); 98 - static void elsa_cs_release(dev_link_t *link); 97 + static int elsa_cs_config(struct pcmcia_device *link); 98 + static void elsa_cs_release(struct pcmcia_device *link); 99 99 100 100 /* 101 101 The attach() and detach() entry points are used to create and destroy ··· 111 111 example, ethernet cards, modems). In other cases, there may be 112 112 many actual or logical devices (SCSI adapters, memory cards with 113 113 multiple partitions). The dev_node_t structures need to be kept 114 - in a linked list starting at the 'dev' field of a dev_link_t 114 + in a linked list starting at the 'dev' field of a struct pcmcia_device 115 115 structure. We allocate them in the card's private data structure, 116 116 because they generally shouldn't be allocated dynamically. 117 117 In this case, we also provide a flag to indicate if a device is ··· 121 121 */ 122 122 123 123 typedef struct local_info_t { 124 - dev_link_t link; 124 + struct pcmcia_device *p_dev; 125 125 dev_node_t node; 126 126 int busy; 127 127 int cardnr; ··· 139 139 140 140 ======================================================================*/ 141 141 142 - static int elsa_cs_attach(struct pcmcia_device *p_dev) 142 + static int elsa_cs_probe(struct pcmcia_device *link) 143 143 { 144 - dev_link_t *link; 145 144 local_info_t *local; 146 145 147 146 DEBUG(0, "elsa_cs_attach()\n"); ··· 149 150 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 150 151 if (!local) return -ENOMEM; 151 152 memset(local, 0, sizeof(local_info_t)); 153 + 154 + local->p_dev = link; 155 + link->priv = local; 156 + 152 157 local->cardnr = -1; 153 - link = &local->link; link->priv = local; 154 158 155 159 /* Interrupt setup */ 156 160 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; ··· 172 170 link->io.IOAddrLines = 3; 173 171 174 172 link->conf.Attributes = CONF_ENABLE_IRQ; 175 - link->conf.Vcc = 50; 176 173 link->conf.IntType = INT_MEMORY_AND_IO; 177 174 178 - link->handle = p_dev; 179 - p_dev->instance = link; 180 - 181 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 182 - elsa_cs_config(link); 183 - 184 - return 0; 175 + return elsa_cs_config(link); 185 176 } /* elsa_cs_attach */ 186 177 187 178 /*====================================================================== ··· 186 191 187 192 ======================================================================*/ 188 193 189 - static void elsa_cs_detach(struct pcmcia_device *p_dev) 194 + static void elsa_cs_detach(struct pcmcia_device *link) 190 195 { 191 - dev_link_t *link = dev_to_instance(p_dev); 192 - local_info_t *info = link->priv; 196 + local_info_t *info = link->priv; 193 197 194 - DEBUG(0, "elsa_cs_detach(0x%p)\n", link); 198 + DEBUG(0, "elsa_cs_detach(0x%p)\n", link); 195 199 196 - if (link->state & DEV_CONFIG) { 197 - info->busy = 1; 198 - elsa_cs_release(link); 199 - } 200 + info->busy = 1; 201 + elsa_cs_release(link); 200 202 201 - kfree(info); 202 - 203 + kfree(info); 203 204 } /* elsa_cs_detach */ 204 205 205 206 /*====================================================================== ··· 205 214 device available to the system. 206 215 207 216 ======================================================================*/ 208 - static int get_tuple(client_handle_t handle, tuple_t *tuple, 217 + static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, 209 218 cisparse_t *parse) 210 219 { 211 220 int i = pcmcia_get_tuple_data(handle, tuple); ··· 213 222 return pcmcia_parse_tuple(handle, tuple, parse); 214 223 } 215 224 216 - static int first_tuple(client_handle_t handle, tuple_t *tuple, 225 + static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, 217 226 cisparse_t *parse) 218 227 { 219 228 int i = pcmcia_get_first_tuple(handle, tuple); ··· 221 230 return get_tuple(handle, tuple, parse); 222 231 } 223 232 224 - static int next_tuple(client_handle_t handle, tuple_t *tuple, 233 + static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, 225 234 cisparse_t *parse) 226 235 { 227 236 int i = pcmcia_get_next_tuple(handle, tuple); ··· 229 238 return get_tuple(handle, tuple, parse); 230 239 } 231 240 232 - static void elsa_cs_config(dev_link_t *link) 241 + static int elsa_cs_config(struct pcmcia_device *link) 233 242 { 234 - client_handle_t handle; 235 243 tuple_t tuple; 236 244 cisparse_t parse; 237 245 local_info_t *dev; ··· 240 250 IsdnCard_t icard; 241 251 242 252 DEBUG(0, "elsa_config(0x%p)\n", link); 243 - handle = link->handle; 244 253 dev = link->priv; 245 254 246 255 /* ··· 251 262 tuple.TupleDataMax = 255; 252 263 tuple.TupleOffset = 0; 253 264 tuple.Attributes = 0; 254 - i = first_tuple(handle, &tuple, &parse); 265 + i = first_tuple(link, &tuple, &parse); 255 266 if (i != CS_SUCCESS) { 256 267 last_fn = ParseTuple; 257 268 goto cs_failed; ··· 259 270 link->conf.ConfigBase = parse.config.base; 260 271 link->conf.Present = parse.config.rmask[0]; 261 272 262 - /* Configure card */ 263 - link->state |= DEV_CONFIG; 264 - 265 273 tuple.TupleData = (cisdata_t *)buf; 266 274 tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 267 275 tuple.Attributes = 0; 268 276 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 269 - i = first_tuple(handle, &tuple, &parse); 277 + i = first_tuple(link, &tuple, &parse); 270 278 while (i == CS_SUCCESS) { 271 279 if ( (cf->io.nwin > 0) && cf->io.win[0].base) { 272 280 printk(KERN_INFO "(elsa_cs: looks like the 96 model)\n"); 273 281 link->conf.ConfigIndex = cf->index; 274 282 link->io.BasePort1 = cf->io.win[0].base; 275 - i = pcmcia_request_io(link->handle, &link->io); 283 + i = pcmcia_request_io(link, &link->io); 276 284 if (i == CS_SUCCESS) break; 277 285 } else { 278 286 printk(KERN_INFO "(elsa_cs: looks like the 97 model)\n"); 279 287 link->conf.ConfigIndex = cf->index; 280 288 for (i = 0, j = 0x2f0; j > 0x100; j -= 0x10) { 281 289 link->io.BasePort1 = j; 282 - i = pcmcia_request_io(link->handle, &link->io); 290 + i = pcmcia_request_io(link, &link->io); 283 291 if (i == CS_SUCCESS) break; 284 292 } 285 293 break; 286 294 } 287 - i = next_tuple(handle, &tuple, &parse); 295 + i = next_tuple(link, &tuple, &parse); 288 296 } 289 297 290 298 if (i != CS_SUCCESS) { ··· 289 303 goto cs_failed; 290 304 } 291 305 292 - i = pcmcia_request_irq(link->handle, &link->irq); 306 + i = pcmcia_request_irq(link, &link->irq); 293 307 if (i != CS_SUCCESS) { 294 308 link->irq.AssignedIRQ = 0; 295 309 last_fn = RequestIRQ; 296 310 goto cs_failed; 297 311 } 298 312 299 - i = pcmcia_request_configuration(link->handle, &link->conf); 313 + i = pcmcia_request_configuration(link, &link->conf); 300 314 if (i != CS_SUCCESS) { 301 315 last_fn = RequestConfiguration; 302 316 goto cs_failed; ··· 307 321 sprintf(dev->node.dev_name, "elsa"); 308 322 dev->node.major = dev->node.minor = 0x0; 309 323 310 - link->dev = &dev->node; 324 + link->dev_node = &dev->node; 311 325 312 326 /* Finally, report what we've done */ 313 - printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d", 314 - dev->node.dev_name, link->conf.ConfigIndex, 315 - link->conf.Vcc/10, link->conf.Vcc%10); 316 - if (link->conf.Vpp1) 317 - printk(", Vpp %d.%d", link->conf.Vpp1/10, link->conf.Vpp1%10); 327 + printk(KERN_INFO "%s: index 0x%02x: ", 328 + dev->node.dev_name, link->conf.ConfigIndex); 318 329 if (link->conf.Attributes & CONF_ENABLE_IRQ) 319 330 printk(", irq %d", link->irq.AssignedIRQ); 320 331 if (link->io.NumPorts1) ··· 321 338 printk(" & 0x%04x-0x%04x", link->io.BasePort2, 322 339 link->io.BasePort2+link->io.NumPorts2-1); 323 340 printk("\n"); 324 - 325 - link->state &= ~DEV_CONFIG_PENDING; 326 341 327 342 icard.para[0] = link->irq.AssignedIRQ; 328 343 icard.para[1] = link->io.BasePort1; ··· 335 354 } else 336 355 ((local_info_t*)link->priv)->cardnr = i; 337 356 338 - return; 357 + return 0; 339 358 cs_failed: 340 - cs_error(link->handle, last_fn, i); 359 + cs_error(link, last_fn, i); 341 360 elsa_cs_release(link); 361 + return -ENODEV; 342 362 } /* elsa_cs_config */ 343 363 344 364 /*====================================================================== ··· 350 368 351 369 ======================================================================*/ 352 370 353 - static void elsa_cs_release(dev_link_t *link) 371 + static void elsa_cs_release(struct pcmcia_device *link) 354 372 { 355 373 local_info_t *local = link->priv; 356 374 ··· 362 380 HiSax_closecard(local->cardnr); 363 381 } 364 382 } 365 - /* Unlink the device chain */ 366 - link->dev = NULL; 367 383 368 - /* Don't bother checking to see if these succeed or not */ 369 - if (link->win) 370 - pcmcia_release_window(link->win); 371 - pcmcia_release_configuration(link->handle); 372 - pcmcia_release_io(link->handle, &link->io); 373 - pcmcia_release_irq(link->handle, &link->irq); 374 - link->state &= ~DEV_CONFIG; 384 + pcmcia_disable_device(link); 375 385 } /* elsa_cs_release */ 376 386 377 - static int elsa_suspend(struct pcmcia_device *p_dev) 387 + static int elsa_suspend(struct pcmcia_device *link) 378 388 { 379 - dev_link_t *link = dev_to_instance(p_dev); 380 389 local_info_t *dev = link->priv; 381 390 382 - link->state |= DEV_SUSPEND; 383 391 dev->busy = 1; 384 - if (link->state & DEV_CONFIG) 385 - pcmcia_release_configuration(link->handle); 386 392 387 393 return 0; 388 394 } 389 395 390 - static int elsa_resume(struct pcmcia_device *p_dev) 396 + static int elsa_resume(struct pcmcia_device *link) 391 397 { 392 - dev_link_t *link = dev_to_instance(p_dev); 393 398 local_info_t *dev = link->priv; 394 399 395 - link->state &= ~DEV_SUSPEND; 396 - if (link->state & DEV_CONFIG) 397 - pcmcia_request_configuration(link->handle, &link->conf); 398 400 dev->busy = 0; 399 401 400 402 return 0; ··· 396 430 .drv = { 397 431 .name = "elsa_cs", 398 432 }, 399 - .probe = elsa_cs_attach, 433 + .probe = elsa_cs_probe, 400 434 .remove = elsa_cs_detach, 401 435 .id_table = elsa_ids, 402 436 .suspend = elsa_suspend,
+49 -94
drivers/isdn/hisax/sedlbauer_cs.c
··· 95 95 event handler. 96 96 */ 97 97 98 - static void sedlbauer_config(dev_link_t *link); 99 - static void sedlbauer_release(dev_link_t *link); 98 + static int sedlbauer_config(struct pcmcia_device *link); 99 + static void sedlbauer_release(struct pcmcia_device *link); 100 100 101 101 /* 102 102 The attach() and detach() entry points are used to create and destroy ··· 119 119 example, ethernet cards, modems). In other cases, there may be 120 120 many actual or logical devices (SCSI adapters, memory cards with 121 121 multiple partitions). The dev_node_t structures need to be kept 122 - in a linked list starting at the 'dev' field of a dev_link_t 122 + in a linked list starting at the 'dev' field of a struct pcmcia_device 123 123 structure. We allocate them in the card's private data structure, 124 124 because they generally shouldn't be allocated dynamically. 125 125 ··· 130 130 */ 131 131 132 132 typedef struct local_info_t { 133 - dev_link_t link; 133 + struct pcmcia_device *p_dev; 134 134 dev_node_t node; 135 135 int stop; 136 136 int cardnr; ··· 148 148 149 149 ======================================================================*/ 150 150 151 - static int sedlbauer_attach(struct pcmcia_device *p_dev) 151 + static int sedlbauer_probe(struct pcmcia_device *link) 152 152 { 153 153 local_info_t *local; 154 - dev_link_t *link; 155 - 154 + 156 155 DEBUG(0, "sedlbauer_attach()\n"); 157 156 158 157 /* Allocate space for private device-specific data */ ··· 159 160 if (!local) return -ENOMEM; 160 161 memset(local, 0, sizeof(local_info_t)); 161 162 local->cardnr = -1; 162 - link = &local->link; link->priv = local; 163 - 163 + 164 + local->p_dev = link; 165 + link->priv = local; 166 + 164 167 /* Interrupt setup */ 165 168 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 166 169 link->irq.IRQInfo1 = IRQ_LEVEL_ID; ··· 183 182 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 184 183 link->io.IOAddrLines = 3; 185 184 186 - 187 185 link->conf.Attributes = 0; 188 - link->conf.Vcc = 50; 189 186 link->conf.IntType = INT_MEMORY_AND_IO; 190 187 191 - link->handle = p_dev; 192 - p_dev->instance = link; 193 - 194 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 195 - sedlbauer_config(link); 196 - 197 - return 0; 188 + return sedlbauer_config(link); 198 189 } /* sedlbauer_attach */ 199 190 200 191 /*====================================================================== ··· 198 205 199 206 ======================================================================*/ 200 207 201 - static void sedlbauer_detach(struct pcmcia_device *p_dev) 208 + static void sedlbauer_detach(struct pcmcia_device *link) 202 209 { 203 - dev_link_t *link = dev_to_instance(p_dev); 210 + DEBUG(0, "sedlbauer_detach(0x%p)\n", link); 204 211 205 - DEBUG(0, "sedlbauer_detach(0x%p)\n", link); 212 + ((local_info_t *)link->priv)->stop = 1; 213 + sedlbauer_release(link); 206 214 207 - if (link->state & DEV_CONFIG) { 208 - ((local_info_t *)link->priv)->stop = 1; 209 - sedlbauer_release(link); 210 - } 211 - 212 - /* This points to the parent local_info_t struct */ 213 - kfree(link->priv); 215 + /* This points to the parent local_info_t struct */ 216 + kfree(link->priv); 214 217 } /* sedlbauer_detach */ 215 218 216 219 /*====================================================================== ··· 219 230 #define CS_CHECK(fn, ret) \ 220 231 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 221 232 222 - static void sedlbauer_config(dev_link_t *link) 233 + static int sedlbauer_config(struct pcmcia_device *link) 223 234 { 224 - client_handle_t handle = link->handle; 225 235 local_info_t *dev = link->priv; 226 236 tuple_t tuple; 227 237 cisparse_t parse; ··· 242 254 tuple.TupleData = buf; 243 255 tuple.TupleDataMax = sizeof(buf); 244 256 tuple.TupleOffset = 0; 245 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 246 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 247 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 257 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 258 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 259 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 248 260 link->conf.ConfigBase = parse.config.base; 249 261 link->conf.Present = parse.config.rmask[0]; 250 - 251 - /* Configure card */ 252 - link->state |= DEV_CONFIG; 253 262 254 - /* Look up the current Vcc */ 255 - CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf)); 256 - link->conf.Vcc = conf.Vcc; 263 + CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &conf)); 257 264 258 265 /* 259 266 In this loop, we scan the CIS for configuration table entries, ··· 263 280 will only use the CIS to fill in implementation-defined details. 264 281 */ 265 282 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 266 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 283 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 267 284 while (1) { 268 285 cistpl_cftable_entry_t dflt = { 0 }; 269 286 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 270 - if (pcmcia_get_tuple_data(handle, &tuple) != 0 || 271 - pcmcia_parse_tuple(handle, &tuple, &parse) != 0) 287 + if (pcmcia_get_tuple_data(link, &tuple) != 0 || 288 + pcmcia_parse_tuple(link, &tuple, &parse) != 0) 272 289 goto next_entry; 273 290 274 291 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; ··· 292 309 } 293 310 294 311 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) 295 - link->conf.Vpp1 = link->conf.Vpp2 = 312 + link->conf.Vpp = 296 313 cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; 297 314 else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) 298 - link->conf.Vpp1 = link->conf.Vpp2 = 315 + link->conf.Vpp = 299 316 dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; 300 317 301 318 /* Do we need to allocate an interrupt? */ ··· 322 339 link->io.NumPorts2 = io->win[1].len; 323 340 } 324 341 /* This reserves IO space but doesn't actually enable it */ 325 - if (pcmcia_request_io(link->handle, &link->io) != 0) 342 + if (pcmcia_request_io(link, &link->io) != 0) 326 343 goto next_entry; 327 344 } 328 345 329 346 /* 330 347 Now set up a common memory window, if needed. There is room 331 - in the dev_link_t structure for one memory window handle, 348 + in the struct pcmcia_device structure for one memory window handle, 332 349 but if the base addresses need to be saved, or if multiple 333 350 windows are needed, the info should go in the private data 334 351 structure for this device. ··· 349 366 req.Size = 0x1000; 350 367 */ 351 368 req.AccessSpeed = 0; 352 - if (pcmcia_request_window(&link->handle, &req, &link->win) != 0) 369 + if (pcmcia_request_window(&link, &req, &link->win) != 0) 353 370 goto next_entry; 354 371 map.Page = 0; map.CardOffset = mem->win[0].card_addr; 355 372 if (pcmcia_map_mem_page(link->win, &map) != 0) ··· 357 374 } 358 375 /* If we got this far, we're cool! */ 359 376 break; 360 - 377 + 361 378 next_entry: 362 - /* new in dummy.cs 2001/01/28 MN 363 - if (link->io.NumPorts1) 364 - pcmcia_release_io(link->handle, &link->io); 365 - */ 366 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); 379 + CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 367 380 } 368 - 381 + 369 382 /* 370 383 Allocate an interrupt line. Note that this does not assign a 371 384 handler to the interrupt, unless the 'Handler' member of the 372 385 irq structure is initialized. 373 386 */ 374 387 if (link->conf.Attributes & CONF_ENABLE_IRQ) 375 - CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 388 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 376 389 377 390 /* 378 391 This actually configures the PCMCIA socket -- setting up 379 392 the I/O windows and the interrupt mapping, and putting the 380 393 card and host interface into "Memory and IO" mode. 381 394 */ 382 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 395 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 383 396 384 397 /* 385 398 At this point, the dev_node_t structure(s) need to be ··· 383 404 */ 384 405 sprintf(dev->node.dev_name, "sedlbauer"); 385 406 dev->node.major = dev->node.minor = 0; 386 - link->dev = &dev->node; 407 + link->dev_node = &dev->node; 387 408 388 409 /* Finally, report what we've done */ 389 - printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d", 390 - dev->node.dev_name, link->conf.ConfigIndex, 391 - link->conf.Vcc/10, link->conf.Vcc%10); 392 - if (link->conf.Vpp1) 393 - printk(", Vpp %d.%d", link->conf.Vpp1/10, link->conf.Vpp1%10); 410 + printk(KERN_INFO "%s: index 0x%02x:", 411 + dev->node.dev_name, link->conf.ConfigIndex); 412 + if (link->conf.Vpp) 413 + printk(", Vpp %d.%d", link->conf.Vpp/10, link->conf.Vpp%10); 394 414 if (link->conf.Attributes & CONF_ENABLE_IRQ) 395 415 printk(", irq %d", link->irq.AssignedIRQ); 396 416 if (link->io.NumPorts1) ··· 402 424 printk(", mem 0x%06lx-0x%06lx", req.Base, 403 425 req.Base+req.Size-1); 404 426 printk("\n"); 405 - 406 - link->state &= ~DEV_CONFIG_PENDING; 407 427 408 428 icard.para[0] = link->irq.AssignedIRQ; 409 429 icard.para[1] = link->io.BasePort1; ··· 413 437 printk(KERN_ERR "sedlbauer_cs: failed to initialize SEDLBAUER PCMCIA %d at i/o %#x\n", 414 438 last_ret, link->io.BasePort1); 415 439 sedlbauer_release(link); 440 + return -ENODEV; 416 441 } else 417 442 ((local_info_t*)link->priv)->cardnr = last_ret; 418 443 419 - return; 444 + return 0; 420 445 421 446 cs_failed: 422 - cs_error(link->handle, last_fn, last_ret); 447 + cs_error(link, last_fn, last_ret); 423 448 sedlbauer_release(link); 449 + return -ENODEV; 424 450 425 451 } /* sedlbauer_config */ 426 452 ··· 434 456 435 457 ======================================================================*/ 436 458 437 - static void sedlbauer_release(dev_link_t *link) 459 + static void sedlbauer_release(struct pcmcia_device *link) 438 460 { 439 461 local_info_t *local = link->priv; 440 462 DEBUG(0, "sedlbauer_release(0x%p)\n", link); ··· 445 467 HiSax_closecard(local->cardnr); 446 468 } 447 469 } 448 - /* Unlink the device chain */ 449 - link->dev = NULL; 450 470 451 - /* 452 - In a normal driver, additional code may be needed to release 453 - other kernel data structures associated with this device. 454 - */ 455 - 456 - /* Don't bother checking to see if these succeed or not */ 457 - if (link->win) 458 - pcmcia_release_window(link->win); 459 - pcmcia_release_configuration(link->handle); 460 - if (link->io.NumPorts1) 461 - pcmcia_release_io(link->handle, &link->io); 462 - if (link->irq.AssignedIRQ) 463 - pcmcia_release_irq(link->handle, &link->irq); 464 - link->state &= ~DEV_CONFIG; 471 + pcmcia_disable_device(link); 465 472 } /* sedlbauer_release */ 466 473 467 - static int sedlbauer_suspend(struct pcmcia_device *p_dev) 474 + static int sedlbauer_suspend(struct pcmcia_device *link) 468 475 { 469 - dev_link_t *link = dev_to_instance(p_dev); 470 476 local_info_t *dev = link->priv; 471 477 472 - link->state |= DEV_SUSPEND; 473 478 dev->stop = 1; 474 - if (link->state & DEV_CONFIG) 475 - pcmcia_release_configuration(link->handle); 476 479 477 480 return 0; 478 481 } 479 482 480 - static int sedlbauer_resume(struct pcmcia_device *p_dev) 483 + static int sedlbauer_resume(struct pcmcia_device *link) 481 484 { 482 - dev_link_t *link = dev_to_instance(p_dev); 483 485 local_info_t *dev = link->priv; 484 486 485 - link->state &= ~DEV_SUSPEND; 486 - if (link->state & DEV_CONFIG) 487 - pcmcia_request_configuration(link->handle, &link->conf); 488 487 dev->stop = 0; 489 488 490 489 return 0; ··· 485 530 .drv = { 486 531 .name = "sedlbauer_cs", 487 532 }, 488 - .probe = sedlbauer_attach, 533 + .probe = sedlbauer_probe, 489 534 .remove = sedlbauer_detach, 490 535 .id_table = sedlbauer_ids, 491 536 .suspend = sedlbauer_suspend,
+43 -76
drivers/isdn/hisax/teles_cs.c
··· 75 75 handler. 76 76 */ 77 77 78 - static void teles_cs_config(dev_link_t *link); 79 - static void teles_cs_release(dev_link_t *link); 78 + static int teles_cs_config(struct pcmcia_device *link); 79 + static void teles_cs_release(struct pcmcia_device *link); 80 80 81 81 /* 82 82 The attach() and detach() entry points are used to create and destroy ··· 89 89 /* 90 90 A linked list of "instances" of the teles_cs device. Each actual 91 91 PCMCIA card corresponds to one device instance, and is described 92 - by one dev_link_t structure (defined in ds.h). 92 + by one struct pcmcia_device structure (defined in ds.h). 93 93 94 94 You may not want to use a linked list for this -- for example, the 95 - memory card driver uses an array of dev_link_t pointers, where minor 95 + memory card driver uses an array of struct pcmcia_device pointers, where minor 96 96 device numbers are used to derive the corresponding array index. 97 97 */ 98 98 ··· 102 102 example, ethernet cards, modems). In other cases, there may be 103 103 many actual or logical devices (SCSI adapters, memory cards with 104 104 multiple partitions). The dev_node_t structures need to be kept 105 - in a linked list starting at the 'dev' field of a dev_link_t 105 + in a linked list starting at the 'dev' field of a struct pcmcia_device 106 106 structure. We allocate them in the card's private data structure, 107 107 because they generally shouldn't be allocated dynamically. 108 108 In this case, we also provide a flag to indicate if a device is ··· 112 112 */ 113 113 114 114 typedef struct local_info_t { 115 - dev_link_t link; 115 + struct pcmcia_device *p_dev; 116 116 dev_node_t node; 117 117 int busy; 118 118 int cardnr; ··· 130 130 131 131 ======================================================================*/ 132 132 133 - static int teles_attach(struct pcmcia_device *p_dev) 133 + static int teles_probe(struct pcmcia_device *link) 134 134 { 135 - dev_link_t *link; 136 135 local_info_t *local; 137 136 138 137 DEBUG(0, "teles_attach()\n"); ··· 141 142 if (!local) return -ENOMEM; 142 143 memset(local, 0, sizeof(local_info_t)); 143 144 local->cardnr = -1; 144 - link = &local->link; link->priv = local; 145 + 146 + local->p_dev = link; 147 + link->priv = local; 145 148 146 149 /* Interrupt setup */ 147 150 link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING|IRQ_FIRST_SHARED; ··· 162 161 link->io.IOAddrLines = 5; 163 162 164 163 link->conf.Attributes = CONF_ENABLE_IRQ; 165 - link->conf.Vcc = 50; 166 164 link->conf.IntType = INT_MEMORY_AND_IO; 167 165 168 - link->handle = p_dev; 169 - p_dev->instance = link; 170 - 171 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 172 - teles_cs_config(link); 173 - 174 - return 0; 166 + return teles_cs_config(link); 175 167 } /* teles_attach */ 176 168 177 169 /*====================================================================== ··· 176 182 177 183 ======================================================================*/ 178 184 179 - static void teles_detach(struct pcmcia_device *p_dev) 185 + static void teles_detach(struct pcmcia_device *link) 180 186 { 181 - dev_link_t *link = dev_to_instance(p_dev); 182 - local_info_t *info = link->priv; 187 + local_info_t *info = link->priv; 183 188 184 - DEBUG(0, "teles_detach(0x%p)\n", link); 189 + DEBUG(0, "teles_detach(0x%p)\n", link); 185 190 186 - if (link->state & DEV_CONFIG) { 187 - info->busy = 1; 188 - teles_cs_release(link); 189 - } 191 + info->busy = 1; 192 + teles_cs_release(link); 190 193 191 - kfree(info); 192 - 194 + kfree(info); 193 195 } /* teles_detach */ 194 196 195 197 /*====================================================================== ··· 195 205 device available to the system. 196 206 197 207 ======================================================================*/ 198 - static int get_tuple(client_handle_t handle, tuple_t *tuple, 208 + static int get_tuple(struct pcmcia_device *handle, tuple_t *tuple, 199 209 cisparse_t *parse) 200 210 { 201 211 int i = pcmcia_get_tuple_data(handle, tuple); ··· 203 213 return pcmcia_parse_tuple(handle, tuple, parse); 204 214 } 205 215 206 - static int first_tuple(client_handle_t handle, tuple_t *tuple, 216 + static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, 207 217 cisparse_t *parse) 208 218 { 209 219 int i = pcmcia_get_first_tuple(handle, tuple); ··· 211 221 return get_tuple(handle, tuple, parse); 212 222 } 213 223 214 - static int next_tuple(client_handle_t handle, tuple_t *tuple, 224 + static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, 215 225 cisparse_t *parse) 216 226 { 217 227 int i = pcmcia_get_next_tuple(handle, tuple); ··· 219 229 return get_tuple(handle, tuple, parse); 220 230 } 221 231 222 - static void teles_cs_config(dev_link_t *link) 232 + static int teles_cs_config(struct pcmcia_device *link) 223 233 { 224 - client_handle_t handle; 225 234 tuple_t tuple; 226 235 cisparse_t parse; 227 236 local_info_t *dev; ··· 230 241 IsdnCard_t icard; 231 242 232 243 DEBUG(0, "teles_config(0x%p)\n", link); 233 - handle = link->handle; 234 244 dev = link->priv; 235 245 236 246 /* ··· 241 253 tuple.TupleDataMax = 255; 242 254 tuple.TupleOffset = 0; 243 255 tuple.Attributes = 0; 244 - i = first_tuple(handle, &tuple, &parse); 256 + i = first_tuple(link, &tuple, &parse); 245 257 if (i != CS_SUCCESS) { 246 258 last_fn = ParseTuple; 247 259 goto cs_failed; ··· 249 261 link->conf.ConfigBase = parse.config.base; 250 262 link->conf.Present = parse.config.rmask[0]; 251 263 252 - /* Configure card */ 253 - link->state |= DEV_CONFIG; 254 - 255 264 tuple.TupleData = (cisdata_t *)buf; 256 265 tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 257 266 tuple.Attributes = 0; 258 267 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 259 - i = first_tuple(handle, &tuple, &parse); 268 + i = first_tuple(link, &tuple, &parse); 260 269 while (i == CS_SUCCESS) { 261 270 if ( (cf->io.nwin > 0) && cf->io.win[0].base) { 262 271 printk(KERN_INFO "(teles_cs: looks like the 96 model)\n"); 263 272 link->conf.ConfigIndex = cf->index; 264 273 link->io.BasePort1 = cf->io.win[0].base; 265 - i = pcmcia_request_io(link->handle, &link->io); 274 + i = pcmcia_request_io(link, &link->io); 266 275 if (i == CS_SUCCESS) break; 267 276 } else { 268 277 printk(KERN_INFO "(teles_cs: looks like the 97 model)\n"); 269 278 link->conf.ConfigIndex = cf->index; 270 279 for (i = 0, j = 0x2f0; j > 0x100; j -= 0x10) { 271 280 link->io.BasePort1 = j; 272 - i = pcmcia_request_io(link->handle, &link->io); 281 + i = pcmcia_request_io(link, &link->io); 273 282 if (i == CS_SUCCESS) break; 274 283 } 275 284 break; 276 285 } 277 - i = next_tuple(handle, &tuple, &parse); 286 + i = next_tuple(link, &tuple, &parse); 278 287 } 279 288 280 289 if (i != CS_SUCCESS) { ··· 279 294 goto cs_failed; 280 295 } 281 296 282 - i = pcmcia_request_irq(link->handle, &link->irq); 297 + i = pcmcia_request_irq(link, &link->irq); 283 298 if (i != CS_SUCCESS) { 284 299 link->irq.AssignedIRQ = 0; 285 300 last_fn = RequestIRQ; 286 301 goto cs_failed; 287 302 } 288 303 289 - i = pcmcia_request_configuration(link->handle, &link->conf); 304 + i = pcmcia_request_configuration(link, &link->conf); 290 305 if (i != CS_SUCCESS) { 291 306 last_fn = RequestConfiguration; 292 307 goto cs_failed; ··· 297 312 sprintf(dev->node.dev_name, "teles"); 298 313 dev->node.major = dev->node.minor = 0x0; 299 314 300 - link->dev = &dev->node; 315 + link->dev_node = &dev->node; 301 316 302 317 /* Finally, report what we've done */ 303 - printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d", 304 - dev->node.dev_name, link->conf.ConfigIndex, 305 - link->conf.Vcc/10, link->conf.Vcc%10); 306 - if (link->conf.Vpp1) 307 - printk(", Vpp %d.%d", link->conf.Vpp1/10, link->conf.Vpp1%10); 318 + printk(KERN_INFO "%s: index 0x%02x:", 319 + dev->node.dev_name, link->conf.ConfigIndex); 308 320 if (link->conf.Attributes & CONF_ENABLE_IRQ) 309 321 printk(", irq %d", link->irq.AssignedIRQ); 310 322 if (link->io.NumPorts1) ··· 311 329 printk(" & 0x%04x-0x%04x", link->io.BasePort2, 312 330 link->io.BasePort2+link->io.NumPorts2-1); 313 331 printk("\n"); 314 - 315 - link->state &= ~DEV_CONFIG_PENDING; 316 332 317 333 icard.para[0] = link->irq.AssignedIRQ; 318 334 icard.para[1] = link->io.BasePort1; ··· 322 342 printk(KERN_ERR "teles_cs: failed to initialize Teles PCMCIA %d at i/o %#x\n", 323 343 i, link->io.BasePort1); 324 344 teles_cs_release(link); 325 - } else 326 - ((local_info_t*)link->priv)->cardnr = i; 345 + return -ENODEV; 346 + } 327 347 328 - return; 348 + ((local_info_t*)link->priv)->cardnr = i; 349 + return 0; 350 + 329 351 cs_failed: 330 - cs_error(link->handle, last_fn, i); 352 + cs_error(link, last_fn, i); 331 353 teles_cs_release(link); 354 + return -ENODEV; 332 355 } /* teles_cs_config */ 333 356 334 357 /*====================================================================== ··· 342 359 343 360 ======================================================================*/ 344 361 345 - static void teles_cs_release(dev_link_t *link) 362 + static void teles_cs_release(struct pcmcia_device *link) 346 363 { 347 364 local_info_t *local = link->priv; 348 365 ··· 354 371 HiSax_closecard(local->cardnr); 355 372 } 356 373 } 357 - /* Unlink the device chain */ 358 - link->dev = NULL; 359 374 360 - /* Don't bother checking to see if these succeed or not */ 361 - if (link->win) 362 - pcmcia_release_window(link->win); 363 - pcmcia_release_configuration(link->handle); 364 - pcmcia_release_io(link->handle, &link->io); 365 - pcmcia_release_irq(link->handle, &link->irq); 366 - link->state &= ~DEV_CONFIG; 375 + pcmcia_disable_device(link); 367 376 } /* teles_cs_release */ 368 377 369 - static int teles_suspend(struct pcmcia_device *p_dev) 378 + static int teles_suspend(struct pcmcia_device *link) 370 379 { 371 - dev_link_t *link = dev_to_instance(p_dev); 372 380 local_info_t *dev = link->priv; 373 381 374 - link->state |= DEV_SUSPEND; 375 382 dev->busy = 1; 376 - if (link->state & DEV_CONFIG) 377 - pcmcia_release_configuration(link->handle); 378 383 379 384 return 0; 380 385 } 381 386 382 - static int teles_resume(struct pcmcia_device *p_dev) 387 + static int teles_resume(struct pcmcia_device *link) 383 388 { 384 - dev_link_t *link = dev_to_instance(p_dev); 385 389 local_info_t *dev = link->priv; 386 390 387 - link->state &= ~DEV_SUSPEND; 388 - if (link->state & DEV_CONFIG) 389 - pcmcia_request_configuration(link->handle, &link->conf); 390 391 dev->busy = 0; 391 392 392 393 return 0; ··· 388 421 .drv = { 389 422 .name = "teles_cs", 390 423 }, 391 - .probe = teles_attach, 424 + .probe = teles_probe, 392 425 .remove = teles_detach, 393 426 .id_table = teles_ids, 394 427 .suspend = teles_suspend,
+48 -67
drivers/mtd/maps/pcmciamtd.c
··· 54 54 #define MAX_PCMCIA_ADDR 0x4000000 55 55 56 56 struct pcmciamtd_dev { 57 - dev_link_t link; /* PCMCIA link */ 57 + struct pcmcia_device *p_dev; 58 58 dev_node_t node; /* device node */ 59 59 caddr_t win_base; /* ioremapped address of PCMCIA window */ 60 60 unsigned int win_size; /* size of window */ ··· 111 111 memreq_t mrq; 112 112 int ret; 113 113 114 - if(!(dev->link.state & DEV_PRESENT)) { 115 - DEBUG(1, "device removed state = 0x%4.4X", dev->link.state); 114 + if (!pcmcia_dev_present(dev->p_dev)) { 115 + DEBUG(1, "device removed"); 116 116 return 0; 117 117 } 118 118 ··· 122 122 dev->offset, mrq.CardOffset); 123 123 mrq.Page = 0; 124 124 if( (ret = pcmcia_map_mem_page(win, &mrq)) != CS_SUCCESS) { 125 - cs_error(dev->link.handle, MapMemPage, ret); 125 + cs_error(dev->p_dev, MapMemPage, ret); 126 126 return NULL; 127 127 } 128 128 dev->offset = mrq.CardOffset; ··· 238 238 239 239 /* read/write{8,16} copy_{from,to} routines with direct access */ 240 240 241 - #define DEV_REMOVED(x) (!(*(u_int *)x->map_priv_1 & DEV_PRESENT)) 241 + #define DEV_REMOVED(x) (!(pcmcia_dev_present(((struct pcmciamtd_dev *)map->map_priv_1)->p_dev))) 242 242 243 243 static map_word pcmcia_read8(struct map_info *map, unsigned long ofs) 244 244 { ··· 319 319 static void pcmciamtd_set_vpp(struct map_info *map, int on) 320 320 { 321 321 struct pcmciamtd_dev *dev = (struct pcmciamtd_dev *)map->map_priv_1; 322 - dev_link_t *link = &dev->link; 322 + struct pcmcia_device *link = dev->p_dev; 323 323 modconf_t mod; 324 324 int ret; 325 325 ··· 328 328 mod.Vpp1 = mod.Vpp2 = on ? dev->vpp : 0; 329 329 330 330 DEBUG(2, "dev = %p on = %d vpp = %d\n", dev, on, dev->vpp); 331 - ret = pcmcia_modify_configuration(link->handle, &mod); 331 + ret = pcmcia_modify_configuration(link, &mod); 332 332 if(ret != CS_SUCCESS) { 333 - cs_error(link->handle, ModifyConfiguration, ret); 333 + cs_error(link, ModifyConfiguration, ret); 334 334 } 335 335 } 336 336 ··· 340 340 * still open, this will be postponed until it is closed. 341 341 */ 342 342 343 - static void pcmciamtd_release(dev_link_t *link) 343 + static void pcmciamtd_release(struct pcmcia_device *link) 344 344 { 345 345 struct pcmciamtd_dev *dev = link->priv; 346 346 ··· 353 353 } 354 354 pcmcia_release_window(link->win); 355 355 } 356 - pcmcia_release_configuration(link->handle); 357 - link->state &= ~DEV_CONFIG; 356 + pcmcia_disable_device(link); 358 357 } 359 358 360 359 361 - static void card_settings(struct pcmciamtd_dev *dev, dev_link_t *link, int *new_name) 360 + static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *link, int *new_name) 362 361 { 363 362 int rc; 364 363 tuple_t tuple; ··· 370 371 tuple.TupleOffset = 0; 371 372 tuple.DesiredTuple = RETURN_FIRST_TUPLE; 372 373 373 - rc = pcmcia_get_first_tuple(link->handle, &tuple); 374 + rc = pcmcia_get_first_tuple(link, &tuple); 374 375 while(rc == CS_SUCCESS) { 375 - rc = pcmcia_get_tuple_data(link->handle, &tuple); 376 + rc = pcmcia_get_tuple_data(link, &tuple); 376 377 if(rc != CS_SUCCESS) { 377 - cs_error(link->handle, GetTupleData, rc); 378 + cs_error(link, GetTupleData, rc); 378 379 break; 379 380 } 380 - rc = pcmcia_parse_tuple(link->handle, &tuple, &parse); 381 + rc = pcmcia_parse_tuple(link, &tuple, &parse); 381 382 if(rc != CS_SUCCESS) { 382 - cs_error(link->handle, ParseTuple, rc); 383 + cs_error(link, ParseTuple, rc); 383 384 break; 384 385 } 385 386 ··· 450 451 DEBUG(2, "Unknown tuple code %d", tuple.TupleCode); 451 452 } 452 453 453 - rc = pcmcia_get_next_tuple(link->handle, &tuple); 454 + rc = pcmcia_get_next_tuple(link, &tuple); 454 455 } 455 456 if(!dev->pcmcia_map.size) 456 457 dev->pcmcia_map.size = MAX_PCMCIA_ADDR; ··· 487 488 #define CS_CHECK(fn, ret) \ 488 489 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 489 490 490 - static void pcmciamtd_config(dev_link_t *link) 491 + static int pcmciamtd_config(struct pcmcia_device *link) 491 492 { 492 493 struct pcmciamtd_dev *dev = link->priv; 493 494 struct mtd_info *mtd = NULL; ··· 503 504 504 505 DEBUG(3, "link=0x%p", link); 505 506 506 - /* Configure card */ 507 - link->state |= DEV_CONFIG; 508 - 509 507 DEBUG(2, "Validating CIS"); 510 - ret = pcmcia_validate_cis(link->handle, &cisinfo); 508 + ret = pcmcia_validate_cis(link, &cisinfo); 511 509 if(ret != CS_SUCCESS) { 512 - cs_error(link->handle, GetTupleData, ret); 510 + cs_error(link, GetTupleData, ret); 513 511 } else { 514 512 DEBUG(2, "ValidateCIS found %d chains", cisinfo.Chains); 515 513 } ··· 534 538 req.Attributes |= (dev->pcmcia_map.bankwidth == 1) ? WIN_DATA_WIDTH_8 : WIN_DATA_WIDTH_16; 535 539 req.Base = 0; 536 540 req.AccessSpeed = mem_speed; 537 - link->win = (window_handle_t)link->handle; 541 + link->win = (window_handle_t)link; 538 542 req.Size = (force_size) ? force_size << 20 : MAX_PCMCIA_ADDR; 539 543 dev->win_size = 0; 540 544 ··· 542 546 int ret; 543 547 DEBUG(2, "requesting window with size = %dKiB memspeed = %d", 544 548 req.Size >> 10, req.AccessSpeed); 545 - ret = pcmcia_request_window(&link->handle, &req, &link->win); 549 + ret = pcmcia_request_window(&link, &req, &link->win); 546 550 DEBUG(2, "ret = %d dev->win_size = %d", ret, dev->win_size); 547 551 if(ret) { 548 552 req.Size >>= 1; ··· 558 562 if(!dev->win_size) { 559 563 err("Cant allocate memory window"); 560 564 pcmciamtd_release(link); 561 - return; 565 + return -ENODEV; 562 566 } 563 567 DEBUG(1, "Allocated a window of %dKiB", dev->win_size >> 10); 564 568 565 569 /* Get write protect status */ 566 - CS_CHECK(GetStatus, pcmcia_get_status(link->handle, &status)); 570 + CS_CHECK(GetStatus, pcmcia_get_status(link, &status)); 567 571 DEBUG(2, "status value: 0x%x window handle = 0x%8.8lx", 568 572 status.CardState, (unsigned long)link->win); 569 573 dev->win_base = ioremap(req.Base, req.Size); 570 574 if(!dev->win_base) { 571 575 err("ioremap(%lu, %u) failed", req.Base, req.Size); 572 576 pcmciamtd_release(link); 573 - return; 577 + return -ENODEV; 574 578 } 575 579 DEBUG(1, "mapped window dev = %p req.base = 0x%lx base = %p size = 0x%x", 576 580 dev, req.Base, dev->win_base, req.Size); ··· 580 584 dev->pcmcia_map.map_priv_2 = (unsigned long)link->win; 581 585 582 586 DEBUG(2, "Getting configuration"); 583 - CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link->handle, &t)); 587 + CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &t)); 584 588 DEBUG(2, "Vcc = %d Vpp1 = %d Vpp2 = %d", t.Vcc, t.Vpp1, t.Vpp2); 585 589 dev->vpp = (vpp) ? vpp : t.Vpp1; 586 590 link->conf.Attributes = 0; 587 - link->conf.Vcc = t.Vcc; 588 591 if(setvpp == 2) { 589 - link->conf.Vpp1 = dev->vpp; 590 - link->conf.Vpp2 = dev->vpp; 592 + link->conf.Vpp = dev->vpp; 591 593 } else { 592 - link->conf.Vpp1 = 0; 593 - link->conf.Vpp2 = 0; 594 + link->conf.Vpp = 0; 594 595 } 595 596 596 597 link->conf.IntType = INT_MEMORY; ··· 599 606 link->conf.ConfigIndex = 0; 600 607 link->conf.Present = t.Present; 601 608 DEBUG(2, "Setting Configuration"); 602 - ret = pcmcia_request_configuration(link->handle, &link->conf); 609 + ret = pcmcia_request_configuration(link, &link->conf); 603 610 if(ret != CS_SUCCESS) { 604 - cs_error(link->handle, RequestConfiguration, ret); 611 + cs_error(link, RequestConfiguration, ret); 612 + return -ENODEV; 605 613 } 606 614 607 615 if(mem_type == 1) { ··· 623 629 if(!mtd) { 624 630 DEBUG(1, "Cant find an MTD"); 625 631 pcmciamtd_release(link); 626 - return; 632 + return -ENODEV; 627 633 } 628 634 629 635 dev->mtd_info = mtd; ··· 648 654 use the faster non-remapping read/write functions */ 649 655 if(mtd->size <= dev->win_size) { 650 656 DEBUG(1, "Using non remapping memory functions"); 651 - dev->pcmcia_map.map_priv_1 = (unsigned long)&(dev->link.state); 652 657 dev->pcmcia_map.map_priv_2 = (unsigned long)dev->win_base; 653 658 if (dev->pcmcia_map.bankwidth == 1) { 654 659 dev->pcmcia_map.read = pcmcia_read8; ··· 665 672 dev->mtd_info = NULL; 666 673 err("Couldnt register MTD device"); 667 674 pcmciamtd_release(link); 668 - return; 675 + return -ENODEV; 669 676 } 670 677 snprintf(dev->node.dev_name, sizeof(dev->node.dev_name), "mtd%d", mtd->index); 671 678 info("mtd%d: %s", mtd->index, mtd->name); 672 - link->state &= ~DEV_CONFIG_PENDING; 673 - link->dev = &dev->node; 674 - return; 679 + link->dev_node = &dev->node; 680 + return 0; 675 681 676 682 cs_failed: 677 - cs_error(link->handle, last_fn, last_ret); 683 + cs_error(link, last_fn, last_ret); 678 684 err("CS Error, exiting"); 679 685 pcmciamtd_release(link); 680 - return; 686 + return -ENODEV; 681 687 } 682 688 683 689 ··· 705 713 * when the device is released. 706 714 */ 707 715 708 - static void pcmciamtd_detach(struct pcmcia_device *p_dev) 716 + static void pcmciamtd_detach(struct pcmcia_device *link) 709 717 { 710 - dev_link_t *link = dev_to_instance(p_dev); 718 + struct pcmciamtd_dev *dev = link->priv; 711 719 712 720 DEBUG(3, "link=0x%p", link); 713 721 714 - if(link->state & DEV_CONFIG) { 715 - struct pcmciamtd_dev *dev = link->priv; 716 - if(dev->mtd_info) { 717 - del_mtd_device(dev->mtd_info); 718 - info("mtd%d: Removed", dev->mtd_info->index); 719 - } 720 - 721 - pcmciamtd_release(link); 722 + if(dev->mtd_info) { 723 + del_mtd_device(dev->mtd_info); 724 + info("mtd%d: Removed", dev->mtd_info->index); 722 725 } 726 + 727 + pcmciamtd_release(link); 723 728 } 724 729 725 730 ··· 725 736 * with Card Services. 726 737 */ 727 738 728 - static int pcmciamtd_attach(struct pcmcia_device *p_dev) 739 + static int pcmciamtd_probe(struct pcmcia_device *link) 729 740 { 730 741 struct pcmciamtd_dev *dev; 731 - dev_link_t *link; 732 742 733 743 /* Create new memory card device */ 734 744 dev = kmalloc(sizeof(*dev), GFP_KERNEL); ··· 735 747 DEBUG(1, "dev=0x%p", dev); 736 748 737 749 memset(dev, 0, sizeof(*dev)); 738 - link = &dev->link; 750 + dev->p_dev = link; 739 751 link->priv = dev; 740 752 741 753 link->conf.Attributes = 0; 742 754 link->conf.IntType = INT_MEMORY; 743 755 744 - link->next = NULL; 745 - link->handle = p_dev; 746 - p_dev->instance = link; 747 - 748 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 749 - pcmciamtd_config(link); 750 - 751 - return 0; 756 + return pcmciamtd_config(link); 752 757 } 753 758 754 759 static struct pcmcia_device_id pcmciamtd_ids[] = { ··· 775 794 .drv = { 776 795 .name = "pcmciamtd" 777 796 }, 778 - .probe = pcmciamtd_attach, 797 + .probe = pcmciamtd_probe, 779 798 .remove = pcmciamtd_detach, 780 799 .owner = THIS_MODULE, 781 800 .id_table = pcmciamtd_ids,
+42 -73
drivers/net/pcmcia/3c574_cs.c
··· 204 204 #define MEDIA_TP 0x00C0 /* Enable link beat and jabber for 10baseT. */ 205 205 206 206 struct el3_private { 207 - dev_link_t link; 207 + struct pcmcia_device *p_dev; 208 208 dev_node_t node; 209 209 struct net_device_stats stats; 210 210 u16 advertising, partner; /* NWay media advertisement */ ··· 225 225 226 226 /* Index of functions. */ 227 227 228 - static void tc574_config(dev_link_t *link); 229 - static void tc574_release(dev_link_t *link); 228 + static int tc574_config(struct pcmcia_device *link); 229 + static void tc574_release(struct pcmcia_device *link); 230 230 231 231 static void mdio_sync(kio_addr_t ioaddr, int bits); 232 232 static int mdio_read(kio_addr_t ioaddr, int phy_id, int location); ··· 256 256 with Card Services. 257 257 */ 258 258 259 - static int tc574_attach(struct pcmcia_device *p_dev) 259 + static int tc574_probe(struct pcmcia_device *link) 260 260 { 261 261 struct el3_private *lp; 262 - dev_link_t *link; 263 262 struct net_device *dev; 264 263 265 264 DEBUG(0, "3c574_attach()\n"); ··· 268 269 if (!dev) 269 270 return -ENOMEM; 270 271 lp = netdev_priv(dev); 271 - link = &lp->link; 272 272 link->priv = dev; 273 + lp->p_dev = link; 273 274 274 275 spin_lock_init(&lp->window_lock); 275 276 link->io.NumPorts1 = 32; ··· 279 280 link->irq.Handler = &el3_interrupt; 280 281 link->irq.Instance = dev; 281 282 link->conf.Attributes = CONF_ENABLE_IRQ; 282 - link->conf.Vcc = 50; 283 283 link->conf.IntType = INT_MEMORY_AND_IO; 284 284 link->conf.ConfigIndex = 1; 285 285 link->conf.Present = PRESENT_OPTION; ··· 296 298 dev->watchdog_timeo = TX_TIMEOUT; 297 299 #endif 298 300 299 - link->handle = p_dev; 300 - p_dev->instance = link; 301 - 302 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 303 - tc574_config(link); 304 - 305 - return 0; 301 + return tc574_config(link); 306 302 } /* tc574_attach */ 307 303 308 304 /* ··· 308 316 309 317 */ 310 318 311 - static void tc574_detach(struct pcmcia_device *p_dev) 319 + static void tc574_detach(struct pcmcia_device *link) 312 320 { 313 - dev_link_t *link = dev_to_instance(p_dev); 314 321 struct net_device *dev = link->priv; 315 322 316 323 DEBUG(0, "3c574_detach(0x%p)\n", link); 317 324 318 - if (link->dev) 325 + if (link->dev_node) 319 326 unregister_netdev(dev); 320 327 321 - if (link->state & DEV_CONFIG) 322 - tc574_release(link); 328 + tc574_release(link); 323 329 324 330 free_netdev(dev); 325 331 } /* tc574_detach */ ··· 333 343 334 344 static const char *ram_split[] = {"5:3", "3:1", "1:1", "3:5"}; 335 345 336 - static void tc574_config(dev_link_t *link) 346 + static int tc574_config(struct pcmcia_device *link) 337 347 { 338 - client_handle_t handle = link->handle; 339 348 struct net_device *dev = link->priv; 340 349 struct el3_private *lp = netdev_priv(dev); 341 350 tuple_t tuple; ··· 352 363 353 364 tuple.Attributes = 0; 354 365 tuple.DesiredTuple = CISTPL_CONFIG; 355 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 366 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 356 367 tuple.TupleData = (cisdata_t *)buf; 357 368 tuple.TupleDataMax = 64; 358 369 tuple.TupleOffset = 0; 359 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 360 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 370 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 371 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 361 372 link->conf.ConfigBase = parse.config.base; 362 373 link->conf.Present = parse.config.rmask[0]; 363 - 364 - /* Configure card */ 365 - link->state |= DEV_CONFIG; 366 374 367 375 link->io.IOAddrLines = 16; 368 376 for (i = j = 0; j < 0x400; j += 0x20) { 369 377 link->io.BasePort1 = j ^ 0x300; 370 - i = pcmcia_request_io(link->handle, &link->io); 378 + i = pcmcia_request_io(link, &link->io); 371 379 if (i == CS_SUCCESS) break; 372 380 } 373 381 if (i != CS_SUCCESS) { 374 - cs_error(link->handle, RequestIO, i); 382 + cs_error(link, RequestIO, i); 375 383 goto failed; 376 384 } 377 - CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 378 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 385 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 386 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 379 387 380 388 dev->irq = link->irq.AssignedIRQ; 381 389 dev->base_addr = link->io.BasePort1; ··· 383 397 the hardware address. The future products may include a modem chip 384 398 and put the address in the CIS. */ 385 399 tuple.DesiredTuple = 0x88; 386 - if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) { 387 - pcmcia_get_tuple_data(handle, &tuple); 400 + if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { 401 + pcmcia_get_tuple_data(link, &tuple); 388 402 for (i = 0; i < 3; i++) 389 403 phys_addr[i] = htons(buf[i]); 390 404 } else { ··· 398 412 } 399 413 } 400 414 tuple.DesiredTuple = CISTPL_VERS_1; 401 - if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS && 402 - pcmcia_get_tuple_data(handle, &tuple) == CS_SUCCESS && 403 - pcmcia_parse_tuple(handle, &tuple, &parse) == CS_SUCCESS) { 415 + if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS && 416 + pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS && 417 + pcmcia_parse_tuple(link, &tuple, &parse) == CS_SUCCESS) { 404 418 cardname = parse.version_1.str + parse.version_1.ofs[1]; 405 419 } else 406 420 cardname = "3Com 3c574"; ··· 459 473 } 460 474 } 461 475 462 - link->state &= ~DEV_CONFIG_PENDING; 463 - link->dev = &lp->node; 464 - SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 476 + link->dev_node = &lp->node; 477 + SET_NETDEV_DEV(dev, &handle_to_dev(link)); 465 478 466 479 if (register_netdev(dev) != 0) { 467 480 printk(KERN_NOTICE "3c574_cs: register_netdev() failed\n"); 468 - link->dev = NULL; 481 + link->dev_node = NULL; 469 482 goto failed; 470 483 } 471 484 ··· 478 493 8 << config.u.ram_size, ram_split[config.u.ram_split], 479 494 config.u.autoselect ? "autoselect " : ""); 480 495 481 - return; 496 + return 0; 482 497 483 498 cs_failed: 484 - cs_error(link->handle, last_fn, last_ret); 499 + cs_error(link, last_fn, last_ret); 485 500 failed: 486 501 tc574_release(link); 487 - return; 502 + return -ENODEV; 488 503 489 504 } /* tc574_config */ 490 505 ··· 494 509 still open, this will be postponed until it is closed. 495 510 */ 496 511 497 - static void tc574_release(dev_link_t *link) 512 + static void tc574_release(struct pcmcia_device *link) 498 513 { 499 - DEBUG(0, "3c574_release(0x%p)\n", link); 500 - 501 - pcmcia_release_configuration(link->handle); 502 - pcmcia_release_io(link->handle, &link->io); 503 - pcmcia_release_irq(link->handle, &link->irq); 504 - 505 - link->state &= ~DEV_CONFIG; 514 + pcmcia_disable_device(link); 506 515 } 507 516 508 - static int tc574_suspend(struct pcmcia_device *p_dev) 517 + static int tc574_suspend(struct pcmcia_device *link) 509 518 { 510 - dev_link_t *link = dev_to_instance(p_dev); 511 519 struct net_device *dev = link->priv; 512 520 513 - link->state |= DEV_SUSPEND; 514 - if (link->state & DEV_CONFIG) { 515 - if (link->open) 516 - netif_device_detach(dev); 517 - pcmcia_release_configuration(link->handle); 518 - } 521 + if (link->open) 522 + netif_device_detach(dev); 519 523 520 524 return 0; 521 525 } 522 526 523 - static int tc574_resume(struct pcmcia_device *p_dev) 527 + static int tc574_resume(struct pcmcia_device *link) 524 528 { 525 - dev_link_t *link = dev_to_instance(p_dev); 526 529 struct net_device *dev = link->priv; 527 530 528 - link->state &= ~DEV_SUSPEND; 529 - if (link->state & DEV_CONFIG) { 530 - pcmcia_request_configuration(link->handle, &link->conf); 531 - if (link->open) { 532 - tc574_reset(dev); 533 - netif_device_attach(dev); 534 - } 531 + if (link->open) { 532 + tc574_reset(dev); 533 + netif_device_attach(dev); 535 534 } 536 535 537 536 return 0; ··· 726 757 static int el3_open(struct net_device *dev) 727 758 { 728 759 struct el3_private *lp = netdev_priv(dev); 729 - dev_link_t *link = &lp->link; 760 + struct pcmcia_device *link = lp->p_dev; 730 761 731 - if (!DEV_OK(link)) 762 + if (!pcmcia_dev_present(link)) 732 763 return -ENODEV; 733 764 734 765 link->open++; ··· 1172 1203 { 1173 1204 kio_addr_t ioaddr = dev->base_addr; 1174 1205 struct el3_private *lp = netdev_priv(dev); 1175 - dev_link_t *link = &lp->link; 1206 + struct pcmcia_device *link = lp->p_dev; 1176 1207 1177 1208 DEBUG(2, "%s: shutting down ethercard.\n", dev->name); 1178 1209 1179 - if (DEV_OK(link)) { 1210 + if (pcmcia_dev_present(link)) { 1180 1211 unsigned long flags; 1181 1212 1182 1213 /* Turn off statistics ASAP. We update lp->stats below. */ ··· 1215 1246 .drv = { 1216 1247 .name = "3c574_cs", 1217 1248 }, 1218 - .probe = tc574_attach, 1249 + .probe = tc574_probe, 1219 1250 .remove = tc574_detach, 1220 1251 .id_table = tc574_ids, 1221 1252 .suspend = tc574_suspend,
+45 -77
drivers/net/pcmcia/3c589_cs.c
··· 105 105 #define TX_TIMEOUT ((400*HZ)/1000) 106 106 107 107 struct el3_private { 108 - dev_link_t link; 108 + struct pcmcia_device *p_dev; 109 109 dev_node_t node; 110 110 struct net_device_stats stats; 111 111 /* For transceiver monitoring */ ··· 142 142 143 143 /*====================================================================*/ 144 144 145 - static void tc589_config(dev_link_t *link); 146 - static void tc589_release(dev_link_t *link); 145 + static int tc589_config(struct pcmcia_device *link); 146 + static void tc589_release(struct pcmcia_device *link); 147 147 148 148 static u16 read_eeprom(kio_addr_t ioaddr, int index); 149 149 static void tc589_reset(struct net_device *dev); ··· 170 170 171 171 ======================================================================*/ 172 172 173 - static int tc589_attach(struct pcmcia_device *p_dev) 173 + static int tc589_probe(struct pcmcia_device *link) 174 174 { 175 175 struct el3_private *lp; 176 - dev_link_t *link; 177 176 struct net_device *dev; 178 177 179 178 DEBUG(0, "3c589_attach()\n"); ··· 182 183 if (!dev) 183 184 return -ENOMEM; 184 185 lp = netdev_priv(dev); 185 - link = &lp->link; 186 186 link->priv = dev; 187 + lp->p_dev = link; 187 188 188 189 spin_lock_init(&lp->lock); 189 190 link->io.NumPorts1 = 16; ··· 193 194 link->irq.Handler = &el3_interrupt; 194 195 link->irq.Instance = dev; 195 196 link->conf.Attributes = CONF_ENABLE_IRQ; 196 - link->conf.Vcc = 50; 197 197 link->conf.IntType = INT_MEMORY_AND_IO; 198 198 link->conf.ConfigIndex = 1; 199 199 link->conf.Present = PRESENT_OPTION; ··· 211 213 #endif 212 214 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 213 215 214 - link->handle = p_dev; 215 - p_dev->instance = link; 216 - 217 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 218 - tc589_config(link); 219 - 220 - return 0; 216 + return tc589_config(link); 221 217 } /* tc589_attach */ 222 218 223 219 /*====================================================================== ··· 223 231 224 232 ======================================================================*/ 225 233 226 - static void tc589_detach(struct pcmcia_device *p_dev) 234 + static void tc589_detach(struct pcmcia_device *link) 227 235 { 228 - dev_link_t *link = dev_to_instance(p_dev); 229 236 struct net_device *dev = link->priv; 230 237 231 238 DEBUG(0, "3c589_detach(0x%p)\n", link); 232 239 233 - if (link->dev) 240 + if (link->dev_node) 234 241 unregister_netdev(dev); 235 242 236 - if (link->state & DEV_CONFIG) 237 - tc589_release(link); 243 + tc589_release(link); 238 244 239 245 free_netdev(dev); 240 246 } /* tc589_detach */ ··· 248 258 #define CS_CHECK(fn, ret) \ 249 259 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 250 260 251 - static void tc589_config(dev_link_t *link) 261 + static int tc589_config(struct pcmcia_device *link) 252 262 { 253 - client_handle_t handle = link->handle; 254 263 struct net_device *dev = link->priv; 255 264 struct el3_private *lp = netdev_priv(dev); 256 265 tuple_t tuple; ··· 264 275 phys_addr = (u16 *)dev->dev_addr; 265 276 tuple.Attributes = 0; 266 277 tuple.DesiredTuple = CISTPL_CONFIG; 267 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 278 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 268 279 tuple.TupleData = (cisdata_t *)buf; 269 280 tuple.TupleDataMax = sizeof(buf); 270 281 tuple.TupleOffset = 0; 271 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 272 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 282 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 283 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 273 284 link->conf.ConfigBase = parse.config.base; 274 285 link->conf.Present = parse.config.rmask[0]; 275 286 276 287 /* Is this a 3c562? */ 277 288 tuple.DesiredTuple = CISTPL_MANFID; 278 289 tuple.Attributes = TUPLE_RETURN_COMMON; 279 - if ((pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) && 280 - (pcmcia_get_tuple_data(handle, &tuple) == CS_SUCCESS)) { 290 + if ((pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) && 291 + (pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS)) { 281 292 if (le16_to_cpu(buf[0]) != MANFID_3COM) 282 293 printk(KERN_INFO "3c589_cs: hmmm, is this really a " 283 294 "3Com card??\n"); 284 295 multi = (le16_to_cpu(buf[1]) == PRODID_3COM_3C562); 285 296 } 286 - 287 - /* Configure card */ 288 - link->state |= DEV_CONFIG; 289 297 290 298 /* For the 3c562, the base address must be xx00-xx7f */ 291 299 link->io.IOAddrLines = 16; 292 300 for (i = j = 0; j < 0x400; j += 0x10) { 293 301 if (multi && (j & 0x80)) continue; 294 302 link->io.BasePort1 = j ^ 0x300; 295 - i = pcmcia_request_io(link->handle, &link->io); 303 + i = pcmcia_request_io(link, &link->io); 296 304 if (i == CS_SUCCESS) break; 297 305 } 298 306 if (i != CS_SUCCESS) { 299 - cs_error(link->handle, RequestIO, i); 307 + cs_error(link, RequestIO, i); 300 308 goto failed; 301 309 } 302 - CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 303 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 310 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 311 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 304 312 305 313 dev->irq = link->irq.AssignedIRQ; 306 314 dev->base_addr = link->io.BasePort1; ··· 307 321 /* The 3c589 has an extra EEPROM for configuration info, including 308 322 the hardware address. The 3c562 puts the address in the CIS. */ 309 323 tuple.DesiredTuple = 0x88; 310 - if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) { 311 - pcmcia_get_tuple_data(handle, &tuple); 324 + if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { 325 + pcmcia_get_tuple_data(link, &tuple); 312 326 for (i = 0; i < 3; i++) 313 327 phys_addr[i] = htons(buf[i]); 314 328 } else { ··· 332 346 else 333 347 printk(KERN_ERR "3c589_cs: invalid if_port requested\n"); 334 348 335 - link->dev = &lp->node; 336 - link->state &= ~DEV_CONFIG_PENDING; 337 - SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 349 + link->dev_node = &lp->node; 350 + SET_NETDEV_DEV(dev, &handle_to_dev(link)); 338 351 339 352 if (register_netdev(dev) != 0) { 340 353 printk(KERN_ERR "3c589_cs: register_netdev() failed\n"); 341 - link->dev = NULL; 354 + link->dev_node = NULL; 342 355 goto failed; 343 356 } 344 357 ··· 351 366 printk(KERN_INFO " %dK FIFO split %s Rx:Tx, %s xcvr\n", 352 367 (fifo & 7) ? 32 : 8, ram_split[(fifo >> 16) & 3], 353 368 if_names[dev->if_port]); 354 - return; 369 + return 0; 355 370 356 371 cs_failed: 357 - cs_error(link->handle, last_fn, last_ret); 372 + cs_error(link, last_fn, last_ret); 358 373 failed: 359 374 tc589_release(link); 360 - return; 361 - 375 + return -ENODEV; 362 376 } /* tc589_config */ 363 377 364 378 /*====================================================================== ··· 368 384 369 385 ======================================================================*/ 370 386 371 - static void tc589_release(dev_link_t *link) 387 + static void tc589_release(struct pcmcia_device *link) 372 388 { 373 - DEBUG(0, "3c589_release(0x%p)\n", link); 374 - 375 - pcmcia_release_configuration(link->handle); 376 - pcmcia_release_io(link->handle, &link->io); 377 - pcmcia_release_irq(link->handle, &link->irq); 378 - 379 - link->state &= ~DEV_CONFIG; 389 + pcmcia_disable_device(link); 380 390 } 381 391 382 - static int tc589_suspend(struct pcmcia_device *p_dev) 392 + static int tc589_suspend(struct pcmcia_device *link) 383 393 { 384 - dev_link_t *link = dev_to_instance(p_dev); 385 394 struct net_device *dev = link->priv; 386 395 387 - link->state |= DEV_SUSPEND; 388 - if (link->state & DEV_CONFIG) { 389 - if (link->open) 390 - netif_device_detach(dev); 391 - pcmcia_release_configuration(link->handle); 392 - } 396 + if (link->open) 397 + netif_device_detach(dev); 393 398 394 399 return 0; 395 400 } 396 401 397 - static int tc589_resume(struct pcmcia_device *p_dev) 402 + static int tc589_resume(struct pcmcia_device *link) 398 403 { 399 - dev_link_t *link = dev_to_instance(p_dev); 400 404 struct net_device *dev = link->priv; 401 405 402 - link->state &= ~DEV_SUSPEND; 403 - if (link->state & DEV_CONFIG) { 404 - pcmcia_request_configuration(link->handle, &link->conf); 405 - if (link->open) { 406 - tc589_reset(dev); 407 - netif_device_attach(dev); 408 - } 406 + if (link->open) { 407 + tc589_reset(dev); 408 + netif_device_attach(dev); 409 409 } 410 410 411 411 return 0; ··· 555 587 static int el3_open(struct net_device *dev) 556 588 { 557 589 struct el3_private *lp = netdev_priv(dev); 558 - dev_link_t *link = &lp->link; 590 + struct pcmcia_device *link = lp->p_dev; 559 591 560 - if (!DEV_OK(link)) 592 + if (!pcmcia_dev_present(link)) 561 593 return -ENODEV; 562 594 563 595 link->open++; ··· 816 848 { 817 849 struct el3_private *lp = netdev_priv(dev); 818 850 unsigned long flags; 819 - dev_link_t *link = &lp->link; 851 + struct pcmcia_device *link = lp->p_dev; 820 852 821 - if (DEV_OK(link)) { 853 + if (pcmcia_dev_present(link)) { 822 854 spin_lock_irqsave(&lp->lock, flags); 823 855 update_stats(dev); 824 856 spin_unlock_irqrestore(&lp->lock, flags); ··· 918 950 static void set_multicast_list(struct net_device *dev) 919 951 { 920 952 struct el3_private *lp = netdev_priv(dev); 921 - dev_link_t *link = &lp->link; 953 + struct pcmcia_device *link = lp->p_dev; 922 954 kio_addr_t ioaddr = dev->base_addr; 923 955 u16 opts = SetRxFilter | RxStation | RxBroadcast; 924 956 925 - if (!(DEV_OK(link))) return; 957 + if (!pcmcia_dev_present(link)) return; 926 958 if (dev->flags & IFF_PROMISC) 927 959 opts |= RxMulticast | RxProm; 928 960 else if (dev->mc_count || (dev->flags & IFF_ALLMULTI)) ··· 933 965 static int el3_close(struct net_device *dev) 934 966 { 935 967 struct el3_private *lp = netdev_priv(dev); 936 - dev_link_t *link = &lp->link; 968 + struct pcmcia_device *link = lp->p_dev; 937 969 kio_addr_t ioaddr = dev->base_addr; 938 970 939 971 DEBUG(1, "%s: shutting down ethercard.\n", dev->name); 940 972 941 - if (DEV_OK(link)) { 973 + if (pcmcia_dev_present(link)) { 942 974 /* Turn off statistics ASAP. We update lp->stats below. */ 943 975 outw(StatsDisable, ioaddr + EL3_CMD); 944 976 ··· 988 1020 .drv = { 989 1021 .name = "3c589_cs", 990 1022 }, 991 - .probe = tc589_attach, 1023 + .probe = tc589_probe, 992 1024 .remove = tc589_detach, 993 1025 .id_table = tc589_ids, 994 1026 .suspend = tc589_suspend,
+45 -81
drivers/net/pcmcia/axnet_cs.c
··· 86 86 87 87 /*====================================================================*/ 88 88 89 - static void axnet_config(dev_link_t *link); 90 - static void axnet_release(dev_link_t *link); 89 + static int axnet_config(struct pcmcia_device *link); 90 + static void axnet_release(struct pcmcia_device *link); 91 91 static int axnet_open(struct net_device *dev); 92 92 static int axnet_close(struct net_device *dev); 93 93 static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); ··· 117 117 /*====================================================================*/ 118 118 119 119 typedef struct axnet_dev_t { 120 - dev_link_t link; 120 + struct pcmcia_device *p_dev; 121 121 dev_node_t node; 122 122 caddr_t base; 123 123 struct timer_list watchdog; ··· 142 142 143 143 ======================================================================*/ 144 144 145 - static int axnet_attach(struct pcmcia_device *p_dev) 145 + static int axnet_probe(struct pcmcia_device *link) 146 146 { 147 147 axnet_dev_t *info; 148 - dev_link_t *link; 149 148 struct net_device *dev; 150 149 151 150 DEBUG(0, "axnet_attach()\n"); ··· 156 157 return -ENOMEM; 157 158 158 159 info = PRIV(dev); 159 - link = &info->link; 160 + info->p_dev = link; 160 161 link->priv = dev; 161 162 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 162 163 link->irq.IRQInfo1 = IRQ_LEVEL_ID; ··· 168 169 dev->do_ioctl = &axnet_ioctl; 169 170 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 170 171 171 - link->handle = p_dev; 172 - p_dev->instance = link; 173 - 174 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 175 - axnet_config(link); 176 - 177 - return 0; 172 + return axnet_config(link); 178 173 } /* axnet_attach */ 179 174 180 175 /*====================================================================== ··· 180 187 181 188 ======================================================================*/ 182 189 183 - static void axnet_detach(struct pcmcia_device *p_dev) 190 + static void axnet_detach(struct pcmcia_device *link) 184 191 { 185 - dev_link_t *link = dev_to_instance(p_dev); 186 192 struct net_device *dev = link->priv; 187 193 188 194 DEBUG(0, "axnet_detach(0x%p)\n", link); 189 195 190 - if (link->dev) 196 + if (link->dev_node) 191 197 unregister_netdev(dev); 192 198 193 - if (link->state & DEV_CONFIG) 194 - axnet_release(link); 199 + axnet_release(link); 195 200 196 201 free_netdev(dev); 197 202 } /* axnet_detach */ ··· 200 209 201 210 ======================================================================*/ 202 211 203 - static int get_prom(dev_link_t *link) 212 + static int get_prom(struct pcmcia_device *link) 204 213 { 205 214 struct net_device *dev = link->priv; 206 215 kio_addr_t ioaddr = dev->base_addr; ··· 254 263 #define CS_CHECK(fn, ret) \ 255 264 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 256 265 257 - static int try_io_port(dev_link_t *link) 266 + static int try_io_port(struct pcmcia_device *link) 258 267 { 259 268 int j, ret; 260 269 if (link->io.NumPorts1 == 32) { ··· 275 284 for (j = 0; j < 0x400; j += 0x20) { 276 285 link->io.BasePort1 = j ^ 0x300; 277 286 link->io.BasePort2 = (j ^ 0x300) + 0x10; 278 - ret = pcmcia_request_io(link->handle, &link->io); 287 + ret = pcmcia_request_io(link, &link->io); 279 288 if (ret == CS_SUCCESS) return ret; 280 289 } 281 290 return ret; 282 291 } else { 283 - return pcmcia_request_io(link->handle, &link->io); 292 + return pcmcia_request_io(link, &link->io); 284 293 } 285 294 } 286 295 287 - static void axnet_config(dev_link_t *link) 296 + static int axnet_config(struct pcmcia_device *link) 288 297 { 289 - client_handle_t handle = link->handle; 290 298 struct net_device *dev = link->priv; 291 299 axnet_dev_t *info = PRIV(dev); 292 300 tuple_t tuple; 293 301 cisparse_t parse; 294 302 int i, j, last_ret, last_fn; 295 303 u_short buf[64]; 296 - config_info_t conf; 297 304 298 305 DEBUG(0, "axnet_config(0x%p)\n", link); 299 306 ··· 300 311 tuple.TupleDataMax = sizeof(buf); 301 312 tuple.TupleOffset = 0; 302 313 tuple.DesiredTuple = CISTPL_CONFIG; 303 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 304 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 305 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 314 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 315 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 316 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 306 317 link->conf.ConfigBase = parse.config.base; 307 318 /* don't trust the CIS on this; Linksys got it wrong */ 308 319 link->conf.Present = 0x63; 309 320 310 - /* Configure card */ 311 - link->state |= DEV_CONFIG; 312 - 313 - /* Look up current Vcc */ 314 - CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf)); 315 - link->conf.Vcc = conf.Vcc; 316 - 317 321 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 318 322 tuple.Attributes = 0; 319 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 323 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 320 324 while (last_ret == CS_SUCCESS) { 321 325 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 322 326 cistpl_io_t *io = &(parse.cftable_entry.io); 323 327 324 - if (pcmcia_get_tuple_data(handle, &tuple) != 0 || 325 - pcmcia_parse_tuple(handle, &tuple, &parse) != 0 || 328 + if (pcmcia_get_tuple_data(link, &tuple) != 0 || 329 + pcmcia_parse_tuple(link, &tuple, &parse) != 0 || 326 330 cfg->index == 0 || cfg->io.nwin == 0) 327 331 goto next_entry; 328 332 ··· 337 355 if (last_ret == CS_SUCCESS) break; 338 356 } 339 357 next_entry: 340 - last_ret = pcmcia_get_next_tuple(handle, &tuple); 358 + last_ret = pcmcia_get_next_tuple(link, &tuple); 341 359 } 342 360 if (last_ret != CS_SUCCESS) { 343 - cs_error(handle, RequestIO, last_ret); 361 + cs_error(link, RequestIO, last_ret); 344 362 goto failed; 345 363 } 346 364 347 - CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq)); 365 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 348 366 349 367 if (link->io.NumPorts2 == 8) { 350 368 link->conf.Attributes |= CONF_ENABLE_SPKR; 351 369 link->conf.Status = CCSR_AUDIO_ENA; 352 370 } 353 371 354 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); 372 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 355 373 dev->irq = link->irq.AssignedIRQ; 356 374 dev->base_addr = link->io.BasePort1; 357 375 ··· 388 406 Bit 2 of CCSR is active low. */ 389 407 if (i == 32) { 390 408 conf_reg_t reg = { 0, CS_WRITE, CISREG_CCSR, 0x04 }; 391 - pcmcia_access_configuration_register(link->handle, &reg); 409 + pcmcia_access_configuration_register(link, &reg); 392 410 for (i = 0; i < 32; i++) { 393 411 j = mdio_read(dev->base_addr + AXNET_MII_EEP, i, 1); 394 412 if ((j != 0) && (j != 0xffff)) break; ··· 396 414 } 397 415 398 416 info->phy_id = (i < 32) ? i : -1; 399 - link->dev = &info->node; 400 - link->state &= ~DEV_CONFIG_PENDING; 401 - SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 417 + link->dev_node = &info->node; 418 + SET_NETDEV_DEV(dev, &handle_to_dev(link)); 402 419 403 420 if (register_netdev(dev) != 0) { 404 421 printk(KERN_NOTICE "axnet_cs: register_netdev() failed\n"); 405 - link->dev = NULL; 422 + link->dev_node = NULL; 406 423 goto failed; 407 424 } 408 425 ··· 417 436 } else { 418 437 printk(KERN_NOTICE " No MII transceivers found!\n"); 419 438 } 420 - return; 439 + return 0; 421 440 422 441 cs_failed: 423 - cs_error(link->handle, last_fn, last_ret); 442 + cs_error(link, last_fn, last_ret); 424 443 failed: 425 444 axnet_release(link); 426 - link->state &= ~DEV_CONFIG_PENDING; 427 - return; 445 + return -ENODEV; 428 446 } /* axnet_config */ 429 447 430 448 /*====================================================================== ··· 434 454 435 455 ======================================================================*/ 436 456 437 - static void axnet_release(dev_link_t *link) 457 + static void axnet_release(struct pcmcia_device *link) 438 458 { 439 - DEBUG(0, "axnet_release(0x%p)\n", link); 440 - 441 - pcmcia_release_configuration(link->handle); 442 - pcmcia_release_io(link->handle, &link->io); 443 - pcmcia_release_irq(link->handle, &link->irq); 444 - 445 - link->state &= ~DEV_CONFIG; 459 + pcmcia_disable_device(link); 446 460 } 447 461 448 - static int axnet_suspend(struct pcmcia_device *p_dev) 462 + static int axnet_suspend(struct pcmcia_device *link) 449 463 { 450 - dev_link_t *link = dev_to_instance(p_dev); 451 464 struct net_device *dev = link->priv; 452 465 453 - link->state |= DEV_SUSPEND; 454 - if (link->state & DEV_CONFIG) { 455 - if (link->open) 456 - netif_device_detach(dev); 457 - pcmcia_release_configuration(link->handle); 458 - } 466 + if (link->open) 467 + netif_device_detach(dev); 459 468 460 469 return 0; 461 470 } 462 471 463 - static int axnet_resume(struct pcmcia_device *p_dev) 472 + static int axnet_resume(struct pcmcia_device *link) 464 473 { 465 - dev_link_t *link = dev_to_instance(p_dev); 466 474 struct net_device *dev = link->priv; 467 475 468 - link->state &= ~DEV_SUSPEND; 469 - if (link->state & DEV_CONFIG) { 470 - pcmcia_request_configuration(link->handle, &link->conf); 471 - if (link->open) { 472 - axnet_reset_8390(dev); 473 - AX88190_init(dev, 1); 474 - netif_device_attach(dev); 475 - } 476 + if (link->open) { 477 + axnet_reset_8390(dev); 478 + AX88190_init(dev, 1); 479 + netif_device_attach(dev); 476 480 } 477 481 478 482 return 0; ··· 526 562 static int axnet_open(struct net_device *dev) 527 563 { 528 564 axnet_dev_t *info = PRIV(dev); 529 - dev_link_t *link = &info->link; 565 + struct pcmcia_device *link = info->p_dev; 530 566 531 567 DEBUG(2, "axnet_open('%s')\n", dev->name); 532 568 533 - if (!DEV_OK(link)) 569 + if (!pcmcia_dev_present(link)) 534 570 return -ENODEV; 535 571 536 572 link->open++; ··· 552 588 static int axnet_close(struct net_device *dev) 553 589 { 554 590 axnet_dev_t *info = PRIV(dev); 555 - dev_link_t *link = &info->link; 591 + struct pcmcia_device *link = info->p_dev; 556 592 557 593 DEBUG(2, "axnet_close('%s')\n", dev->name); 558 594 ··· 797 833 .drv = { 798 834 .name = "axnet_cs", 799 835 }, 800 - .probe = axnet_attach, 836 + .probe = axnet_probe, 801 837 .remove = axnet_detach, 802 838 .id_table = axnet_ids, 803 839 .suspend = axnet_suspend,
+44 -83
drivers/net/pcmcia/com20020_cs.c
··· 118 118 119 119 /*====================================================================*/ 120 120 121 - static void com20020_config(dev_link_t *link); 122 - static void com20020_release(dev_link_t *link); 121 + static int com20020_config(struct pcmcia_device *link); 122 + static void com20020_release(struct pcmcia_device *link); 123 123 124 124 static void com20020_detach(struct pcmcia_device *p_dev); 125 125 ··· 138 138 139 139 ======================================================================*/ 140 140 141 - static int com20020_attach(struct pcmcia_device *p_dev) 141 + static int com20020_probe(struct pcmcia_device *p_dev) 142 142 { 143 - dev_link_t *link; 144 143 com20020_dev_t *info; 145 144 struct net_device *dev; 146 145 struct arcnet_local *lp; ··· 147 148 DEBUG(0, "com20020_attach()\n"); 148 149 149 150 /* Create new network device */ 150 - link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); 151 - if (!link) 152 - return -ENOMEM; 153 - 154 151 info = kmalloc(sizeof(struct com20020_dev_t), GFP_KERNEL); 155 152 if (!info) 156 153 goto fail_alloc_info; ··· 156 161 goto fail_alloc_dev; 157 162 158 163 memset(info, 0, sizeof(struct com20020_dev_t)); 159 - memset(link, 0, sizeof(struct dev_link_t)); 160 164 lp = dev->priv; 161 165 lp->timeout = timeout; 162 166 lp->backplane = backplane; ··· 166 172 /* fill in our module parameters as defaults */ 167 173 dev->dev_addr[0] = node; 168 174 169 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 170 - link->io.NumPorts1 = 16; 171 - link->io.IOAddrLines = 16; 172 - link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 173 - link->irq.IRQInfo1 = IRQ_LEVEL_ID; 174 - link->conf.Attributes = CONF_ENABLE_IRQ; 175 - link->conf.Vcc = 50; 176 - link->conf.IntType = INT_MEMORY_AND_IO; 177 - link->conf.Present = PRESENT_OPTION; 175 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 176 + p_dev->io.NumPorts1 = 16; 177 + p_dev->io.IOAddrLines = 16; 178 + p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 179 + p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; 180 + p_dev->conf.Attributes = CONF_ENABLE_IRQ; 181 + p_dev->conf.IntType = INT_MEMORY_AND_IO; 182 + p_dev->conf.Present = PRESENT_OPTION; 178 183 179 - link->irq.Instance = info->dev = dev; 180 - link->priv = info; 184 + p_dev->irq.Instance = info->dev = dev; 185 + p_dev->priv = info; 181 186 182 - link->state |= DEV_PRESENT; 183 - com20020_config(link); 184 - 185 - return 0; 187 + return com20020_config(p_dev); 186 188 187 189 fail_alloc_dev: 188 190 kfree(info); 189 191 fail_alloc_info: 190 - kfree(link); 191 192 return -ENOMEM; 192 193 } /* com20020_attach */ 193 194 ··· 195 206 196 207 ======================================================================*/ 197 208 198 - static void com20020_detach(struct pcmcia_device *p_dev) 209 + static void com20020_detach(struct pcmcia_device *link) 199 210 { 200 - dev_link_t *link = dev_to_instance(p_dev); 201 211 struct com20020_dev_t *info = link->priv; 202 212 struct net_device *dev = info->dev; 203 213 ··· 204 216 205 217 DEBUG(0, "com20020_detach(0x%p)\n", link); 206 218 207 - if (link->dev) { 219 + if (link->dev_node) { 208 220 DEBUG(1,"unregister...\n"); 209 221 210 222 unregister_netdev(dev); ··· 217 229 free_irq(dev->irq, dev); 218 230 } 219 231 220 - if (link->state & DEV_CONFIG) 221 - com20020_release(link); 232 + com20020_release(link); 222 233 223 234 /* Unlink device structure, free bits */ 224 235 DEBUG(1,"unlinking...\n"); ··· 232 245 DEBUG(1,"kfree2...\n"); 233 246 kfree(info); 234 247 } 235 - DEBUG(1,"kfree3...\n"); 236 - kfree(link); 237 248 238 249 } /* com20020_detach */ 239 250 ··· 246 261 #define CS_CHECK(fn, ret) \ 247 262 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 248 263 249 - static void com20020_config(dev_link_t *link) 264 + static int com20020_config(struct pcmcia_device *link) 250 265 { 251 266 struct arcnet_local *lp; 252 - client_handle_t handle; 253 267 tuple_t tuple; 254 268 cisparse_t parse; 255 269 com20020_dev_t *info; ··· 257 273 u_char buf[64]; 258 274 int ioaddr; 259 275 260 - handle = link->handle; 261 276 info = link->priv; 262 277 dev = info->dev; 263 278 ··· 269 286 tuple.TupleDataMax = 64; 270 287 tuple.TupleOffset = 0; 271 288 tuple.DesiredTuple = CISTPL_CONFIG; 272 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 273 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 274 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 289 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 290 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 291 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 275 292 link->conf.ConfigBase = parse.config.base; 276 - 277 - /* Configure card */ 278 - link->state |= DEV_CONFIG; 279 293 280 294 DEBUG(1,"arcnet: baseport1 is %Xh\n", link->io.BasePort1); 281 295 i = !CS_SUCCESS; ··· 281 301 for (ioaddr = 0x100; ioaddr < 0x400; ioaddr += 0x10) 282 302 { 283 303 link->io.BasePort1 = ioaddr; 284 - i = pcmcia_request_io(link->handle, &link->io); 304 + i = pcmcia_request_io(link, &link->io); 285 305 if (i == CS_SUCCESS) 286 306 break; 287 307 } 288 308 } 289 309 else 290 - i = pcmcia_request_io(link->handle, &link->io); 310 + i = pcmcia_request_io(link, &link->io); 291 311 292 312 if (i != CS_SUCCESS) 293 313 { ··· 301 321 DEBUG(1,"arcnet: request IRQ %d (%Xh/%Xh)\n", 302 322 link->irq.AssignedIRQ, 303 323 link->irq.IRQInfo1, link->irq.IRQInfo2); 304 - i = pcmcia_request_irq(link->handle, &link->irq); 324 + i = pcmcia_request_irq(link, &link->irq); 305 325 if (i != CS_SUCCESS) 306 326 { 307 327 DEBUG(1,"arcnet: requestIRQ failed totally!\n"); ··· 310 330 311 331 dev->irq = link->irq.AssignedIRQ; 312 332 313 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 333 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 314 334 315 335 if (com20020_check(dev)) 316 336 { ··· 322 342 lp->card_name = "PCMCIA COM20020"; 323 343 lp->card_flags = ARC_CAN_10MBIT; /* pretend all of them can 10Mbit */ 324 344 325 - link->dev = &info->node; 326 - link->state &= ~DEV_CONFIG_PENDING; 327 - SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 345 + link->dev_node = &info->node; 346 + SET_NETDEV_DEV(dev, &handle_to_dev(link)); 328 347 329 348 i = com20020_found(dev, 0); /* calls register_netdev */ 330 349 331 350 if (i != 0) { 332 351 DEBUG(1,KERN_NOTICE "com20020_cs: com20020_found() failed\n"); 333 - link->dev = NULL; 352 + link->dev_node = NULL; 334 353 goto failed; 335 354 } 336 355 ··· 337 358 338 359 DEBUG(1,KERN_INFO "%s: port %#3lx, irq %d\n", 339 360 dev->name, dev->base_addr, dev->irq); 340 - return; 361 + return 0; 341 362 342 363 cs_failed: 343 - cs_error(link->handle, last_fn, last_ret); 364 + cs_error(link, last_fn, last_ret); 344 365 failed: 345 366 DEBUG(1,"com20020_config failed...\n"); 346 367 com20020_release(link); 368 + return -ENODEV; 347 369 } /* com20020_config */ 348 370 349 371 /*====================================================================== ··· 355 375 356 376 ======================================================================*/ 357 377 358 - static void com20020_release(dev_link_t *link) 378 + static void com20020_release(struct pcmcia_device *link) 359 379 { 360 - 361 - DEBUG(1,"release...\n"); 362 - 363 - DEBUG(0, "com20020_release(0x%p)\n", link); 364 - 365 - pcmcia_release_configuration(link->handle); 366 - pcmcia_release_io(link->handle, &link->io); 367 - pcmcia_release_irq(link->handle, &link->irq); 368 - 369 - link->state &= ~(DEV_CONFIG | DEV_RELEASE_PENDING); 380 + DEBUG(0, "com20020_release(0x%p)\n", link); 381 + pcmcia_disable_device(link); 370 382 } 371 383 372 - static int com20020_suspend(struct pcmcia_device *p_dev) 384 + static int com20020_suspend(struct pcmcia_device *link) 373 385 { 374 - dev_link_t *link = dev_to_instance(p_dev); 375 386 com20020_dev_t *info = link->priv; 376 387 struct net_device *dev = info->dev; 377 388 378 - link->state |= DEV_SUSPEND; 379 - if (link->state & DEV_CONFIG) { 380 - if (link->open) { 381 - netif_device_detach(dev); 382 - } 383 - pcmcia_release_configuration(link->handle); 384 - } 389 + if (link->open) 390 + netif_device_detach(dev); 385 391 386 392 return 0; 387 393 } 388 394 389 - static int com20020_resume(struct pcmcia_device *p_dev) 395 + static int com20020_resume(struct pcmcia_device *link) 390 396 { 391 - dev_link_t *link = dev_to_instance(p_dev); 392 397 com20020_dev_t *info = link->priv; 393 398 struct net_device *dev = info->dev; 394 399 395 - link->state &= ~DEV_SUSPEND; 396 - if (link->state & DEV_CONFIG) { 397 - pcmcia_request_configuration(link->handle, &link->conf); 398 - if (link->open) { 399 - int ioaddr = dev->base_addr; 400 - struct arcnet_local *lp = dev->priv; 401 - ARCRESET; 402 - } 403 - } 400 + if (link->open) { 401 + int ioaddr = dev->base_addr; 402 + struct arcnet_local *lp = dev->priv; 403 + ARCRESET; 404 + } 404 405 405 406 return 0; 406 407 } ··· 397 436 .drv = { 398 437 .name = "com20020_cs", 399 438 }, 400 - .probe = com20020_attach, 439 + .probe = com20020_probe, 401 440 .remove = com20020_detach, 402 441 .id_table = com20020_ids, 403 442 .suspend = com20020_suspend,
+63 -103
drivers/net/pcmcia/fmvj18x_cs.c
··· 84 84 /* 85 85 PCMCIA event handlers 86 86 */ 87 - static void fmvj18x_config(dev_link_t *link); 88 - static int fmvj18x_get_hwinfo(dev_link_t *link, u_char *node_id); 89 - static int fmvj18x_setup_mfc(dev_link_t *link); 90 - static void fmvj18x_release(dev_link_t *link); 87 + static int fmvj18x_config(struct pcmcia_device *link); 88 + static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id); 89 + static int fmvj18x_setup_mfc(struct pcmcia_device *link); 90 + static void fmvj18x_release(struct pcmcia_device *link); 91 91 static void fmvj18x_detach(struct pcmcia_device *p_dev); 92 92 93 93 /* ··· 116 116 driver specific data structure 117 117 */ 118 118 typedef struct local_info_t { 119 - dev_link_t link; 119 + struct pcmcia_device *p_dev; 120 120 dev_node_t node; 121 121 struct net_device_stats stats; 122 122 long open_time; ··· 228 228 #define BANK_1U 0x24 /* bank 1 (CONFIG_1) */ 229 229 #define BANK_2U 0x28 /* bank 2 (CONFIG_1) */ 230 230 231 - static int fmvj18x_attach(struct pcmcia_device *p_dev) 231 + static int fmvj18x_probe(struct pcmcia_device *link) 232 232 { 233 233 local_info_t *lp; 234 - dev_link_t *link; 235 234 struct net_device *dev; 236 235 237 236 DEBUG(0, "fmvj18x_attach()\n"); ··· 240 241 if (!dev) 241 242 return -ENOMEM; 242 243 lp = netdev_priv(dev); 243 - link = &lp->link; 244 244 link->priv = dev; 245 + lp->p_dev = link; 245 246 246 247 /* The io structure describes IO port mapping */ 247 248 link->io.NumPorts1 = 32; ··· 256 257 257 258 /* General socket configuration */ 258 259 link->conf.Attributes = CONF_ENABLE_IRQ; 259 - link->conf.Vcc = 50; 260 260 link->conf.IntType = INT_MEMORY_AND_IO; 261 261 262 262 /* The FMVJ18x specific entries in the device structure. */ ··· 272 274 #endif 273 275 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 274 276 275 - link->handle = p_dev; 276 - p_dev->instance = link; 277 - 278 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 279 - fmvj18x_config(link); 280 - 281 - return 0; 277 + return fmvj18x_config(link); 282 278 } /* fmvj18x_attach */ 283 279 284 280 /*====================================================================*/ 285 281 286 - static void fmvj18x_detach(struct pcmcia_device *p_dev) 282 + static void fmvj18x_detach(struct pcmcia_device *link) 287 283 { 288 - dev_link_t *link = dev_to_instance(p_dev); 289 284 struct net_device *dev = link->priv; 290 285 291 286 DEBUG(0, "fmvj18x_detach(0x%p)\n", link); 292 287 293 - if (link->dev) 288 + if (link->dev_node) 294 289 unregister_netdev(dev); 295 290 296 - if (link->state & DEV_CONFIG) 297 - fmvj18x_release(link); 291 + fmvj18x_release(link); 298 292 299 293 free_netdev(dev); 300 294 } /* fmvj18x_detach */ ··· 296 306 #define CS_CHECK(fn, ret) \ 297 307 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 298 308 299 - static int mfc_try_io_port(dev_link_t *link) 309 + static int mfc_try_io_port(struct pcmcia_device *link) 300 310 { 301 311 int i, ret; 302 312 static const kio_addr_t serial_base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; ··· 308 318 link->io.NumPorts2 = 0; 309 319 printk(KERN_NOTICE "fmvj18x_cs: out of resource for serial\n"); 310 320 } 311 - ret = pcmcia_request_io(link->handle, &link->io); 321 + ret = pcmcia_request_io(link, &link->io); 312 322 if (ret == CS_SUCCESS) return ret; 313 323 } 314 324 return ret; 315 325 } 316 326 317 - static int ungermann_try_io_port(dev_link_t *link) 327 + static int ungermann_try_io_port(struct pcmcia_device *link) 318 328 { 319 329 int ret; 320 330 kio_addr_t ioaddr; ··· 324 334 */ 325 335 for (ioaddr = 0x300; ioaddr < 0x3e0; ioaddr += 0x20) { 326 336 link->io.BasePort1 = ioaddr; 327 - ret = pcmcia_request_io(link->handle, &link->io); 337 + ret = pcmcia_request_io(link, &link->io); 328 338 if (ret == CS_SUCCESS) { 329 339 /* calculate ConfigIndex value */ 330 340 link->conf.ConfigIndex = ··· 335 345 return ret; /* RequestIO failed */ 336 346 } 337 347 338 - static void fmvj18x_config(dev_link_t *link) 348 + static int fmvj18x_config(struct pcmcia_device *link) 339 349 { 340 - client_handle_t handle = link->handle; 341 350 struct net_device *dev = link->priv; 342 351 local_info_t *lp = netdev_priv(dev); 343 352 tuple_t tuple; ··· 355 366 registers. 356 367 */ 357 368 tuple.DesiredTuple = CISTPL_CONFIG; 358 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 369 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 359 370 tuple.TupleData = (u_char *)buf; 360 371 tuple.TupleDataMax = 64; 361 372 tuple.TupleOffset = 0; 362 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 363 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 364 - 365 - /* Configure card */ 366 - link->state |= DEV_CONFIG; 373 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 374 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 367 375 368 376 link->conf.ConfigBase = parse.config.base; 369 377 link->conf.Present = parse.config.rmask[0]; 370 378 371 379 tuple.DesiredTuple = CISTPL_FUNCE; 372 380 tuple.TupleOffset = 0; 373 - if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) { 381 + if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) { 374 382 /* Yes, I have CISTPL_FUNCE. Let's check CISTPL_MANFID */ 375 383 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 376 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 377 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 378 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 384 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 385 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 386 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 379 387 link->conf.ConfigIndex = parse.cftable_entry.index; 380 388 tuple.DesiredTuple = CISTPL_MANFID; 381 - if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) 382 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 389 + if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) 390 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 383 391 else 384 392 buf[0] = 0xffff; 385 393 switch (le16_to_cpu(buf[0])) { 386 394 case MANFID_TDK: 387 395 cardtype = TDK; 388 - if (le16_to_cpu(buf[1]) == PRODID_TDK_CF010) { 389 - cs_status_t status; 390 - pcmcia_get_status(handle, &status); 391 - if (status.CardState & CS_EVENT_3VCARD) 392 - link->conf.Vcc = 33; /* inserted in 3.3V slot */ 393 - } else if (le16_to_cpu(buf[1]) == PRODID_TDK_GN3410 396 + if (le16_to_cpu(buf[1]) == PRODID_TDK_GN3410 394 397 || le16_to_cpu(buf[1]) == PRODID_TDK_NP9610 395 398 || le16_to_cpu(buf[1]) == PRODID_TDK_MN3200) { 396 399 /* MultiFunction Card */ ··· 410 429 } else { 411 430 /* old type card */ 412 431 tuple.DesiredTuple = CISTPL_MANFID; 413 - if (pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) 414 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 432 + if (pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) 433 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 415 434 else 416 435 buf[0] = 0xffff; 417 436 switch (le16_to_cpu(buf[0])) { ··· 442 461 ret = ungermann_try_io_port(link); 443 462 if (ret != CS_SUCCESS) goto cs_failed; 444 463 } else { 445 - CS_CHECK(RequestIO, pcmcia_request_io(link->handle, &link->io)); 464 + CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); 446 465 } 447 - CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 448 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 466 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 467 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 449 468 dev->irq = link->irq.AssignedIRQ; 450 469 dev->base_addr = link->io.BasePort1; 451 470 ··· 474 493 case CONTEC: 475 494 tuple.DesiredTuple = CISTPL_FUNCE; 476 495 tuple.TupleOffset = 0; 477 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 496 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 478 497 tuple.TupleOffset = 0; 479 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 498 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 480 499 if (cardtype == MBH10304) { 481 500 /* MBH10304's CIS_FUNCE is corrupted */ 482 501 node_id = &(tuple.TupleData[5]); 483 502 card_name = "FMV-J182"; 484 503 } else { 485 504 while (tuple.TupleData[0] != CISTPL_FUNCE_LAN_NODE_ID ) { 486 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); 487 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 505 + CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 506 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 488 507 } 489 508 node_id = &(tuple.TupleData[2]); 490 509 if( cardtype == TDK ) { ··· 526 545 } 527 546 528 547 lp->cardtype = cardtype; 529 - link->dev = &lp->node; 530 - link->state &= ~DEV_CONFIG_PENDING; 531 - SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 548 + link->dev_node = &lp->node; 549 + SET_NETDEV_DEV(dev, &handle_to_dev(link)); 532 550 533 551 if (register_netdev(dev) != 0) { 534 552 printk(KERN_NOTICE "fmvj18x_cs: register_netdev() failed\n"); 535 - link->dev = NULL; 553 + link->dev_node = NULL; 536 554 goto failed; 537 555 } 538 556 ··· 544 564 for (i = 0; i < 6; i++) 545 565 printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n")); 546 566 547 - return; 567 + return 0; 548 568 549 569 cs_failed: 550 570 /* All Card Services errors end up here */ 551 - cs_error(link->handle, last_fn, last_ret); 571 + cs_error(link, last_fn, last_ret); 552 572 failed: 553 573 fmvj18x_release(link); 554 - link->state &= ~DEV_CONFIG_PENDING; 555 - 574 + return -ENODEV; 556 575 } /* fmvj18x_config */ 557 576 /*====================================================================*/ 558 577 559 - static int fmvj18x_get_hwinfo(dev_link_t *link, u_char *node_id) 578 + static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id) 560 579 { 561 580 win_req_t req; 562 581 memreq_t mem; ··· 566 587 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 567 588 req.Base = 0; req.Size = 0; 568 589 req.AccessSpeed = 0; 569 - i = pcmcia_request_window(&link->handle, &req, &link->win); 590 + i = pcmcia_request_window(&link, &req, &link->win); 570 591 if (i != CS_SUCCESS) { 571 - cs_error(link->handle, RequestWindow, i); 592 + cs_error(link, RequestWindow, i); 572 593 return -1; 573 594 } 574 595 ··· 602 623 iounmap(base); 603 624 j = pcmcia_release_window(link->win); 604 625 if (j != CS_SUCCESS) 605 - cs_error(link->handle, ReleaseWindow, j); 626 + cs_error(link, ReleaseWindow, j); 606 627 return (i != 0x200) ? 0 : -1; 607 628 608 629 } /* fmvj18x_get_hwinfo */ 609 630 /*====================================================================*/ 610 631 611 - static int fmvj18x_setup_mfc(dev_link_t *link) 632 + static int fmvj18x_setup_mfc(struct pcmcia_device *link) 612 633 { 613 634 win_req_t req; 614 635 memreq_t mem; ··· 621 642 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 622 643 req.Base = 0; req.Size = 0; 623 644 req.AccessSpeed = 0; 624 - i = pcmcia_request_window(&link->handle, &req, &link->win); 645 + i = pcmcia_request_window(&link, &req, &link->win); 625 646 if (i != CS_SUCCESS) { 626 - cs_error(link->handle, RequestWindow, i); 647 + cs_error(link, RequestWindow, i); 627 648 return -1; 628 649 } 629 650 ··· 645 666 iounmap(base); 646 667 j = pcmcia_release_window(link->win); 647 668 if (j != CS_SUCCESS) 648 - cs_error(link->handle, ReleaseWindow, j); 669 + cs_error(link, ReleaseWindow, j); 649 670 return 0; 650 671 651 672 } 652 673 /*====================================================================*/ 653 674 654 - static void fmvj18x_release(dev_link_t *link) 675 + static void fmvj18x_release(struct pcmcia_device *link) 655 676 { 656 - 657 - DEBUG(0, "fmvj18x_release(0x%p)\n", link); 658 - 659 - /* Don't bother checking to see if these succeed or not */ 660 - pcmcia_release_window(link->win); 661 - pcmcia_release_configuration(link->handle); 662 - pcmcia_release_io(link->handle, &link->io); 663 - pcmcia_release_irq(link->handle, &link->irq); 664 - 665 - link->state &= ~DEV_CONFIG; 677 + DEBUG(0, "fmvj18x_release(0x%p)\n", link); 678 + pcmcia_disable_device(link); 666 679 } 667 680 668 - static int fmvj18x_suspend(struct pcmcia_device *p_dev) 681 + static int fmvj18x_suspend(struct pcmcia_device *link) 669 682 { 670 - dev_link_t *link = dev_to_instance(p_dev); 671 683 struct net_device *dev = link->priv; 672 684 673 - link->state |= DEV_SUSPEND; 674 - if (link->state & DEV_CONFIG) { 675 - if (link->open) 676 - netif_device_detach(dev); 677 - pcmcia_release_configuration(link->handle); 678 - } 679 - 685 + if (link->open) 686 + netif_device_detach(dev); 680 687 681 688 return 0; 682 689 } 683 690 684 - static int fmvj18x_resume(struct pcmcia_device *p_dev) 691 + static int fmvj18x_resume(struct pcmcia_device *link) 685 692 { 686 - dev_link_t *link = dev_to_instance(p_dev); 687 693 struct net_device *dev = link->priv; 688 694 689 - link->state &= ~DEV_SUSPEND; 690 - if (link->state & DEV_CONFIG) { 691 - pcmcia_request_configuration(link->handle, &link->conf); 692 - if (link->open) { 693 - fjn_reset(dev); 694 - netif_device_attach(dev); 695 - } 695 + if (link->open) { 696 + fjn_reset(dev); 697 + netif_device_attach(dev); 696 698 } 697 699 698 700 return 0; ··· 711 751 .drv = { 712 752 .name = "fmvj18x_cs", 713 753 }, 714 - .probe = fmvj18x_attach, 754 + .probe = fmvj18x_probe, 715 755 .remove = fmvj18x_detach, 716 756 .id_table = fmvj18x_ids, 717 757 .suspend = fmvj18x_suspend, ··· 1108 1148 static int fjn_open(struct net_device *dev) 1109 1149 { 1110 1150 struct local_info_t *lp = netdev_priv(dev); 1111 - dev_link_t *link = &lp->link; 1151 + struct pcmcia_device *link = lp->p_dev; 1112 1152 1113 1153 DEBUG(4, "fjn_open('%s').\n", dev->name); 1114 1154 1115 - if (!DEV_OK(link)) 1155 + if (!pcmcia_dev_present(link)) 1116 1156 return -ENODEV; 1117 1157 1118 1158 link->open++; ··· 1133 1173 static int fjn_close(struct net_device *dev) 1134 1174 { 1135 1175 struct local_info_t *lp = netdev_priv(dev); 1136 - dev_link_t *link = &lp->link; 1176 + struct pcmcia_device *link = lp->p_dev; 1137 1177 kio_addr_t ioaddr = dev->base_addr; 1138 1178 1139 1179 DEBUG(4, "fjn_close('%s').\n", dev->name);
+51 -80
drivers/net/pcmcia/ibmtr_cs.c
··· 105 105 106 106 /*====================================================================*/ 107 107 108 - static void ibmtr_config(dev_link_t *link); 108 + static int ibmtr_config(struct pcmcia_device *link); 109 109 static void ibmtr_hw_setup(struct net_device *dev, u_int mmiobase); 110 - static void ibmtr_release(dev_link_t *link); 110 + static void ibmtr_release(struct pcmcia_device *link); 111 111 static void ibmtr_detach(struct pcmcia_device *p_dev); 112 112 113 113 /*====================================================================*/ 114 114 115 115 typedef struct ibmtr_dev_t { 116 - dev_link_t link; 116 + struct pcmcia_device *p_dev; 117 117 struct net_device *dev; 118 118 dev_node_t node; 119 119 window_handle_t sram_win_handle; ··· 138 138 139 139 ======================================================================*/ 140 140 141 - static int ibmtr_attach(struct pcmcia_device *p_dev) 141 + static int ibmtr_attach(struct pcmcia_device *link) 142 142 { 143 143 ibmtr_dev_t *info; 144 - dev_link_t *link; 145 144 struct net_device *dev; 146 - 145 + 147 146 DEBUG(0, "ibmtr_attach()\n"); 148 147 149 148 /* Create new token-ring device */ ··· 155 156 return -ENOMEM; 156 157 } 157 158 158 - link = &info->link; 159 + info->p_dev = link; 159 160 link->priv = info; 160 161 info->ti = netdev_priv(dev); 161 162 ··· 166 167 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 167 168 link->irq.Handler = &tok_interrupt; 168 169 link->conf.Attributes = CONF_ENABLE_IRQ; 169 - link->conf.Vcc = 50; 170 170 link->conf.IntType = INT_MEMORY_AND_IO; 171 171 link->conf.Present = PRESENT_OPTION; 172 172 173 173 link->irq.Instance = info->dev = dev; 174 - 174 + 175 175 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 176 176 177 - link->handle = p_dev; 178 - p_dev->instance = link; 179 - 180 - link->state |= DEV_PRESENT; 181 - ibmtr_config(link); 182 - 183 - return 0; 177 + return ibmtr_config(link); 184 178 } /* ibmtr_attach */ 185 179 186 180 /*====================================================================== ··· 185 193 186 194 ======================================================================*/ 187 195 188 - static void ibmtr_detach(struct pcmcia_device *p_dev) 196 + static void ibmtr_detach(struct pcmcia_device *link) 189 197 { 190 - dev_link_t *link = dev_to_instance(p_dev); 191 198 struct ibmtr_dev_t *info = link->priv; 192 199 struct net_device *dev = info->dev; 193 200 194 201 DEBUG(0, "ibmtr_detach(0x%p)\n", link); 195 202 196 - if (link->dev) 203 + if (link->dev_node) 197 204 unregister_netdev(dev); 198 205 199 206 { 200 207 struct tok_info *ti = netdev_priv(dev); 201 208 del_timer_sync(&(ti->tr_timer)); 202 209 } 203 - if (link->state & DEV_CONFIG) 204 - ibmtr_release(link); 210 + 211 + ibmtr_release(link); 205 212 206 213 free_netdev(dev); 207 214 kfree(info); ··· 217 226 #define CS_CHECK(fn, ret) \ 218 227 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 219 228 220 - static void ibmtr_config(dev_link_t *link) 229 + static int ibmtr_config(struct pcmcia_device *link) 221 230 { 222 - client_handle_t handle = link->handle; 223 231 ibmtr_dev_t *info = link->priv; 224 232 struct net_device *dev = info->dev; 225 233 struct tok_info *ti = netdev_priv(dev); ··· 236 246 tuple.TupleDataMax = 64; 237 247 tuple.TupleOffset = 0; 238 248 tuple.DesiredTuple = CISTPL_CONFIG; 239 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 240 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 241 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 249 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 250 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 251 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 242 252 link->conf.ConfigBase = parse.config.base; 243 - 244 - /* Configure card */ 245 - link->state |= DEV_CONFIG; 246 - 247 253 link->conf.ConfigIndex = 0x61; 248 254 249 255 /* Determine if this is PRIMARY or ALTERNATE. */ 250 256 251 257 /* Try PRIMARY card at 0xA20-0xA23 */ 252 258 link->io.BasePort1 = 0xA20; 253 - i = pcmcia_request_io(link->handle, &link->io); 259 + i = pcmcia_request_io(link, &link->io); 254 260 if (i != CS_SUCCESS) { 255 261 /* Couldn't get 0xA20-0xA23. Try ALTERNATE at 0xA24-0xA27. */ 256 262 link->io.BasePort1 = 0xA24; 257 - CS_CHECK(RequestIO, pcmcia_request_io(link->handle, &link->io)); 263 + CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); 258 264 } 259 265 dev->base_addr = link->io.BasePort1; 260 266 261 - CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 267 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 262 268 dev->irq = link->irq.AssignedIRQ; 263 269 ti->irq = link->irq.AssignedIRQ; 264 270 ti->global_int_enable=GLOBAL_INT_ENABLE+((dev->irq==9) ? 2 : dev->irq); ··· 265 279 req.Base = 0; 266 280 req.Size = 0x2000; 267 281 req.AccessSpeed = 250; 268 - CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &link->win)); 282 + CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win)); 269 283 270 284 mem.CardOffset = mmiobase; 271 285 mem.Page = 0; ··· 278 292 req.Base = 0; 279 293 req.Size = sramsize * 1024; 280 294 req.AccessSpeed = 250; 281 - CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &info->sram_win_handle)); 295 + CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &info->sram_win_handle)); 282 296 283 297 mem.CardOffset = srambase; 284 298 mem.Page = 0; ··· 288 302 ti->sram_virt = ioremap(req.Base, req.Size); 289 303 ti->sram_phys = req.Base; 290 304 291 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 305 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 292 306 293 307 /* Set up the Token-Ring Controller Configuration Register and 294 308 turn on the card. Check the "Local Area Network Credit Card 295 309 Adapters Technical Reference" SC30-3585 for this info. */ 296 310 ibmtr_hw_setup(dev, mmiobase); 297 311 298 - link->dev = &info->node; 299 - link->state &= ~DEV_CONFIG_PENDING; 300 - SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 312 + link->dev_node = &info->node; 313 + SET_NETDEV_DEV(dev, &handle_to_dev(link)); 301 314 302 315 i = ibmtr_probe_card(dev); 303 316 if (i != 0) { 304 317 printk(KERN_NOTICE "ibmtr_cs: register_netdev() failed\n"); 305 - link->dev = NULL; 318 + link->dev_node = NULL; 306 319 goto failed; 307 320 } 308 321 ··· 315 330 for (i = 0; i < TR_ALEN; i++) 316 331 printk("%02X", dev->dev_addr[i]); 317 332 printk("\n"); 318 - return; 333 + return 0; 319 334 320 335 cs_failed: 321 - cs_error(link->handle, last_fn, last_ret); 336 + cs_error(link, last_fn, last_ret); 322 337 failed: 323 338 ibmtr_release(link); 339 + return -ENODEV; 324 340 } /* ibmtr_config */ 325 341 326 342 /*====================================================================== ··· 332 346 333 347 ======================================================================*/ 334 348 335 - static void ibmtr_release(dev_link_t *link) 349 + static void ibmtr_release(struct pcmcia_device *link) 336 350 { 337 - ibmtr_dev_t *info = link->priv; 338 - struct net_device *dev = info->dev; 339 - 340 - DEBUG(0, "ibmtr_release(0x%p)\n", link); 341 - 342 - pcmcia_release_configuration(link->handle); 343 - pcmcia_release_io(link->handle, &link->io); 344 - pcmcia_release_irq(link->handle, &link->irq); 345 - if (link->win) { 346 - struct tok_info *ti = netdev_priv(dev); 347 - iounmap(ti->mmio); 348 - pcmcia_release_window(link->win); 349 - pcmcia_release_window(info->sram_win_handle); 350 - } 351 - 352 - link->state &= ~DEV_CONFIG; 353 - } 354 - 355 - static int ibmtr_suspend(struct pcmcia_device *p_dev) 356 - { 357 - dev_link_t *link = dev_to_instance(p_dev); 358 351 ibmtr_dev_t *info = link->priv; 359 352 struct net_device *dev = info->dev; 360 353 361 - link->state |= DEV_SUSPEND; 362 - if (link->state & DEV_CONFIG) { 363 - if (link->open) 364 - netif_device_detach(dev); 365 - pcmcia_release_configuration(link->handle); 366 - } 354 + DEBUG(0, "ibmtr_release(0x%p)\n", link); 355 + 356 + if (link->win) { 357 + struct tok_info *ti = netdev_priv(dev); 358 + iounmap(ti->mmio); 359 + pcmcia_release_window(info->sram_win_handle); 360 + } 361 + pcmcia_disable_device(link); 362 + } 363 + 364 + static int ibmtr_suspend(struct pcmcia_device *link) 365 + { 366 + ibmtr_dev_t *info = link->priv; 367 + struct net_device *dev = info->dev; 368 + 369 + if (link->open) 370 + netif_device_detach(dev); 367 371 368 372 return 0; 369 373 } 370 374 371 - static int ibmtr_resume(struct pcmcia_device *p_dev) 375 + static int ibmtr_resume(struct pcmcia_device *link) 372 376 { 373 - dev_link_t *link = dev_to_instance(p_dev); 374 377 ibmtr_dev_t *info = link->priv; 375 378 struct net_device *dev = info->dev; 376 379 377 - link->state &= ~DEV_SUSPEND; 378 - if (link->state & DEV_CONFIG) { 379 - pcmcia_request_configuration(link->handle, &link->conf); 380 - if (link->open) { 381 - ibmtr_probe(dev); /* really? */ 382 - netif_device_attach(dev); 383 - } 384 - } 380 + if (link->open) { 381 + ibmtr_probe(dev); /* really? */ 382 + netif_device_attach(dev); 383 + } 385 384 386 385 return 0; 387 386 }
+46 -80
drivers/net/pcmcia/nmclan_cs.c
··· 362 362 } mace_statistics; 363 363 364 364 typedef struct _mace_private { 365 - dev_link_t link; 365 + struct pcmcia_device *p_dev; 366 366 dev_node_t node; 367 367 struct net_device_stats linux_stats; /* Linux statistics counters */ 368 368 mace_statistics mace_stats; /* MACE chip statistics counters */ ··· 417 417 Function Prototypes 418 418 ---------------------------------------------------------------------------- */ 419 419 420 - static void nmclan_config(dev_link_t *link); 421 - static void nmclan_release(dev_link_t *link); 420 + static int nmclan_config(struct pcmcia_device *link); 421 + static void nmclan_release(struct pcmcia_device *link); 422 422 423 423 static void nmclan_reset(struct net_device *dev); 424 424 static int mace_config(struct net_device *dev, struct ifmap *map); ··· 443 443 Services. 444 444 ---------------------------------------------------------------------------- */ 445 445 446 - static int nmclan_attach(struct pcmcia_device *p_dev) 446 + static int nmclan_probe(struct pcmcia_device *link) 447 447 { 448 448 mace_private *lp; 449 - dev_link_t *link; 450 449 struct net_device *dev; 451 450 452 451 DEBUG(0, "nmclan_attach()\n"); ··· 456 457 if (!dev) 457 458 return -ENOMEM; 458 459 lp = netdev_priv(dev); 459 - link = &lp->link; 460 + lp->p_dev = link; 460 461 link->priv = dev; 461 462 462 463 spin_lock_init(&lp->bank_lock); ··· 468 469 link->irq.Handler = &mace_interrupt; 469 470 link->irq.Instance = dev; 470 471 link->conf.Attributes = CONF_ENABLE_IRQ; 471 - link->conf.Vcc = 50; 472 472 link->conf.IntType = INT_MEMORY_AND_IO; 473 473 link->conf.ConfigIndex = 1; 474 474 link->conf.Present = PRESENT_OPTION; ··· 487 489 dev->watchdog_timeo = TX_TIMEOUT; 488 490 #endif 489 491 490 - link->handle = p_dev; 491 - p_dev->instance = link; 492 - 493 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 494 - nmclan_config(link); 495 - 496 - return 0; 492 + return nmclan_config(link); 497 493 } /* nmclan_attach */ 498 494 499 495 /* ---------------------------------------------------------------------------- ··· 498 506 when the device is released. 499 507 ---------------------------------------------------------------------------- */ 500 508 501 - static void nmclan_detach(struct pcmcia_device *p_dev) 509 + static void nmclan_detach(struct pcmcia_device *link) 502 510 { 503 - dev_link_t *link = dev_to_instance(p_dev); 504 511 struct net_device *dev = link->priv; 505 512 506 513 DEBUG(0, "nmclan_detach(0x%p)\n", link); 507 514 508 - if (link->dev) 515 + if (link->dev_node) 509 516 unregister_netdev(dev); 510 517 511 - if (link->state & DEV_CONFIG) 512 - nmclan_release(link); 518 + nmclan_release(link); 513 519 514 520 free_netdev(dev); 515 521 } /* nmclan_detach */ ··· 651 661 #define CS_CHECK(fn, ret) \ 652 662 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 653 663 654 - static void nmclan_config(dev_link_t *link) 664 + static int nmclan_config(struct pcmcia_device *link) 655 665 { 656 - client_handle_t handle = link->handle; 657 666 struct net_device *dev = link->priv; 658 667 mace_private *lp = netdev_priv(dev); 659 668 tuple_t tuple; ··· 668 679 tuple.TupleDataMax = 64; 669 680 tuple.TupleOffset = 0; 670 681 tuple.DesiredTuple = CISTPL_CONFIG; 671 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 672 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 673 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 682 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 683 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 684 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 674 685 link->conf.ConfigBase = parse.config.base; 675 686 676 - /* Configure card */ 677 - link->state |= DEV_CONFIG; 678 - 679 - CS_CHECK(RequestIO, pcmcia_request_io(handle, &link->io)); 680 - CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq)); 681 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); 687 + CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); 688 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 689 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 682 690 dev->irq = link->irq.AssignedIRQ; 683 691 dev->base_addr = link->io.BasePort1; 684 692 ··· 686 700 tuple.TupleData = buf; 687 701 tuple.TupleDataMax = 64; 688 702 tuple.TupleOffset = 0; 689 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 690 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 703 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 704 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 691 705 memcpy(dev->dev_addr, tuple.TupleData, ETHER_ADDR_LEN); 692 706 693 707 /* Verify configuration by reading the MACE ID. */ ··· 702 716 } else { 703 717 printk(KERN_NOTICE "nmclan_cs: mace id not found: %x %x should" 704 718 " be 0x40 0x?9\n", sig[0], sig[1]); 705 - link->state &= ~DEV_CONFIG_PENDING; 706 - return; 719 + return -ENODEV; 707 720 } 708 721 } 709 722 ··· 715 730 else 716 731 printk(KERN_NOTICE "nmclan_cs: invalid if_port requested\n"); 717 732 718 - link->dev = &lp->node; 719 - link->state &= ~DEV_CONFIG_PENDING; 720 - SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 733 + link->dev_node = &lp->node; 734 + SET_NETDEV_DEV(dev, &handle_to_dev(link)); 721 735 722 736 i = register_netdev(dev); 723 737 if (i != 0) { 724 738 printk(KERN_NOTICE "nmclan_cs: register_netdev() failed\n"); 725 - link->dev = NULL; 739 + link->dev_node = NULL; 726 740 goto failed; 727 741 } 728 742 ··· 731 747 dev->name, dev->base_addr, dev->irq, if_names[dev->if_port]); 732 748 for (i = 0; i < 6; i++) 733 749 printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n")); 734 - return; 750 + return 0; 735 751 736 752 cs_failed: 737 - cs_error(link->handle, last_fn, last_ret); 753 + cs_error(link, last_fn, last_ret); 738 754 failed: 739 - nmclan_release(link); 740 - return; 741 - 755 + nmclan_release(link); 756 + return -ENODEV; 742 757 } /* nmclan_config */ 743 758 744 759 /* ---------------------------------------------------------------------------- ··· 746 763 net device, and release the PCMCIA configuration. If the device 747 764 is still open, this will be postponed until it is closed. 748 765 ---------------------------------------------------------------------------- */ 749 - static void nmclan_release(dev_link_t *link) 766 + static void nmclan_release(struct pcmcia_device *link) 750 767 { 751 - 752 - DEBUG(0, "nmclan_release(0x%p)\n", link); 753 - 754 - pcmcia_release_configuration(link->handle); 755 - pcmcia_release_io(link->handle, &link->io); 756 - pcmcia_release_irq(link->handle, &link->irq); 757 - 758 - link->state &= ~DEV_CONFIG; 768 + DEBUG(0, "nmclan_release(0x%p)\n", link); 769 + pcmcia_disable_device(link); 759 770 } 760 771 761 - static int nmclan_suspend(struct pcmcia_device *p_dev) 772 + static int nmclan_suspend(struct pcmcia_device *link) 762 773 { 763 - dev_link_t *link = dev_to_instance(p_dev); 764 774 struct net_device *dev = link->priv; 765 775 766 - link->state |= DEV_SUSPEND; 767 - if (link->state & DEV_CONFIG) { 768 - if (link->open) 769 - netif_device_detach(dev); 770 - pcmcia_release_configuration(link->handle); 771 - } 772 - 776 + if (link->open) 777 + netif_device_detach(dev); 773 778 774 779 return 0; 775 780 } 776 781 777 - static int nmclan_resume(struct pcmcia_device *p_dev) 782 + static int nmclan_resume(struct pcmcia_device *link) 778 783 { 779 - dev_link_t *link = dev_to_instance(p_dev); 780 784 struct net_device *dev = link->priv; 781 785 782 - link->state &= ~DEV_SUSPEND; 783 - if (link->state & DEV_CONFIG) { 784 - pcmcia_request_configuration(link->handle, &link->conf); 785 - if (link->open) { 786 - nmclan_reset(dev); 787 - netif_device_attach(dev); 788 - } 786 + if (link->open) { 787 + nmclan_reset(dev); 788 + netif_device_attach(dev); 789 789 } 790 790 791 791 return 0; ··· 784 818 mace_private *lp = netdev_priv(dev); 785 819 786 820 #if RESET_XILINX 787 - dev_link_t *link = &lp->link; 821 + struct pcmcia_device *link = &lp->link; 788 822 conf_reg_t reg; 789 823 u_long OrigCorValue; 790 824 ··· 793 827 reg.Action = CS_READ; 794 828 reg.Offset = CISREG_COR; 795 829 reg.Value = 0; 796 - pcmcia_access_configuration_register(link->handle, &reg); 830 + pcmcia_access_configuration_register(link, &reg); 797 831 OrigCorValue = reg.Value; 798 832 799 833 /* Reset Xilinx */ ··· 802 836 DEBUG(1, "nmclan_reset: OrigCorValue=0x%lX, resetting...\n", 803 837 OrigCorValue); 804 838 reg.Value = COR_SOFT_RESET; 805 - pcmcia_access_configuration_register(link->handle, &reg); 839 + pcmcia_access_configuration_register(link, &reg); 806 840 /* Need to wait for 20 ms for PCMCIA to finish reset. */ 807 841 808 842 /* Restore original COR configuration index */ 809 843 reg.Value = COR_LEVEL_REQ | (OrigCorValue & COR_CONFIG_MASK); 810 - pcmcia_access_configuration_register(link->handle, &reg); 844 + pcmcia_access_configuration_register(link, &reg); 811 845 /* Xilinx is now completely reset along with the MACE chip. */ 812 846 lp->tx_free_frames=AM2150_MAX_TX_FRAMES; 813 847 ··· 851 885 { 852 886 kio_addr_t ioaddr = dev->base_addr; 853 887 mace_private *lp = netdev_priv(dev); 854 - dev_link_t *link = &lp->link; 888 + struct pcmcia_device *link = lp->p_dev; 855 889 856 - if (!DEV_OK(link)) 890 + if (!pcmcia_dev_present(link)) 857 891 return -ENODEV; 858 892 859 893 link->open++; ··· 874 908 { 875 909 kio_addr_t ioaddr = dev->base_addr; 876 910 mace_private *lp = netdev_priv(dev); 877 - dev_link_t *link = &lp->link; 911 + struct pcmcia_device *link = lp->p_dev; 878 912 879 913 DEBUG(2, "%s: shutting down ethercard.\n", dev->name); 880 914 ··· 929 963 static void mace_tx_timeout(struct net_device *dev) 930 964 { 931 965 mace_private *lp = netdev_priv(dev); 932 - dev_link_t *link = &lp->link; 966 + struct pcmcia_device *link = lp->p_dev; 933 967 934 968 printk(KERN_NOTICE "%s: transmit timed out -- ", dev->name); 935 969 #if RESET_ON_TIMEOUT 936 970 printk("resetting card\n"); 937 - pcmcia_reset_card(link->handle, NULL); 971 + pcmcia_reset_card(link, NULL); 938 972 #else /* #if RESET_ON_TIMEOUT */ 939 973 printk("NOT resetting card\n"); 940 974 #endif /* #if RESET_ON_TIMEOUT */ ··· 1601 1635 .drv = { 1602 1636 .name = "nmclan_cs", 1603 1637 }, 1604 - .probe = nmclan_attach, 1638 + .probe = nmclan_probe, 1605 1639 .remove = nmclan_detach, 1606 1640 .id_table = nmclan_ids, 1607 1641 .suspend = nmclan_suspend,
+63 -98
drivers/net/pcmcia/pcnet_cs.c
··· 103 103 /*====================================================================*/ 104 104 105 105 static void mii_phy_probe(struct net_device *dev); 106 - static void pcnet_config(dev_link_t *link); 107 - static void pcnet_release(dev_link_t *link); 106 + static int pcnet_config(struct pcmcia_device *link); 107 + static void pcnet_release(struct pcmcia_device *link); 108 108 static int pcnet_open(struct net_device *dev); 109 109 static int pcnet_close(struct net_device *dev); 110 110 static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); ··· 113 113 static void ei_watchdog(u_long arg); 114 114 static void pcnet_reset_8390(struct net_device *dev); 115 115 static int set_config(struct net_device *dev, struct ifmap *map); 116 - static int setup_shmem_window(dev_link_t *link, int start_pg, 116 + static int setup_shmem_window(struct pcmcia_device *link, int start_pg, 117 117 int stop_pg, int cm_offset); 118 - static int setup_dma_config(dev_link_t *link, int start_pg, 118 + static int setup_dma_config(struct pcmcia_device *link, int start_pg, 119 119 int stop_pg); 120 120 121 121 static void pcnet_detach(struct pcmcia_device *p_dev); ··· 214 214 static hw_info_t dl10022_info = { 0, 0, 0, 0, IS_DL10022|HAS_MII }; 215 215 216 216 typedef struct pcnet_dev_t { 217 - dev_link_t link; 217 + struct pcmcia_device *p_dev; 218 218 dev_node_t node; 219 219 u_int flags; 220 220 void __iomem *base; ··· 240 240 241 241 ======================================================================*/ 242 242 243 - static int pcnet_probe(struct pcmcia_device *p_dev) 243 + static int pcnet_probe(struct pcmcia_device *link) 244 244 { 245 245 pcnet_dev_t *info; 246 - dev_link_t *link; 247 246 struct net_device *dev; 248 247 249 248 DEBUG(0, "pcnet_attach()\n"); ··· 251 252 dev = __alloc_ei_netdev(sizeof(pcnet_dev_t)); 252 253 if (!dev) return -ENOMEM; 253 254 info = PRIV(dev); 254 - link = &info->link; 255 + info->p_dev = link; 255 256 link->priv = dev; 256 257 257 258 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; ··· 264 265 dev->stop = &pcnet_close; 265 266 dev->set_config = &set_config; 266 267 267 - link->handle = p_dev; 268 - p_dev->instance = link; 269 - 270 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 271 - pcnet_config(link); 272 - 273 - return 0; 268 + return pcnet_config(link); 274 269 } /* pcnet_attach */ 275 270 276 271 /*====================================================================== ··· 276 283 277 284 ======================================================================*/ 278 285 279 - static void pcnet_detach(struct pcmcia_device *p_dev) 286 + static void pcnet_detach(struct pcmcia_device *link) 280 287 { 281 - dev_link_t *link = dev_to_instance(p_dev); 282 288 struct net_device *dev = link->priv; 283 289 284 290 DEBUG(0, "pcnet_detach(0x%p)\n", link); 285 291 286 - if (link->dev) 292 + if (link->dev_node) 287 293 unregister_netdev(dev); 288 294 289 - if (link->state & DEV_CONFIG) 290 - pcnet_release(link); 295 + pcnet_release(link); 291 296 292 297 free_netdev(dev); 293 298 } /* pcnet_detach */ ··· 297 306 298 307 ======================================================================*/ 299 308 300 - static hw_info_t *get_hwinfo(dev_link_t *link) 309 + static hw_info_t *get_hwinfo(struct pcmcia_device *link) 301 310 { 302 311 struct net_device *dev = link->priv; 303 312 win_req_t req; ··· 309 318 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 310 319 req.Base = 0; req.Size = 0; 311 320 req.AccessSpeed = 0; 312 - i = pcmcia_request_window(&link->handle, &req, &link->win); 321 + i = pcmcia_request_window(&link, &req, &link->win); 313 322 if (i != CS_SUCCESS) { 314 - cs_error(link->handle, RequestWindow, i); 323 + cs_error(link, RequestWindow, i); 315 324 return NULL; 316 325 } 317 326 ··· 334 343 iounmap(virt); 335 344 j = pcmcia_release_window(link->win); 336 345 if (j != CS_SUCCESS) 337 - cs_error(link->handle, ReleaseWindow, j); 346 + cs_error(link, ReleaseWindow, j); 338 347 return (i < NR_INFO) ? hw_info+i : NULL; 339 348 } /* get_hwinfo */ 340 349 ··· 346 355 347 356 ======================================================================*/ 348 357 349 - static hw_info_t *get_prom(dev_link_t *link) 358 + static hw_info_t *get_prom(struct pcmcia_device *link) 350 359 { 351 360 struct net_device *dev = link->priv; 352 361 kio_addr_t ioaddr = dev->base_addr; ··· 400 409 401 410 ======================================================================*/ 402 411 403 - static hw_info_t *get_dl10019(dev_link_t *link) 412 + static hw_info_t *get_dl10019(struct pcmcia_device *link) 404 413 { 405 414 struct net_device *dev = link->priv; 406 415 int i; ··· 422 431 423 432 ======================================================================*/ 424 433 425 - static hw_info_t *get_ax88190(dev_link_t *link) 434 + static hw_info_t *get_ax88190(struct pcmcia_device *link) 426 435 { 427 436 struct net_device *dev = link->priv; 428 437 kio_addr_t ioaddr = dev->base_addr; ··· 455 464 456 465 ======================================================================*/ 457 466 458 - static hw_info_t *get_hwired(dev_link_t *link) 467 + static hw_info_t *get_hwired(struct pcmcia_device *link) 459 468 { 460 469 struct net_device *dev = link->priv; 461 470 int i; ··· 482 491 #define CS_CHECK(fn, ret) \ 483 492 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 484 493 485 - static int try_io_port(dev_link_t *link) 494 + static int try_io_port(struct pcmcia_device *link) 486 495 { 487 496 int j, ret; 488 497 if (link->io.NumPorts1 == 32) { ··· 503 512 for (j = 0; j < 0x400; j += 0x20) { 504 513 link->io.BasePort1 = j ^ 0x300; 505 514 link->io.BasePort2 = (j ^ 0x300) + 0x10; 506 - ret = pcmcia_request_io(link->handle, &link->io); 515 + ret = pcmcia_request_io(link, &link->io); 507 516 if (ret == CS_SUCCESS) return ret; 508 517 } 509 518 return ret; 510 519 } else { 511 - return pcmcia_request_io(link->handle, &link->io); 520 + return pcmcia_request_io(link, &link->io); 512 521 } 513 522 } 514 523 515 - static void pcnet_config(dev_link_t *link) 524 + static int pcnet_config(struct pcmcia_device *link) 516 525 { 517 - client_handle_t handle = link->handle; 518 526 struct net_device *dev = link->priv; 519 527 pcnet_dev_t *info = PRIV(dev); 520 528 tuple_t tuple; ··· 521 531 int i, last_ret, last_fn, start_pg, stop_pg, cm_offset; 522 532 int manfid = 0, prodid = 0, has_shmem = 0; 523 533 u_short buf[64]; 524 - config_info_t conf; 525 534 hw_info_t *hw_info; 526 535 527 536 DEBUG(0, "pcnet_config(0x%p)\n", link); ··· 530 541 tuple.TupleDataMax = sizeof(buf); 531 542 tuple.TupleOffset = 0; 532 543 tuple.DesiredTuple = CISTPL_CONFIG; 533 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 534 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 535 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 544 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 545 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 546 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 536 547 link->conf.ConfigBase = parse.config.base; 537 548 link->conf.Present = parse.config.rmask[0]; 538 549 539 - /* Configure card */ 540 - link->state |= DEV_CONFIG; 541 - 542 - /* Look up current Vcc */ 543 - CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf)); 544 - link->conf.Vcc = conf.Vcc; 545 - 546 550 tuple.DesiredTuple = CISTPL_MANFID; 547 551 tuple.Attributes = TUPLE_RETURN_COMMON; 548 - if ((pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) && 549 - (pcmcia_get_tuple_data(handle, &tuple) == CS_SUCCESS)) { 552 + if ((pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) && 553 + (pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS)) { 550 554 manfid = le16_to_cpu(buf[0]); 551 555 prodid = le16_to_cpu(buf[1]); 552 556 } 553 557 554 558 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 555 559 tuple.Attributes = 0; 556 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 560 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 557 561 while (last_ret == CS_SUCCESS) { 558 562 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 559 563 cistpl_io_t *io = &(parse.cftable_entry.io); 560 564 561 - if (pcmcia_get_tuple_data(handle, &tuple) != 0 || 562 - pcmcia_parse_tuple(handle, &tuple, &parse) != 0 || 565 + if (pcmcia_get_tuple_data(link, &tuple) != 0 || 566 + pcmcia_parse_tuple(link, &tuple, &parse) != 0 || 563 567 cfg->index == 0 || cfg->io.nwin == 0) 564 568 goto next_entry; 565 569 ··· 576 594 if (last_ret == CS_SUCCESS) break; 577 595 } 578 596 next_entry: 579 - last_ret = pcmcia_get_next_tuple(handle, &tuple); 597 + last_ret = pcmcia_get_next_tuple(link, &tuple); 580 598 } 581 599 if (last_ret != CS_SUCCESS) { 582 - cs_error(handle, RequestIO, last_ret); 600 + cs_error(link, RequestIO, last_ret); 583 601 goto failed; 584 602 } 585 603 586 - CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq)); 604 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 587 605 588 606 if (link->io.NumPorts2 == 8) { 589 607 link->conf.Attributes |= CONF_ENABLE_SPKR; ··· 593 611 (prodid == PRODID_IBM_HOME_AND_AWAY)) 594 612 link->conf.ConfigIndex |= 0x10; 595 613 596 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); 614 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 597 615 dev->irq = link->irq.AssignedIRQ; 598 616 dev->base_addr = link->io.BasePort1; 599 617 if (info->flags & HAS_MISC_REG) { ··· 661 679 info->eth_phy = 0; 662 680 } 663 681 664 - link->dev = &info->node; 665 - link->state &= ~DEV_CONFIG_PENDING; 666 - SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 682 + link->dev_node = &info->node; 683 + SET_NETDEV_DEV(dev, &handle_to_dev(link)); 667 684 668 685 #ifdef CONFIG_NET_POLL_CONTROLLER 669 686 dev->poll_controller = ei_poll; ··· 670 689 671 690 if (register_netdev(dev) != 0) { 672 691 printk(KERN_NOTICE "pcnet_cs: register_netdev() failed\n"); 673 - link->dev = NULL; 692 + link->dev_node = NULL; 674 693 goto failed; 675 694 } 676 695 ··· 693 712 printk(" hw_addr "); 694 713 for (i = 0; i < 6; i++) 695 714 printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n")); 696 - return; 715 + return 0; 697 716 698 717 cs_failed: 699 - cs_error(link->handle, last_fn, last_ret); 718 + cs_error(link, last_fn, last_ret); 700 719 failed: 701 720 pcnet_release(link); 702 - link->state &= ~DEV_CONFIG_PENDING; 703 - return; 721 + return -ENODEV; 704 722 } /* pcnet_config */ 705 723 706 724 /*====================================================================== ··· 710 730 711 731 ======================================================================*/ 712 732 713 - static void pcnet_release(dev_link_t *link) 733 + static void pcnet_release(struct pcmcia_device *link) 714 734 { 715 - pcnet_dev_t *info = PRIV(link->priv); 735 + pcnet_dev_t *info = PRIV(link->priv); 716 736 717 - DEBUG(0, "pcnet_release(0x%p)\n", link); 737 + DEBUG(0, "pcnet_release(0x%p)\n", link); 718 738 719 - if (info->flags & USE_SHMEM) { 720 - iounmap(info->base); 721 - pcmcia_release_window(link->win); 722 - } 723 - pcmcia_release_configuration(link->handle); 724 - pcmcia_release_io(link->handle, &link->io); 725 - pcmcia_release_irq(link->handle, &link->irq); 739 + if (info->flags & USE_SHMEM) 740 + iounmap(info->base); 726 741 727 - link->state &= ~DEV_CONFIG; 742 + pcmcia_disable_device(link); 728 743 } 729 744 730 745 /*====================================================================== ··· 731 756 732 757 ======================================================================*/ 733 758 734 - static int pcnet_suspend(struct pcmcia_device *p_dev) 759 + static int pcnet_suspend(struct pcmcia_device *link) 735 760 { 736 - dev_link_t *link = dev_to_instance(p_dev); 737 761 struct net_device *dev = link->priv; 738 762 739 - link->state |= DEV_SUSPEND; 740 - if (link->state & DEV_CONFIG) { 741 - if (link->open) 742 - netif_device_detach(dev); 743 - pcmcia_release_configuration(link->handle); 744 - } 763 + if (link->open) 764 + netif_device_detach(dev); 745 765 746 766 return 0; 747 767 } 748 768 749 - static int pcnet_resume(struct pcmcia_device *p_dev) 769 + static int pcnet_resume(struct pcmcia_device *link) 750 770 { 751 - dev_link_t *link = dev_to_instance(p_dev); 752 771 struct net_device *dev = link->priv; 753 772 754 - link->state &= ~DEV_SUSPEND; 755 - if (link->state & DEV_CONFIG) { 756 - pcmcia_request_configuration(link->handle, &link->conf); 757 - if (link->open) { 758 - pcnet_reset_8390(dev); 759 - NS8390_init(dev, 1); 760 - netif_device_attach(dev); 761 - } 773 + if (link->open) { 774 + pcnet_reset_8390(dev); 775 + NS8390_init(dev, 1); 776 + netif_device_attach(dev); 762 777 } 763 778 764 779 return 0; ··· 988 1023 static int pcnet_open(struct net_device *dev) 989 1024 { 990 1025 pcnet_dev_t *info = PRIV(dev); 991 - dev_link_t *link = &info->link; 992 - 1026 + struct pcmcia_device *link = info->p_dev; 1027 + 993 1028 DEBUG(2, "pcnet_open('%s')\n", dev->name); 994 1029 995 - if (!DEV_OK(link)) 1030 + if (!pcmcia_dev_present(link)) 996 1031 return -ENODEV; 997 1032 998 1033 link->open++; ··· 1016 1051 static int pcnet_close(struct net_device *dev) 1017 1052 { 1018 1053 pcnet_dev_t *info = PRIV(dev); 1019 - dev_link_t *link = &info->link; 1054 + struct pcmcia_device *link = info->p_dev; 1020 1055 1021 1056 DEBUG(2, "pcnet_close('%s')\n", dev->name); 1022 1057 ··· 1394 1429 1395 1430 /*====================================================================*/ 1396 1431 1397 - static int setup_dma_config(dev_link_t *link, int start_pg, 1432 + static int setup_dma_config(struct pcmcia_device *link, int start_pg, 1398 1433 int stop_pg) 1399 1434 { 1400 1435 struct net_device *dev = link->priv; ··· 1497 1532 1498 1533 /*====================================================================*/ 1499 1534 1500 - static int setup_shmem_window(dev_link_t *link, int start_pg, 1535 + static int setup_shmem_window(struct pcmcia_device *link, int start_pg, 1501 1536 int stop_pg, int cm_offset) 1502 1537 { 1503 1538 struct net_device *dev = link->priv; ··· 1519 1554 req.Attributes |= WIN_USE_WAIT; 1520 1555 req.Base = 0; req.Size = window_size; 1521 1556 req.AccessSpeed = mem_speed; 1522 - CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &link->win)); 1557 + CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win)); 1523 1558 1524 1559 mem.CardOffset = (start_pg << 8) + cm_offset; 1525 1560 offset = mem.CardOffset % window_size; ··· 1560 1595 return 0; 1561 1596 1562 1597 cs_failed: 1563 - cs_error(link->handle, last_fn, last_ret); 1598 + cs_error(link, last_fn, last_ret); 1564 1599 failed: 1565 1600 return 1; 1566 1601 }
+101 -134
drivers/net/pcmcia/smc91c92_cs.c
··· 49 49 #include <pcmcia/cisreg.h> 50 50 #include <pcmcia/ciscode.h> 51 51 #include <pcmcia/ds.h> 52 + #include <pcmcia/ss.h> 52 53 53 54 #include <asm/io.h> 54 55 #include <asm/system.h> ··· 104 103 #define MEMORY_WAIT_TIME 8 105 104 106 105 struct smc_private { 107 - dev_link_t link; 106 + struct pcmcia_device *p_dev; 108 107 spinlock_t lock; 109 108 u_short manfid; 110 109 u_short cardid; ··· 279 278 /*====================================================================*/ 280 279 281 280 static void smc91c92_detach(struct pcmcia_device *p_dev); 282 - static void smc91c92_config(dev_link_t *link); 283 - static void smc91c92_release(dev_link_t *link); 281 + static int smc91c92_config(struct pcmcia_device *link); 282 + static void smc91c92_release(struct pcmcia_device *link); 284 283 285 284 static int smc_open(struct net_device *dev); 286 285 static int smc_close(struct net_device *dev); ··· 309 308 310 309 ======================================================================*/ 311 310 312 - static int smc91c92_attach(struct pcmcia_device *p_dev) 311 + static int smc91c92_probe(struct pcmcia_device *link) 313 312 { 314 313 struct smc_private *smc; 315 - dev_link_t *link; 316 314 struct net_device *dev; 317 315 318 316 DEBUG(0, "smc91c92_attach()\n"); ··· 321 321 if (!dev) 322 322 return -ENOMEM; 323 323 smc = netdev_priv(dev); 324 - link = &smc->link; 324 + smc->p_dev = link; 325 325 link->priv = dev; 326 326 327 327 spin_lock_init(&smc->lock); ··· 333 333 link->irq.Handler = &smc_interrupt; 334 334 link->irq.Instance = dev; 335 335 link->conf.Attributes = CONF_ENABLE_IRQ; 336 - link->conf.Vcc = 50; 337 336 link->conf.IntType = INT_MEMORY_AND_IO; 338 337 339 338 /* The SMC91c92-specific entries in the device structure. */ ··· 356 357 smc->mii_if.phy_id_mask = 0x1f; 357 358 smc->mii_if.reg_num_mask = 0x1f; 358 359 359 - link->handle = p_dev; 360 - p_dev->instance = link; 361 - 362 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 363 - smc91c92_config(link); 364 - 365 - return 0; 360 + return smc91c92_config(link); 366 361 } /* smc91c92_attach */ 367 362 368 363 /*====================================================================== ··· 368 375 369 376 ======================================================================*/ 370 377 371 - static void smc91c92_detach(struct pcmcia_device *p_dev) 378 + static void smc91c92_detach(struct pcmcia_device *link) 372 379 { 373 - dev_link_t *link = dev_to_instance(p_dev); 374 380 struct net_device *dev = link->priv; 375 381 376 382 DEBUG(0, "smc91c92_detach(0x%p)\n", link); 377 383 378 - if (link->dev) 384 + if (link->dev_node) 379 385 unregister_netdev(dev); 380 386 381 - if (link->state & DEV_CONFIG) 382 - smc91c92_release(link); 387 + smc91c92_release(link); 383 388 384 389 free_netdev(dev); 385 390 } /* smc91c92_detach */ ··· 405 414 406 415 /*====================================================================*/ 407 416 408 - static int first_tuple(client_handle_t handle, tuple_t *tuple, 417 + static int first_tuple(struct pcmcia_device *handle, tuple_t *tuple, 409 418 cisparse_t *parse) 410 419 { 411 420 int i; ··· 416 425 return pcmcia_parse_tuple(handle, tuple, parse); 417 426 } 418 427 419 - static int next_tuple(client_handle_t handle, tuple_t *tuple, 428 + static int next_tuple(struct pcmcia_device *handle, tuple_t *tuple, 420 429 cisparse_t *parse) 421 430 { 422 431 int i; ··· 438 447 439 448 ======================================================================*/ 440 449 441 - static int mhz_3288_power(dev_link_t *link) 450 + static int mhz_3288_power(struct pcmcia_device *link) 442 451 { 443 452 struct net_device *dev = link->priv; 444 453 struct smc_private *smc = netdev_priv(dev); ··· 460 469 return 0; 461 470 } 462 471 463 - static int mhz_mfc_config(dev_link_t *link) 472 + static int mhz_mfc_config(struct pcmcia_device *link) 464 473 { 465 474 struct net_device *dev = link->priv; 466 475 struct smc_private *smc = netdev_priv(dev); ··· 495 504 tuple->TupleDataMax = 255; 496 505 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; 497 506 498 - i = first_tuple(link->handle, tuple, parse); 507 + i = first_tuple(link, tuple, parse); 499 508 /* The Megahertz combo cards have modem-like CIS entries, so 500 509 we have to explicitly try a bunch of port combinations. */ 501 510 while (i == CS_SUCCESS) { ··· 504 513 for (k = 0; k < 0x400; k += 0x10) { 505 514 if (k & 0x80) continue; 506 515 link->io.BasePort1 = k ^ 0x300; 507 - i = pcmcia_request_io(link->handle, &link->io); 516 + i = pcmcia_request_io(link, &link->io); 508 517 if (i == CS_SUCCESS) break; 509 518 } 510 519 if (i == CS_SUCCESS) break; 511 - i = next_tuple(link->handle, tuple, parse); 520 + i = next_tuple(link, tuple, parse); 512 521 } 513 522 if (i != CS_SUCCESS) 514 523 goto free_cfg_mem; ··· 518 527 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 519 528 req.Base = req.Size = 0; 520 529 req.AccessSpeed = 0; 521 - i = pcmcia_request_window(&link->handle, &req, &link->win); 530 + i = pcmcia_request_window(&link, &req, &link->win); 522 531 if (i != CS_SUCCESS) 523 532 goto free_cfg_mem; 524 533 smc->base = ioremap(req.Base, req.Size); ··· 537 546 return i; 538 547 } 539 548 540 - static int mhz_setup(dev_link_t *link) 549 + static int mhz_setup(struct pcmcia_device *link) 541 550 { 542 - client_handle_t handle = link->handle; 543 551 struct net_device *dev = link->priv; 544 552 struct smc_cfg_mem *cfg_mem; 545 553 tuple_t *tuple; ··· 561 571 /* Read the station address from the CIS. It is stored as the last 562 572 (fourth) string in the Version 1 Version/ID tuple. */ 563 573 tuple->DesiredTuple = CISTPL_VERS_1; 564 - if (first_tuple(handle, tuple, parse) != CS_SUCCESS) { 574 + if (first_tuple(link, tuple, parse) != CS_SUCCESS) { 565 575 rc = -1; 566 576 goto free_cfg_mem; 567 577 } 568 578 /* Ugh -- the EM1144 card has two VERS_1 tuples!?! */ 569 - if (next_tuple(handle, tuple, parse) != CS_SUCCESS) 570 - first_tuple(handle, tuple, parse); 579 + if (next_tuple(link, tuple, parse) != CS_SUCCESS) 580 + first_tuple(link, tuple, parse); 571 581 if (parse->version_1.ns > 3) { 572 582 station_addr = parse->version_1.str + parse->version_1.ofs[3]; 573 583 if (cvt_ascii_address(dev, station_addr) == 0) { ··· 578 588 579 589 /* Another possibility: for the EM3288, in a special tuple */ 580 590 tuple->DesiredTuple = 0x81; 581 - if (pcmcia_get_first_tuple(handle, tuple) != CS_SUCCESS) { 591 + if (pcmcia_get_first_tuple(link, tuple) != CS_SUCCESS) { 582 592 rc = -1; 583 593 goto free_cfg_mem; 584 594 } 585 - if (pcmcia_get_tuple_data(handle, tuple) != CS_SUCCESS) { 595 + if (pcmcia_get_tuple_data(link, tuple) != CS_SUCCESS) { 586 596 rc = -1; 587 597 goto free_cfg_mem; 588 598 } ··· 606 616 607 617 ======================================================================*/ 608 618 609 - static void mot_config(dev_link_t *link) 619 + static void mot_config(struct pcmcia_device *link) 610 620 { 611 621 struct net_device *dev = link->priv; 612 622 struct smc_private *smc = netdev_priv(dev); ··· 627 637 mdelay(100); 628 638 } 629 639 630 - static int mot_setup(dev_link_t *link) 640 + static int mot_setup(struct pcmcia_device *link) 631 641 { 632 642 struct net_device *dev = link->priv; 633 643 kio_addr_t ioaddr = dev->base_addr; ··· 661 671 662 672 /*====================================================================*/ 663 673 664 - static int smc_config(dev_link_t *link) 674 + static int smc_config(struct pcmcia_device *link) 665 675 { 666 676 struct net_device *dev = link->priv; 667 677 struct smc_cfg_mem *cfg_mem; ··· 686 696 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; 687 697 688 698 link->io.NumPorts1 = 16; 689 - i = first_tuple(link->handle, tuple, parse); 699 + i = first_tuple(link, tuple, parse); 690 700 while (i != CS_NO_MORE_ITEMS) { 691 701 if (i == CS_SUCCESS) { 692 702 link->conf.ConfigIndex = cf->index; 693 703 link->io.BasePort1 = cf->io.win[0].base; 694 704 link->io.IOAddrLines = cf->io.flags & CISTPL_IO_LINES_MASK; 695 - i = pcmcia_request_io(link->handle, &link->io); 705 + i = pcmcia_request_io(link, &link->io); 696 706 if (i == CS_SUCCESS) break; 697 707 } 698 - i = next_tuple(link->handle, tuple, parse); 708 + i = next_tuple(link, tuple, parse); 699 709 } 700 710 if (i == CS_SUCCESS) 701 711 dev->base_addr = link->io.BasePort1; ··· 704 714 return i; 705 715 } 706 716 707 - static int smc_setup(dev_link_t *link) 717 + static int smc_setup(struct pcmcia_device *link) 708 718 { 709 - client_handle_t handle = link->handle; 710 719 struct net_device *dev = link->priv; 711 720 struct smc_cfg_mem *cfg_mem; 712 721 tuple_t *tuple; ··· 728 739 729 740 /* Check for a LAN function extension tuple */ 730 741 tuple->DesiredTuple = CISTPL_FUNCE; 731 - i = first_tuple(handle, tuple, parse); 742 + i = first_tuple(link, tuple, parse); 732 743 while (i == CS_SUCCESS) { 733 744 if (parse->funce.type == CISTPL_FUNCE_LAN_NODE_ID) 734 745 break; 735 - i = next_tuple(handle, tuple, parse); 746 + i = next_tuple(link, tuple, parse); 736 747 } 737 748 if (i == CS_SUCCESS) { 738 749 node_id = (cistpl_lan_node_id_t *)parse->funce.data; ··· 745 756 } 746 757 /* Try the third string in the Version 1 Version/ID tuple. */ 747 758 tuple->DesiredTuple = CISTPL_VERS_1; 748 - if (first_tuple(handle, tuple, parse) != CS_SUCCESS) { 759 + if (first_tuple(link, tuple, parse) != CS_SUCCESS) { 749 760 rc = -1; 750 761 goto free_cfg_mem; 751 762 } ··· 763 774 764 775 /*====================================================================*/ 765 776 766 - static int osi_config(dev_link_t *link) 777 + static int osi_config(struct pcmcia_device *link) 767 778 { 768 779 struct net_device *dev = link->priv; 769 780 static const kio_addr_t com[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; ··· 783 794 784 795 for (i = j = 0; j < 4; j++) { 785 796 link->io.BasePort2 = com[j]; 786 - i = pcmcia_request_io(link->handle, &link->io); 797 + i = pcmcia_request_io(link, &link->io); 787 798 if (i == CS_SUCCESS) break; 788 799 } 789 800 if (i != CS_SUCCESS) { 790 801 /* Fallback: turn off hard decode */ 791 802 link->conf.ConfigIndex = 0x03; 792 803 link->io.NumPorts2 = 0; 793 - i = pcmcia_request_io(link->handle, &link->io); 804 + i = pcmcia_request_io(link, &link->io); 794 805 } 795 806 dev->base_addr = link->io.BasePort1 + 0x10; 796 807 return i; 797 808 } 798 809 799 - static int osi_setup(dev_link_t *link, u_short manfid, u_short cardid) 810 + static int osi_setup(struct pcmcia_device *link, u_short manfid, u_short cardid) 800 811 { 801 - client_handle_t handle = link->handle; 802 812 struct net_device *dev = link->priv; 803 813 struct smc_cfg_mem *cfg_mem; 804 814 tuple_t *tuple; ··· 818 830 819 831 /* Read the station address from tuple 0x90, subtuple 0x04 */ 820 832 tuple->DesiredTuple = 0x90; 821 - i = pcmcia_get_first_tuple(handle, tuple); 833 + i = pcmcia_get_first_tuple(link, tuple); 822 834 while (i == CS_SUCCESS) { 823 - i = pcmcia_get_tuple_data(handle, tuple); 835 + i = pcmcia_get_tuple_data(link, tuple); 824 836 if ((i != CS_SUCCESS) || (buf[0] == 0x04)) 825 837 break; 826 - i = pcmcia_get_next_tuple(handle, tuple); 838 + i = pcmcia_get_next_tuple(link, tuple); 827 839 } 828 840 if (i != CS_SUCCESS) { 829 841 rc = -1; ··· 856 868 return rc; 857 869 } 858 870 859 - static int smc91c92_suspend(struct pcmcia_device *p_dev) 871 + static int smc91c92_suspend(struct pcmcia_device *link) 860 872 { 861 - dev_link_t *link = dev_to_instance(p_dev); 862 873 struct net_device *dev = link->priv; 863 874 864 - link->state |= DEV_SUSPEND; 865 - if (link->state & DEV_CONFIG) { 866 - if (link->open) 867 - netif_device_detach(dev); 868 - pcmcia_release_configuration(link->handle); 869 - } 875 + if (link->open) 876 + netif_device_detach(dev); 870 877 871 878 return 0; 872 879 } 873 880 874 - static int smc91c92_resume(struct pcmcia_device *p_dev) 881 + static int smc91c92_resume(struct pcmcia_device *link) 875 882 { 876 - dev_link_t *link = dev_to_instance(p_dev); 877 883 struct net_device *dev = link->priv; 878 884 struct smc_private *smc = netdev_priv(dev); 879 885 int i; 880 886 881 - link->state &= ~DEV_SUSPEND; 882 - if (link->state & DEV_CONFIG) { 883 - if ((smc->manfid == MANFID_MEGAHERTZ) && 884 - (smc->cardid == PRODID_MEGAHERTZ_EM3288)) 885 - mhz_3288_power(link); 886 - pcmcia_request_configuration(link->handle, &link->conf); 887 - if (smc->manfid == MANFID_MOTOROLA) 888 - mot_config(link); 889 - if ((smc->manfid == MANFID_OSITECH) && 890 - (smc->cardid != PRODID_OSITECH_SEVEN)) { 891 - /* Power up the card and enable interrupts */ 892 - set_bits(0x0300, dev->base_addr-0x10+OSITECH_AUI_PWR); 893 - set_bits(0x0300, dev->base_addr-0x10+OSITECH_RESET_ISR); 887 + if ((smc->manfid == MANFID_MEGAHERTZ) && 888 + (smc->cardid == PRODID_MEGAHERTZ_EM3288)) 889 + mhz_3288_power(link); 890 + if (smc->manfid == MANFID_MOTOROLA) 891 + mot_config(link); 892 + if ((smc->manfid == MANFID_OSITECH) && 893 + (smc->cardid != PRODID_OSITECH_SEVEN)) { 894 + /* Power up the card and enable interrupts */ 895 + set_bits(0x0300, dev->base_addr-0x10+OSITECH_AUI_PWR); 896 + set_bits(0x0300, dev->base_addr-0x10+OSITECH_RESET_ISR); 897 + } 898 + if (((smc->manfid == MANFID_OSITECH) && 899 + (smc->cardid == PRODID_OSITECH_SEVEN)) || 900 + ((smc->manfid == MANFID_PSION) && 901 + (smc->cardid == PRODID_PSION_NET100))) { 902 + /* Download the Seven of Diamonds firmware */ 903 + for (i = 0; i < sizeof(__Xilinx7OD); i++) { 904 + outb(__Xilinx7OD[i], link->io.BasePort1+2); 905 + udelay(50); 894 906 } 895 - if (((smc->manfid == MANFID_OSITECH) && 896 - (smc->cardid == PRODID_OSITECH_SEVEN)) || 897 - ((smc->manfid == MANFID_PSION) && 898 - (smc->cardid == PRODID_PSION_NET100))) { 899 - /* Download the Seven of Diamonds firmware */ 900 - for (i = 0; i < sizeof(__Xilinx7OD); i++) { 901 - outb(__Xilinx7OD[i], link->io.BasePort1+2); 902 - udelay(50); 903 - } 904 - } 905 - if (link->open) { 906 - smc_reset(dev); 907 - netif_device_attach(dev); 908 - } 907 + } 908 + if (link->open) { 909 + smc_reset(dev); 910 + netif_device_attach(dev); 909 911 } 910 912 911 913 return 0; ··· 909 931 910 932 ======================================================================*/ 911 933 912 - static int check_sig(dev_link_t *link) 934 + static int check_sig(struct pcmcia_device *link) 913 935 { 914 936 struct net_device *dev = link->priv; 915 937 kio_addr_t ioaddr = dev->base_addr; ··· 942 964 } 943 965 944 966 if (width) { 945 - printk(KERN_INFO "smc91c92_cs: using 8-bit IO window.\n"); 946 - smc91c92_suspend(link->handle); 947 - pcmcia_release_io(link->handle, &link->io); 948 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 949 - pcmcia_request_io(link->handle, &link->io); 950 - smc91c92_resume(link->handle); 951 - return check_sig(link); 967 + modconf_t mod = { 968 + .Attributes = CONF_IO_CHANGE_WIDTH, 969 + }; 970 + printk(KERN_INFO "smc91c92_cs: using 8-bit IO window.\n"); 971 + 972 + smc91c92_suspend(link); 973 + pcmcia_modify_configuration(link, &mod); 974 + smc91c92_resume(link); 975 + return check_sig(link); 952 976 } 953 977 return -ENODEV; 954 978 } ··· 964 984 ======================================================================*/ 965 985 966 986 #define CS_EXIT_TEST(ret, svc, label) \ 967 - if (ret != CS_SUCCESS) { cs_error(link->handle, svc, ret); goto label; } 987 + if (ret != CS_SUCCESS) { cs_error(link, svc, ret); goto label; } 968 988 969 - static void smc91c92_config(dev_link_t *link) 989 + static int smc91c92_config(struct pcmcia_device *link) 970 990 { 971 - client_handle_t handle = link->handle; 972 991 struct net_device *dev = link->priv; 973 992 struct smc_private *smc = netdev_priv(dev); 974 993 struct smc_cfg_mem *cfg_mem; ··· 994 1015 tuple->TupleDataMax = 64; 995 1016 996 1017 tuple->DesiredTuple = CISTPL_CONFIG; 997 - i = first_tuple(handle, tuple, parse); 1018 + i = first_tuple(link, tuple, parse); 998 1019 CS_EXIT_TEST(i, ParseTuple, config_failed); 999 1020 link->conf.ConfigBase = parse->config.base; 1000 1021 link->conf.Present = parse->config.rmask[0]; 1001 1022 1002 1023 tuple->DesiredTuple = CISTPL_MANFID; 1003 1024 tuple->Attributes = TUPLE_RETURN_COMMON; 1004 - if (first_tuple(handle, tuple, parse) == CS_SUCCESS) { 1025 + if (first_tuple(link, tuple, parse) == CS_SUCCESS) { 1005 1026 smc->manfid = parse->manfid.manf; 1006 1027 smc->cardid = parse->manfid.card; 1007 1028 } 1008 - 1009 - /* Configure card */ 1010 - link->state |= DEV_CONFIG; 1011 1029 1012 1030 if ((smc->manfid == MANFID_OSITECH) && 1013 1031 (smc->cardid != PRODID_OSITECH_SEVEN)) { ··· 1019 1043 } 1020 1044 CS_EXIT_TEST(i, RequestIO, config_failed); 1021 1045 1022 - i = pcmcia_request_irq(link->handle, &link->irq); 1046 + i = pcmcia_request_irq(link, &link->irq); 1023 1047 CS_EXIT_TEST(i, RequestIRQ, config_failed); 1024 - i = pcmcia_request_configuration(link->handle, &link->conf); 1048 + i = pcmcia_request_configuration(link, &link->conf); 1025 1049 CS_EXIT_TEST(i, RequestConfiguration, config_failed); 1026 1050 1027 1051 if (smc->manfid == MANFID_MOTOROLA) ··· 1100 1124 SMC_SELECT_BANK(0); 1101 1125 } 1102 1126 1103 - link->dev = &smc->node; 1104 - link->state &= ~DEV_CONFIG_PENDING; 1105 - SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 1127 + link->dev_node = &smc->node; 1128 + SET_NETDEV_DEV(dev, &handle_to_dev(link)); 1106 1129 1107 1130 if (register_netdev(dev) != 0) { 1108 1131 printk(KERN_ERR "smc91c92_cs: register_netdev() failed\n"); 1109 - link->dev = NULL; 1132 + link->dev_node = NULL; 1110 1133 goto config_undo; 1111 1134 } 1112 1135 ··· 1135 1160 } 1136 1161 } 1137 1162 kfree(cfg_mem); 1138 - return; 1163 + return 0; 1139 1164 1140 1165 config_undo: 1141 1166 unregister_netdev(dev); 1142 1167 config_failed: /* CS_EXIT_TEST() calls jump to here... */ 1143 1168 smc91c92_release(link); 1144 - link->state &= ~DEV_CONFIG_PENDING; 1145 1169 kfree(cfg_mem); 1146 - 1170 + return -ENODEV; 1147 1171 } /* smc91c92_config */ 1148 1172 1149 1173 /*====================================================================== ··· 1153 1179 1154 1180 ======================================================================*/ 1155 1181 1156 - static void smc91c92_release(dev_link_t *link) 1182 + static void smc91c92_release(struct pcmcia_device *link) 1157 1183 { 1158 - 1159 - DEBUG(0, "smc91c92_release(0x%p)\n", link); 1160 - 1161 - pcmcia_release_configuration(link->handle); 1162 - pcmcia_release_io(link->handle, &link->io); 1163 - pcmcia_release_irq(link->handle, &link->irq); 1164 - if (link->win) { 1165 - struct net_device *dev = link->priv; 1166 - struct smc_private *smc = netdev_priv(dev); 1167 - iounmap(smc->base); 1168 - pcmcia_release_window(link->win); 1169 - } 1170 - 1171 - link->state &= ~DEV_CONFIG; 1184 + DEBUG(0, "smc91c92_release(0x%p)\n", link); 1185 + if (link->win) { 1186 + struct net_device *dev = link->priv; 1187 + struct smc_private *smc = netdev_priv(dev); 1188 + iounmap(smc->base); 1189 + } 1190 + pcmcia_disable_device(link); 1172 1191 } 1173 1192 1174 1193 /*====================================================================== ··· 1250 1283 static int smc_open(struct net_device *dev) 1251 1284 { 1252 1285 struct smc_private *smc = netdev_priv(dev); 1253 - dev_link_t *link = &smc->link; 1286 + struct pcmcia_device *link = smc->p_dev; 1254 1287 1255 1288 #ifdef PCMCIA_DEBUG 1256 1289 DEBUG(0, "%s: smc_open(%p), ID/Window %4.4x.\n", ··· 1259 1292 #endif 1260 1293 1261 1294 /* Check that the PCMCIA card is still here. */ 1262 - if (!DEV_OK(link)) 1295 + if (!pcmcia_dev_present(link)) 1263 1296 return -ENODEV; 1264 1297 /* Physical device present signature. */ 1265 1298 if (check_sig(link) < 0) { ··· 1287 1320 static int smc_close(struct net_device *dev) 1288 1321 { 1289 1322 struct smc_private *smc = netdev_priv(dev); 1290 - dev_link_t *link = &smc->link; 1323 + struct pcmcia_device *link = smc->p_dev; 1291 1324 kio_addr_t ioaddr = dev->base_addr; 1292 1325 1293 1326 DEBUG(0, "%s: smc_close(), status %4.4x.\n", ··· 2278 2311 .drv = { 2279 2312 .name = "smc91c92_cs", 2280 2313 }, 2281 - .probe = smc91c92_attach, 2314 + .probe = smc91c92_probe, 2282 2315 .remove = smc91c92_detach, 2283 2316 .id_table = smc91c92_ids, 2284 2317 .suspend = smc91c92_suspend,
+76 -109
drivers/net/pcmcia/xirc2ps_cs.c
··· 289 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); 293 - static void xirc2ps_config(dev_link_t * link); 294 - static void xirc2ps_release(dev_link_t * link); 292 + static int has_ce2_string(struct pcmcia_device * link); 293 + static int xirc2ps_config(struct pcmcia_device * link); 294 + static void xirc2ps_release(struct pcmcia_device * link); 295 295 296 296 /**************** 297 297 * The attach() and detach() entry points are used to create and destroy ··· 313 313 /**************** 314 314 * A linked list of "instances" of the device. Each actual 315 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 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 320 * device numbers are used to derive the corresponding array index. 321 321 */ 322 322 ··· 326 326 * example, ethernet cards, modems). In other cases, there may be 327 327 * many actual or logical devices (SCSI adapters, memory cards with 328 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 330 * structure. We allocate them in the card's private data structure, 331 331 * because they generally can't be allocated dynamically. 332 332 */ 333 333 334 334 typedef struct local_info_t { 335 - dev_link_t link; 335 + struct pcmcia_device *p_dev; 336 336 dev_node_t node; 337 337 struct net_device_stats stats; 338 338 int card_type; ··· 355 355 static struct net_device_stats *do_get_stats(struct net_device *dev); 356 356 static void set_addresses(struct net_device *dev); 357 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 359 static int do_config(struct net_device *dev, struct ifmap *map); 360 360 static int do_open(struct net_device *dev); 361 361 static int do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); ··· 368 368 369 369 /*=============== Helper functions =========================*/ 370 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 373 int err; 374 374 ··· 379 379 } 380 380 381 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 384 int err; 385 385 ··· 553 553 */ 554 554 555 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 558 struct net_device *dev; 560 559 local_info_t *local; 561 560 ··· 565 566 if (!dev) 566 567 return -ENOMEM; 567 568 local = netdev_priv(dev); 568 - link = &local->link; 569 + local->p_dev = link; 569 570 link->priv = dev; 570 571 571 572 /* General socket configuration */ 572 573 link->conf.Attributes = CONF_ENABLE_IRQ; 573 - link->conf.Vcc = 50; 574 574 link->conf.IntType = INT_MEMORY_AND_IO; 575 575 link->conf.ConfigIndex = 1; 576 576 link->conf.Present = PRESENT_OPTION; ··· 591 593 dev->watchdog_timeo = TX_TIMEOUT; 592 594 #endif 593 595 594 - link->handle = p_dev; 595 - p_dev->instance = link; 596 - 597 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 598 - xirc2ps_config(link); 599 - 600 - return 0; 596 + return xirc2ps_config(link); 601 597 } /* xirc2ps_attach */ 602 598 603 599 /**************** ··· 602 610 */ 603 611 604 612 static void 605 - xirc2ps_detach(struct pcmcia_device *p_dev) 613 + xirc2ps_detach(struct pcmcia_device *link) 606 614 { 607 - dev_link_t *link = dev_to_instance(p_dev); 608 615 struct net_device *dev = link->priv; 609 616 610 617 DEBUG(0, "detach(0x%p)\n", link); 611 618 612 - if (link->dev) 619 + if (link->dev_node) 613 620 unregister_netdev(dev); 614 621 615 - if (link->state & DEV_CONFIG) 616 - xirc2ps_release(link); 622 + xirc2ps_release(link); 617 623 618 624 free_netdev(dev); 619 625 } /* xirc2ps_detach */ ··· 635 645 * 636 646 */ 637 647 static int 638 - set_card_type(dev_link_t *link, const void *s) 648 + set_card_type(struct pcmcia_device *link, const void *s) 639 649 { 640 650 struct net_device *dev = link->priv; 641 651 local_info_t *local = netdev_priv(dev); ··· 704 714 * Returns: true if this is a CE2 705 715 */ 706 716 static int 707 - has_ce2_string(dev_link_t * link) 717 + has_ce2_string(struct pcmcia_device * link) 708 718 { 709 - client_handle_t handle = link->handle; 710 719 tuple_t tuple; 711 720 cisparse_t parse; 712 721 u_char buf[256]; ··· 715 726 tuple.TupleDataMax = 254; 716 727 tuple.TupleOffset = 0; 717 728 tuple.DesiredTuple = CISTPL_VERS_1; 718 - if (!first_tuple(handle, &tuple, &parse) && parse.version_1.ns > 2) { 729 + if (!first_tuple(link, &tuple, &parse) && parse.version_1.ns > 2) { 719 730 if (strstr(parse.version_1.str + parse.version_1.ofs[2], "CE2")) 720 731 return 1; 721 732 } ··· 727 738 * is received, to configure the PCMCIA socket, and to make the 728 739 * ethernet device available to the system. 729 740 */ 730 - static void 731 - xirc2ps_config(dev_link_t * link) 741 + static int 742 + xirc2ps_config(struct pcmcia_device * link) 732 743 { 733 - client_handle_t handle = link->handle; 734 744 struct net_device *dev = link->priv; 735 745 local_info_t *local = netdev_priv(dev); 736 746 tuple_t tuple; ··· 755 767 756 768 /* Is this a valid card */ 757 769 tuple.DesiredTuple = CISTPL_MANFID; 758 - if ((err=first_tuple(handle, &tuple, &parse))) { 770 + if ((err=first_tuple(link, &tuple, &parse))) { 759 771 printk(KNOT_XIRC "manfid not found in CIS\n"); 760 772 goto failure; 761 773 } ··· 791 803 792 804 /* get configuration stuff */ 793 805 tuple.DesiredTuple = CISTPL_CONFIG; 794 - if ((err=first_tuple(handle, &tuple, &parse))) 806 + if ((err=first_tuple(link, &tuple, &parse))) 795 807 goto cis_error; 796 808 link->conf.ConfigBase = parse.config.base; 797 809 link->conf.Present = parse.config.rmask[0]; 798 810 799 811 /* get the ethernet address from the CIS */ 800 812 tuple.DesiredTuple = CISTPL_FUNCE; 801 - for (err = first_tuple(handle, &tuple, &parse); !err; 802 - err = next_tuple(handle, &tuple, &parse)) { 813 + for (err = first_tuple(link, &tuple, &parse); !err; 814 + err = next_tuple(link, &tuple, &parse)) { 803 815 /* Once I saw two CISTPL_FUNCE_LAN_NODE_ID entries: 804 816 * the first one with a length of zero the second correct - 805 817 * so I skip all entries with length 0 */ ··· 809 821 } 810 822 if (err) { /* not found: try to get the node-id from tuple 0x89 */ 811 823 tuple.DesiredTuple = 0x89; /* data layout looks like tuple 0x22 */ 812 - if ((err = pcmcia_get_first_tuple(handle, &tuple)) == 0 && 813 - (err = pcmcia_get_tuple_data(handle, &tuple)) == 0) { 824 + if ((err = pcmcia_get_first_tuple(link, &tuple)) == 0 && 825 + (err = pcmcia_get_tuple_data(link, &tuple)) == 0) { 814 826 if (tuple.TupleDataLen == 8 && *buf == CISTPL_FUNCE_LAN_NODE_ID) 815 827 memcpy(&parse, buf, 8); 816 828 else ··· 819 831 } 820 832 if (err) { /* another try (James Lehmer's CE2 version 4.1)*/ 821 833 tuple.DesiredTuple = CISTPL_FUNCE; 822 - for (err = first_tuple(handle, &tuple, &parse); !err; 823 - err = next_tuple(handle, &tuple, &parse)) { 834 + for (err = first_tuple(link, &tuple, &parse); !err; 835 + err = next_tuple(link, &tuple, &parse)) { 824 836 if (parse.funce.type == 0x02 && parse.funce.data[0] == 1 825 837 && parse.funce.data[1] == 6 && tuple.TupleDataLen == 13) { 826 838 buf[1] = 4; ··· 841 853 for (i=0; i < 6; i++) 842 854 dev->dev_addr[i] = node_id->id[i]; 843 855 844 - /* Configure card */ 845 - link->state |= DEV_CONFIG; 846 - 847 856 link->io.IOAddrLines =10; 848 857 link->io.Attributes1 = IO_DATA_PATH_WIDTH_16; 849 858 link->irq.Attributes = IRQ_HANDLE_PRESENT; ··· 860 875 * Ethernet port */ 861 876 link->io.NumPorts1 = 16; /* no Mako stuff anymore */ 862 877 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 863 - for (err = first_tuple(handle, &tuple, &parse); !err; 864 - err = next_tuple(handle, &tuple, &parse)) { 878 + for (err = first_tuple(link, &tuple, &parse); !err; 879 + err = next_tuple(link, &tuple, &parse)) { 865 880 if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8) { 866 881 for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { 867 882 link->conf.ConfigIndex = cf->index ; 868 883 link->io.BasePort2 = cf->io.win[0].base; 869 884 link->io.BasePort1 = ioaddr; 870 - if (!(err=pcmcia_request_io(link->handle, &link->io))) 885 + if (!(err=pcmcia_request_io(link, &link->io))) 871 886 goto port_found; 872 887 } 873 888 } ··· 881 896 */ 882 897 for (pass=0; pass < 2; pass++) { 883 898 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 884 - for (err = first_tuple(handle, &tuple, &parse); !err; 885 - err = next_tuple(handle, &tuple, &parse)){ 899 + for (err = first_tuple(link, &tuple, &parse); !err; 900 + err = next_tuple(link, &tuple, &parse)){ 886 901 if (cf->io.nwin > 0 && (cf->io.win[0].base & 0xf) == 8){ 887 902 link->conf.ConfigIndex = cf->index ; 888 903 link->io.BasePort2 = cf->io.win[0].base; 889 904 link->io.BasePort1 = link->io.BasePort2 890 905 + (pass ? (cf->index & 0x20 ? -24:8) 891 906 : (cf->index & 0x20 ? 8:-24)); 892 - if (!(err=pcmcia_request_io(link->handle, &link->io))) 907 + if (!(err=pcmcia_request_io(link, &link->io))) 893 908 goto port_found; 894 909 } 895 910 } ··· 904 919 link->io.NumPorts1 = 16; 905 920 for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) { 906 921 link->io.BasePort1 = ioaddr; 907 - if (!(err=pcmcia_request_io(link->handle, &link->io))) 922 + if (!(err=pcmcia_request_io(link, &link->io))) 908 923 goto port_found; 909 924 } 910 925 link->io.BasePort1 = 0; /* let CS decide */ 911 - if ((err=pcmcia_request_io(link->handle, &link->io))) { 912 - cs_error(link->handle, RequestIO, err); 926 + if ((err=pcmcia_request_io(link, &link->io))) { 927 + cs_error(link, RequestIO, err); 913 928 goto config_error; 914 929 } 915 930 } ··· 921 936 * Now allocate an interrupt line. Note that this does not 922 937 * actually assign a handler to the interrupt. 923 938 */ 924 - if ((err=pcmcia_request_irq(link->handle, &link->irq))) { 925 - cs_error(link->handle, RequestIRQ, err); 939 + if ((err=pcmcia_request_irq(link, &link->irq))) { 940 + cs_error(link, RequestIRQ, err); 926 941 goto config_error; 927 942 } 928 943 ··· 930 945 * This actually configures the PCMCIA socket -- setting up 931 946 * the I/O windows and the interrupt mapping. 932 947 */ 933 - if ((err=pcmcia_request_configuration(link->handle, &link->conf))) { 934 - cs_error(link->handle, RequestConfiguration, err); 948 + if ((err=pcmcia_request_configuration(link, &link->conf))) { 949 + cs_error(link, RequestConfiguration, err); 935 950 goto config_error; 936 951 } 937 952 ··· 948 963 reg.Action = CS_WRITE; 949 964 reg.Offset = CISREG_IOBASE_0; 950 965 reg.Value = link->io.BasePort2 & 0xff; 951 - if ((err = pcmcia_access_configuration_register(link->handle, &reg))) { 952 - cs_error(link->handle, AccessConfigurationRegister, err); 966 + if ((err = pcmcia_access_configuration_register(link, &reg))) { 967 + cs_error(link, AccessConfigurationRegister, err); 953 968 goto config_error; 954 969 } 955 970 reg.Action = CS_WRITE; 956 971 reg.Offset = CISREG_IOBASE_1; 957 972 reg.Value = (link->io.BasePort2 >> 8) & 0xff; 958 - if ((err = pcmcia_access_configuration_register(link->handle, &reg))) { 959 - cs_error(link->handle, AccessConfigurationRegister, err); 973 + if ((err = pcmcia_access_configuration_register(link, &reg))) { 974 + cs_error(link, AccessConfigurationRegister, err); 960 975 goto config_error; 961 976 } 962 977 ··· 967 982 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 968 983 req.Base = req.Size = 0; 969 984 req.AccessSpeed = 0; 970 - if ((err = pcmcia_request_window(&link->handle, &req, &link->win))) { 971 - cs_error(link->handle, RequestWindow, err); 985 + if ((err = pcmcia_request_window(&link, &req, &link->win))) { 986 + cs_error(link, RequestWindow, err); 972 987 goto config_error; 973 988 } 974 989 local->dingo_ccr = ioremap(req.Base,0x1000) + 0x0800; 975 990 mem.CardOffset = 0x0; 976 991 mem.Page = 0; 977 992 if ((err = pcmcia_map_mem_page(link->win, &mem))) { 978 - cs_error(link->handle, MapMemPage, err); 993 + cs_error(link, MapMemPage, err); 979 994 goto config_error; 980 995 } 981 996 ··· 1035 1050 if (local->dingo) 1036 1051 do_reset(dev, 1); /* a kludge to make the cem56 work */ 1037 1052 1038 - link->dev = &local->node; 1039 - link->state &= ~DEV_CONFIG_PENDING; 1040 - SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 1053 + link->dev_node = &local->node; 1054 + SET_NETDEV_DEV(dev, &handle_to_dev(link)); 1041 1055 1042 1056 if ((err=register_netdev(dev))) { 1043 1057 printk(KNOT_XIRC "register_netdev() failed\n"); 1044 - link->dev = NULL; 1058 + link->dev_node = NULL; 1045 1059 goto config_error; 1046 1060 } 1047 1061 ··· 1053 1069 printk("%c%02X", i?':':' ', dev->dev_addr[i]); 1054 1070 printk("\n"); 1055 1071 1056 - return; 1072 + return 0; 1057 1073 1058 1074 config_error: 1059 - link->state &= ~DEV_CONFIG_PENDING; 1060 1075 xirc2ps_release(link); 1061 - return; 1076 + return -ENODEV; 1062 1077 1063 1078 cis_error: 1064 1079 printk(KNOT_XIRC "unable to parse CIS\n"); 1065 1080 failure: 1066 - link->state &= ~DEV_CONFIG_PENDING; 1081 + return -ENODEV; 1067 1082 } /* xirc2ps_config */ 1068 1083 1069 1084 /**************** ··· 1071 1088 * still open, this will be postponed until it is closed. 1072 1089 */ 1073 1090 static void 1074 - xirc2ps_release(dev_link_t *link) 1091 + xirc2ps_release(struct pcmcia_device *link) 1075 1092 { 1093 + DEBUG(0, "release(0x%p)\n", link); 1076 1094 1077 - DEBUG(0, "release(0x%p)\n", link); 1078 - 1079 - if (link->win) { 1080 - struct net_device *dev = link->priv; 1081 - local_info_t *local = netdev_priv(dev); 1082 - if (local->dingo) 1083 - iounmap(local->dingo_ccr - 0x0800); 1084 - pcmcia_release_window(link->win); 1085 - } 1086 - pcmcia_release_configuration(link->handle); 1087 - pcmcia_release_io(link->handle, &link->io); 1088 - pcmcia_release_irq(link->handle, &link->irq); 1089 - link->state &= ~DEV_CONFIG; 1090 - 1095 + if (link->win) { 1096 + struct net_device *dev = link->priv; 1097 + local_info_t *local = netdev_priv(dev); 1098 + if (local->dingo) 1099 + iounmap(local->dingo_ccr - 0x0800); 1100 + } 1101 + pcmcia_disable_device(link); 1091 1102 } /* xirc2ps_release */ 1092 1103 1093 1104 /*====================================================================*/ 1094 1105 1095 1106 1096 - static int xirc2ps_suspend(struct pcmcia_device *p_dev) 1107 + static int xirc2ps_suspend(struct pcmcia_device *link) 1097 1108 { 1098 - dev_link_t *link = dev_to_instance(p_dev); 1099 1109 struct net_device *dev = link->priv; 1100 1110 1101 - link->state |= DEV_SUSPEND; 1102 - if (link->state & DEV_CONFIG) { 1103 - if (link->open) { 1104 - netif_device_detach(dev); 1105 - do_powerdown(dev); 1106 - } 1107 - pcmcia_release_configuration(link->handle); 1111 + if (link->open) { 1112 + netif_device_detach(dev); 1113 + do_powerdown(dev); 1108 1114 } 1109 1115 1110 1116 return 0; 1111 1117 } 1112 1118 1113 - static int xirc2ps_resume(struct pcmcia_device *p_dev) 1119 + static int xirc2ps_resume(struct pcmcia_device *link) 1114 1120 { 1115 - dev_link_t *link = dev_to_instance(p_dev); 1116 1121 struct net_device *dev = link->priv; 1117 1122 1118 - link->state &= ~DEV_SUSPEND; 1119 - if (link->state & DEV_CONFIG) { 1120 - pcmcia_request_configuration(link->handle, &link->conf); 1121 - if (link->open) { 1122 - do_reset(dev,1); 1123 - netif_device_attach(dev); 1124 - } 1123 + if (link->open) { 1124 + do_reset(dev,1); 1125 + netif_device_attach(dev); 1125 1126 } 1126 1127 1127 1128 return 0; ··· 1519 1552 do_open(struct net_device *dev) 1520 1553 { 1521 1554 local_info_t *lp = netdev_priv(dev); 1522 - dev_link_t *link = &lp->link; 1555 + struct pcmcia_device *link = lp->p_dev; 1523 1556 1524 1557 DEBUG(0, "do_open(%p)\n", dev); 1525 1558 1526 1559 /* Check that the PCMCIA card is still here. */ 1527 1560 /* Physical device present signature. */ 1528 - if (!DEV_OK(link)) 1561 + if (!pcmcia_dev_present(link)) 1529 1562 return -ENODEV; 1530 1563 1531 1564 /* okay */ ··· 1849 1882 { 1850 1883 kio_addr_t ioaddr = dev->base_addr; 1851 1884 local_info_t *lp = netdev_priv(dev); 1852 - dev_link_t *link = &lp->link; 1885 + struct pcmcia_device *link = lp->p_dev; 1853 1886 1854 1887 DEBUG(0, "do_stop(%p)\n", dev); 1855 1888 ··· 1902 1935 .drv = { 1903 1936 .name = "xirc2ps_cs", 1904 1937 }, 1905 - .probe = xirc2ps_attach, 1938 + .probe = xirc2ps_probe, 1906 1939 .remove = xirc2ps_detach, 1907 1940 .id_table = xirc2ps_ids, 1908 1941 .suspend = xirc2ps_suspend,
+50 -108
drivers/net/wireless/airo_cs.c
··· 80 80 event handler. 81 81 */ 82 82 83 - static void airo_config(dev_link_t *link); 84 - static void airo_release(dev_link_t *link); 83 + static int airo_config(struct pcmcia_device *link); 84 + static void airo_release(struct pcmcia_device *link); 85 85 86 86 /* 87 87 The attach() and detach() entry points are used to create and destroy ··· 101 101 /* 102 102 A linked list of "instances" of the aironet device. Each actual 103 103 PCMCIA card corresponds to one device instance, and is described 104 - by one dev_link_t structure (defined in ds.h). 104 + by one struct pcmcia_device structure (defined in ds.h). 105 105 106 106 You may not want to use a linked list for this -- for example, the 107 - memory card driver uses an array of dev_link_t pointers, where minor 107 + memory card driver uses an array of struct pcmcia_device pointers, where minor 108 108 device numbers are used to derive the corresponding array index. 109 109 */ 110 110 ··· 114 114 example, ethernet cards, modems). In other cases, there may be 115 115 many actual or logical devices (SCSI adapters, memory cards with 116 116 multiple partitions). The dev_node_t structures need to be kept 117 - in a linked list starting at the 'dev' field of a dev_link_t 117 + in a linked list starting at the 'dev' field of a struct pcmcia_device 118 118 structure. We allocate them in the card's private data structure, 119 119 because they generally shouldn't be allocated dynamically. 120 120 ··· 141 141 142 142 ======================================================================*/ 143 143 144 - static int airo_attach(struct pcmcia_device *p_dev) 144 + static int airo_probe(struct pcmcia_device *p_dev) 145 145 { 146 - dev_link_t *link; 147 146 local_info_t *local; 148 147 149 148 DEBUG(0, "airo_attach()\n"); 150 149 151 - /* Initialize the dev_link_t structure */ 152 - link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); 153 - if (!link) { 154 - printk(KERN_ERR "airo_cs: no memory for new device\n"); 155 - return -ENOMEM; 156 - } 157 - 158 150 /* Interrupt setup */ 159 - link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 160 - link->irq.IRQInfo1 = IRQ_LEVEL_ID; 161 - link->irq.Handler = NULL; 151 + p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 152 + p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; 153 + p_dev->irq.Handler = NULL; 162 154 163 155 /* 164 156 General socket configuration defaults can go here. In this ··· 159 167 and attributes of IO windows) are fixed by the nature of the 160 168 device, and can be hard-wired here. 161 169 */ 162 - link->conf.Attributes = 0; 163 - link->conf.Vcc = 50; 164 - link->conf.IntType = INT_MEMORY_AND_IO; 170 + p_dev->conf.Attributes = 0; 171 + p_dev->conf.IntType = INT_MEMORY_AND_IO; 165 172 166 173 /* Allocate space for private device-specific data */ 167 174 local = kzalloc(sizeof(local_info_t), GFP_KERNEL); 168 175 if (!local) { 169 176 printk(KERN_ERR "airo_cs: no memory for new device\n"); 170 - kfree (link); 171 177 return -ENOMEM; 172 178 } 173 - link->priv = local; 179 + p_dev->priv = local; 174 180 175 - link->handle = p_dev; 176 - p_dev->instance = link; 177 - 178 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 179 - airo_config(link); 180 - 181 - return 0; 181 + return airo_config(p_dev); 182 182 } /* airo_attach */ 183 183 184 184 /*====================================================================== ··· 182 198 183 199 ======================================================================*/ 184 200 185 - static void airo_detach(struct pcmcia_device *p_dev) 201 + static void airo_detach(struct pcmcia_device *link) 186 202 { 187 - dev_link_t *link = dev_to_instance(p_dev); 188 - 189 203 DEBUG(0, "airo_detach(0x%p)\n", link); 190 204 191 - if (link->state & DEV_CONFIG) 192 - airo_release(link); 205 + airo_release(link); 193 206 194 207 if ( ((local_info_t*)link->priv)->eth_dev ) { 195 208 stop_airo_card( ((local_info_t*)link->priv)->eth_dev, 0 ); ··· 194 213 ((local_info_t*)link->priv)->eth_dev = NULL; 195 214 196 215 kfree(link->priv); 197 - kfree(link); 198 216 } /* airo_detach */ 199 217 200 218 /*====================================================================== ··· 207 227 #define CS_CHECK(fn, ret) \ 208 228 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 209 229 210 - static void airo_config(dev_link_t *link) 230 + static int airo_config(struct pcmcia_device *link) 211 231 { 212 - client_handle_t handle; 213 232 tuple_t tuple; 214 233 cisparse_t parse; 215 234 local_info_t *dev; ··· 216 237 u_char buf[64]; 217 238 win_req_t req; 218 239 memreq_t map; 219 - 220 - handle = link->handle; 240 + 221 241 dev = link->priv; 222 242 223 243 DEBUG(0, "airo_config(0x%p)\n", link); ··· 230 252 tuple.TupleData = buf; 231 253 tuple.TupleDataMax = sizeof(buf); 232 254 tuple.TupleOffset = 0; 233 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 234 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 235 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 255 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 256 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 257 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 236 258 link->conf.ConfigBase = parse.config.base; 237 259 link->conf.Present = parse.config.rmask[0]; 238 - 239 - /* Configure card */ 240 - link->state |= DEV_CONFIG; 241 - 260 + 242 261 /* 243 262 In this loop, we scan the CIS for configuration table entries, 244 263 each of which describes a valid card configuration, including ··· 249 274 will only use the CIS to fill in implementation-defined details. 250 275 */ 251 276 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 252 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 277 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 253 278 while (1) { 254 279 cistpl_cftable_entry_t dflt = { 0 }; 255 280 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 256 - if (pcmcia_get_tuple_data(handle, &tuple) != 0 || 257 - pcmcia_parse_tuple(handle, &tuple, &parse) != 0) 281 + if (pcmcia_get_tuple_data(link, &tuple) != 0 || 282 + pcmcia_parse_tuple(link, &tuple, &parse) != 0) 258 283 goto next_entry; 259 284 260 285 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; ··· 269 294 270 295 /* Use power settings for Vcc and Vpp if present */ 271 296 /* Note that the CIS values need to be rescaled */ 272 - if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) 273 - link->conf.Vcc = cfg->vcc.param[CISTPL_POWER_VNOM]/10000; 274 - else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) 275 - link->conf.Vcc = dflt.vcc.param[CISTPL_POWER_VNOM]/10000; 276 - 277 297 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) 278 - link->conf.Vpp1 = link->conf.Vpp2 = 298 + link->conf.Vpp = 279 299 cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; 280 300 else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) 281 - link->conf.Vpp1 = link->conf.Vpp2 = 301 + link->conf.Vpp = 282 302 dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; 283 303 284 304 /* Do we need to allocate an interrupt? */ ··· 299 329 } 300 330 301 331 /* This reserves IO space but doesn't actually enable it */ 302 - if (pcmcia_request_io(link->handle, &link->io) != 0) 332 + if (pcmcia_request_io(link, &link->io) != 0) 303 333 goto next_entry; 304 334 305 335 /* 306 336 Now set up a common memory window, if needed. There is room 307 - in the dev_link_t structure for one memory window handle, 337 + in the struct pcmcia_device structure for one memory window handle, 308 338 but if the base addresses need to be saved, or if multiple 309 339 windows are needed, the info should go in the private data 310 340 structure for this device. ··· 320 350 req.Base = mem->win[0].host_addr; 321 351 req.Size = mem->win[0].len; 322 352 req.AccessSpeed = 0; 323 - if (pcmcia_request_window(&link->handle, &req, &link->win) != 0) 353 + if (pcmcia_request_window(&link, &req, &link->win) != 0) 324 354 goto next_entry; 325 355 map.Page = 0; map.CardOffset = mem->win[0].card_addr; 326 356 if (pcmcia_map_mem_page(link->win, &map) != 0) ··· 330 360 break; 331 361 332 362 next_entry: 333 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); 363 + CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 334 364 } 335 365 336 366 /* ··· 339 369 irq structure is initialized. 340 370 */ 341 371 if (link->conf.Attributes & CONF_ENABLE_IRQ) 342 - CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 372 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 343 373 344 374 /* 345 375 This actually configures the PCMCIA socket -- setting up 346 376 the I/O windows and the interrupt mapping, and putting the 347 377 card and host interface into "Memory and IO" mode. 348 378 */ 349 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 379 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 350 380 ((local_info_t*)link->priv)->eth_dev = 351 381 init_airo_card( link->irq.AssignedIRQ, 352 - link->io.BasePort1, 1, &handle_to_dev(handle) ); 382 + link->io.BasePort1, 1, &handle_to_dev(link) ); 353 383 if (!((local_info_t*)link->priv)->eth_dev) goto cs_failed; 354 384 355 385 /* 356 386 At this point, the dev_node_t structure(s) need to be 357 - initialized and arranged in a linked list at link->dev. 387 + initialized and arranged in a linked list at link->dev_node. 358 388 */ 359 389 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name ); 360 390 dev->node.major = dev->node.minor = 0; 361 - link->dev = &dev->node; 391 + link->dev_node = &dev->node; 362 392 363 393 /* Finally, report what we've done */ 364 - printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d", 365 - dev->node.dev_name, link->conf.ConfigIndex, 366 - link->conf.Vcc/10, link->conf.Vcc%10); 367 - if (link->conf.Vpp1) 368 - printk(", Vpp %d.%d", link->conf.Vpp1/10, link->conf.Vpp1%10); 394 + printk(KERN_INFO "%s: index 0x%02x: ", 395 + dev->node.dev_name, link->conf.ConfigIndex); 396 + if (link->conf.Vpp) 397 + printk(", Vpp %d.%d", link->conf.Vpp/10, link->conf.Vpp%10); 369 398 if (link->conf.Attributes & CONF_ENABLE_IRQ) 370 399 printk(", irq %d", link->irq.AssignedIRQ); 371 400 if (link->io.NumPorts1) ··· 377 408 printk(", mem 0x%06lx-0x%06lx", req.Base, 378 409 req.Base+req.Size-1); 379 410 printk("\n"); 380 - 381 - link->state &= ~DEV_CONFIG_PENDING; 382 - return; 383 - 411 + return 0; 412 + 384 413 cs_failed: 385 - cs_error(link->handle, last_fn, last_ret); 414 + cs_error(link, last_fn, last_ret); 386 415 airo_release(link); 387 - 416 + return -ENODEV; 388 417 } /* airo_config */ 389 418 390 419 /*====================================================================== ··· 393 426 394 427 ======================================================================*/ 395 428 396 - static void airo_release(dev_link_t *link) 429 + static void airo_release(struct pcmcia_device *link) 397 430 { 398 431 DEBUG(0, "airo_release(0x%p)\n", link); 399 - 400 - /* Unlink the device chain */ 401 - link->dev = NULL; 402 - 403 - /* 404 - In a normal driver, additional code may be needed to release 405 - other kernel data structures associated with this device. 406 - */ 407 - 408 - /* Don't bother checking to see if these succeed or not */ 409 - if (link->win) 410 - pcmcia_release_window(link->win); 411 - pcmcia_release_configuration(link->handle); 412 - if (link->io.NumPorts1) 413 - pcmcia_release_io(link->handle, &link->io); 414 - if (link->irq.AssignedIRQ) 415 - pcmcia_release_irq(link->handle, &link->irq); 416 - link->state &= ~DEV_CONFIG; 432 + pcmcia_disable_device(link); 417 433 } 418 434 419 - static int airo_suspend(struct pcmcia_device *p_dev) 435 + static int airo_suspend(struct pcmcia_device *link) 420 436 { 421 - dev_link_t *link = dev_to_instance(p_dev); 422 437 local_info_t *local = link->priv; 423 438 424 - link->state |= DEV_SUSPEND; 425 - if (link->state & DEV_CONFIG) { 426 - netif_device_detach(local->eth_dev); 427 - pcmcia_release_configuration(link->handle); 428 - } 439 + netif_device_detach(local->eth_dev); 429 440 430 441 return 0; 431 442 } 432 443 433 - static int airo_resume(struct pcmcia_device *p_dev) 444 + static int airo_resume(struct pcmcia_device *link) 434 445 { 435 - dev_link_t *link = dev_to_instance(p_dev); 436 446 local_info_t *local = link->priv; 437 447 438 - link->state &= ~DEV_SUSPEND; 439 - if (link->state & DEV_CONFIG) { 440 - pcmcia_request_configuration(link->handle, &link->conf); 448 + if (link->open) { 441 449 reset_airo_card(local->eth_dev); 442 450 netif_device_attach(local->eth_dev); 443 451 } ··· 434 492 .drv = { 435 493 .name = "airo_cs", 436 494 }, 437 - .probe = airo_attach, 495 + .probe = airo_probe, 438 496 .remove = airo_detach, 439 497 .id_table = airo_ids, 440 498 .suspend = airo_suspend,
+56 -106
drivers/net/wireless/atmel_cs.c
··· 91 91 event handler. 92 92 */ 93 93 94 - static void atmel_config(dev_link_t *link); 95 - static void atmel_release(dev_link_t *link); 94 + static int atmel_config(struct pcmcia_device *link); 95 + static void atmel_release(struct pcmcia_device *link); 96 96 97 97 /* 98 98 The attach() and detach() entry points are used to create and destroy ··· 112 112 /* 113 113 A linked list of "instances" of the atmelnet device. Each actual 114 114 PCMCIA card corresponds to one device instance, and is described 115 - by one dev_link_t structure (defined in ds.h). 115 + by one struct pcmcia_device structure (defined in ds.h). 116 116 117 117 You may not want to use a linked list for this -- for example, the 118 - memory card driver uses an array of dev_link_t pointers, where minor 118 + memory card driver uses an array of struct pcmcia_device pointers, where minor 119 119 device numbers are used to derive the corresponding array index. 120 120 */ 121 121 ··· 125 125 example, ethernet cards, modems). In other cases, there may be 126 126 many actual or logical devices (SCSI adapters, memory cards with 127 127 multiple partitions). The dev_node_t structures need to be kept 128 - in a linked list starting at the 'dev' field of a dev_link_t 128 + in a linked list starting at the 'dev' field of a struct pcmcia_device 129 129 structure. We allocate them in the card's private data structure, 130 130 because they generally shouldn't be allocated dynamically. 131 131 ··· 152 152 153 153 ======================================================================*/ 154 154 155 - static int atmel_attach(struct pcmcia_device *p_dev) 155 + static int atmel_probe(struct pcmcia_device *p_dev) 156 156 { 157 - dev_link_t *link; 158 157 local_info_t *local; 159 158 160 159 DEBUG(0, "atmel_attach()\n"); 161 160 162 - /* Initialize the dev_link_t structure */ 163 - link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); 164 - if (!link) { 165 - printk(KERN_ERR "atmel_cs: no memory for new device\n"); 166 - return -ENOMEM; 167 - } 168 - 169 161 /* Interrupt setup */ 170 - link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 171 - link->irq.IRQInfo1 = IRQ_LEVEL_ID; 172 - link->irq.Handler = NULL; 162 + p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 163 + p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; 164 + p_dev->irq.Handler = NULL; 173 165 174 166 /* 175 167 General socket configuration defaults can go here. In this ··· 170 178 and attributes of IO windows) are fixed by the nature of the 171 179 device, and can be hard-wired here. 172 180 */ 173 - link->conf.Attributes = 0; 174 - link->conf.Vcc = 50; 175 - link->conf.IntType = INT_MEMORY_AND_IO; 181 + p_dev->conf.Attributes = 0; 182 + p_dev->conf.IntType = INT_MEMORY_AND_IO; 176 183 177 184 /* Allocate space for private device-specific data */ 178 185 local = kzalloc(sizeof(local_info_t), GFP_KERNEL); 179 186 if (!local) { 180 187 printk(KERN_ERR "atmel_cs: no memory for new device\n"); 181 - kfree (link); 182 188 return -ENOMEM; 183 189 } 184 - link->priv = local; 190 + p_dev->priv = local; 185 191 186 - link->handle = p_dev; 187 - p_dev->instance = link; 188 - 189 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 190 - atmel_config(link); 191 - 192 - return 0; 192 + return atmel_config(p_dev); 193 193 } /* atmel_attach */ 194 194 195 195 /*====================================================================== ··· 193 209 194 210 ======================================================================*/ 195 211 196 - static void atmel_detach(struct pcmcia_device *p_dev) 212 + static void atmel_detach(struct pcmcia_device *link) 197 213 { 198 - dev_link_t *link = dev_to_instance(p_dev); 199 - 200 214 DEBUG(0, "atmel_detach(0x%p)\n", link); 201 215 202 - if (link->state & DEV_CONFIG) 203 - atmel_release(link); 216 + atmel_release(link); 204 217 205 218 kfree(link->priv); 206 - kfree(link); 207 219 } 208 220 209 221 /*====================================================================== ··· 216 236 /* Call-back function to interrogate PCMCIA-specific information 217 237 about the current existance of the card */ 218 238 static int card_present(void *arg) 219 - { 220 - dev_link_t *link = (dev_link_t *)arg; 221 - if (link->state & DEV_SUSPEND) 222 - return 0; 223 - else if (link->state & DEV_PRESENT) 239 + { 240 + struct pcmcia_device *link = (struct pcmcia_device *)arg; 241 + 242 + if (pcmcia_dev_present(link)) 224 243 return 1; 225 - 244 + 226 245 return 0; 227 246 } 228 247 229 - static void atmel_config(dev_link_t *link) 248 + static int atmel_config(struct pcmcia_device *link) 230 249 { 231 - client_handle_t handle; 232 250 tuple_t tuple; 233 251 cisparse_t parse; 234 252 local_info_t *dev; ··· 234 256 u_char buf[64]; 235 257 struct pcmcia_device_id *did; 236 258 237 - handle = link->handle; 238 259 dev = link->priv; 239 - did = handle_to_dev(handle).driver_data; 260 + did = handle_to_dev(link).driver_data; 240 261 241 262 DEBUG(0, "atmel_config(0x%p)\n", link); 242 263 ··· 249 272 registers. 250 273 */ 251 274 tuple.DesiredTuple = CISTPL_CONFIG; 252 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 253 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 254 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 275 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 276 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 277 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 255 278 link->conf.ConfigBase = parse.config.base; 256 279 link->conf.Present = parse.config.rmask[0]; 257 - 258 - /* Configure card */ 259 - link->state |= DEV_CONFIG; 260 - 280 + 261 281 /* 262 282 In this loop, we scan the CIS for configuration table entries, 263 283 each of which describes a valid card configuration, including ··· 268 294 will only use the CIS to fill in implementation-defined details. 269 295 */ 270 296 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 271 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 297 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 272 298 while (1) { 273 299 cistpl_cftable_entry_t dflt = { 0 }; 274 300 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 275 - if (pcmcia_get_tuple_data(handle, &tuple) != 0 || 276 - pcmcia_parse_tuple(handle, &tuple, &parse) != 0) 301 + if (pcmcia_get_tuple_data(link, &tuple) != 0 || 302 + pcmcia_parse_tuple(link, &tuple, &parse) != 0) 277 303 goto next_entry; 278 304 279 305 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; ··· 288 314 289 315 /* Use power settings for Vcc and Vpp if present */ 290 316 /* Note that the CIS values need to be rescaled */ 291 - if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) 292 - link->conf.Vcc = cfg->vcc.param[CISTPL_POWER_VNOM]/10000; 293 - else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) 294 - link->conf.Vcc = dflt.vcc.param[CISTPL_POWER_VNOM]/10000; 295 - 296 317 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) 297 - link->conf.Vpp1 = link->conf.Vpp2 = 318 + link->conf.Vpp = 298 319 cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; 299 320 else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) 300 - link->conf.Vpp1 = link->conf.Vpp2 = 321 + link->conf.Vpp = 301 322 dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; 302 323 303 324 /* Do we need to allocate an interrupt? */ ··· 318 349 } 319 350 320 351 /* This reserves IO space but doesn't actually enable it */ 321 - if (pcmcia_request_io(link->handle, &link->io) != 0) 352 + if (pcmcia_request_io(link, &link->io) != 0) 322 353 goto next_entry; 323 354 324 355 /* If we got this far, we're cool! */ 325 356 break; 326 357 327 358 next_entry: 328 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); 359 + CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 329 360 } 330 361 331 362 /* ··· 334 365 irq structure is initialized. 335 366 */ 336 367 if (link->conf.Attributes & CONF_ENABLE_IRQ) 337 - CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 368 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 338 369 339 370 /* 340 371 This actually configures the PCMCIA socket -- setting up 341 372 the I/O windows and the interrupt mapping, and putting the 342 373 card and host interface into "Memory and IO" mode. 343 374 */ 344 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 375 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 345 376 346 377 if (link->irq.AssignedIRQ == 0) { 347 378 printk(KERN_ALERT ··· 353 384 init_atmel_card(link->irq.AssignedIRQ, 354 385 link->io.BasePort1, 355 386 did ? did->driver_info : ATMEL_FW_TYPE_NONE, 356 - &handle_to_dev(handle), 387 + &handle_to_dev(link), 357 388 card_present, 358 389 link); 359 390 if (!((local_info_t*)link->priv)->eth_dev) ··· 362 393 363 394 /* 364 395 At this point, the dev_node_t structure(s) need to be 365 - initialized and arranged in a linked list at link->dev. 396 + initialized and arranged in a linked list at link->dev_node. 366 397 */ 367 398 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name ); 368 399 dev->node.major = dev->node.minor = 0; 369 - link->dev = &dev->node; 370 - 371 - link->state &= ~DEV_CONFIG_PENDING; 372 - return; 373 - 400 + link->dev_node = &dev->node; 401 + 402 + return 0; 403 + 374 404 cs_failed: 375 - cs_error(link->handle, last_fn, last_ret); 405 + cs_error(link, last_fn, last_ret); 376 406 atmel_release(link); 407 + return -ENODEV; 377 408 } 378 409 379 410 /*====================================================================== ··· 384 415 385 416 ======================================================================*/ 386 417 387 - static void atmel_release(dev_link_t *link) 418 + static void atmel_release(struct pcmcia_device *link) 388 419 { 389 420 struct net_device *dev = ((local_info_t*)link->priv)->eth_dev; 390 - 421 + 391 422 DEBUG(0, "atmel_release(0x%p)\n", link); 392 - 393 - /* Unlink the device chain */ 394 - link->dev = NULL; 395 - 396 - if (dev) 423 + 424 + if (dev) 397 425 stop_atmel_card(dev); 398 - ((local_info_t*)link->priv)->eth_dev = NULL; 399 - 400 - /* Don't bother checking to see if these succeed or not */ 401 - pcmcia_release_configuration(link->handle); 402 - if (link->io.NumPorts1) 403 - pcmcia_release_io(link->handle, &link->io); 404 - if (link->irq.AssignedIRQ) 405 - pcmcia_release_irq(link->handle, &link->irq); 406 - link->state &= ~DEV_CONFIG; 426 + ((local_info_t*)link->priv)->eth_dev = NULL; 427 + 428 + pcmcia_disable_device(link); 407 429 } 408 430 409 - static int atmel_suspend(struct pcmcia_device *dev) 431 + static int atmel_suspend(struct pcmcia_device *link) 410 432 { 411 - dev_link_t *link = dev_to_instance(dev); 412 433 local_info_t *local = link->priv; 413 434 414 - link->state |= DEV_SUSPEND; 415 - if (link->state & DEV_CONFIG) { 416 - netif_device_detach(local->eth_dev); 417 - pcmcia_release_configuration(link->handle); 418 - } 435 + netif_device_detach(local->eth_dev); 419 436 420 437 return 0; 421 438 } 422 439 423 - static int atmel_resume(struct pcmcia_device *dev) 440 + static int atmel_resume(struct pcmcia_device *link) 424 441 { 425 - dev_link_t *link = dev_to_instance(dev); 426 442 local_info_t *local = link->priv; 427 443 428 - link->state &= ~DEV_SUSPEND; 429 - if (link->state & DEV_CONFIG) { 430 - pcmcia_request_configuration(link->handle, &link->conf); 431 - atmel_open(local->eth_dev); 432 - netif_device_attach(local->eth_dev); 433 - } 444 + atmel_open(local->eth_dev); 445 + netif_device_attach(local->eth_dev); 434 446 435 447 return 0; 436 448 } ··· 465 515 .drv = { 466 516 .name = "atmel_cs", 467 517 }, 468 - .probe = atmel_attach, 518 + .probe = atmel_probe, 469 519 .remove = atmel_detach, 470 520 .id_table = atmel_ids, 471 521 .suspend = atmel_suspend,
+79 -119
drivers/net/wireless/hostap/hostap_cs.c
··· 42 42 /* struct local_info::hw_priv */ 43 43 struct hostap_cs_priv { 44 44 dev_node_t node; 45 - dev_link_t *link; 45 + struct pcmcia_device *link; 46 46 int sandisk_connectplus; 47 47 }; 48 48 ··· 204 204 205 205 static void prism2_detach(struct pcmcia_device *p_dev); 206 206 static void prism2_release(u_long arg); 207 - static int prism2_config(dev_link_t *link); 207 + static int prism2_config(struct pcmcia_device *link); 208 208 209 209 210 210 static int prism2_pccard_card_present(local_info_t *local) 211 211 { 212 212 struct hostap_cs_priv *hw_priv = local->hw_priv; 213 - if (hw_priv != NULL && hw_priv->link != NULL && 214 - ((hw_priv->link->state & (DEV_PRESENT | DEV_CONFIG)) == 215 - (DEV_PRESENT | DEV_CONFIG))) 213 + if (hw_priv != NULL && hw_priv->link != NULL && pcmcia_dev_present(hw_priv->link)) 216 214 return 1; 217 215 return 0; 218 216 } ··· 235 237 reg.Action = CS_WRITE; 236 238 reg.Offset = 0x10; /* 0x3f0 IO base 1 */ 237 239 reg.Value = hw_priv->link->io.BasePort1 & 0x00ff; 238 - res = pcmcia_access_configuration_register(hw_priv->link->handle, 240 + res = pcmcia_access_configuration_register(hw_priv->link, 239 241 &reg); 240 242 if (res != CS_SUCCESS) { 241 243 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -" ··· 247 249 reg.Action = CS_WRITE; 248 250 reg.Offset = 0x12; /* 0x3f2 IO base 2 */ 249 251 reg.Value = (hw_priv->link->io.BasePort1 & 0xff00) >> 8; 250 - res = pcmcia_access_configuration_register(hw_priv->link->handle, 252 + res = pcmcia_access_configuration_register(hw_priv->link, 251 253 &reg); 252 254 if (res != CS_SUCCESS) { 253 255 printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -" ··· 299 301 tuple.TupleData = buf; 300 302 tuple.TupleDataMax = sizeof(buf); 301 303 tuple.TupleOffset = 0; 302 - if (pcmcia_get_first_tuple(hw_priv->link->handle, &tuple) || 303 - pcmcia_get_tuple_data(hw_priv->link->handle, &tuple) || 304 - pcmcia_parse_tuple(hw_priv->link->handle, &tuple, parse) || 304 + if (pcmcia_get_first_tuple(hw_priv->link, &tuple) || 305 + pcmcia_get_tuple_data(hw_priv->link, &tuple) || 306 + pcmcia_parse_tuple(hw_priv->link, &tuple, parse) || 305 307 parse->manfid.manf != 0xd601 || parse->manfid.card != 0x0101) { 306 308 /* No SanDisk manfid found */ 307 309 ret = -ENODEV; ··· 309 311 } 310 312 311 313 tuple.DesiredTuple = CISTPL_LONGLINK_MFC; 312 - if (pcmcia_get_first_tuple(hw_priv->link->handle, &tuple) || 313 - pcmcia_get_tuple_data(hw_priv->link->handle, &tuple) || 314 - pcmcia_parse_tuple(hw_priv->link->handle, &tuple, parse) || 314 + if (pcmcia_get_first_tuple(hw_priv->link, &tuple) || 315 + pcmcia_get_tuple_data(hw_priv->link, &tuple) || 316 + pcmcia_parse_tuple(hw_priv->link, &tuple, parse) || 315 317 parse->longlink_mfc.nfn < 2) { 316 318 /* No multi-function links found */ 317 319 ret = -ENODEV; ··· 326 328 reg.Action = CS_WRITE; 327 329 reg.Offset = CISREG_COR; 328 330 reg.Value = COR_SOFT_RESET; 329 - res = pcmcia_access_configuration_register(hw_priv->link->handle, 331 + res = pcmcia_access_configuration_register(hw_priv->link, 330 332 &reg); 331 333 if (res != CS_SUCCESS) { 332 334 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", ··· 343 345 * will be enabled during the first cor_sreset call. 344 346 */ 345 347 reg.Value = COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE | COR_FUNC_ENA; 346 - res = pcmcia_access_configuration_register(hw_priv->link->handle, 348 + res = pcmcia_access_configuration_register(hw_priv->link, 347 349 &reg); 348 350 if (res != CS_SUCCESS) { 349 351 printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n", ··· 378 380 reg.Action = CS_READ; 379 381 reg.Offset = CISREG_COR; 380 382 reg.Value = 0; 381 - res = pcmcia_access_configuration_register(hw_priv->link->handle, 383 + res = pcmcia_access_configuration_register(hw_priv->link, 382 384 &reg); 383 385 if (res != CS_SUCCESS) { 384 386 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n", ··· 390 392 391 393 reg.Action = CS_WRITE; 392 394 reg.Value |= COR_SOFT_RESET; 393 - res = pcmcia_access_configuration_register(hw_priv->link->handle, 395 + res = pcmcia_access_configuration_register(hw_priv->link, 394 396 &reg); 395 397 if (res != CS_SUCCESS) { 396 398 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n", ··· 403 405 reg.Value &= ~COR_SOFT_RESET; 404 406 if (hw_priv->sandisk_connectplus) 405 407 reg.Value |= COR_IREQ_ENA; 406 - res = pcmcia_access_configuration_register(hw_priv->link->handle, 408 + res = pcmcia_access_configuration_register(hw_priv->link, 407 409 &reg); 408 410 if (res != CS_SUCCESS) { 409 411 printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n", ··· 437 439 reg.Action = CS_READ; 438 440 reg.Offset = CISREG_COR; 439 441 reg.Value = 0; 440 - res = pcmcia_access_configuration_register(hw_priv->link->handle, 442 + res = pcmcia_access_configuration_register(hw_priv->link, 441 443 &reg); 442 444 if (res != CS_SUCCESS) { 443 445 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 " ··· 450 452 451 453 reg.Action = CS_WRITE; 452 454 reg.Value |= COR_SOFT_RESET; 453 - res = pcmcia_access_configuration_register(hw_priv->link->handle, 455 + res = pcmcia_access_configuration_register(hw_priv->link, 454 456 &reg); 455 457 if (res != CS_SUCCESS) { 456 458 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 " ··· 464 466 reg.Action = CS_WRITE; 465 467 reg.Value = hcr; 466 468 reg.Offset = CISREG_CCSR; 467 - res = pcmcia_access_configuration_register(hw_priv->link->handle, 469 + res = pcmcia_access_configuration_register(hw_priv->link, 468 470 &reg); 469 471 if (res != CS_SUCCESS) { 470 472 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 " ··· 476 478 reg.Action = CS_WRITE; 477 479 reg.Offset = CISREG_COR; 478 480 reg.Value = old_cor & ~COR_SOFT_RESET; 479 - res = pcmcia_access_configuration_register(hw_priv->link->handle, 481 + res = pcmcia_access_configuration_register(hw_priv->link, 480 482 &reg); 481 483 if (res != CS_SUCCESS) { 482 484 printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 " ··· 499 501 500 502 /* allocate local data and register with CardServices 501 503 * initialize dev_link structure, but do not configure the card yet */ 502 - static int prism2_attach(struct pcmcia_device *p_dev) 504 + static int hostap_cs_probe(struct pcmcia_device *p_dev) 503 505 { 504 - dev_link_t *link; 505 - 506 - link = kmalloc(sizeof(dev_link_t), GFP_KERNEL); 507 - if (link == NULL) 508 - return -ENOMEM; 509 - 510 - memset(link, 0, sizeof(dev_link_t)); 506 + int ret; 511 507 512 508 PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info); 513 - link->conf.Vcc = 33; 514 - link->conf.IntType = INT_MEMORY_AND_IO; 509 + p_dev->conf.IntType = INT_MEMORY_AND_IO; 515 510 516 - link->handle = p_dev; 517 - p_dev->instance = link; 518 - 519 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 520 - if (prism2_config(link)) 511 + ret = prism2_config(p_dev); 512 + if (ret) { 521 513 PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n"); 514 + } 522 515 523 - return 0; 516 + return ret; 524 517 } 525 518 526 519 527 - static void prism2_detach(struct pcmcia_device *p_dev) 520 + static void prism2_detach(struct pcmcia_device *link) 528 521 { 529 - dev_link_t *link = dev_to_instance(p_dev); 530 - 531 522 PDEBUG(DEBUG_FLOW, "prism2_detach\n"); 532 523 533 - if (link->state & DEV_CONFIG) { 534 - prism2_release((u_long)link); 535 - } 524 + prism2_release((u_long)link); 536 525 537 526 /* release net devices */ 538 527 if (link->priv) { ··· 532 547 prism2_free_local_data(dev); 533 548 kfree(hw_priv); 534 549 } 535 - kfree(link); 536 550 } 537 551 538 552 ··· 542 558 do { int ret = (retf); \ 543 559 if (ret != 0) { \ 544 560 PDEBUG(DEBUG_EXTRA, "CardServices(" #fn ") returned %d\n", ret); \ 545 - cs_error(link->handle, fn, ret); \ 561 + cs_error(link, fn, ret); \ 546 562 goto next_entry; \ 547 563 } \ 548 564 } while (0) ··· 550 566 551 567 /* run after a CARD_INSERTION event is received to configure the PCMCIA 552 568 * socket and make the device available to the system */ 553 - static int prism2_config(dev_link_t *link) 569 + static int prism2_config(struct pcmcia_device *link) 554 570 { 555 571 struct net_device *dev; 556 572 struct hostap_interface *iface; ··· 579 595 tuple.TupleData = buf; 580 596 tuple.TupleDataMax = sizeof(buf); 581 597 tuple.TupleOffset = 0; 582 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link->handle, &tuple)); 583 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link->handle, &tuple)); 584 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(link->handle, &tuple, parse)); 598 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 599 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 600 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, parse)); 585 601 link->conf.ConfigBase = parse->config.base; 586 602 link->conf.Present = parse->config.rmask[0]; 587 603 588 604 CS_CHECK(GetConfigurationInfo, 589 - pcmcia_get_configuration_info(link->handle, &conf)); 590 - PDEBUG(DEBUG_HW, "%s: %s Vcc=%d (from config)\n", dev_info, 591 - ignore_cis_vcc ? "ignoring" : "setting", conf.Vcc); 592 - link->conf.Vcc = conf.Vcc; 605 + pcmcia_get_configuration_info(link, &conf)); 593 606 594 607 /* Look for an appropriate configuration table entry in the CIS */ 595 608 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 596 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link->handle, &tuple)); 609 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 597 610 for (;;) { 598 611 cistpl_cftable_entry_t *cfg = &(parse->cftable_entry); 599 612 CFG_CHECK2(GetTupleData, 600 - pcmcia_get_tuple_data(link->handle, &tuple)); 613 + pcmcia_get_tuple_data(link, &tuple)); 601 614 CFG_CHECK2(ParseTuple, 602 - pcmcia_parse_tuple(link->handle, &tuple, parse)); 615 + pcmcia_parse_tuple(link, &tuple, parse)); 603 616 604 617 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) 605 618 dflt = *cfg; ··· 631 650 } 632 651 633 652 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 634 - link->conf.Vpp1 = link->conf.Vpp2 = 653 + link->conf.Vpp = 635 654 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 636 655 else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) 637 - link->conf.Vpp1 = link->conf.Vpp2 = 656 + link->conf.Vpp = 638 657 dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; 639 658 640 659 /* Do we need to allocate an interrupt? */ ··· 676 695 677 696 /* This reserves IO space but doesn't actually enable it */ 678 697 CFG_CHECK2(RequestIO, 679 - pcmcia_request_io(link->handle, &link->io)); 698 + pcmcia_request_io(link, &link->io)); 680 699 681 700 /* This configuration table entry is OK */ 682 701 break; 683 702 684 703 next_entry: 685 704 CS_CHECK(GetNextTuple, 686 - pcmcia_get_next_tuple(link->handle, &tuple)); 705 + pcmcia_get_next_tuple(link, &tuple)); 687 706 } 688 707 689 708 /* Need to allocate net_device before requesting IRQ handler */ 690 709 dev = prism2_init_local_data(&prism2_pccard_funcs, 0, 691 - &handle_to_dev(link->handle)); 710 + &handle_to_dev(link)); 692 711 if (dev == NULL) 693 712 goto failed; 694 713 link->priv = dev; ··· 698 717 local->hw_priv = hw_priv; 699 718 hw_priv->link = link; 700 719 strcpy(hw_priv->node.dev_name, dev->name); 701 - link->dev = &hw_priv->node; 720 + link->dev_node = &hw_priv->node; 702 721 703 722 /* 704 723 * Allocate an interrupt line. Note that this does not assign a ··· 711 730 link->irq.Handler = prism2_interrupt; 712 731 link->irq.Instance = dev; 713 732 CS_CHECK(RequestIRQ, 714 - pcmcia_request_irq(link->handle, &link->irq)); 733 + pcmcia_request_irq(link, &link->irq)); 715 734 } 716 735 717 736 /* ··· 720 739 * card and host interface into "Memory and IO" mode. 721 740 */ 722 741 CS_CHECK(RequestConfiguration, 723 - pcmcia_request_configuration(link->handle, &link->conf)); 742 + pcmcia_request_configuration(link, &link->conf)); 724 743 725 744 dev->irq = link->irq.AssignedIRQ; 726 745 dev->base_addr = link->io.BasePort1; 727 746 728 747 /* Finally, report what we've done */ 729 - printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d", 730 - dev_info, link->conf.ConfigIndex, 731 - link->conf.Vcc / 10, link->conf.Vcc % 10); 732 - if (link->conf.Vpp1) 733 - printk(", Vpp %d.%d", link->conf.Vpp1 / 10, 734 - link->conf.Vpp1 % 10); 748 + printk(KERN_INFO "%s: index 0x%02x: ", 749 + dev_info, link->conf.ConfigIndex); 750 + if (link->conf.Vpp) 751 + printk(", Vpp %d.%d", link->conf.Vpp / 10, 752 + link->conf.Vpp % 10); 735 753 if (link->conf.Attributes & CONF_ENABLE_IRQ) 736 754 printk(", irq %d", link->irq.AssignedIRQ); 737 755 if (link->io.NumPorts1) ··· 740 760 printk(" & 0x%04x-0x%04x", link->io.BasePort2, 741 761 link->io.BasePort2+link->io.NumPorts2-1); 742 762 printk("\n"); 743 - 744 - link->state |= DEV_CONFIG; 745 - link->state &= ~DEV_CONFIG_PENDING; 746 763 747 764 local->shutdown = 0; 748 765 ··· 755 778 return ret; 756 779 757 780 cs_failed: 758 - cs_error(link->handle, last_fn, last_ret); 781 + cs_error(link, last_fn, last_ret); 759 782 760 783 failed: 761 784 kfree(parse); ··· 767 790 768 791 static void prism2_release(u_long arg) 769 792 { 770 - dev_link_t *link = (dev_link_t *)arg; 793 + struct pcmcia_device *link = (struct pcmcia_device *)arg; 771 794 772 795 PDEBUG(DEBUG_FLOW, "prism2_release\n"); 773 796 ··· 776 799 struct hostap_interface *iface; 777 800 778 801 iface = netdev_priv(dev); 779 - if (link->state & DEV_CONFIG) 780 - prism2_hw_shutdown(dev, 0); 802 + prism2_hw_shutdown(dev, 0); 781 803 iface->local->shutdown = 1; 782 804 } 783 805 784 - if (link->win) 785 - pcmcia_release_window(link->win); 786 - pcmcia_release_configuration(link->handle); 787 - if (link->io.NumPorts1) 788 - pcmcia_release_io(link->handle, &link->io); 789 - if (link->irq.AssignedIRQ) 790 - pcmcia_release_irq(link->handle, &link->irq); 791 - 792 - link->state &= ~DEV_CONFIG; 793 - 806 + pcmcia_disable_device(link); 794 807 PDEBUG(DEBUG_FLOW, "release - done\n"); 795 808 } 796 809 797 - static int hostap_cs_suspend(struct pcmcia_device *p_dev) 810 + static int hostap_cs_suspend(struct pcmcia_device *link) 798 811 { 799 - dev_link_t *link = dev_to_instance(p_dev); 800 812 struct net_device *dev = (struct net_device *) link->priv; 801 813 int dev_open = 0; 814 + struct hostap_interface *iface = NULL; 815 + 816 + if (dev) 817 + iface = netdev_priv(dev); 802 818 803 819 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info); 804 - 805 - link->state |= DEV_SUSPEND; 806 - 807 - if (link->state & DEV_CONFIG) { 808 - struct hostap_interface *iface = netdev_priv(dev); 809 - if (iface && iface->local) 810 - dev_open = iface->local->num_dev_open > 0; 811 - if (dev_open) { 812 - netif_stop_queue(dev); 813 - netif_device_detach(dev); 814 - } 815 - prism2_suspend(dev); 816 - pcmcia_release_configuration(link->handle); 820 + if (iface && iface->local) 821 + dev_open = iface->local->num_dev_open > 0; 822 + if (dev_open) { 823 + netif_stop_queue(dev); 824 + netif_device_detach(dev); 817 825 } 826 + prism2_suspend(dev); 818 827 819 828 return 0; 820 829 } 821 830 822 - static int hostap_cs_resume(struct pcmcia_device *p_dev) 831 + static int hostap_cs_resume(struct pcmcia_device *link) 823 832 { 824 - dev_link_t *link = dev_to_instance(p_dev); 825 833 struct net_device *dev = (struct net_device *) link->priv; 826 834 int dev_open = 0; 835 + struct hostap_interface *iface = NULL; 836 + 837 + if (dev) 838 + iface = netdev_priv(dev); 827 839 828 840 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info); 829 841 830 - link->state &= ~DEV_SUSPEND; 831 - if (link->state & DEV_CONFIG) { 832 - struct hostap_interface *iface = netdev_priv(dev); 833 - if (iface && iface->local) 834 - dev_open = iface->local->num_dev_open > 0; 842 + if (iface && iface->local) 843 + dev_open = iface->local->num_dev_open > 0; 835 844 836 - pcmcia_request_configuration(link->handle, &link->conf); 837 - 838 - prism2_hw_shutdown(dev, 1); 839 - prism2_hw_config(dev, dev_open ? 0 : 1); 840 - if (dev_open) { 841 - netif_device_attach(dev); 842 - netif_start_queue(dev); 843 - } 845 + prism2_hw_shutdown(dev, 1); 846 + prism2_hw_config(dev, dev_open ? 0 : 1); 847 + if (dev_open) { 848 + netif_device_attach(dev); 849 + netif_start_queue(dev); 844 850 } 845 851 846 852 return 0; ··· 890 930 .drv = { 891 931 .name = "hostap_cs", 892 932 }, 893 - .probe = prism2_attach, 933 + .probe = hostap_cs_probe, 894 934 .remove = prism2_detach, 895 935 .owner = THIS_MODULE, 896 936 .id_table = hostap_cs_ids,
+48 -79
drivers/net/wireless/netwave_cs.c
··· 190 190 /*====================================================================*/ 191 191 192 192 /* PCMCIA (Card Services) related functions */ 193 - static void netwave_release(dev_link_t *link); /* Card removal */ 194 - static void netwave_pcmcia_config(dev_link_t *arg); /* Runs after card 193 + static void netwave_release(struct pcmcia_device *link); /* Card removal */ 194 + static int netwave_pcmcia_config(struct pcmcia_device *arg); /* Runs after card 195 195 insertion */ 196 196 static void netwave_detach(struct pcmcia_device *p_dev); /* Destroy instance */ 197 197 ··· 221 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 225 to keep track of a socket, but there will usually be some device 226 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 228 a device-specific private data structure, like this. 229 229 230 230 A driver needs to provide a dev_node_t structure for each device ··· 232 232 example, ethernet cards, modems). In other cases, there may be 233 233 many actual or logical devices (SCSI adapters, memory cards with 234 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 236 structure. We allocate them in the card's private data structure, 237 237 because they generally can't be allocated dynamically. 238 238 */ ··· 268 268 }; 269 269 270 270 typedef struct netwave_private { 271 - dev_link_t link; 271 + struct pcmcia_device *p_dev; 272 272 spinlock_t spinlock; /* Serialize access to the hardware (SMP) */ 273 273 dev_node_t node; 274 274 u_char __iomem *ramBase; ··· 376 376 * configure the card at this point -- we wait until we receive a 377 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 381 struct net_device *dev; 383 382 netwave_private *priv; 384 383 385 384 DEBUG(0, "netwave_attach()\n"); 386 385 387 - /* Initialize the dev_link_t structure */ 386 + /* Initialize the struct pcmcia_device structure */ 388 387 dev = alloc_etherdev(sizeof(netwave_private)); 389 388 if (!dev) 390 389 return -ENOMEM; 391 390 priv = netdev_priv(dev); 392 - link = &priv->link; 391 + priv->p_dev = link; 393 392 link->priv = dev; 394 393 395 394 /* The io structure describes IO port mapping */ ··· 405 406 406 407 /* General socket configuration */ 407 408 link->conf.Attributes = CONF_ENABLE_IRQ; 408 - link->conf.Vcc = 50; 409 409 link->conf.IntType = INT_MEMORY_AND_IO; 410 410 link->conf.ConfigIndex = 1; 411 411 link->conf.Present = PRESENT_OPTION; ··· 428 430 dev->stop = &netwave_close; 429 431 link->irq.Instance = dev; 430 432 431 - link->handle = p_dev; 432 - p_dev->instance = link; 433 - 434 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 435 - netwave_pcmcia_config( link); 436 - 437 - return 0; 433 + return netwave_pcmcia_config( link); 438 434 } /* netwave_attach */ 439 435 440 436 /* ··· 439 447 * structures are freed. Otherwise, the structures will be freed 440 448 * when the device is released. 441 449 */ 442 - static void netwave_detach(struct pcmcia_device *p_dev) 450 + static void netwave_detach(struct pcmcia_device *link) 443 451 { 444 - dev_link_t *link = dev_to_instance(p_dev); 445 452 struct net_device *dev = link->priv; 446 453 447 454 DEBUG(0, "netwave_detach(0x%p)\n", link); 448 455 449 - if (link->state & DEV_CONFIG) 450 - netwave_release(link); 456 + netwave_release(link); 451 457 452 - if (link->dev) 458 + if (link->dev_node) 453 459 unregister_netdev(dev); 454 460 455 461 free_netdev(dev); ··· 733 743 #define CS_CHECK(fn, ret) \ 734 744 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 735 745 736 - static void netwave_pcmcia_config(dev_link_t *link) { 737 - client_handle_t handle = link->handle; 746 + static int netwave_pcmcia_config(struct pcmcia_device *link) { 738 747 struct net_device *dev = link->priv; 739 748 netwave_private *priv = netdev_priv(dev); 740 749 tuple_t tuple; ··· 755 766 tuple.TupleDataMax = 64; 756 767 tuple.TupleOffset = 0; 757 768 tuple.DesiredTuple = CISTPL_CONFIG; 758 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 759 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 760 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 769 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 770 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 771 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 761 772 link->conf.ConfigBase = parse.config.base; 762 773 link->conf.Present = parse.config.rmask[0]; 763 - 764 - /* Configure card */ 765 - link->state |= DEV_CONFIG; 766 774 767 775 /* 768 776 * Try allocating IO ports. This tries a few fixed addresses. ··· 768 782 */ 769 783 for (i = j = 0x0; j < 0x400; j += 0x20) { 770 784 link->io.BasePort1 = j ^ 0x300; 771 - i = pcmcia_request_io(link->handle, &link->io); 785 + i = pcmcia_request_io(link, &link->io); 772 786 if (i == CS_SUCCESS) break; 773 787 } 774 788 if (i != CS_SUCCESS) { 775 - cs_error(link->handle, RequestIO, i); 789 + cs_error(link, RequestIO, i); 776 790 goto failed; 777 791 } 778 792 ··· 780 794 * Now allocate an interrupt line. Note that this does not 781 795 * actually assign a handler to the interrupt. 782 796 */ 783 - CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq)); 797 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 784 798 785 799 /* 786 800 * This actually configures the PCMCIA socket -- setting up 787 801 * the I/O windows and the interrupt mapping. 788 802 */ 789 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); 803 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 790 804 791 805 /* 792 - * Allocate a 32K memory window. Note that the dev_link_t 806 + * Allocate a 32K memory window. Note that the struct pcmcia_device 793 807 * structure provides space for one window handle -- if your 794 808 * device needs several windows, you'll need to keep track of 795 809 * the handles in your private data structure, dev->priv. ··· 799 813 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_CM|WIN_ENABLE; 800 814 req.Base = 0; req.Size = 0x8000; 801 815 req.AccessSpeed = mem_speed; 802 - CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &link->win)); 816 + CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win)); 803 817 mem.CardOffset = 0x20000; mem.Page = 0; 804 818 CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem)); 805 819 ··· 809 823 810 824 dev->irq = link->irq.AssignedIRQ; 811 825 dev->base_addr = link->io.BasePort1; 812 - SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 826 + SET_NETDEV_DEV(dev, &handle_to_dev(link)); 813 827 814 828 if (register_netdev(dev) != 0) { 815 829 printk(KERN_DEBUG "netwave_cs: register_netdev() failed\n"); ··· 817 831 } 818 832 819 833 strcpy(priv->node.dev_name, dev->name); 820 - link->dev = &priv->node; 821 - link->state &= ~DEV_CONFIG_PENDING; 834 + link->dev_node = &priv->node; 822 835 823 836 /* Reset card before reading physical address */ 824 837 netwave_doreset(dev->base_addr, ramBase); ··· 837 852 printk(KERN_DEBUG "Netwave_reset: revision %04x %04x\n", 838 853 get_uint16(ramBase + NETWAVE_EREG_ARW), 839 854 get_uint16(ramBase + NETWAVE_EREG_ARW+2)); 840 - return; 855 + return 0; 841 856 842 857 cs_failed: 843 - cs_error(link->handle, last_fn, last_ret); 858 + cs_error(link, last_fn, last_ret); 844 859 failed: 845 860 netwave_release(link); 861 + return -ENODEV; 846 862 } /* netwave_pcmcia_config */ 847 863 848 864 /* ··· 853 867 * device, and release the PCMCIA configuration. If the device is 854 868 * still open, this will be postponed until it is closed. 855 869 */ 856 - static void netwave_release(dev_link_t *link) 870 + static void netwave_release(struct pcmcia_device *link) 857 871 { 858 - struct net_device *dev = link->priv; 859 - netwave_private *priv = netdev_priv(dev); 872 + struct net_device *dev = link->priv; 873 + netwave_private *priv = netdev_priv(dev); 860 874 861 - DEBUG(0, "netwave_release(0x%p)\n", link); 875 + DEBUG(0, "netwave_release(0x%p)\n", link); 862 876 863 - /* Don't bother checking to see if these succeed or not */ 864 - if (link->win) { 865 - iounmap(priv->ramBase); 866 - pcmcia_release_window(link->win); 867 - } 868 - pcmcia_release_configuration(link->handle); 869 - pcmcia_release_io(link->handle, &link->io); 870 - pcmcia_release_irq(link->handle, &link->irq); 871 - 872 - link->state &= ~DEV_CONFIG; 877 + pcmcia_disable_device(link); 878 + if (link->win) 879 + iounmap(priv->ramBase); 873 880 } 874 881 875 - static int netwave_suspend(struct pcmcia_device *p_dev) 882 + static int netwave_suspend(struct pcmcia_device *link) 876 883 { 877 - dev_link_t *link = dev_to_instance(p_dev); 878 884 struct net_device *dev = link->priv; 879 885 880 - link->state |= DEV_SUSPEND; 881 - if (link->state & DEV_CONFIG) { 882 - if (link->open) 883 - netif_device_detach(dev); 884 - pcmcia_release_configuration(link->handle); 885 - } 886 + if (link->open) 887 + netif_device_detach(dev); 886 888 887 889 return 0; 888 890 } 889 891 890 - static int netwave_resume(struct pcmcia_device *p_dev) 892 + static int netwave_resume(struct pcmcia_device *link) 891 893 { 892 - dev_link_t *link = dev_to_instance(p_dev); 893 894 struct net_device *dev = link->priv; 894 895 895 - link->state &= ~DEV_SUSPEND; 896 - if (link->state & DEV_CONFIG) { 897 - pcmcia_request_configuration(link->handle, &link->conf); 898 - if (link->open) { 899 - netwave_reset(dev); 900 - netif_device_attach(dev); 901 - } 896 + if (link->open) { 897 + netwave_reset(dev); 898 + netif_device_attach(dev); 902 899 } 903 900 904 901 return 0; ··· 1088 1119 u_char __iomem *ramBase; 1089 1120 struct net_device *dev = (struct net_device *)dev_id; 1090 1121 struct netwave_private *priv = netdev_priv(dev); 1091 - dev_link_t *link = &priv->link; 1122 + struct pcmcia_device *link = priv->p_dev; 1092 1123 int i; 1093 1124 1094 1125 if (!netif_device_present(dev)) ··· 1107 1138 1108 1139 status = inb(iobase + NETWAVE_REG_ASR); 1109 1140 1110 - if (!DEV_OK(link)) { 1141 + if (!pcmcia_dev_present(link)) { 1111 1142 DEBUG(1, "netwave_interrupt: Interrupt with status 0x%x " 1112 1143 "from removed or suspended card!\n", status); 1113 1144 break; ··· 1342 1373 1343 1374 static int netwave_open(struct net_device *dev) { 1344 1375 netwave_private *priv = netdev_priv(dev); 1345 - dev_link_t *link = &priv->link; 1376 + struct pcmcia_device *link = priv->p_dev; 1346 1377 1347 1378 DEBUG(1, "netwave_open: starting.\n"); 1348 1379 1349 - if (!DEV_OK(link)) 1380 + if (!pcmcia_dev_present(link)) 1350 1381 return -ENODEV; 1351 1382 1352 1383 link->open++; ··· 1359 1390 1360 1391 static int netwave_close(struct net_device *dev) { 1361 1392 netwave_private *priv = netdev_priv(dev); 1362 - dev_link_t *link = &priv->link; 1393 + struct pcmcia_device *link = priv->p_dev; 1363 1394 1364 1395 DEBUG(1, "netwave_close: finishing.\n"); 1365 1396 ··· 1380 1411 .drv = { 1381 1412 .name = "netwave_cs", 1382 1413 }, 1383 - .probe = netwave_attach, 1414 + .probe = netwave_probe, 1384 1415 .remove = netwave_detach, 1385 1416 .id_table = netwave_ids, 1386 1417 .suspend = netwave_suspend,
+77 -116
drivers/net/wireless/orinoco_cs.c
··· 49 49 /* PCMCIA specific device information (goes in the card field of 50 50 * struct orinoco_private */ 51 51 struct orinoco_pccard { 52 - dev_link_t link; 52 + struct pcmcia_device *p_dev; 53 53 dev_node_t node; 54 54 55 55 /* Used to handle hard reset */ ··· 63 63 /* Function prototypes */ 64 64 /********************************************************************/ 65 65 66 - static void orinoco_cs_config(dev_link_t *link); 67 - static void orinoco_cs_release(dev_link_t *link); 66 + static int orinoco_cs_config(struct pcmcia_device *link); 67 + static void orinoco_cs_release(struct pcmcia_device *link); 68 68 static void orinoco_cs_detach(struct pcmcia_device *p_dev); 69 69 70 70 /********************************************************************/ ··· 75 75 orinoco_cs_hard_reset(struct orinoco_private *priv) 76 76 { 77 77 struct orinoco_pccard *card = priv->card; 78 - dev_link_t *link = &card->link; 78 + struct pcmcia_device *link = card->p_dev; 79 79 int err; 80 80 81 81 /* We need atomic ops here, because we're not holding the lock */ 82 82 set_bit(0, &card->hard_reset_in_progress); 83 83 84 - err = pcmcia_reset_card(link->handle, NULL); 84 + err = pcmcia_reset_card(link, NULL); 85 85 if (err) 86 86 return err; 87 87 ··· 104 104 * configure the card at this point -- we wait until we receive a card 105 105 * insertion event. */ 106 106 static int 107 - orinoco_cs_attach(struct pcmcia_device *p_dev) 107 + orinoco_cs_probe(struct pcmcia_device *link) 108 108 { 109 109 struct net_device *dev; 110 110 struct orinoco_private *priv; 111 111 struct orinoco_pccard *card; 112 - dev_link_t *link; 113 112 114 113 dev = alloc_orinocodev(sizeof(*card), orinoco_cs_hard_reset); 115 114 if (! dev) ··· 117 118 card = priv->card; 118 119 119 120 /* Link both structures together */ 120 - link = &card->link; 121 + card->p_dev = link; 121 122 link->priv = dev; 122 123 123 124 /* Interrupt setup */ ··· 134 135 link->conf.Attributes = 0; 135 136 link->conf.IntType = INT_MEMORY_AND_IO; 136 137 137 - /* Register with Card Services */ 138 - link->next = NULL; 139 - 140 - link->handle = p_dev; 141 - p_dev->instance = link; 142 - 143 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 144 - orinoco_cs_config(link); 145 - 146 - return 0; 138 + return orinoco_cs_config(link); 147 139 } /* orinoco_cs_attach */ 148 140 149 141 /* ··· 143 153 * are freed. Otherwise, the structures will be freed when the device 144 154 * is released. 145 155 */ 146 - static void orinoco_cs_detach(struct pcmcia_device *p_dev) 156 + static void orinoco_cs_detach(struct pcmcia_device *link) 147 157 { 148 - dev_link_t *link = dev_to_instance(p_dev); 149 158 struct net_device *dev = link->priv; 150 159 151 - if (link->state & DEV_CONFIG) 152 - orinoco_cs_release(link); 160 + orinoco_cs_release(link); 153 161 154 - DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); 155 - if (link->dev) { 162 + DEBUG(0, PFX "detach: link=%p link->dev_node=%p\n", link, link->dev_node); 163 + if (link->dev_node) { 156 164 DEBUG(0, PFX "About to unregister net device %p\n", 157 165 dev); 158 166 unregister_netdev(dev); ··· 168 180 last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; \ 169 181 } while (0) 170 182 171 - static void 172 - orinoco_cs_config(dev_link_t *link) 183 + static int 184 + orinoco_cs_config(struct pcmcia_device *link) 173 185 { 174 186 struct net_device *dev = link->priv; 175 - client_handle_t handle = link->handle; 176 187 struct orinoco_private *priv = netdev_priv(dev); 177 188 struct orinoco_pccard *card = priv->card; 178 189 hermes_t *hw = &priv->hw; ··· 183 196 cisparse_t parse; 184 197 void __iomem *mem; 185 198 186 - CS_CHECK(ValidateCIS, pcmcia_validate_cis(handle, &info)); 199 + CS_CHECK(ValidateCIS, pcmcia_validate_cis(link, &info)); 187 200 188 201 /* 189 202 * This reads the card's CONFIG tuple to find its ··· 194 207 tuple.TupleData = buf; 195 208 tuple.TupleDataMax = sizeof(buf); 196 209 tuple.TupleOffset = 0; 197 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 198 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 199 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 210 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 211 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 212 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 200 213 link->conf.ConfigBase = parse.config.base; 201 214 link->conf.Present = parse.config.rmask[0]; 202 215 203 - /* Configure card */ 204 - link->state |= DEV_CONFIG; 205 - 206 216 /* Look up the current Vcc */ 207 217 CS_CHECK(GetConfigurationInfo, 208 - pcmcia_get_configuration_info(handle, &conf)); 209 - link->conf.Vcc = conf.Vcc; 218 + pcmcia_get_configuration_info(link, &conf)); 210 219 211 220 /* 212 221 * In this loop, we scan the CIS for configuration table ··· 219 236 * implementation-defined details. 220 237 */ 221 238 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 222 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 239 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 223 240 while (1) { 224 241 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 225 242 cistpl_cftable_entry_t dflt = { .index = 0 }; 226 243 227 - if ( (pcmcia_get_tuple_data(handle, &tuple) != 0) 228 - || (pcmcia_parse_tuple(handle, &tuple, &parse) != 0)) 244 + if ( (pcmcia_get_tuple_data(link, &tuple) != 0) 245 + || (pcmcia_parse_tuple(link, &tuple, &parse) != 0)) 229 246 goto next_entry; 230 247 231 248 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) ··· 257 274 } 258 275 259 276 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 260 - link->conf.Vpp1 = link->conf.Vpp2 = 277 + link->conf.Vpp = 261 278 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 262 279 else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) 263 - link->conf.Vpp1 = link->conf.Vpp2 = 280 + link->conf.Vpp = 264 281 dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; 265 282 266 283 /* Do we need to allocate an interrupt? */ ··· 290 307 } 291 308 292 309 /* This reserves IO space but doesn't actually enable it */ 293 - if (pcmcia_request_io(link->handle, &link->io) != 0) 310 + if (pcmcia_request_io(link, &link->io) != 0) 294 311 goto next_entry; 295 312 } 296 313 ··· 300 317 break; 301 318 302 319 next_entry: 303 - if (link->io.NumPorts1) 304 - pcmcia_release_io(link->handle, &link->io); 305 - last_ret = pcmcia_get_next_tuple(handle, &tuple); 320 + pcmcia_disable_device(link); 321 + last_ret = pcmcia_get_next_tuple(link, &tuple); 306 322 if (last_ret == CS_NO_MORE_ITEMS) { 307 323 printk(KERN_ERR PFX "GetNextTuple(): No matching " 308 324 "CIS configuration. Maybe you need the " ··· 315 333 * a handler to the interrupt, unless the 'Handler' member of 316 334 * the irq structure is initialized. 317 335 */ 318 - CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 336 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 319 337 320 338 /* We initialize the hermes structure before completing PCMCIA 321 339 * configuration just in case the interrupt handler gets ··· 332 350 * card and host interface into "Memory and IO" mode. 333 351 */ 334 352 CS_CHECK(RequestConfiguration, 335 - pcmcia_request_configuration(link->handle, &link->conf)); 353 + pcmcia_request_configuration(link, &link->conf)); 336 354 337 355 /* Ok, we have the configuration, prepare to register the netdev */ 338 356 dev->base_addr = link->io.BasePort1; ··· 340 358 SET_MODULE_OWNER(dev); 341 359 card->node.major = card->node.minor = 0; 342 360 343 - SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 361 + SET_NETDEV_DEV(dev, &handle_to_dev(link)); 344 362 /* Tell the stack we exist */ 345 363 if (register_netdev(dev) != 0) { 346 364 printk(KERN_ERR PFX "register_netdev() failed\n"); ··· 348 366 } 349 367 350 368 /* At this point, the dev_node_t structure(s) needs to be 351 - * initialized and arranged in a linked list at link->dev. */ 369 + * initialized and arranged in a linked list at link->dev_node. */ 352 370 strcpy(card->node.dev_name, dev->name); 353 - link->dev = &card->node; /* link->dev being non-NULL is also 371 + link->dev_node = &card->node; /* link->dev_node being non-NULL is also 354 372 used to indicate that the 355 373 net_device has been registered */ 356 - link->state &= ~DEV_CONFIG_PENDING; 357 374 358 375 /* Finally, report what we've done */ 359 - printk(KERN_DEBUG "%s: index 0x%02x: Vcc %d.%d", 360 - dev->name, link->conf.ConfigIndex, 361 - link->conf.Vcc / 10, link->conf.Vcc % 10); 362 - if (link->conf.Vpp1) 363 - printk(", Vpp %d.%d", link->conf.Vpp1 / 10, 364 - link->conf.Vpp1 % 10); 376 + printk(KERN_DEBUG "%s: index 0x%02x: ", 377 + dev->name, link->conf.ConfigIndex); 378 + if (link->conf.Vpp) 379 + printk(", Vpp %d.%d", link->conf.Vpp / 10, 380 + link->conf.Vpp % 10); 365 381 printk(", irq %d", link->irq.AssignedIRQ); 366 382 if (link->io.NumPorts1) 367 383 printk(", io 0x%04x-0x%04x", link->io.BasePort1, ··· 369 389 link->io.BasePort2 + link->io.NumPorts2 - 1); 370 390 printk("\n"); 371 391 372 - return; 392 + return 0; 373 393 374 394 cs_failed: 375 - cs_error(link->handle, last_fn, last_ret); 395 + cs_error(link, last_fn, last_ret); 376 396 377 397 failed: 378 398 orinoco_cs_release(link); 399 + return -ENODEV; 379 400 } /* orinoco_cs_config */ 380 401 381 402 /* ··· 385 404 * still open, this will be postponed until it is closed. 386 405 */ 387 406 static void 388 - orinoco_cs_release(dev_link_t *link) 407 + orinoco_cs_release(struct pcmcia_device *link) 389 408 { 390 409 struct net_device *dev = link->priv; 391 410 struct orinoco_private *priv = netdev_priv(dev); ··· 397 416 priv->hw_unavailable++; 398 417 spin_unlock_irqrestore(&priv->lock, flags); 399 418 400 - /* Don't bother checking to see if these succeed or not */ 401 - pcmcia_release_configuration(link->handle); 402 - if (link->io.NumPorts1) 403 - pcmcia_release_io(link->handle, &link->io); 404 - if (link->irq.AssignedIRQ) 405 - pcmcia_release_irq(link->handle, &link->irq); 406 - link->state &= ~DEV_CONFIG; 419 + pcmcia_disable_device(link); 407 420 if (priv->hw.iobase) 408 421 ioport_unmap(priv->hw.iobase); 409 422 } /* orinoco_cs_release */ 410 423 411 - static int orinoco_cs_suspend(struct pcmcia_device *p_dev) 424 + static int orinoco_cs_suspend(struct pcmcia_device *link) 412 425 { 413 - dev_link_t *link = dev_to_instance(p_dev); 414 426 struct net_device *dev = link->priv; 415 427 struct orinoco_private *priv = netdev_priv(dev); 416 428 struct orinoco_pccard *card = priv->card; 417 429 int err = 0; 418 430 unsigned long flags; 419 431 420 - link->state |= DEV_SUSPEND; 421 - if (link->state & DEV_CONFIG) { 422 - /* This is probably racy, but I can't think of 423 - a better way, short of rewriting the PCMCIA 424 - layer to not suck :-( */ 425 - if (! test_bit(0, &card->hard_reset_in_progress)) { 426 - spin_lock_irqsave(&priv->lock, flags); 432 + /* This is probably racy, but I can't think of 433 + a better way, short of rewriting the PCMCIA 434 + layer to not suck :-( */ 435 + if (! test_bit(0, &card->hard_reset_in_progress)) { 436 + spin_lock_irqsave(&priv->lock, flags); 427 437 428 - err = __orinoco_down(dev); 429 - if (err) 430 - printk(KERN_WARNING "%s: Error %d downing interface\n", 431 - dev->name, err); 438 + err = __orinoco_down(dev); 439 + if (err) 440 + printk(KERN_WARNING "%s: Error %d downing interface\n", 441 + dev->name, err); 432 442 433 - netif_device_detach(dev); 434 - priv->hw_unavailable++; 443 + netif_device_detach(dev); 444 + priv->hw_unavailable++; 435 445 436 - spin_unlock_irqrestore(&priv->lock, flags); 437 - } 438 - 439 - pcmcia_release_configuration(link->handle); 446 + spin_unlock_irqrestore(&priv->lock, flags); 440 447 } 441 448 442 449 return 0; 443 450 } 444 451 445 - static int orinoco_cs_resume(struct pcmcia_device *p_dev) 452 + static int orinoco_cs_resume(struct pcmcia_device *link) 446 453 { 447 - dev_link_t *link = dev_to_instance(p_dev); 448 454 struct net_device *dev = link->priv; 449 455 struct orinoco_private *priv = netdev_priv(dev); 450 456 struct orinoco_pccard *card = priv->card; 451 457 int err = 0; 452 458 unsigned long flags; 453 459 454 - link->state &= ~DEV_SUSPEND; 455 - if (link->state & DEV_CONFIG) { 456 - /* FIXME: should we double check that this is 457 - * the same card as we had before */ 458 - pcmcia_request_configuration(link->handle, &link->conf); 459 - 460 - if (! test_bit(0, &card->hard_reset_in_progress)) { 461 - err = orinoco_reinit_firmware(dev); 462 - if (err) { 463 - printk(KERN_ERR "%s: Error %d re-initializing firmware\n", 464 - dev->name, err); 465 - return -EIO; 466 - } 467 - 468 - spin_lock_irqsave(&priv->lock, flags); 469 - 470 - netif_device_attach(dev); 471 - priv->hw_unavailable--; 472 - 473 - if (priv->open && ! priv->hw_unavailable) { 474 - err = __orinoco_up(dev); 475 - if (err) 476 - printk(KERN_ERR "%s: Error %d restarting card\n", 477 - dev->name, err); 478 - } 479 - 480 - spin_unlock_irqrestore(&priv->lock, flags); 460 + if (! test_bit(0, &card->hard_reset_in_progress)) { 461 + err = orinoco_reinit_firmware(dev); 462 + if (err) { 463 + printk(KERN_ERR "%s: Error %d re-initializing firmware\n", 464 + dev->name, err); 465 + return -EIO; 481 466 } 467 + 468 + spin_lock_irqsave(&priv->lock, flags); 469 + 470 + netif_device_attach(dev); 471 + priv->hw_unavailable--; 472 + 473 + if (priv->open && ! priv->hw_unavailable) { 474 + err = __orinoco_up(dev); 475 + if (err) 476 + printk(KERN_ERR "%s: Error %d restarting card\n", 477 + dev->name, err); 478 + } 479 + 480 + spin_unlock_irqrestore(&priv->lock, flags); 482 481 } 483 482 484 483 return 0; ··· 565 604 .drv = { 566 605 .name = DRIVER_NAME, 567 606 }, 568 - .probe = orinoco_cs_attach, 607 + .probe = orinoco_cs_probe, 569 608 .remove = orinoco_cs_detach, 570 609 .id_table = orinoco_cs_ids, 571 610 .suspend = orinoco_cs_suspend,
+108 -169
drivers/net/wireless/ray_cs.c
··· 90 90 #define DEBUG(n, args...) 91 91 #endif 92 92 /** Prototypes based on PCMCIA skeleton driver *******************************/ 93 - static void ray_config(dev_link_t *link); 94 - static void ray_release(dev_link_t *link); 93 + static int ray_config(struct pcmcia_device *link); 94 + static void ray_release(struct pcmcia_device *link); 95 95 static void ray_detach(struct pcmcia_device *p_dev); 96 96 97 97 /***** Prototypes indicated by device structure ******************************/ ··· 190 190 static char *phy_addr = NULL; 191 191 192 192 193 - /* A linked list of "instances" of the ray device. Each actual 194 - PCMCIA card corresponds to one device instance, and is described 195 - by one dev_link_t structure (defined in ds.h). 196 - */ 197 - static dev_link_t *dev_list = NULL; 198 - 199 - /* A dev_link_t structure has fields for most things that are needed 193 + /* A struct pcmcia_device structure has fields for most things that are needed 200 194 to keep track of a socket, but there will usually be some device 201 195 specific information that also needs to be kept track of. The 202 - 'priv' pointer in a dev_link_t structure can be used to point to 196 + 'priv' pointer in a struct pcmcia_device structure can be used to point to 203 197 a device-specific private data structure, like this. 204 198 */ 205 199 static unsigned int ray_mem_speed = 500; 200 + 201 + /* WARNING: THIS DRIVER IS NOT CAPABLE OF HANDLING MULTIPLE DEVICES! */ 202 + static struct pcmcia_device *this_device = NULL; 206 203 207 204 MODULE_AUTHOR("Corey Thomas <corey@world.std.com>"); 208 205 MODULE_DESCRIPTION("Raylink/WebGear wireless LAN driver"); ··· 303 306 configure the card at this point -- we wait until we receive a 304 307 card insertion event. 305 308 =============================================================================*/ 306 - static int ray_attach(struct pcmcia_device *p_dev) 309 + static int ray_probe(struct pcmcia_device *p_dev) 307 310 { 308 - dev_link_t *link; 309 311 ray_dev_t *local; 310 312 struct net_device *dev; 311 - 313 + 312 314 DEBUG(1, "ray_attach()\n"); 313 - 314 - /* Initialize the dev_link_t structure */ 315 - link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); 316 - 317 - if (!link) 318 - return -ENOMEM; 319 315 320 316 /* Allocate space for private device-specific data */ 321 317 dev = alloc_etherdev(sizeof(ray_dev_t)); 322 - 323 318 if (!dev) 324 319 goto fail_alloc_dev; 325 320 326 321 local = dev->priv; 327 - 328 - memset(link, 0, sizeof(struct dev_link_t)); 322 + local->finder = p_dev; 329 323 330 324 /* The io structure describes IO port mapping. None used here */ 331 - link->io.NumPorts1 = 0; 332 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 333 - link->io.IOAddrLines = 5; 325 + p_dev->io.NumPorts1 = 0; 326 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 327 + p_dev->io.IOAddrLines = 5; 334 328 335 329 /* Interrupt setup. For PCMCIA, driver takes what's given */ 336 - link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; 337 - link->irq.IRQInfo1 = IRQ_LEVEL_ID; 338 - link->irq.Handler = &ray_interrupt; 330 + p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; 331 + p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; 332 + p_dev->irq.Handler = &ray_interrupt; 339 333 340 334 /* General socket configuration */ 341 - link->conf.Attributes = CONF_ENABLE_IRQ; 342 - link->conf.Vcc = 50; 343 - link->conf.IntType = INT_MEMORY_AND_IO; 344 - link->conf.ConfigIndex = 1; 345 - link->conf.Present = PRESENT_OPTION; 335 + p_dev->conf.Attributes = CONF_ENABLE_IRQ; 336 + p_dev->conf.IntType = INT_MEMORY_AND_IO; 337 + p_dev->conf.ConfigIndex = 1; 338 + p_dev->conf.Present = PRESENT_OPTION; 346 339 347 - link->priv = dev; 348 - link->irq.Instance = dev; 340 + p_dev->priv = dev; 341 + p_dev->irq.Instance = dev; 349 342 350 - local->finder = link; 343 + local->finder = p_dev; 351 344 local->card_status = CARD_INSERTED; 352 345 local->authentication_state = UNAUTHENTICATED; 353 346 local->num_multi = 0; 354 - DEBUG(2,"ray_attach link = %p, dev = %p, local = %p, intr = %p\n", 355 - link,dev,local,&ray_interrupt); 347 + DEBUG(2,"ray_attach p_dev = %p, dev = %p, local = %p, intr = %p\n", 348 + p_dev,dev,local,&ray_interrupt); 356 349 357 350 /* Raylink entries in the device structure */ 358 351 dev->hard_start_xmit = &ray_dev_start_xmit; ··· 366 379 367 380 init_timer(&local->timer); 368 381 369 - link->handle = p_dev; 370 - p_dev->instance = link; 371 - 372 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 373 - ray_config(link); 374 - 375 - return 0; 382 + this_device = p_dev; 383 + return ray_config(p_dev); 376 384 377 385 fail_alloc_dev: 378 - kfree(link); 379 386 return -ENOMEM; 380 387 } /* ray_attach */ 381 388 /*============================================================================= ··· 378 397 structures are freed. Otherwise, the structures will be freed 379 398 when the device is released. 380 399 =============================================================================*/ 381 - static void ray_detach(struct pcmcia_device *p_dev) 400 + static void ray_detach(struct pcmcia_device *link) 382 401 { 383 - dev_link_t *link = dev_to_instance(p_dev); 384 - dev_link_t **linkp; 385 402 struct net_device *dev; 386 403 ray_dev_t *local; 387 404 388 405 DEBUG(1, "ray_detach(0x%p)\n", link); 389 - 390 - /* Locate device structure */ 391 - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) 392 - if (*linkp == link) break; 393 - if (*linkp == NULL) 394 - return; 395 406 407 + this_device = NULL; 396 408 dev = link->priv; 397 409 398 - if (link->state & DEV_CONFIG) { 399 - ray_release(link); 410 + ray_release(link); 400 411 401 - local = (ray_dev_t *)dev->priv; 402 - del_timer(&local->timer); 403 - } 412 + local = (ray_dev_t *)dev->priv; 413 + del_timer(&local->timer); 404 414 405 - /* Unlink device structure, free pieces */ 406 - *linkp = link->next; 407 415 if (link->priv) { 408 - if (link->dev) unregister_netdev(dev); 416 + if (link->dev_node) unregister_netdev(dev); 409 417 free_netdev(dev); 410 418 } 411 - kfree(link); 412 419 DEBUG(2,"ray_cs ray_detach ending\n"); 413 420 } /* ray_detach */ 414 421 /*============================================================================= ··· 407 438 #define CS_CHECK(fn, ret) \ 408 439 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 409 440 #define MAX_TUPLE_SIZE 128 410 - static void ray_config(dev_link_t *link) 441 + static int ray_config(struct pcmcia_device *link) 411 442 { 412 - client_handle_t handle = link->handle; 413 443 tuple_t tuple; 414 444 cisparse_t parse; 415 445 int last_fn = 0, last_ret = 0; ··· 423 455 424 456 /* This reads the card's CONFIG tuple to find its configuration regs */ 425 457 tuple.DesiredTuple = CISTPL_CONFIG; 426 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 458 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 427 459 tuple.TupleData = buf; 428 460 tuple.TupleDataMax = MAX_TUPLE_SIZE; 429 461 tuple.TupleOffset = 0; 430 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 431 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 462 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 463 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 432 464 link->conf.ConfigBase = parse.config.base; 433 465 link->conf.Present = parse.config.rmask[0]; 434 466 435 467 /* Determine card type and firmware version */ 436 468 buf[0] = buf[MAX_TUPLE_SIZE - 1] = 0; 437 469 tuple.DesiredTuple = CISTPL_VERS_1; 438 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 470 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 439 471 tuple.TupleData = buf; 440 472 tuple.TupleDataMax = MAX_TUPLE_SIZE; 441 473 tuple.TupleOffset = 2; 442 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 474 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 443 475 444 476 for (i=0; i<tuple.TupleDataLen - 4; i++) 445 477 if (buf[i] == 0) buf[i] = ' '; 446 478 printk(KERN_INFO "ray_cs Detected: %s\n",buf); 447 479 448 - /* Configure card */ 449 - link->state |= DEV_CONFIG; 450 - 451 480 /* Now allocate an interrupt line. Note that this does not 452 481 actually assign a handler to the interrupt. 453 482 */ 454 - CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 483 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 455 484 dev->irq = link->irq.AssignedIRQ; 456 485 457 486 /* This actually configures the PCMCIA socket -- setting up 458 487 the I/O windows and the interrupt mapping. 459 488 */ 460 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 489 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 461 490 462 491 /*** Set up 32k window for shared memory (transmit and control) ************/ 463 492 req.Attributes = WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT; 464 493 req.Base = 0; 465 494 req.Size = 0x8000; 466 495 req.AccessSpeed = ray_mem_speed; 467 - CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &link->win)); 496 + CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win)); 468 497 mem.CardOffset = 0x0000; mem.Page = 0; 469 498 CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem)); 470 499 local->sram = ioremap(req.Base,req.Size); ··· 471 506 req.Base = 0; 472 507 req.Size = 0x4000; 473 508 req.AccessSpeed = ray_mem_speed; 474 - CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &local->rmem_handle)); 509 + CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &local->rmem_handle)); 475 510 mem.CardOffset = 0x8000; mem.Page = 0; 476 511 CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->rmem_handle, &mem)); 477 512 local->rmem = ioremap(req.Base,req.Size); ··· 481 516 req.Base = 0; 482 517 req.Size = 0x1000; 483 518 req.AccessSpeed = ray_mem_speed; 484 - CS_CHECK(RequestWindow, pcmcia_request_window(&link->handle, &req, &local->amem_handle)); 519 + CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &local->amem_handle)); 485 520 mem.CardOffset = 0x0000; mem.Page = 0; 486 521 CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->amem_handle, &mem)); 487 522 local->amem = ioremap(req.Base,req.Size); ··· 491 526 DEBUG(3,"ray_config amem=%p\n",local->amem); 492 527 if (ray_init(dev) < 0) { 493 528 ray_release(link); 494 - return; 529 + return -ENODEV; 495 530 } 496 531 497 - SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 532 + SET_NETDEV_DEV(dev, &handle_to_dev(link)); 498 533 i = register_netdev(dev); 499 534 if (i != 0) { 500 535 printk("ray_config register_netdev() failed\n"); 501 536 ray_release(link); 502 - return; 537 + return i; 503 538 } 504 539 505 540 strcpy(local->node.dev_name, dev->name); 506 - link->dev = &local->node; 541 + link->dev_node = &local->node; 507 542 508 - link->state &= ~DEV_CONFIG_PENDING; 509 543 printk(KERN_INFO "%s: RayLink, irq %d, hw_addr ", 510 544 dev->name, dev->irq); 511 545 for (i = 0; i < 6; i++) 512 546 printk("%02X%s", dev->dev_addr[i], ((i<5) ? ":" : "\n")); 513 547 514 - return; 548 + return 0; 515 549 516 550 cs_failed: 517 - cs_error(link->handle, last_fn, last_ret); 551 + cs_error(link, last_fn, last_ret); 518 552 519 553 ray_release(link); 554 + return -ENODEV; 520 555 } /* ray_config */ 521 556 522 557 static inline struct ccs __iomem *ccs_base(ray_dev_t *dev) ··· 543 578 UCHAR *p; 544 579 struct ccs __iomem *pccs; 545 580 ray_dev_t *local = (ray_dev_t *)dev->priv; 546 - dev_link_t *link = local->finder; 581 + struct pcmcia_device *link = local->finder; 547 582 DEBUG(1, "ray_init(0x%p)\n", dev); 548 - if (!(link->state & DEV_PRESENT)) { 583 + if (!(pcmcia_dev_present(link))) { 549 584 DEBUG(0,"ray_init - device not present\n"); 550 585 return -1; 551 586 } ··· 605 640 int ccsindex; 606 641 ray_dev_t *local = (ray_dev_t *)dev->priv; 607 642 struct ccs __iomem *pccs; 608 - dev_link_t *link = local->finder; 643 + struct pcmcia_device *link = local->finder; 609 644 610 645 DEBUG(1,"dl_startup_params entered\n"); 611 - if (!(link->state & DEV_PRESENT)) { 646 + if (!(pcmcia_dev_present(link))) { 612 647 DEBUG(2,"ray_cs dl_startup_params - device not present\n"); 613 648 return -1; 614 649 } ··· 712 747 ray_dev_t *local = (ray_dev_t *)data; 713 748 struct ccs __iomem *pccs = ccs_base(local) + local->dl_param_ccs; 714 749 UCHAR status; 715 - dev_link_t *link = local->finder; 750 + struct pcmcia_device *link = local->finder; 716 751 717 - if (!(link->state & DEV_PRESENT)) { 752 + if (!(pcmcia_dev_present(link))) { 718 753 DEBUG(2,"ray_cs verify_dl_startup - device not present\n"); 719 754 return; 720 755 } ··· 752 787 ray_dev_t *local = (ray_dev_t *)data; 753 788 struct ccs __iomem *pccs; 754 789 int ccsindex; 755 - dev_link_t *link = local->finder; 756 - if (!(link->state & DEV_PRESENT)) { 790 + struct pcmcia_device *link = local->finder; 791 + if (!(pcmcia_dev_present(link))) { 757 792 DEBUG(2,"ray_cs start_net - device not present\n"); 758 793 return; 759 794 } ··· 779 814 780 815 struct ccs __iomem *pccs; 781 816 int ccsindex; 782 - dev_link_t *link = local->finder; 817 + struct pcmcia_device *link = local->finder; 783 818 784 - if (!(link->state & DEV_PRESENT)) { 819 + if (!(pcmcia_dev_present(link))) { 785 820 DEBUG(2,"ray_cs join_net - device not present\n"); 786 821 return; 787 822 } ··· 805 840 device, and release the PCMCIA configuration. If the device is 806 841 still open, this will be postponed until it is closed. 807 842 =============================================================================*/ 808 - static void ray_release(dev_link_t *link) 843 + static void ray_release(struct pcmcia_device *link) 809 844 { 810 845 struct net_device *dev = link->priv; 811 846 ray_dev_t *local = dev->priv; ··· 814 849 DEBUG(1, "ray_release(0x%p)\n", link); 815 850 816 851 del_timer(&local->timer); 817 - link->state &= ~DEV_CONFIG; 818 852 819 853 iounmap(local->sram); 820 854 iounmap(local->rmem); 821 855 iounmap(local->amem); 822 856 /* Do bother checking to see if these succeed or not */ 823 - i = pcmcia_release_window(link->win); 824 - if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseWindow(link->win) ret = %x\n",i); 825 857 i = pcmcia_release_window(local->amem_handle); 826 858 if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseWindow(local->amem) ret = %x\n",i); 827 859 i = pcmcia_release_window(local->rmem_handle); 828 860 if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseWindow(local->rmem) ret = %x\n",i); 829 - i = pcmcia_release_configuration(link->handle); 830 - if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseConfiguration ret = %x\n",i); 831 - i = pcmcia_release_irq(link->handle, &link->irq); 832 - if ( i != CS_SUCCESS ) DEBUG(0,"ReleaseIRQ ret = %x\n",i); 861 + pcmcia_disable_device(link); 833 862 834 863 DEBUG(2,"ray_release ending\n"); 835 864 } 836 865 837 - static int ray_suspend(struct pcmcia_device *p_dev) 866 + static int ray_suspend(struct pcmcia_device *link) 838 867 { 839 - dev_link_t *link = dev_to_instance(p_dev); 840 868 struct net_device *dev = link->priv; 841 869 842 - link->state |= DEV_SUSPEND; 843 - if (link->state & DEV_CONFIG) { 844 - if (link->open) 845 - netif_device_detach(dev); 846 - 847 - pcmcia_release_configuration(link->handle); 848 - } 849 - 870 + if (link->open) 871 + netif_device_detach(dev); 850 872 851 873 return 0; 852 874 } 853 875 854 - static int ray_resume(struct pcmcia_device *p_dev) 876 + static int ray_resume(struct pcmcia_device *link) 855 877 { 856 - dev_link_t *link = dev_to_instance(p_dev); 857 878 struct net_device *dev = link->priv; 858 879 859 - link->state &= ~DEV_SUSPEND; 860 - if (link->state & DEV_CONFIG) { 861 - pcmcia_request_configuration(link->handle, &link->conf); 862 - if (link->open) { 863 - ray_reset(dev); 864 - netif_device_attach(dev); 865 - } 866 - } 880 + if (link->open) { 881 + ray_reset(dev); 882 + netif_device_attach(dev); 883 + } 867 884 868 885 return 0; 869 886 } ··· 857 910 int i; 858 911 #endif /* RAY_IMMEDIATE_INIT */ 859 912 ray_dev_t *local = dev->priv; 860 - dev_link_t *link = local->finder; 913 + struct pcmcia_device *link = local->finder; 861 914 862 915 DEBUG(1,"ray_dev_init(dev=%p)\n",dev); 863 - if (!(link->state & DEV_PRESENT)) { 916 + if (!(pcmcia_dev_present(link))) { 864 917 DEBUG(2,"ray_dev_init - device not present\n"); 865 918 return -1; 866 919 } ··· 891 944 static int ray_dev_config(struct net_device *dev, struct ifmap *map) 892 945 { 893 946 ray_dev_t *local = dev->priv; 894 - dev_link_t *link = local->finder; 947 + struct pcmcia_device *link = local->finder; 895 948 /* Dummy routine to satisfy device structure */ 896 949 DEBUG(1,"ray_dev_config(dev=%p,ifmap=%p)\n",dev,map); 897 - if (!(link->state & DEV_PRESENT)) { 950 + if (!(pcmcia_dev_present(link))) { 898 951 DEBUG(2,"ray_dev_config - device not present\n"); 899 952 return -1; 900 953 } ··· 905 958 static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev) 906 959 { 907 960 ray_dev_t *local = dev->priv; 908 - dev_link_t *link = local->finder; 961 + struct pcmcia_device *link = local->finder; 909 962 short length = skb->len; 910 963 911 - if (!(link->state & DEV_PRESENT)) { 964 + if (!(pcmcia_dev_present(link))) { 912 965 DEBUG(2,"ray_dev_start_xmit - device not present\n"); 913 966 return -1; 914 967 } ··· 1517 1570 static iw_stats * ray_get_wireless_stats(struct net_device * dev) 1518 1571 { 1519 1572 ray_dev_t * local = (ray_dev_t *) dev->priv; 1520 - dev_link_t *link = local->finder; 1573 + struct pcmcia_device *link = local->finder; 1521 1574 struct status __iomem *p = local->sram + STATUS_BASE; 1522 1575 1523 1576 if(local == (ray_dev_t *) NULL) ··· 1535 1588 } 1536 1589 #endif /* WIRELESS_SPY */ 1537 1590 1538 - if((link->state & DEV_PRESENT)) { 1591 + if(pcmcia_dev_present(link)) { 1539 1592 local->wstats.qual.noise = readb(&p->rxnoise); 1540 1593 local->wstats.qual.updated |= 4; 1541 1594 } ··· 1604 1657 /*===========================================================================*/ 1605 1658 static int ray_open(struct net_device *dev) 1606 1659 { 1607 - dev_link_t *link; 1608 1660 ray_dev_t *local = (ray_dev_t *)dev->priv; 1661 + struct pcmcia_device *link; 1662 + link = local->finder; 1609 1663 1610 1664 DEBUG(1, "ray_open('%s')\n", dev->name); 1611 1665 1612 - for (link = dev_list; link; link = link->next) 1613 - if (link->priv == dev) break; 1614 - if (!DEV_OK(link)) { 1615 - return -ENODEV; 1616 - } 1617 - 1618 - if (link->open == 0) local->num_multi = 0; 1666 + if (link->open == 0) 1667 + local->num_multi = 0; 1619 1668 link->open++; 1620 1669 1621 1670 /* If the card is not started, time to start it ! - Jean II */ ··· 1638 1695 /*===========================================================================*/ 1639 1696 static int ray_dev_close(struct net_device *dev) 1640 1697 { 1641 - dev_link_t *link; 1698 + ray_dev_t *local = (ray_dev_t *)dev->priv; 1699 + struct pcmcia_device *link; 1700 + link = local->finder; 1642 1701 1643 1702 DEBUG(1, "ray_dev_close('%s')\n", dev->name); 1644 - 1645 - for (link = dev_list; link; link = link->next) 1646 - if (link->priv == dev) break; 1647 - if (link == NULL) 1648 - return -ENODEV; 1649 1703 1650 1704 link->open--; 1651 1705 netif_stop_queue(dev); ··· 1665 1725 static int interrupt_ecf(ray_dev_t *local, int ccs) 1666 1726 { 1667 1727 int i = 50; 1668 - dev_link_t *link = local->finder; 1728 + struct pcmcia_device *link = local->finder; 1669 1729 1670 - if (!(link->state & DEV_PRESENT)) { 1730 + if (!(pcmcia_dev_present(link))) { 1671 1731 DEBUG(2,"ray_cs interrupt_ecf - device not present\n"); 1672 1732 return -1; 1673 1733 } ··· 1692 1752 { 1693 1753 int i; 1694 1754 struct ccs __iomem *pccs = ccs_base(local); 1695 - dev_link_t *link = local->finder; 1755 + struct pcmcia_device *link = local->finder; 1696 1756 1697 - if (!(link->state & DEV_PRESENT)) { 1757 + if (!(pcmcia_dev_present(link))) { 1698 1758 DEBUG(2,"ray_cs get_free_tx_ccs - device not present\n"); 1699 1759 return ECARDGONE; 1700 1760 } ··· 1723 1783 { 1724 1784 int i; 1725 1785 struct ccs __iomem *pccs = ccs_base(local); 1726 - dev_link_t *link = local->finder; 1786 + struct pcmcia_device *link = local->finder; 1727 1787 1728 - if (!(link->state & DEV_PRESENT)) { 1788 + if (!(pcmcia_dev_present(link))) { 1729 1789 DEBUG(2,"ray_cs get_free_ccs - device not present\n"); 1730 1790 return ECARDGONE; 1731 1791 } ··· 1798 1858 static struct net_device_stats *ray_get_stats(struct net_device *dev) 1799 1859 { 1800 1860 ray_dev_t *local = (ray_dev_t *)dev->priv; 1801 - dev_link_t *link = local->finder; 1861 + struct pcmcia_device *link = local->finder; 1802 1862 struct status __iomem *p = local->sram + STATUS_BASE; 1803 - if (!(link->state & DEV_PRESENT)) { 1863 + if (!(pcmcia_dev_present(link))) { 1804 1864 DEBUG(2,"ray_cs net_device_stats - device not present\n"); 1805 1865 return &local->stats; 1806 1866 } ··· 1828 1888 static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value, int len) 1829 1889 { 1830 1890 ray_dev_t *local = (ray_dev_t *)dev->priv; 1831 - dev_link_t *link = local->finder; 1891 + struct pcmcia_device *link = local->finder; 1832 1892 int ccsindex; 1833 1893 int i; 1834 1894 struct ccs __iomem *pccs; 1835 1895 1836 - if (!(link->state & DEV_PRESENT)) { 1896 + if (!(pcmcia_dev_present(link))) { 1837 1897 DEBUG(2,"ray_update_parm - device not present\n"); 1838 1898 return; 1839 1899 } ··· 1865 1925 struct ccs __iomem *pccs; 1866 1926 int i = 0; 1867 1927 ray_dev_t *local = (ray_dev_t *)dev->priv; 1868 - dev_link_t *link = local->finder; 1928 + struct pcmcia_device *link = local->finder; 1869 1929 void __iomem *p = local->sram + HOST_TO_ECF_BASE; 1870 1930 1871 - if (!(link->state & DEV_PRESENT)) { 1931 + if (!(pcmcia_dev_present(link))) { 1872 1932 DEBUG(2,"ray_update_multi_list - device not present\n"); 1873 1933 return; 1874 1934 } ··· 1945 2005 static irqreturn_t ray_interrupt(int irq, void *dev_id, struct pt_regs * regs) 1946 2006 { 1947 2007 struct net_device *dev = (struct net_device *)dev_id; 1948 - dev_link_t *link; 2008 + struct pcmcia_device *link; 1949 2009 ray_dev_t *local; 1950 2010 struct ccs __iomem *pccs; 1951 2011 struct rcs __iomem *prcs; ··· 1960 2020 DEBUG(4,"ray_cs: interrupt for *dev=%p\n",dev); 1961 2021 1962 2022 local = (ray_dev_t *)dev->priv; 1963 - link = (dev_link_t *)local->finder; 1964 - if ( ! (link->state & DEV_PRESENT) || link->state & DEV_SUSPEND ) { 2023 + link = (struct pcmcia_device *)local->finder; 2024 + if (!pcmcia_dev_present(link)) { 1965 2025 DEBUG(2,"ray_cs interrupt from device not present or suspended.\n"); 1966 2026 return IRQ_NONE; 1967 2027 } ··· 2480 2540 /*===========================================================================*/ 2481 2541 static void authenticate(ray_dev_t *local) 2482 2542 { 2483 - dev_link_t *link = local->finder; 2543 + struct pcmcia_device *link = local->finder; 2484 2544 DEBUG(0,"ray_cs Starting authentication.\n"); 2485 - if (!(link->state & DEV_PRESENT)) { 2545 + if (!(pcmcia_dev_present(link))) { 2486 2546 DEBUG(2,"ray_cs authenticate - device not present\n"); 2487 2547 return; 2488 2548 } ··· 2546 2606 static void associate(ray_dev_t *local) 2547 2607 { 2548 2608 struct ccs __iomem *pccs; 2549 - dev_link_t *link = local->finder; 2609 + struct pcmcia_device *link = local->finder; 2550 2610 struct net_device *dev = link->priv; 2551 2611 int ccsindex; 2552 - if (!(link->state & DEV_PRESENT)) { 2612 + if (!(pcmcia_dev_present(link))) { 2553 2613 DEBUG(2,"ray_cs associate - device not present\n"); 2554 2614 return; 2555 2615 } ··· 2629 2689 * eg ifconfig 2630 2690 */ 2631 2691 int i; 2632 - dev_link_t *link; 2692 + struct pcmcia_device *link; 2633 2693 struct net_device *dev; 2634 2694 ray_dev_t *local; 2635 2695 UCHAR *p; 2636 2696 struct freq_hop_element *pfh; 2637 2697 UCHAR c[33]; 2638 2698 2639 - link = dev_list; 2699 + link = this_device; 2640 2700 if (!link) 2641 2701 return 0; 2642 2702 dev = (struct net_device *)link->priv; ··· 2838 2898 .drv = { 2839 2899 .name = "ray_cs", 2840 2900 }, 2841 - .probe = ray_attach, 2901 + .probe = ray_probe, 2842 2902 .remove = ray_detach, 2843 2903 .id_table = ray_ids, 2844 2904 .suspend = ray_suspend, ··· 2880 2940 #endif 2881 2941 2882 2942 pcmcia_unregister_driver(&ray_driver); 2883 - BUG_ON(dev_list != NULL); 2884 2943 } /* exit_ray_cs */ 2885 2944 2886 2945 module_init(init_ray_cs);
+1 -1
drivers/net/wireless/ray_cs.h
··· 31 31 void __iomem *sram; /* pointer to beginning of shared RAM */ 32 32 void __iomem *amem; /* pointer to attribute mem window */ 33 33 void __iomem *rmem; /* pointer to receive buffer window */ 34 - dev_link_t *finder; /* pointer back to dev_link_t for card */ 34 + struct pcmcia_device *finder; /* pointer back to struct pcmcia_device for card */ 35 35 struct timer_list timer; 36 36 long tx_ccs_lock; 37 37 long ccs_lock;
+69 -104
drivers/net/wireless/spectrum_cs.c
··· 63 63 /* PCMCIA specific device information (goes in the card field of 64 64 * struct orinoco_private */ 65 65 struct orinoco_pccard { 66 - dev_link_t link; 66 + struct pcmcia_device *p_dev; 67 67 dev_node_t node; 68 68 }; 69 69 ··· 71 71 /* Function prototypes */ 72 72 /********************************************************************/ 73 73 74 - static void spectrum_cs_config(dev_link_t *link); 75 - static void spectrum_cs_release(dev_link_t *link); 74 + static int spectrum_cs_config(struct pcmcia_device *link); 75 + static void spectrum_cs_release(struct pcmcia_device *link); 76 76 77 77 /********************************************************************/ 78 78 /* Firmware downloader */ ··· 238 238 * If IDLE is 1, stop the firmware, so that it can be safely rewritten. 239 239 */ 240 240 static int 241 - spectrum_reset(dev_link_t *link, int idle) 241 + spectrum_reset(struct pcmcia_device *link, int idle) 242 242 { 243 243 int last_ret, last_fn; 244 244 conf_reg_t reg; 245 245 u_int save_cor; 246 246 247 247 /* Doing it if hardware is gone is guaranteed crash */ 248 - if (!(link->state & DEV_CONFIG)) 248 + if (pcmcia_dev_present(link)) 249 249 return -ENODEV; 250 250 251 251 /* Save original COR value */ ··· 253 253 reg.Action = CS_READ; 254 254 reg.Offset = CISREG_COR; 255 255 CS_CHECK(AccessConfigurationRegister, 256 - pcmcia_access_configuration_register(link->handle, &reg)); 256 + pcmcia_access_configuration_register(link, &reg)); 257 257 save_cor = reg.Value; 258 258 259 259 /* Soft-Reset card */ ··· 261 261 reg.Offset = CISREG_COR; 262 262 reg.Value = (save_cor | COR_SOFT_RESET); 263 263 CS_CHECK(AccessConfigurationRegister, 264 - pcmcia_access_configuration_register(link->handle, &reg)); 264 + pcmcia_access_configuration_register(link, &reg)); 265 265 udelay(1000); 266 266 267 267 /* Read CCSR */ 268 268 reg.Action = CS_READ; 269 269 reg.Offset = CISREG_CCSR; 270 270 CS_CHECK(AccessConfigurationRegister, 271 - pcmcia_access_configuration_register(link->handle, &reg)); 271 + pcmcia_access_configuration_register(link, &reg)); 272 272 273 273 /* 274 274 * Start or stop the firmware. Memory width bit should be ··· 278 278 reg.Offset = CISREG_CCSR; 279 279 reg.Value = (idle ? HCR_IDLE : HCR_RUN) | (reg.Value & HCR_MEM16); 280 280 CS_CHECK(AccessConfigurationRegister, 281 - pcmcia_access_configuration_register(link->handle, &reg)); 281 + pcmcia_access_configuration_register(link, &reg)); 282 282 udelay(1000); 283 283 284 284 /* Restore original COR configuration index */ ··· 286 286 reg.Offset = CISREG_COR; 287 287 reg.Value = (save_cor & ~COR_SOFT_RESET); 288 288 CS_CHECK(AccessConfigurationRegister, 289 - pcmcia_access_configuration_register(link->handle, &reg)); 289 + pcmcia_access_configuration_register(link, &reg)); 290 290 udelay(1000); 291 291 return 0; 292 292 293 293 cs_failed: 294 - cs_error(link->handle, last_fn, last_ret); 294 + cs_error(link, last_fn, last_ret); 295 295 return -ENODEV; 296 296 } 297 297 ··· 441 441 * care of the PDA - read it and then write it on top of the firmware. 442 442 */ 443 443 static int 444 - spectrum_dl_image(hermes_t *hw, dev_link_t *link, 444 + spectrum_dl_image(hermes_t *hw, struct pcmcia_device *link, 445 445 const unsigned char *image) 446 446 { 447 447 int ret; ··· 505 505 * reset on the card, to make sure it's in a sane state. 506 506 */ 507 507 static int 508 - spectrum_dl_firmware(hermes_t *hw, dev_link_t *link) 508 + spectrum_dl_firmware(hermes_t *hw, struct pcmcia_device *link) 509 509 { 510 510 int ret; 511 - client_handle_t handle = link->handle; 512 511 const struct firmware *fw_entry; 513 512 514 513 if (request_firmware(&fw_entry, primary_fw_name, 515 - &handle_to_dev(handle)) == 0) { 514 + &handle_to_dev(link)) == 0) { 516 515 primsym = fw_entry->data; 517 516 } else { 518 517 printk(KERN_ERR PFX "Cannot find firmware: %s\n", ··· 520 521 } 521 522 522 523 if (request_firmware(&fw_entry, secondary_fw_name, 523 - &handle_to_dev(handle)) == 0) { 524 + &handle_to_dev(link)) == 0) { 524 525 secsym = fw_entry->data; 525 526 } else { 526 527 printk(KERN_ERR PFX "Cannot find firmware: %s\n", ··· 553 554 spectrum_cs_hard_reset(struct orinoco_private *priv) 554 555 { 555 556 struct orinoco_pccard *card = priv->card; 556 - dev_link_t *link = &card->link; 557 + struct pcmcia_device *link = card->p_dev; 557 558 int err; 558 559 559 560 if (!hermes_present(&priv->hw)) { 560 561 /* The firmware needs to be reloaded */ 561 - if (spectrum_dl_firmware(&priv->hw, &card->link) != 0) { 562 + if (spectrum_dl_firmware(&priv->hw, link) != 0) { 562 563 printk(KERN_ERR PFX "Firmware download failed\n"); 563 564 err = -ENODEV; 564 565 } ··· 583 584 * configure the card at this point -- we wait until we receive a card 584 585 * insertion event. */ 585 586 static int 586 - spectrum_cs_attach(struct pcmcia_device *p_dev) 587 + spectrum_cs_probe(struct pcmcia_device *link) 587 588 { 588 589 struct net_device *dev; 589 590 struct orinoco_private *priv; 590 591 struct orinoco_pccard *card; 591 - dev_link_t *link; 592 592 593 593 dev = alloc_orinocodev(sizeof(*card), spectrum_cs_hard_reset); 594 594 if (! dev) ··· 596 598 card = priv->card; 597 599 598 600 /* Link both structures together */ 599 - link = &card->link; 601 + card->p_dev = link; 600 602 link->priv = dev; 601 603 602 604 /* Interrupt setup */ ··· 613 615 link->conf.Attributes = 0; 614 616 link->conf.IntType = INT_MEMORY_AND_IO; 615 617 616 - link->handle = p_dev; 617 - p_dev->instance = link; 618 - 619 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 620 - spectrum_cs_config(link); 621 - 622 - return 0; 618 + return spectrum_cs_config(link); 623 619 } /* spectrum_cs_attach */ 624 620 625 621 /* ··· 622 630 * are freed. Otherwise, the structures will be freed when the device 623 631 * is released. 624 632 */ 625 - static void spectrum_cs_detach(struct pcmcia_device *p_dev) 633 + static void spectrum_cs_detach(struct pcmcia_device *link) 626 634 { 627 - dev_link_t *link = dev_to_instance(p_dev); 628 635 struct net_device *dev = link->priv; 629 636 630 - if (link->state & DEV_CONFIG) 631 - spectrum_cs_release(link); 637 + spectrum_cs_release(link); 632 638 633 - DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); 634 - if (link->dev) { 639 + DEBUG(0, PFX "detach: link=%p link->dev_node=%p\n", link, link->dev_node); 640 + if (link->dev_node) { 635 641 DEBUG(0, PFX "About to unregister net device %p\n", 636 642 dev); 637 643 unregister_netdev(dev); ··· 643 653 * device available to the system. 644 654 */ 645 655 646 - static void 647 - spectrum_cs_config(dev_link_t *link) 656 + static int 657 + spectrum_cs_config(struct pcmcia_device *link) 648 658 { 649 659 struct net_device *dev = link->priv; 650 - client_handle_t handle = link->handle; 651 660 struct orinoco_private *priv = netdev_priv(dev); 652 661 struct orinoco_pccard *card = priv->card; 653 662 hermes_t *hw = &priv->hw; ··· 658 669 cisparse_t parse; 659 670 void __iomem *mem; 660 671 661 - CS_CHECK(ValidateCIS, pcmcia_validate_cis(handle, &info)); 672 + CS_CHECK(ValidateCIS, pcmcia_validate_cis(link, &info)); 662 673 663 674 /* 664 675 * This reads the card's CONFIG tuple to find its ··· 669 680 tuple.TupleData = buf; 670 681 tuple.TupleDataMax = sizeof(buf); 671 682 tuple.TupleOffset = 0; 672 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 673 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 674 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 683 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 684 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 685 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 675 686 link->conf.ConfigBase = parse.config.base; 676 687 link->conf.Present = parse.config.rmask[0]; 677 688 678 - /* Configure card */ 679 - link->state |= DEV_CONFIG; 680 - 681 689 /* Look up the current Vcc */ 682 690 CS_CHECK(GetConfigurationInfo, 683 - pcmcia_get_configuration_info(handle, &conf)); 684 - link->conf.Vcc = conf.Vcc; 691 + pcmcia_get_configuration_info(link, &conf)); 685 692 686 693 /* 687 694 * In this loop, we scan the CIS for configuration table ··· 694 709 * implementation-defined details. 695 710 */ 696 711 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 697 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 712 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 698 713 while (1) { 699 714 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 700 715 cistpl_cftable_entry_t dflt = { .index = 0 }; 701 716 702 - if ( (pcmcia_get_tuple_data(handle, &tuple) != 0) 703 - || (pcmcia_parse_tuple(handle, &tuple, &parse) != 0)) 717 + if ( (pcmcia_get_tuple_data(link, &tuple) != 0) 718 + || (pcmcia_parse_tuple(link, &tuple, &parse) != 0)) 704 719 goto next_entry; 705 720 706 721 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) ··· 732 747 } 733 748 734 749 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 735 - link->conf.Vpp1 = link->conf.Vpp2 = 750 + link->conf.Vpp = 736 751 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 737 752 else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) 738 - link->conf.Vpp1 = link->conf.Vpp2 = 753 + link->conf.Vpp = 739 754 dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; 740 755 741 756 /* Do we need to allocate an interrupt? */ ··· 765 780 } 766 781 767 782 /* This reserves IO space but doesn't actually enable it */ 768 - if (pcmcia_request_io(link->handle, &link->io) != 0) 783 + if (pcmcia_request_io(link, &link->io) != 0) 769 784 goto next_entry; 770 785 } 771 786 ··· 775 790 break; 776 791 777 792 next_entry: 778 - if (link->io.NumPorts1) 779 - pcmcia_release_io(link->handle, &link->io); 780 - last_ret = pcmcia_get_next_tuple(handle, &tuple); 793 + pcmcia_disable_device(link); 794 + last_ret = pcmcia_get_next_tuple(link, &tuple); 781 795 if (last_ret == CS_NO_MORE_ITEMS) { 782 796 printk(KERN_ERR PFX "GetNextTuple(): No matching " 783 797 "CIS configuration. Maybe you need the " ··· 790 806 * a handler to the interrupt, unless the 'Handler' member of 791 807 * the irq structure is initialized. 792 808 */ 793 - CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 809 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 794 810 795 811 /* We initialize the hermes structure before completing PCMCIA 796 812 * configuration just in case the interrupt handler gets ··· 807 823 * card and host interface into "Memory and IO" mode. 808 824 */ 809 825 CS_CHECK(RequestConfiguration, 810 - pcmcia_request_configuration(link->handle, &link->conf)); 826 + pcmcia_request_configuration(link, &link->conf)); 811 827 812 828 /* Ok, we have the configuration, prepare to register the netdev */ 813 829 dev->base_addr = link->io.BasePort1; ··· 820 836 goto failed; 821 837 } 822 838 823 - SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 839 + SET_NETDEV_DEV(dev, &handle_to_dev(link)); 824 840 /* Tell the stack we exist */ 825 841 if (register_netdev(dev) != 0) { 826 842 printk(KERN_ERR PFX "register_netdev() failed\n"); ··· 828 844 } 829 845 830 846 /* At this point, the dev_node_t structure(s) needs to be 831 - * initialized and arranged in a linked list at link->dev. */ 847 + * initialized and arranged in a linked list at link->dev_node. */ 832 848 strcpy(card->node.dev_name, dev->name); 833 - link->dev = &card->node; /* link->dev being non-NULL is also 849 + link->dev_node = &card->node; /* link->dev_node being non-NULL is also 834 850 used to indicate that the 835 851 net_device has been registered */ 836 - link->state &= ~DEV_CONFIG_PENDING; 837 852 838 853 /* Finally, report what we've done */ 839 - printk(KERN_DEBUG "%s: index 0x%02x: Vcc %d.%d", 840 - dev->name, link->conf.ConfigIndex, 841 - link->conf.Vcc / 10, link->conf.Vcc % 10); 842 - if (link->conf.Vpp1) 843 - printk(", Vpp %d.%d", link->conf.Vpp1 / 10, 844 - link->conf.Vpp1 % 10); 854 + printk(KERN_DEBUG "%s: index 0x%02x: ", 855 + dev->name, link->conf.ConfigIndex); 856 + if (link->conf.Vpp) 857 + printk(", Vpp %d.%d", link->conf.Vpp / 10, 858 + link->conf.Vpp % 10); 845 859 printk(", irq %d", link->irq.AssignedIRQ); 846 860 if (link->io.NumPorts1) 847 861 printk(", io 0x%04x-0x%04x", link->io.BasePort1, ··· 849 867 link->io.BasePort2 + link->io.NumPorts2 - 1); 850 868 printk("\n"); 851 869 852 - return; 870 + return 0; 853 871 854 872 cs_failed: 855 - cs_error(link->handle, last_fn, last_ret); 873 + cs_error(link, last_fn, last_ret); 856 874 857 875 failed: 858 876 spectrum_cs_release(link); 877 + return -ENODEV; 859 878 } /* spectrum_cs_config */ 860 879 861 880 /* ··· 865 882 * still open, this will be postponed until it is closed. 866 883 */ 867 884 static void 868 - spectrum_cs_release(dev_link_t *link) 885 + spectrum_cs_release(struct pcmcia_device *link) 869 886 { 870 887 struct net_device *dev = link->priv; 871 888 struct orinoco_private *priv = netdev_priv(dev); ··· 877 894 priv->hw_unavailable++; 878 895 spin_unlock_irqrestore(&priv->lock, flags); 879 896 880 - /* Don't bother checking to see if these succeed or not */ 881 - pcmcia_release_configuration(link->handle); 882 - if (link->io.NumPorts1) 883 - pcmcia_release_io(link->handle, &link->io); 884 - if (link->irq.AssignedIRQ) 885 - pcmcia_release_irq(link->handle, &link->irq); 886 - link->state &= ~DEV_CONFIG; 897 + pcmcia_disable_device(link); 887 898 if (priv->hw.iobase) 888 899 ioport_unmap(priv->hw.iobase); 889 900 } /* spectrum_cs_release */ 890 901 891 902 892 903 static int 893 - spectrum_cs_suspend(struct pcmcia_device *p_dev) 904 + spectrum_cs_suspend(struct pcmcia_device *link) 894 905 { 895 - dev_link_t *link = dev_to_instance(p_dev); 896 906 struct net_device *dev = link->priv; 897 907 struct orinoco_private *priv = netdev_priv(dev); 898 908 unsigned long flags; 899 909 int err = 0; 900 910 901 - link->state |= DEV_SUSPEND; 902 911 /* Mark the device as stopped, to block IO until later */ 903 - if (link->state & DEV_CONFIG) { 904 - spin_lock_irqsave(&priv->lock, flags); 912 + spin_lock_irqsave(&priv->lock, flags); 905 913 906 - err = __orinoco_down(dev); 907 - if (err) 908 - printk(KERN_WARNING "%s: Error %d downing interface\n", 909 - dev->name, err); 914 + err = __orinoco_down(dev); 915 + if (err) 916 + printk(KERN_WARNING "%s: Error %d downing interface\n", 917 + dev->name, err); 910 918 911 - netif_device_detach(dev); 912 - priv->hw_unavailable++; 919 + netif_device_detach(dev); 920 + priv->hw_unavailable++; 913 921 914 - spin_unlock_irqrestore(&priv->lock, flags); 915 - 916 - pcmcia_release_configuration(link->handle); 917 - } 922 + spin_unlock_irqrestore(&priv->lock, flags); 918 923 919 924 return 0; 920 925 } 921 926 922 927 static int 923 - spectrum_cs_resume(struct pcmcia_device *p_dev) 928 + spectrum_cs_resume(struct pcmcia_device *link) 924 929 { 925 - dev_link_t *link = dev_to_instance(p_dev); 926 930 struct net_device *dev = link->priv; 927 931 struct orinoco_private *priv = netdev_priv(dev); 928 932 929 - link->state &= ~DEV_SUSPEND; 930 - if (link->state & DEV_CONFIG) { 931 - /* FIXME: should we double check that this is 932 - * the same card as we had before */ 933 - pcmcia_request_configuration(link->handle, &link->conf); 934 - netif_device_attach(dev); 935 - priv->hw_unavailable--; 936 - schedule_work(&priv->reset_work); 937 - } 933 + netif_device_attach(dev); 934 + priv->hw_unavailable--; 935 + schedule_work(&priv->reset_work); 936 + 938 937 return 0; 939 938 } 940 939 ··· 944 979 .drv = { 945 980 .name = DRIVER_NAME, 946 981 }, 947 - .probe = spectrum_cs_attach, 982 + .probe = spectrum_cs_probe, 948 983 .remove = spectrum_cs_detach, 949 984 .suspend = spectrum_cs_suspend, 950 985 .resume = spectrum_cs_resume,
+72 -117
drivers/net/wireless/wavelan_cs.c
··· 1005 1005 wv_82593_reconfig(struct net_device * dev) 1006 1006 { 1007 1007 net_local * lp = netdev_priv(dev); 1008 - dev_link_t * link = lp->link; 1008 + struct pcmcia_device * link = lp->link; 1009 1009 unsigned long flags; 1010 1010 1011 1011 /* Arm the flag, will be cleard in wv_82593_config() */ ··· 3744 3744 { 3745 3745 int i; 3746 3746 conf_reg_t reg = { 0, CS_READ, CISREG_COR, 0 }; 3747 - dev_link_t * link = ((net_local *)netdev_priv(dev))->link; 3747 + struct pcmcia_device * link = ((net_local *)netdev_priv(dev))->link; 3748 3748 3749 3749 #ifdef DEBUG_CONFIG_TRACE 3750 3750 printk(KERN_DEBUG "%s: ->wv_pcmcia_reset()\n", dev->name); 3751 3751 #endif 3752 3752 3753 - i = pcmcia_access_configuration_register(link->handle, &reg); 3753 + i = pcmcia_access_configuration_register(link, &reg); 3754 3754 if(i != CS_SUCCESS) 3755 3755 { 3756 - cs_error(link->handle, AccessConfigurationRegister, i); 3756 + cs_error(link, AccessConfigurationRegister, i); 3757 3757 return FALSE; 3758 3758 } 3759 3759 ··· 3764 3764 3765 3765 reg.Action = CS_WRITE; 3766 3766 reg.Value = reg.Value | COR_SW_RESET; 3767 - i = pcmcia_access_configuration_register(link->handle, &reg); 3767 + i = pcmcia_access_configuration_register(link, &reg); 3768 3768 if(i != CS_SUCCESS) 3769 3769 { 3770 - cs_error(link->handle, AccessConfigurationRegister, i); 3770 + cs_error(link, AccessConfigurationRegister, i); 3771 3771 return FALSE; 3772 3772 } 3773 3773 3774 3774 reg.Action = CS_WRITE; 3775 3775 reg.Value = COR_LEVEL_IRQ | COR_CONFIG; 3776 - i = pcmcia_access_configuration_register(link->handle, &reg); 3776 + i = pcmcia_access_configuration_register(link, &reg); 3777 3777 if(i != CS_SUCCESS) 3778 3778 { 3779 - cs_error(link->handle, AccessConfigurationRegister, i); 3779 + cs_error(link, AccessConfigurationRegister, i); 3780 3780 return FALSE; 3781 3781 } 3782 3782 ··· 3940 3940 * (called by wavelan_event()) 3941 3941 */ 3942 3942 static inline int 3943 - wv_pcmcia_config(dev_link_t * link) 3943 + wv_pcmcia_config(struct pcmcia_device * link) 3944 3944 { 3945 - client_handle_t handle = link->handle; 3946 3945 tuple_t tuple; 3947 3946 cisparse_t parse; 3948 3947 struct net_device * dev = (struct net_device *) link->priv; ··· 3964 3965 { 3965 3966 tuple.Attributes = 0; 3966 3967 tuple.DesiredTuple = CISTPL_CONFIG; 3967 - i = pcmcia_get_first_tuple(handle, &tuple); 3968 + i = pcmcia_get_first_tuple(link, &tuple); 3968 3969 if(i != CS_SUCCESS) 3969 3970 break; 3970 3971 tuple.TupleData = (cisdata_t *)buf; 3971 3972 tuple.TupleDataMax = 64; 3972 3973 tuple.TupleOffset = 0; 3973 - i = pcmcia_get_tuple_data(handle, &tuple); 3974 + i = pcmcia_get_tuple_data(link, &tuple); 3974 3975 if(i != CS_SUCCESS) 3975 3976 break; 3976 - i = pcmcia_parse_tuple(handle, &tuple, &parse); 3977 + i = pcmcia_parse_tuple(link, &tuple, &parse); 3977 3978 if(i != CS_SUCCESS) 3978 3979 break; 3979 3980 link->conf.ConfigBase = parse.config.base; ··· 3982 3983 while(0); 3983 3984 if(i != CS_SUCCESS) 3984 3985 { 3985 - cs_error(link->handle, ParseTuple, i); 3986 - link->state &= ~DEV_CONFIG_PENDING; 3986 + cs_error(link, ParseTuple, i); 3987 3987 return FALSE; 3988 3988 } 3989 - 3990 - /* Configure card */ 3991 - link->state |= DEV_CONFIG; 3989 + 3992 3990 do 3993 3991 { 3994 - i = pcmcia_request_io(link->handle, &link->io); 3992 + i = pcmcia_request_io(link, &link->io); 3995 3993 if(i != CS_SUCCESS) 3996 3994 { 3997 - cs_error(link->handle, RequestIO, i); 3995 + cs_error(link, RequestIO, i); 3998 3996 break; 3999 3997 } 4000 3998 ··· 3999 4003 * Now allocate an interrupt line. Note that this does not 4000 4004 * actually assign a handler to the interrupt. 4001 4005 */ 4002 - i = pcmcia_request_irq(link->handle, &link->irq); 4006 + i = pcmcia_request_irq(link, &link->irq); 4003 4007 if(i != CS_SUCCESS) 4004 4008 { 4005 - cs_error(link->handle, RequestIRQ, i); 4009 + cs_error(link, RequestIRQ, i); 4006 4010 break; 4007 4011 } 4008 4012 ··· 4011 4015 * the I/O windows and the interrupt mapping. 4012 4016 */ 4013 4017 link->conf.ConfigIndex = 1; 4014 - i = pcmcia_request_configuration(link->handle, &link->conf); 4018 + i = pcmcia_request_configuration(link, &link->conf); 4015 4019 if(i != CS_SUCCESS) 4016 4020 { 4017 - cs_error(link->handle, RequestConfiguration, i); 4021 + cs_error(link, RequestConfiguration, i); 4018 4022 break; 4019 4023 } 4020 4024 4021 4025 /* 4022 - * Allocate a small memory window. Note that the dev_link_t 4026 + * Allocate a small memory window. Note that the struct pcmcia_device 4023 4027 * structure provides space for one window handle -- if your 4024 4028 * device needs several windows, you'll need to keep track of 4025 4029 * the handles in your private data structure, link->priv. ··· 4027 4031 req.Attributes = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 4028 4032 req.Base = req.Size = 0; 4029 4033 req.AccessSpeed = mem_speed; 4030 - i = pcmcia_request_window(&link->handle, &req, &link->win); 4034 + i = pcmcia_request_window(&link, &req, &link->win); 4031 4035 if(i != CS_SUCCESS) 4032 4036 { 4033 - cs_error(link->handle, RequestWindow, i); 4037 + cs_error(link, RequestWindow, i); 4034 4038 break; 4035 4039 } 4036 4040 ··· 4042 4046 i = pcmcia_map_mem_page(link->win, &mem); 4043 4047 if(i != CS_SUCCESS) 4044 4048 { 4045 - cs_error(link->handle, MapMemPage, i); 4049 + cs_error(link, MapMemPage, i); 4046 4050 break; 4047 4051 } 4048 4052 ··· 4056 4060 lp->mem, dev->irq, (u_int) dev->base_addr); 4057 4061 #endif 4058 4062 4059 - SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 4063 + SET_NETDEV_DEV(dev, &handle_to_dev(link)); 4060 4064 i = register_netdev(dev); 4061 4065 if(i != 0) 4062 4066 { ··· 4068 4072 } 4069 4073 while(0); /* Humm... Disguised goto !!! */ 4070 4074 4071 - link->state &= ~DEV_CONFIG_PENDING; 4072 4075 /* If any step failed, release any partially configured state */ 4073 4076 if(i != 0) 4074 4077 { ··· 4076 4081 } 4077 4082 4078 4083 strcpy(((net_local *) netdev_priv(dev))->node.dev_name, dev->name); 4079 - link->dev = &((net_local *) netdev_priv(dev))->node; 4084 + link->dev_node = &((net_local *) netdev_priv(dev))->node; 4080 4085 4081 4086 #ifdef DEBUG_CONFIG_TRACE 4082 4087 printk(KERN_DEBUG "<-wv_pcmcia_config()\n"); ··· 4091 4096 * still open, this will be postponed until it is closed. 4092 4097 */ 4093 4098 static void 4094 - wv_pcmcia_release(dev_link_t *link) 4099 + wv_pcmcia_release(struct pcmcia_device *link) 4095 4100 { 4096 - struct net_device * dev = (struct net_device *) link->priv; 4097 - net_local * lp = netdev_priv(dev); 4101 + struct net_device * dev = (struct net_device *) link->priv; 4102 + net_local * lp = netdev_priv(dev); 4098 4103 4099 4104 #ifdef DEBUG_CONFIG_TRACE 4100 - printk(KERN_DEBUG "%s: -> wv_pcmcia_release(0x%p)\n", dev->name, link); 4105 + printk(KERN_DEBUG "%s: -> wv_pcmcia_release(0x%p)\n", dev->name, link); 4101 4106 #endif 4102 4107 4103 - /* Don't bother checking to see if these succeed or not */ 4104 - iounmap(lp->mem); 4105 - pcmcia_release_window(link->win); 4106 - pcmcia_release_configuration(link->handle); 4107 - pcmcia_release_io(link->handle, &link->io); 4108 - pcmcia_release_irq(link->handle, &link->irq); 4109 - 4110 - link->state &= ~DEV_CONFIG; 4108 + iounmap(lp->mem); 4109 + pcmcia_disable_device(link); 4111 4110 4112 4111 #ifdef DEBUG_CONFIG_TRACE 4113 - printk(KERN_DEBUG "%s: <- wv_pcmcia_release()\n", dev->name); 4112 + printk(KERN_DEBUG "%s: <- wv_pcmcia_release()\n", dev->name); 4114 4113 #endif 4115 4114 } 4116 4115 ··· 4468 4479 wavelan_open(struct net_device * dev) 4469 4480 { 4470 4481 net_local * lp = netdev_priv(dev); 4471 - dev_link_t * link = lp->link; 4482 + struct pcmcia_device * link = lp->link; 4472 4483 kio_addr_t base = dev->base_addr; 4473 4484 4474 4485 #ifdef DEBUG_CALLBACK_TRACE ··· 4522 4533 static int 4523 4534 wavelan_close(struct net_device * dev) 4524 4535 { 4525 - dev_link_t * link = ((net_local *)netdev_priv(dev))->link; 4536 + struct pcmcia_device * link = ((net_local *)netdev_priv(dev))->link; 4526 4537 kio_addr_t base = dev->base_addr; 4527 4538 4528 4539 #ifdef DEBUG_CALLBACK_TRACE ··· 4576 4587 * card insertion event. 4577 4588 */ 4578 4589 static int 4579 - wavelan_attach(struct pcmcia_device *p_dev) 4590 + wavelan_probe(struct pcmcia_device *p_dev) 4580 4591 { 4581 - dev_link_t * link; /* Info for cardmgr */ 4582 4592 struct net_device * dev; /* Interface generic data */ 4583 4593 net_local * lp; /* Interface specific data */ 4594 + int ret; 4584 4595 4585 4596 #ifdef DEBUG_CALLBACK_TRACE 4586 4597 printk(KERN_DEBUG "-> wavelan_attach()\n"); 4587 4598 #endif 4588 4599 4589 - /* Initialize the dev_link_t structure */ 4590 - link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); 4591 - if (!link) return -ENOMEM; 4592 - 4593 4600 /* The io structure describes IO port mapping */ 4594 - link->io.NumPorts1 = 8; 4595 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 4596 - link->io.IOAddrLines = 3; 4601 + p_dev->io.NumPorts1 = 8; 4602 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 4603 + p_dev->io.IOAddrLines = 3; 4597 4604 4598 4605 /* Interrupt setup */ 4599 - link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; 4600 - link->irq.IRQInfo1 = IRQ_LEVEL_ID; 4601 - link->irq.Handler = wavelan_interrupt; 4606 + p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; 4607 + p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; 4608 + p_dev->irq.Handler = wavelan_interrupt; 4602 4609 4603 4610 /* General socket configuration */ 4604 - link->conf.Attributes = CONF_ENABLE_IRQ; 4605 - link->conf.Vcc = 50; 4606 - link->conf.IntType = INT_MEMORY_AND_IO; 4607 - 4608 - /* Chain drivers */ 4609 - link->next = NULL; 4611 + p_dev->conf.Attributes = CONF_ENABLE_IRQ; 4612 + p_dev->conf.IntType = INT_MEMORY_AND_IO; 4610 4613 4611 4614 /* Allocate the generic data structure */ 4612 4615 dev = alloc_etherdev(sizeof(net_local)); 4613 - if (!dev) { 4614 - kfree(link); 4616 + if (!dev) 4615 4617 return -ENOMEM; 4616 - } 4617 - link->priv = link->irq.Instance = dev; 4618 + 4619 + p_dev->priv = p_dev->irq.Instance = dev; 4618 4620 4619 4621 lp = netdev_priv(dev); 4620 4622 ··· 4622 4642 spin_lock_init(&lp->spinlock); 4623 4643 4624 4644 /* back links */ 4625 - lp->link = link; 4626 4645 lp->dev = dev; 4627 4646 4628 4647 /* wavelan NET3 callbacks */ ··· 4647 4668 /* Other specific data */ 4648 4669 dev->mtu = WAVELAN_MTU; 4649 4670 4650 - link->handle = p_dev; 4651 - p_dev->instance = link; 4671 + ret = wv_pcmcia_config(p_dev); 4672 + if (ret) 4673 + return ret; 4652 4674 4653 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 4654 - if(wv_pcmcia_config(link) && 4655 - wv_hw_config(dev)) 4656 - wv_init_info(dev); 4657 - else 4675 + ret = wv_hw_config(dev); 4676 + if (ret) { 4658 4677 dev->irq = 0; 4678 + pcmcia_disable_device(p_dev); 4679 + return ret; 4680 + } 4681 + 4682 + wv_init_info(dev); 4659 4683 4660 4684 #ifdef DEBUG_CALLBACK_TRACE 4661 4685 printk(KERN_DEBUG "<- wavelan_attach()\n"); ··· 4675 4693 * is released. 4676 4694 */ 4677 4695 static void 4678 - wavelan_detach(struct pcmcia_device *p_dev) 4696 + wavelan_detach(struct pcmcia_device *link) 4679 4697 { 4680 - dev_link_t *link = dev_to_instance(p_dev); 4681 - 4682 4698 #ifdef DEBUG_CALLBACK_TRACE 4683 4699 printk(KERN_DEBUG "-> wavelan_detach(0x%p)\n", link); 4684 4700 #endif 4685 4701 4686 - /* 4687 - * If the device is currently configured and active, we won't 4688 - * actually delete it yet. Instead, it is marked so that when the 4689 - * release() function is called, that will trigger a proper 4690 - * detach(). 4691 - */ 4692 - if(link->state & DEV_CONFIG) 4693 - { 4694 - /* Some others haven't done their job : give them another chance */ 4695 - wv_pcmcia_release(link); 4696 - } 4702 + /* Some others haven't done their job : give them another chance */ 4703 + wv_pcmcia_release(link); 4697 4704 4698 4705 /* Free pieces */ 4699 4706 if(link->priv) ··· 4691 4720 4692 4721 /* Remove ourselves from the kernel list of ethernet devices */ 4693 4722 /* Warning : can't be called from interrupt, timer or wavelan_close() */ 4694 - if (link->dev) 4723 + if (link->dev_node) 4695 4724 unregister_netdev(dev); 4696 - link->dev = NULL; 4725 + link->dev_node = NULL; 4697 4726 ((net_local *)netdev_priv(dev))->link = NULL; 4698 4727 ((net_local *)netdev_priv(dev))->dev = NULL; 4699 4728 free_netdev(dev); 4700 4729 } 4701 - kfree(link); 4702 4730 4703 4731 #ifdef DEBUG_CALLBACK_TRACE 4704 4732 printk(KERN_DEBUG "<- wavelan_detach()\n"); 4705 4733 #endif 4706 4734 } 4707 4735 4708 - static int wavelan_suspend(struct pcmcia_device *p_dev) 4736 + static int wavelan_suspend(struct pcmcia_device *link) 4709 4737 { 4710 - dev_link_t *link = dev_to_instance(p_dev); 4711 4738 struct net_device * dev = (struct net_device *) link->priv; 4712 4739 4713 4740 /* NB: wavelan_close will be called, but too late, so we are ··· 4717 4748 /* Stop receiving new messages and wait end of transmission */ 4718 4749 wv_ru_stop(dev); 4719 4750 4751 + if (link->open) 4752 + netif_device_detach(dev); 4753 + 4720 4754 /* Power down the module */ 4721 4755 hacr_write(dev->base_addr, HACR_DEFAULT & (~HACR_PWR_STAT)); 4722 - 4723 - /* The card is now suspended */ 4724 - link->state |= DEV_SUSPEND; 4725 - 4726 - if(link->state & DEV_CONFIG) 4727 - { 4728 - if(link->open) 4729 - netif_device_detach(dev); 4730 - pcmcia_release_configuration(link->handle); 4731 - } 4732 4756 4733 4757 return 0; 4734 4758 } 4735 4759 4736 - static int wavelan_resume(struct pcmcia_device *p_dev) 4760 + static int wavelan_resume(struct pcmcia_device *link) 4737 4761 { 4738 - dev_link_t *link = dev_to_instance(p_dev); 4739 4762 struct net_device * dev = (struct net_device *) link->priv; 4740 4763 4741 - link->state &= ~DEV_SUSPEND; 4742 - if(link->state & DEV_CONFIG) 4743 - { 4744 - pcmcia_request_configuration(link->handle, &link->conf); 4745 - if(link->open) /* If RESET -> True, If RESUME -> False ? */ 4746 - { 4747 - wv_hw_reset(dev); 4748 - netif_device_attach(dev); 4749 - } 4764 + if (link->open) { 4765 + wv_hw_reset(dev); 4766 + netif_device_attach(dev); 4750 4767 } 4751 4768 4752 4769 return 0; ··· 4753 4798 .drv = { 4754 4799 .name = "wavelan_cs", 4755 4800 }, 4756 - .probe = wavelan_attach, 4801 + .probe = wavelan_probe, 4757 4802 .remove = wavelan_detach, 4758 4803 .id_table = wavelan_ids, 4759 4804 .suspend = wavelan_suspend,
+3 -3
drivers/net/wireless/wavelan_cs.p.h
··· 602 602 dev_node_t node; /* ???? What is this stuff ???? */ 603 603 struct net_device * dev; /* Reverse link... */ 604 604 spinlock_t spinlock; /* Serialize access to the hardware (SMP) */ 605 - dev_link_t * link; /* pcmcia structure */ 605 + struct pcmcia_device * link; /* pcmcia structure */ 606 606 en_stats stats; /* Ethernet interface statistics */ 607 607 int nresets; /* Number of hw resets */ 608 608 u_char configured; /* If it is configured */ ··· 733 733 static inline void 734 734 wv_hw_reset(struct net_device *); /* Same, + start receiver unit */ 735 735 static inline int 736 - wv_pcmcia_config(dev_link_t *); /* Configure the pcmcia interface */ 736 + wv_pcmcia_config(struct pcmcia_device *); /* Configure the pcmcia interface */ 737 737 static void 738 - wv_pcmcia_release(dev_link_t *);/* Remove a device */ 738 + wv_pcmcia_release(struct pcmcia_device *);/* Remove a device */ 739 739 /* ---------------------- INTERRUPT HANDLING ---------------------- */ 740 740 static irqreturn_t 741 741 wavelan_interrupt(int, /* Interrupt handler */
+1
drivers/net/wireless/wl3501.h
··· 611 611 struct iw_spy_data spy_data; 612 612 struct iw_public_data wireless_data; 613 613 struct dev_node_t node; 614 + struct pcmcia_device *p_dev; 614 615 }; 615 616 #endif
+53 -125
drivers/net/wireless/wl3501_cs.c
··· 103 103 * release a socket, in response to card insertion and ejection events. They 104 104 * are invoked from the wl24 event handler. 105 105 */ 106 - static void wl3501_config(dev_link_t *link); 107 - static void wl3501_release(dev_link_t *link); 106 + static int wl3501_config(struct pcmcia_device *link); 107 + static void wl3501_release(struct pcmcia_device *link); 108 108 109 109 /* 110 110 * The dev_info variable is the "key" that is used to match up this ··· 225 225 { 226 226 iw_set_mgmt_info_element(from->id, to, from->data, from->len); 227 227 } 228 - 229 - /* 230 - * A linked list of "instances" of the wl24 device. Each actual PCMCIA card 231 - * corresponds to one device instance, and is described by one dev_link_t 232 - * structure (defined in ds.h). 233 - * 234 - * You may not want to use a linked list for this -- for example, the memory 235 - * card driver uses an array of dev_link_t pointers, where minor device numbers 236 - * are used to derive the corresponding array index. 237 - */ 238 - static dev_link_t *wl3501_dev_list; 239 228 240 229 static inline void wl3501_switch_page(struct wl3501_card *this, u8 page) 241 230 { ··· 1270 1281 struct wl3501_card *this = dev->priv; 1271 1282 int rc = -ENODEV; 1272 1283 unsigned long flags; 1273 - dev_link_t *link; 1284 + struct pcmcia_device *link; 1285 + link = this->p_dev; 1274 1286 1275 1287 spin_lock_irqsave(&this->lock, flags); 1276 - /* Check if the device is in wl3501_dev_list */ 1277 - for (link = wl3501_dev_list; link; link = link->next) 1278 - if (link->priv == dev) 1279 - break; 1280 - if (!link) 1281 - goto out; 1282 1288 link->open--; 1283 1289 1284 1290 /* Stop wl3501_hard_start_xmit() from now on */ ··· 1285 1301 1286 1302 rc = 0; 1287 1303 printk(KERN_INFO "%s: WL3501 closed\n", dev->name); 1288 - out: 1289 1304 spin_unlock_irqrestore(&this->lock, flags); 1290 1305 return rc; 1291 1306 } ··· 1383 1400 int rc = -ENODEV; 1384 1401 struct wl3501_card *this = dev->priv; 1385 1402 unsigned long flags; 1386 - dev_link_t *link; 1403 + struct pcmcia_device *link; 1404 + link = this->p_dev; 1387 1405 1388 1406 spin_lock_irqsave(&this->lock, flags); 1389 - /* Check if the device is in wl3501_dev_list */ 1390 - for (link = wl3501_dev_list; link; link = link->next) 1391 - if (link->priv == dev) 1392 - break; 1393 - if (!DEV_OK(link)) 1407 + if (!pcmcia_dev_present(link)) 1394 1408 goto out; 1395 1409 netif_device_attach(dev); 1396 1410 link->open++; ··· 1477 1497 * Services. If it has been released, all local data structures are freed. 1478 1498 * Otherwise, the structures will be freed when the device is released. 1479 1499 */ 1480 - static void wl3501_detach(struct pcmcia_device *p_dev) 1500 + static void wl3501_detach(struct pcmcia_device *link) 1481 1501 { 1482 - dev_link_t *link = dev_to_instance(p_dev); 1483 - dev_link_t **linkp; 1484 1502 struct net_device *dev = link->priv; 1485 - 1486 - /* Locate device structure */ 1487 - for (linkp = &wl3501_dev_list; *linkp; linkp = &(*linkp)->next) 1488 - if (*linkp == link) 1489 - break; 1490 - if (!*linkp) 1491 - goto out; 1492 1503 1493 1504 /* If the device is currently configured and active, we won't actually 1494 1505 * delete it yet. Instead, it is marked so that when the release() 1495 1506 * function is called, that will trigger a proper detach(). */ 1496 1507 1497 - if (link->state & DEV_CONFIG) { 1498 - while (link->open > 0) 1499 - wl3501_close(dev); 1508 + while (link->open > 0) 1509 + wl3501_close(dev); 1500 1510 1501 - netif_device_detach(dev); 1502 - wl3501_release(link); 1503 - } 1504 - 1505 - /* Unlink device structure, free pieces */ 1506 - *linkp = link->next; 1511 + netif_device_detach(dev); 1512 + wl3501_release(link); 1507 1513 1508 1514 if (link->priv) 1509 1515 free_netdev(link->priv); 1510 - kfree(link); 1511 - out: 1516 + 1512 1517 return; 1513 1518 } 1514 1519 ··· 1918 1953 * The dev_link structure is initialized, but we don't actually configure the 1919 1954 * card at this point -- we wait until we receive a card insertion event. 1920 1955 */ 1921 - static int wl3501_attach(struct pcmcia_device *p_dev) 1956 + static int wl3501_probe(struct pcmcia_device *p_dev) 1922 1957 { 1923 - dev_link_t *link; 1924 1958 struct net_device *dev; 1925 1959 struct wl3501_card *this; 1926 1960 1927 - /* Initialize the dev_link_t structure */ 1928 - link = kzalloc(sizeof(*link), GFP_KERNEL); 1929 - if (!link) 1930 - return -ENOMEM; 1931 - 1932 1961 /* The io structure describes IO port mapping */ 1933 - link->io.NumPorts1 = 16; 1934 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 1935 - link->io.IOAddrLines = 5; 1962 + p_dev->io.NumPorts1 = 16; 1963 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 1964 + p_dev->io.IOAddrLines = 5; 1936 1965 1937 1966 /* Interrupt setup */ 1938 - link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; 1939 - link->irq.IRQInfo1 = IRQ_LEVEL_ID; 1940 - link->irq.Handler = wl3501_interrupt; 1967 + p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; 1968 + p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; 1969 + p_dev->irq.Handler = wl3501_interrupt; 1941 1970 1942 1971 /* General socket configuration */ 1943 - link->conf.Attributes = CONF_ENABLE_IRQ; 1944 - link->conf.Vcc = 50; 1945 - link->conf.IntType = INT_MEMORY_AND_IO; 1946 - link->conf.ConfigIndex = 1; 1947 - link->conf.Present = PRESENT_OPTION; 1972 + p_dev->conf.Attributes = CONF_ENABLE_IRQ; 1973 + p_dev->conf.IntType = INT_MEMORY_AND_IO; 1974 + p_dev->conf.ConfigIndex = 1; 1975 + p_dev->conf.Present = PRESENT_OPTION; 1948 1976 1949 1977 dev = alloc_etherdev(sizeof(struct wl3501_card)); 1950 1978 if (!dev) ··· 1950 1992 dev->get_stats = wl3501_get_stats; 1951 1993 this = dev->priv; 1952 1994 this->wireless_data.spy_data = &this->spy_data; 1995 + this->p_dev = p_dev; 1953 1996 dev->wireless_data = &this->wireless_data; 1954 1997 dev->wireless_handlers = (struct iw_handler_def *)&wl3501_handler_def; 1955 1998 SET_ETHTOOL_OPS(dev, &ops); 1956 1999 netif_stop_queue(dev); 1957 - link->priv = link->irq.Instance = dev; 2000 + p_dev->priv = p_dev->irq.Instance = dev; 1958 2001 1959 - link->handle = p_dev; 1960 - p_dev->instance = link; 1961 - 1962 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 1963 - wl3501_config(link); 1964 - 1965 - return 0; 2002 + return wl3501_config(p_dev); 1966 2003 out_link: 1967 - kfree(link); 1968 - link = NULL; 1969 2004 return -ENOMEM; 1970 2005 } 1971 2006 ··· 1973 2022 * received, to configure the PCMCIA socket, and to make the ethernet device 1974 2023 * available to the system. 1975 2024 */ 1976 - static void wl3501_config(dev_link_t *link) 2025 + static int wl3501_config(struct pcmcia_device *link) 1977 2026 { 1978 2027 tuple_t tuple; 1979 2028 cisparse_t parse; 1980 - client_handle_t handle = link->handle; 1981 2029 struct net_device *dev = link->priv; 1982 2030 int i = 0, j, last_fn, last_ret; 1983 2031 unsigned char bf[64]; ··· 1985 2035 /* This reads the card's CONFIG tuple to find its config registers. */ 1986 2036 tuple.Attributes = 0; 1987 2037 tuple.DesiredTuple = CISTPL_CONFIG; 1988 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 2038 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 1989 2039 tuple.TupleData = bf; 1990 2040 tuple.TupleDataMax = sizeof(bf); 1991 2041 tuple.TupleOffset = 0; 1992 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 1993 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 2042 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 2043 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 1994 2044 link->conf.ConfigBase = parse.config.base; 1995 2045 link->conf.Present = parse.config.rmask[0]; 1996 - 1997 - /* Configure card */ 1998 - link->state |= DEV_CONFIG; 1999 2046 2000 2047 /* Try allocating IO ports. This tries a few fixed addresses. If you 2001 2048 * want, you can also read the card's config table to pick addresses -- ··· 2003 2056 * 0x200-0x2ff, and so on, because this seems safer */ 2004 2057 link->io.BasePort1 = j; 2005 2058 link->io.BasePort2 = link->io.BasePort1 + 0x10; 2006 - i = pcmcia_request_io(link->handle, &link->io); 2059 + i = pcmcia_request_io(link, &link->io); 2007 2060 if (i == CS_SUCCESS) 2008 2061 break; 2009 2062 } 2010 2063 if (i != CS_SUCCESS) { 2011 - cs_error(link->handle, RequestIO, i); 2064 + cs_error(link, RequestIO, i); 2012 2065 goto failed; 2013 2066 } 2014 2067 2015 2068 /* Now allocate an interrupt line. Note that this does not actually 2016 2069 * assign a handler to the interrupt. */ 2017 2070 2018 - CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 2071 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 2019 2072 2020 2073 /* This actually configures the PCMCIA socket -- setting up the I/O 2021 2074 * windows and the interrupt mapping. */ 2022 2075 2023 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 2076 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 2024 2077 2025 2078 dev->irq = link->irq.AssignedIRQ; 2026 2079 dev->base_addr = link->io.BasePort1; 2027 - SET_NETDEV_DEV(dev, &handle_to_dev(handle)); 2080 + SET_NETDEV_DEV(dev, &handle_to_dev(link)); 2028 2081 if (register_netdev(dev)) { 2029 2082 printk(KERN_NOTICE "wl3501_cs: register_netdev() failed\n"); 2030 2083 goto failed; ··· 2035 2088 this = dev->priv; 2036 2089 /* 2037 2090 * At this point, the dev_node_t structure(s) should be initialized and 2038 - * arranged in a linked list at link->dev. 2091 + * arranged in a linked list at link->dev_node. 2039 2092 */ 2040 - link->dev = &this->node; 2041 - link->state &= ~DEV_CONFIG_PENDING; 2093 + link->dev_node = &this->node; 2042 2094 2043 2095 this->base_addr = dev->base_addr; 2044 2096 ··· 2073 2127 spin_lock_init(&this->lock); 2074 2128 init_waitqueue_head(&this->wait); 2075 2129 netif_start_queue(dev); 2076 - goto out; 2130 + return 0; 2131 + 2077 2132 cs_failed: 2078 - cs_error(link->handle, last_fn, last_ret); 2133 + cs_error(link, last_fn, last_ret); 2079 2134 failed: 2080 2135 wl3501_release(link); 2081 - out: 2082 - return; 2136 + return -ENODEV; 2083 2137 } 2084 2138 2085 2139 /** ··· 2090 2144 * and release the PCMCIA configuration. If the device is still open, this 2091 2145 * will be postponed until it is closed. 2092 2146 */ 2093 - static void wl3501_release(dev_link_t *link) 2147 + static void wl3501_release(struct pcmcia_device *link) 2094 2148 { 2095 2149 struct net_device *dev = link->priv; 2096 2150 2097 2151 /* Unlink the device chain */ 2098 - if (link->dev) { 2152 + if (link->dev_node) 2099 2153 unregister_netdev(dev); 2100 - link->dev = NULL; 2101 - } 2102 2154 2103 - /* Don't bother checking to see if these succeed or not */ 2104 - pcmcia_release_configuration(link->handle); 2105 - pcmcia_release_io(link->handle, &link->io); 2106 - pcmcia_release_irq(link->handle, &link->irq); 2107 - link->state &= ~DEV_CONFIG; 2155 + pcmcia_disable_device(link); 2108 2156 } 2109 2157 2110 - static int wl3501_suspend(struct pcmcia_device *p_dev) 2158 + static int wl3501_suspend(struct pcmcia_device *link) 2111 2159 { 2112 - dev_link_t *link = dev_to_instance(p_dev); 2113 2160 struct net_device *dev = link->priv; 2114 2161 2115 - link->state |= DEV_SUSPEND; 2116 - 2117 2162 wl3501_pwr_mgmt(dev->priv, WL3501_SUSPEND); 2118 - if (link->state & DEV_CONFIG) { 2119 - if (link->open) 2120 - netif_device_detach(dev); 2121 - pcmcia_release_configuration(link->handle); 2122 - } 2163 + if (link->open) 2164 + netif_device_detach(dev); 2123 2165 2124 2166 return 0; 2125 2167 } 2126 2168 2127 - static int wl3501_resume(struct pcmcia_device *p_dev) 2169 + static int wl3501_resume(struct pcmcia_device *link) 2128 2170 { 2129 - dev_link_t *link = dev_to_instance(p_dev); 2130 2171 struct net_device *dev = link->priv; 2131 2172 2132 2173 wl3501_pwr_mgmt(dev->priv, WL3501_RESUME); 2133 - if (link->state & DEV_CONFIG) { 2134 - pcmcia_request_configuration(link->handle, &link->conf); 2135 - if (link->open) { 2136 - wl3501_reset(dev); 2137 - netif_device_attach(dev); 2138 - } 2174 + if (link->open) { 2175 + wl3501_reset(dev); 2176 + netif_device_attach(dev); 2139 2177 } 2140 2178 2141 2179 return 0; ··· 2137 2207 .drv = { 2138 2208 .name = "wl3501_cs", 2139 2209 }, 2140 - .probe = wl3501_attach, 2210 + .probe = wl3501_probe, 2141 2211 .remove = wl3501_detach, 2142 2212 .id_table = wl3501_ids, 2143 2213 .suspend = wl3501_suspend, ··· 2151 2221 2152 2222 static void __exit wl3501_exit_module(void) 2153 2223 { 2154 - dprintk(0, ": unloading"); 2155 2224 pcmcia_unregister_driver(&wl3501_driver); 2156 - BUG_ON(wl3501_dev_list != NULL); 2157 2225 } 2158 2226 2159 2227 module_init(wl3501_init_module);
+36 -93
drivers/parport/parport_cs.c
··· 81 81 #define FORCE_EPP_MODE 0x08 82 82 83 83 typedef struct parport_info_t { 84 - dev_link_t link; 84 + struct pcmcia_device *p_dev; 85 85 int ndev; 86 86 dev_node_t node; 87 87 struct parport *port; 88 88 } parport_info_t; 89 89 90 90 static void parport_detach(struct pcmcia_device *p_dev); 91 - static void parport_config(dev_link_t *link); 92 - static void parport_cs_release(dev_link_t *); 91 + static int parport_config(struct pcmcia_device *link); 92 + static void parport_cs_release(struct pcmcia_device *); 93 93 94 94 /*====================================================================== 95 95 ··· 99 99 100 100 ======================================================================*/ 101 101 102 - static int parport_attach(struct pcmcia_device *p_dev) 102 + static int parport_probe(struct pcmcia_device *link) 103 103 { 104 104 parport_info_t *info; 105 - dev_link_t *link; 106 105 107 106 DEBUG(0, "parport_attach()\n"); 108 107 ··· 109 110 info = kmalloc(sizeof(*info), GFP_KERNEL); 110 111 if (!info) return -ENOMEM; 111 112 memset(info, 0, sizeof(*info)); 112 - link = &info->link; link->priv = info; 113 + link->priv = info; 114 + info->p_dev = link; 113 115 114 116 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 115 117 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 116 118 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 117 119 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 118 120 link->conf.Attributes = CONF_ENABLE_IRQ; 119 - link->conf.Vcc = 50; 120 121 link->conf.IntType = INT_MEMORY_AND_IO; 121 122 122 - link->handle = p_dev; 123 - p_dev->instance = link; 124 - 125 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 126 - parport_config(link); 127 - 128 - return 0; 123 + return parport_config(link); 129 124 } /* parport_attach */ 130 125 131 126 /*====================================================================== ··· 131 138 132 139 ======================================================================*/ 133 140 134 - static void parport_detach(struct pcmcia_device *p_dev) 141 + static void parport_detach(struct pcmcia_device *link) 135 142 { 136 - dev_link_t *link = dev_to_instance(p_dev); 137 - 138 143 DEBUG(0, "parport_detach(0x%p)\n", link); 139 144 140 - if (link->state & DEV_CONFIG) 141 - parport_cs_release(link); 145 + parport_cs_release(link); 142 146 143 147 kfree(link->priv); 144 148 } /* parport_detach */ ··· 151 161 #define CS_CHECK(fn, ret) \ 152 162 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 153 163 154 - void parport_config(dev_link_t *link) 164 + static int parport_config(struct pcmcia_device *link) 155 165 { 156 - client_handle_t handle = link->handle; 157 166 parport_info_t *info = link->priv; 158 167 tuple_t tuple; 159 168 u_short buf[128]; 160 169 cisparse_t parse; 161 - config_info_t conf; 162 170 cistpl_cftable_entry_t *cfg = &parse.cftable_entry; 163 171 cistpl_cftable_entry_t dflt = { 0 }; 164 172 struct parport *p; ··· 168 180 tuple.TupleOffset = 0; tuple.TupleDataMax = 255; 169 181 tuple.Attributes = 0; 170 182 tuple.DesiredTuple = CISTPL_CONFIG; 171 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 172 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 173 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 183 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 184 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 185 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 174 186 link->conf.ConfigBase = parse.config.base; 175 187 link->conf.Present = parse.config.rmask[0]; 176 - 177 - /* Configure card */ 178 - link->state |= DEV_CONFIG; 179 188 180 - /* Not sure if this is right... look up the current Vcc */ 181 - CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf)); 182 - 183 189 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 184 190 tuple.Attributes = 0; 185 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 191 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 186 192 while (1) { 187 - if (pcmcia_get_tuple_data(handle, &tuple) != 0 || 188 - pcmcia_parse_tuple(handle, &tuple, &parse) != 0) 193 + if (pcmcia_get_tuple_data(link, &tuple) != 0 || 194 + pcmcia_parse_tuple(link, &tuple, &parse) != 0) 189 195 goto next_entry; 190 196 191 197 if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { ··· 194 212 link->io.BasePort2 = io->win[1].base; 195 213 link->io.NumPorts2 = io->win[1].len; 196 214 } 197 - if (pcmcia_request_io(link->handle, &link->io) != 0) 215 + if (pcmcia_request_io(link, &link->io) != 0) 198 216 goto next_entry; 199 217 /* If we've got this far, we're done */ 200 218 break; ··· 202 220 203 221 next_entry: 204 222 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; 205 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); 223 + CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 206 224 } 207 225 208 - CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq)); 209 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); 226 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 227 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 210 228 211 - release_region(link->io.BasePort1, link->io.NumPorts1); 212 - if (link->io.NumPorts2) 213 - release_region(link->io.BasePort2, link->io.NumPorts2); 214 229 p = parport_pc_probe_port(link->io.BasePort1, link->io.BasePort2, 215 230 link->irq.AssignedIRQ, PARPORT_DMA_NONE, 216 231 NULL); ··· 226 247 info->node.minor = p->number; 227 248 info->port = p; 228 249 strcpy(info->node.dev_name, p->name); 229 - link->dev = &info->node; 250 + link->dev_node = &info->node; 230 251 231 - link->state &= ~DEV_CONFIG_PENDING; 232 - return; 233 - 252 + return 0; 253 + 234 254 cs_failed: 235 - cs_error(link->handle, last_fn, last_ret); 255 + cs_error(link, last_fn, last_ret); 236 256 failed: 237 257 parport_cs_release(link); 238 - link->state &= ~DEV_CONFIG_PENDING; 239 - 258 + return -ENODEV; 240 259 } /* parport_config */ 241 260 242 261 /*====================================================================== ··· 245 268 246 269 ======================================================================*/ 247 270 248 - void parport_cs_release(dev_link_t *link) 271 + void parport_cs_release(struct pcmcia_device *link) 249 272 { 250 - parport_info_t *info = link->priv; 251 - 252 - DEBUG(0, "parport_release(0x%p)\n", link); 273 + parport_info_t *info = link->priv; 253 274 254 - if (info->ndev) { 255 - struct parport *p = info->port; 256 - parport_pc_unregister_port(p); 257 - request_region(link->io.BasePort1, link->io.NumPorts1, 258 - info->node.dev_name); 259 - if (link->io.NumPorts2) 260 - request_region(link->io.BasePort2, link->io.NumPorts2, 261 - info->node.dev_name); 262 - } 263 - info->ndev = 0; 264 - link->dev = NULL; 265 - 266 - pcmcia_release_configuration(link->handle); 267 - pcmcia_release_io(link->handle, &link->io); 268 - pcmcia_release_irq(link->handle, &link->irq); 269 - 270 - link->state &= ~DEV_CONFIG; 275 + DEBUG(0, "parport_release(0x%p)\n", link); 271 276 277 + if (info->ndev) { 278 + struct parport *p = info->port; 279 + parport_pc_unregister_port(p); 280 + } 281 + info->ndev = 0; 282 + 283 + pcmcia_disable_device(link); 272 284 } /* parport_cs_release */ 273 285 274 - static int parport_suspend(struct pcmcia_device *dev) 275 - { 276 - dev_link_t *link = dev_to_instance(dev); 277 - 278 - link->state |= DEV_SUSPEND; 279 - if (link->state & DEV_CONFIG) 280 - pcmcia_release_configuration(link->handle); 281 - 282 - return 0; 283 - } 284 - 285 - static int parport_resume(struct pcmcia_device *dev) 286 - { 287 - dev_link_t *link = dev_to_instance(dev); 288 - 289 - link->state &= ~DEV_SUSPEND; 290 - if (DEV_OK(link)) 291 - pcmcia_request_configuration(link->handle, &link->conf); 292 - 293 - return 0; 294 - } 295 286 296 287 static struct pcmcia_device_id parport_ids[] = { 297 288 PCMCIA_DEVICE_FUNC_ID(3), ··· 273 328 .drv = { 274 329 .name = "parport_cs", 275 330 }, 276 - .probe = parport_attach, 331 + .probe = parport_probe, 277 332 .remove = parport_detach, 278 333 .id_table = parport_ids, 279 - .suspend = parport_suspend, 280 - .resume = parport_resume, 281 334 }; 282 335 283 336 static int __init init_parport_cs(void)
+7
drivers/pcmcia/Kconfig
··· 263 263 Say Y here to support the CompactFlash controller on OMAP. 264 264 Note that this doesn't support "True IDE" mode. 265 265 266 + config AT91_CF 267 + tristate "AT91 CompactFlash Controller" 268 + depends on PCMCIA && ARCH_AT91RM9200 269 + help 270 + Say Y here to support the CompactFlash controller on AT91 chips. 271 + Or choose M to compile the driver as a module named "at91_cf". 272 + 266 273 config PCCARD_NONSTATIC 267 274 tristate 268 275
+2 -1
drivers/pcmcia/Makefile
··· 10 10 pcmcia_core-$(CONFIG_CARDBUS) += cardbus.o 11 11 obj-$(CONFIG_PCCARD) += pcmcia_core.o 12 12 13 - pcmcia-y += ds.o pcmcia_compat.o pcmcia_resource.o 13 + pcmcia-y += ds.o pcmcia_resource.o 14 14 pcmcia-$(CONFIG_PCMCIA_IOCTL) += pcmcia_ioctl.o 15 15 obj-$(CONFIG_PCMCIA) += pcmcia.o 16 16 ··· 36 36 obj-$(CONFIG_PCMCIA_VRC4171) += vrc4171_card.o 37 37 obj-$(CONFIG_PCMCIA_VRC4173) += vrc4173_cardu.o 38 38 obj-$(CONFIG_OMAP_CF) += omap_cf.o 39 + obj-$(CONFIG_AT91_CF) += at91_cf.o 39 40 40 41 sa11xx_core-y += soc_common.o sa11xx_base.o 41 42 pxa2xx_core-y += soc_common.o pxa2xx_base.o
+365
drivers/pcmcia/at91_cf.c
··· 1 + /* 2 + * at91_cf.c -- AT91 CompactFlash controller driver 3 + * 4 + * Copyright (C) 2005 David Brownell 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License as published by 8 + * the Free Software Foundation; either version 2 of the License, or 9 + * (at your option) any later version. 10 + */ 11 + 12 + #include <linux/module.h> 13 + #include <linux/kernel.h> 14 + #include <linux/sched.h> 15 + #include <linux/platform_device.h> 16 + #include <linux/errno.h> 17 + #include <linux/init.h> 18 + #include <linux/interrupt.h> 19 + 20 + #include <pcmcia/ss.h> 21 + 22 + #include <asm/hardware.h> 23 + #include <asm/io.h> 24 + #include <asm/sizes.h> 25 + 26 + #include <asm/arch/at91rm9200.h> 27 + #include <asm/arch/board.h> 28 + #include <asm/arch/gpio.h> 29 + 30 + 31 + #define CF_SIZE 0x30000000 /* CS5+CS6: unavailable */ 32 + 33 + /* 34 + * A0..A10 work in each range; A23 indicates I/O space; A25 is CFRNW; 35 + * some other bit in {A24,A22..A11} is nREG to flag memory access 36 + * (vs attributes). So more than 2KB/region would just be waste. 37 + */ 38 + #define CF_ATTR_PHYS (AT91_CF_BASE) 39 + #define CF_IO_PHYS (AT91_CF_BASE + (1 << 23)) 40 + #define CF_MEM_PHYS (AT91_CF_BASE + 0x017ff800) 41 + 42 + /*--------------------------------------------------------------------------*/ 43 + 44 + static const char driver_name[] = "at91_cf"; 45 + 46 + struct at91_cf_socket { 47 + struct pcmcia_socket socket; 48 + 49 + unsigned present:1; 50 + 51 + struct platform_device *pdev; 52 + struct at91_cf_data *board; 53 + }; 54 + 55 + #define SZ_2K (2 * SZ_1K) 56 + 57 + static inline int at91_cf_present(struct at91_cf_socket *cf) 58 + { 59 + return !at91_get_gpio_value(cf->board->det_pin); 60 + } 61 + 62 + /*--------------------------------------------------------------------------*/ 63 + 64 + static int at91_cf_ss_init(struct pcmcia_socket *s) 65 + { 66 + return 0; 67 + } 68 + 69 + static irqreturn_t at91_cf_irq(int irq, void *_cf, struct pt_regs *r) 70 + { 71 + struct at91_cf_socket *cf = (struct at91_cf_socket *) _cf; 72 + 73 + if (irq == cf->board->det_pin) { 74 + unsigned present = at91_cf_present(cf); 75 + 76 + /* kick pccard as needed */ 77 + if (present != cf->present) { 78 + cf->present = present; 79 + pr_debug("%s: card %s\n", driver_name, present ? "present" : "gone"); 80 + pcmcia_parse_events(&cf->socket, SS_DETECT); 81 + } 82 + } 83 + 84 + return IRQ_HANDLED; 85 + } 86 + 87 + static int at91_cf_get_status(struct pcmcia_socket *s, u_int *sp) 88 + { 89 + struct at91_cf_socket *cf; 90 + 91 + if (!sp) 92 + return -EINVAL; 93 + 94 + cf = container_of(s, struct at91_cf_socket, socket); 95 + 96 + /* NOTE: we assume 3VCARD, not XVCARD... */ 97 + if (at91_cf_present(cf)) { 98 + int rdy = cf->board->irq_pin; /* RDY/nIRQ */ 99 + int vcc = cf->board->vcc_pin; 100 + 101 + *sp = SS_DETECT | SS_3VCARD; 102 + if (!rdy || at91_get_gpio_value(rdy)) 103 + *sp |= SS_READY; 104 + if (!vcc || at91_get_gpio_value(vcc)) 105 + *sp |= SS_POWERON; 106 + } else 107 + *sp = 0; 108 + 109 + return 0; 110 + } 111 + 112 + static int at91_cf_set_socket(struct pcmcia_socket *sock, struct socket_state_t *s) 113 + { 114 + struct at91_cf_socket *cf; 115 + 116 + cf = container_of(sock, struct at91_cf_socket, socket); 117 + 118 + /* switch Vcc if needed and possible */ 119 + if (cf->board->vcc_pin) { 120 + switch (s->Vcc) { 121 + case 0: 122 + at91_set_gpio_value(cf->board->vcc_pin, 0); 123 + break; 124 + case 33: 125 + at91_set_gpio_value(cf->board->vcc_pin, 1); 126 + break; 127 + default: 128 + return -EINVAL; 129 + } 130 + } 131 + 132 + /* toggle reset if needed */ 133 + at91_set_gpio_value(cf->board->rst_pin, s->flags & SS_RESET); 134 + 135 + pr_debug("%s: Vcc %d, io_irq %d, flags %04x csc %04x\n", 136 + driver_name, s->Vcc, s->io_irq, s->flags, s->csc_mask); 137 + 138 + return 0; 139 + } 140 + 141 + static int at91_cf_ss_suspend(struct pcmcia_socket *s) 142 + { 143 + return at91_cf_set_socket(s, &dead_socket); 144 + } 145 + 146 + /* we already mapped the I/O region */ 147 + static int at91_cf_set_io_map(struct pcmcia_socket *s, struct pccard_io_map *io) 148 + { 149 + struct at91_cf_socket *cf; 150 + u32 csr; 151 + 152 + cf = container_of(s, struct at91_cf_socket, socket); 153 + io->flags &= (MAP_ACTIVE | MAP_16BIT | MAP_AUTOSZ); 154 + 155 + /* 156 + * Use 16 bit accesses unless/until we need 8-bit i/o space. 157 + * Always set CSR4 ... PCMCIA won't always unmap things. 158 + */ 159 + csr = at91_sys_read(AT91_SMC_CSR(4)) & ~AT91_SMC_DBW; 160 + 161 + /* 162 + * NOTE: this CF controller ignores IOIS16, so we can't really do 163 + * MAP_AUTOSZ. The 16bit mode allows single byte access on either 164 + * D0-D7 (even addr) or D8-D15 (odd), so it's close enough for many 165 + * purposes (and handles ide-cs). 166 + * 167 + * The 8bit mode is needed for odd byte access on D0-D7. It seems 168 + * some cards only like that way to get at the odd byte, despite 169 + * CF 3.0 spec table 35 also giving the D8-D15 option. 170 + */ 171 + if (!(io->flags & (MAP_16BIT|MAP_AUTOSZ))) { 172 + csr |= AT91_SMC_DBW_8; 173 + pr_debug("%s: 8bit i/o bus\n", driver_name); 174 + } else { 175 + csr |= AT91_SMC_DBW_16; 176 + pr_debug("%s: 16bit i/o bus\n", driver_name); 177 + } 178 + at91_sys_write(AT91_SMC_CSR(4), csr); 179 + 180 + io->start = cf->socket.io_offset; 181 + io->stop = io->start + SZ_2K - 1; 182 + 183 + return 0; 184 + } 185 + 186 + /* pcmcia layer maps/unmaps mem regions */ 187 + static int at91_cf_set_mem_map(struct pcmcia_socket *s, struct pccard_mem_map *map) 188 + { 189 + struct at91_cf_socket *cf; 190 + 191 + if (map->card_start) 192 + return -EINVAL; 193 + 194 + cf = container_of(s, struct at91_cf_socket, socket); 195 + 196 + map->flags &= MAP_ACTIVE|MAP_ATTRIB|MAP_16BIT; 197 + if (map->flags & MAP_ATTRIB) 198 + map->static_start = CF_ATTR_PHYS; 199 + else 200 + map->static_start = CF_MEM_PHYS; 201 + 202 + return 0; 203 + } 204 + 205 + static struct pccard_operations at91_cf_ops = { 206 + .init = at91_cf_ss_init, 207 + .suspend = at91_cf_ss_suspend, 208 + .get_status = at91_cf_get_status, 209 + .set_socket = at91_cf_set_socket, 210 + .set_io_map = at91_cf_set_io_map, 211 + .set_mem_map = at91_cf_set_mem_map, 212 + }; 213 + 214 + /*--------------------------------------------------------------------------*/ 215 + 216 + static int __init at91_cf_probe(struct device *dev) 217 + { 218 + struct at91_cf_socket *cf; 219 + struct at91_cf_data *board = dev->platform_data; 220 + struct platform_device *pdev = to_platform_device(dev); 221 + unsigned int csa; 222 + int status; 223 + 224 + if (!board || !board->det_pin || !board->rst_pin) 225 + return -ENODEV; 226 + 227 + cf = kcalloc(1, sizeof *cf, GFP_KERNEL); 228 + if (!cf) 229 + return -ENOMEM; 230 + 231 + cf->board = board; 232 + cf->pdev = pdev; 233 + dev_set_drvdata(dev, cf); 234 + 235 + /* CF takes over CS4, CS5, CS6 */ 236 + csa = at91_sys_read(AT91_EBI_CSA); 237 + at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH); 238 + 239 + /* force poweron defaults for these pins ... */ 240 + (void) at91_set_A_periph(AT91_PIN_PC9, 0); /* A25/CFRNW */ 241 + (void) at91_set_A_periph(AT91_PIN_PC10, 0); /* NCS4/CFCS */ 242 + (void) at91_set_A_periph(AT91_PIN_PC11, 0); /* NCS5/CFCE1 */ 243 + (void) at91_set_A_periph(AT91_PIN_PC12, 0); /* NCS6/CFCE2 */ 244 + 245 + /* nWAIT is _not_ a default setting */ 246 + (void) at91_set_A_periph(AT91_PIN_PC6, 1); /* nWAIT */ 247 + 248 + /* 249 + * Static memory controller timing adjustments. 250 + * REVISIT: these timings are in terms of MCK cycles, so 251 + * when MCK changes (cpufreq etc) so must these values... 252 + */ 253 + at91_sys_write(AT91_SMC_CSR(4), AT91_SMC_ACSS_STD | AT91_SMC_DBW_16 | AT91_SMC_BAT | AT91_SMC_WSEN 254 + | AT91_SMC_NWS_(32) /* wait states */ 255 + | AT91_SMC_RWSETUP_(6) /* setup time */ 256 + | AT91_SMC_RWHOLD_(4) /* hold time */ 257 + ); 258 + 259 + /* must be a GPIO; ergo must trigger on both edges */ 260 + status = request_irq(board->det_pin, at91_cf_irq, 261 + SA_SAMPLE_RANDOM, driver_name, cf); 262 + if (status < 0) 263 + goto fail0; 264 + 265 + /* 266 + * The card driver will request this irq later as needed. 267 + * but it causes lots of "irqNN: nobody cared" messages 268 + * unless we report that we handle everything (sigh). 269 + * (Note: DK board doesn't wire the IRQ pin...) 270 + */ 271 + if (board->irq_pin) { 272 + status = request_irq(board->irq_pin, at91_cf_irq, 273 + SA_SHIRQ, driver_name, cf); 274 + if (status < 0) 275 + goto fail0a; 276 + cf->socket.pci_irq = board->irq_pin; 277 + } 278 + else 279 + cf->socket.pci_irq = NR_IRQS + 1; 280 + 281 + /* pcmcia layer only remaps "real" memory not iospace */ 282 + cf->socket.io_offset = (unsigned long) ioremap(CF_IO_PHYS, SZ_2K); 283 + if (!cf->socket.io_offset) 284 + goto fail1; 285 + 286 + /* reserve CS4, CS5, and CS6 regions; but use just CS4 */ 287 + if (!request_mem_region(AT91_CF_BASE, CF_SIZE, driver_name)) 288 + goto fail1; 289 + 290 + pr_info("%s: irqs det #%d, io #%d\n", driver_name, 291 + board->det_pin, board->irq_pin); 292 + 293 + cf->socket.owner = THIS_MODULE; 294 + cf->socket.dev.dev = dev; 295 + cf->socket.ops = &at91_cf_ops; 296 + cf->socket.resource_ops = &pccard_static_ops; 297 + cf->socket.features = SS_CAP_PCCARD | SS_CAP_STATIC_MAP 298 + | SS_CAP_MEM_ALIGN; 299 + cf->socket.map_size = SZ_2K; 300 + cf->socket.io[0].NumPorts = SZ_2K; 301 + 302 + status = pcmcia_register_socket(&cf->socket); 303 + if (status < 0) 304 + goto fail2; 305 + 306 + return 0; 307 + 308 + fail2: 309 + iounmap((void __iomem *) cf->socket.io_offset); 310 + release_mem_region(AT91_CF_BASE, CF_SIZE); 311 + fail1: 312 + if (board->irq_pin) 313 + free_irq(board->irq_pin, cf); 314 + fail0a: 315 + free_irq(board->det_pin, cf); 316 + fail0: 317 + at91_sys_write(AT91_EBI_CSA, csa); 318 + kfree(cf); 319 + return status; 320 + } 321 + 322 + static int __exit at91_cf_remove(struct device *dev) 323 + { 324 + struct at91_cf_socket *cf = dev_get_drvdata(dev); 325 + unsigned int csa; 326 + 327 + pcmcia_unregister_socket(&cf->socket); 328 + free_irq(cf->board->irq_pin, cf); 329 + free_irq(cf->board->det_pin, cf); 330 + iounmap((void __iomem *) cf->socket.io_offset); 331 + release_mem_region(AT91_CF_BASE, CF_SIZE); 332 + 333 + csa = at91_sys_read(AT91_EBI_CSA); 334 + at91_sys_write(AT91_EBI_CSA, csa & ~AT91_EBI_CS4A); 335 + 336 + kfree(cf); 337 + return 0; 338 + } 339 + 340 + static struct device_driver at91_cf_driver = { 341 + .name = (char *) driver_name, 342 + .bus = &platform_bus_type, 343 + .probe = at91_cf_probe, 344 + .remove = __exit_p(at91_cf_remove), 345 + .suspend = pcmcia_socket_dev_suspend, 346 + .resume = pcmcia_socket_dev_resume, 347 + }; 348 + 349 + /*--------------------------------------------------------------------------*/ 350 + 351 + static int __init at91_cf_init(void) 352 + { 353 + return driver_register(&at91_cf_driver); 354 + } 355 + module_init(at91_cf_init); 356 + 357 + static void __exit at91_cf_exit(void) 358 + { 359 + driver_unregister(&at91_cf_driver); 360 + } 361 + module_exit(at91_cf_exit); 362 + 363 + MODULE_DESCRIPTION("AT91 Compact Flash Driver"); 364 + MODULE_AUTHOR("David Brownell"); 365 + MODULE_LICENSE("GPL");
-1
drivers/pcmcia/cistpl.c
··· 12 12 * (C) 1999 David A. Hinds 13 13 */ 14 14 15 - #include <linux/config.h> 16 15 #include <linux/module.h> 17 16 #include <linux/moduleparam.h> 18 17 #include <linux/kernel.h>
+20 -23
drivers/pcmcia/cs.c
··· 16 16 #include <linux/moduleparam.h> 17 17 #include <linux/init.h> 18 18 #include <linux/kernel.h> 19 - #include <linux/config.h> 20 19 #include <linux/string.h> 21 20 #include <linux/major.h> 22 21 #include <linux/errno.h> ··· 110 111 list_for_each_entry(socket, &pcmcia_socket_list, socket_list) { 111 112 if (socket->dev.dev != dev) 112 113 continue; 113 - down(&socket->skt_sem); 114 + mutex_lock(&socket->skt_mutex); 114 115 socket_suspend(socket); 115 - up(&socket->skt_sem); 116 + mutex_unlock(&socket->skt_mutex); 116 117 } 117 118 up_read(&pcmcia_socket_list_rwsem); 118 119 ··· 128 129 list_for_each_entry(socket, &pcmcia_socket_list, socket_list) { 129 130 if (socket->dev.dev != dev) 130 131 continue; 131 - down(&socket->skt_sem); 132 + mutex_lock(&socket->skt_mutex); 132 133 socket_resume(socket); 133 - up(&socket->skt_sem); 134 + mutex_unlock(&socket->skt_mutex); 134 135 } 135 136 up_read(&pcmcia_socket_list_rwsem); 136 137 ··· 236 237 init_completion(&socket->socket_released); 237 238 init_completion(&socket->thread_done); 238 239 init_waitqueue_head(&socket->thread_wait); 239 - init_MUTEX(&socket->skt_sem); 240 + mutex_init(&socket->skt_mutex); 240 241 spin_lock_init(&socket->thread_lock); 241 242 242 243 ret = kernel_thread(pccardd, socket, CLONE_KERNEL); ··· 405 406 cb_free(s); 406 407 #endif 407 408 s->functions = 0; 408 - kfree(s->config); 409 - s->config = NULL; 410 409 411 410 s->ops->get_status(s, &status); 412 411 if (status & SS_POWERON) { ··· 661 664 spin_unlock_irqrestore(&skt->thread_lock, flags); 662 665 663 666 if (events) { 664 - down(&skt->skt_sem); 667 + mutex_lock(&skt->skt_mutex); 665 668 if (events & SS_DETECT) 666 669 socket_detect_change(skt); 667 670 if (events & SS_BATDEAD) ··· 670 673 send_event(skt, CS_EVENT_BATTERY_LOW, CS_EVENT_PRI_LOW); 671 674 if (events & SS_READY) 672 675 send_event(skt, CS_EVENT_READY_CHANGE, CS_EVENT_PRI_LOW); 673 - up(&skt->skt_sem); 676 + mutex_unlock(&skt->skt_mutex); 674 677 continue; 675 678 } 676 679 ··· 714 717 { 715 718 int ret = 0; 716 719 717 - /* s->skt_sem also protects s->callback */ 718 - down(&s->skt_sem); 720 + /* s->skt_mutex also protects s->callback */ 721 + mutex_lock(&s->skt_mutex); 719 722 720 723 if (c) { 721 724 /* registration */ ··· 731 734 } else 732 735 s->callback = NULL; 733 736 err: 734 - up(&s->skt_sem); 737 + mutex_unlock(&s->skt_mutex); 735 738 736 739 return ret; 737 740 } ··· 749 752 750 753 cs_dbg(skt, 1, "resetting socket\n"); 751 754 752 - down(&skt->skt_sem); 755 + mutex_lock(&skt->skt_mutex); 753 756 do { 754 757 if (!(skt->state & SOCKET_PRESENT)) { 755 758 ret = CS_NO_CARD; ··· 778 781 779 782 ret = CS_SUCCESS; 780 783 } while (0); 781 - up(&skt->skt_sem); 784 + mutex_unlock(&skt->skt_mutex); 782 785 783 786 return ret; 784 787 } /* reset_card */ ··· 794 797 795 798 cs_dbg(skt, 1, "suspending socket\n"); 796 799 797 - down(&skt->skt_sem); 800 + mutex_lock(&skt->skt_mutex); 798 801 do { 799 802 if (!(skt->state & SOCKET_PRESENT)) { 800 803 ret = CS_NO_CARD; ··· 811 814 } 812 815 ret = socket_suspend(skt); 813 816 } while (0); 814 - up(&skt->skt_sem); 817 + mutex_unlock(&skt->skt_mutex); 815 818 816 819 return ret; 817 820 } /* suspend_card */ ··· 824 827 825 828 cs_dbg(skt, 1, "waking up socket\n"); 826 829 827 - down(&skt->skt_sem); 830 + mutex_lock(&skt->skt_mutex); 828 831 do { 829 832 if (!(skt->state & SOCKET_PRESENT)) { 830 833 ret = CS_NO_CARD; ··· 838 841 if (!ret && skt->callback) 839 842 skt->callback->resume(skt); 840 843 } while (0); 841 - up(&skt->skt_sem); 844 + mutex_unlock(&skt->skt_mutex); 842 845 843 846 return ret; 844 847 } /* resume_card */ ··· 852 855 853 856 cs_dbg(skt, 1, "user eject request\n"); 854 857 855 - down(&skt->skt_sem); 858 + mutex_lock(&skt->skt_mutex); 856 859 do { 857 860 if (!(skt->state & SOCKET_PRESENT)) { 858 861 ret = -ENODEV; ··· 868 871 socket_remove(skt); 869 872 ret = 0; 870 873 } while (0); 871 - up(&skt->skt_sem); 874 + mutex_unlock(&skt->skt_mutex); 872 875 873 876 return ret; 874 877 } /* eject_card */ ··· 881 884 882 885 cs_dbg(skt, 1, "user insert request\n"); 883 886 884 - down(&skt->skt_sem); 887 + mutex_lock(&skt->skt_mutex); 885 888 do { 886 889 if (skt->state & SOCKET_PRESENT) { 887 890 ret = -EBUSY; ··· 893 896 } 894 897 ret = 0; 895 898 } while (0); 896 - up(&skt->skt_sem); 899 + mutex_unlock(&skt->skt_mutex); 897 900 898 901 return ret; 899 902 } /* insert_card */
+6 -13
drivers/pcmcia/cs_internal.h
··· 15 15 #ifndef _LINUX_CS_INTERNAL_H 16 16 #define _LINUX_CS_INTERNAL_H 17 17 18 - #include <linux/config.h> 18 + #include <linux/kref.h> 19 19 20 20 /* Flags in client state */ 21 21 #define CLIENT_CONFIG_LOCKED 0x0001 ··· 23 23 #define CLIENT_IO_REQ 0x0004 24 24 #define CLIENT_UNBOUND 0x0008 25 25 #define CLIENT_STALE 0x0010 26 - #define CLIENT_WIN_REQ(i) (0x20<<(i)) 26 + #define CLIENT_WIN_REQ(i) (0x1<<(i)) 27 27 #define CLIENT_CARDBUS 0x8000 28 28 29 29 #define REGION_MAGIC 0xE3C9 ··· 31 31 u_short region_magic; 32 32 u_short state; 33 33 dev_info_t dev_info; 34 - client_handle_t mtd; 34 + struct pcmcia_device *mtd; 35 35 u_int MediaID; 36 36 region_info_t info; 37 37 } region_t; ··· 40 40 41 41 /* Each card function gets one of these guys */ 42 42 typedef struct config_t { 43 + struct kref ref; 43 44 u_int state; 44 45 u_int Attributes; 45 46 u_int IntType; 46 47 u_int ConfigBase; 47 48 u_char Status, Pin, Copy, Option, ExtStatus; 48 - u_int Present; 49 49 u_int CardValues; 50 50 io_req_t io; 51 51 struct { ··· 95 95 } 96 96 } 97 97 98 - #define CHECK_SOCKET(s) \ 99 - (((s) >= sockets) || (socket_table[s]->ops == NULL)) 100 - 101 - #define SOCKET(h) (h->socket) 102 - #define CONFIG(h) (&SOCKET(h)->config[(h)->func]) 103 - 104 98 /* In cardbus.c */ 105 99 int cb_alloc(struct pcmcia_socket *s); 106 100 void cb_free(struct pcmcia_socket *s); ··· 127 133 extern struct rw_semaphore pcmcia_socket_list_rwsem; 128 134 extern struct list_head pcmcia_socket_list; 129 135 int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int idx, win_req_t *req); 130 - int pccard_get_configuration_info(struct pcmcia_socket *s, unsigned int function, config_info_t *config); 136 + int pccard_get_configuration_info(struct pcmcia_socket *s, struct pcmcia_device *p_dev, config_info_t *config); 131 137 int pccard_reset_card(struct pcmcia_socket *skt); 132 - int pccard_get_status(struct pcmcia_socket *s, unsigned int function, cs_status_t *status); 133 - int pccard_access_configuration_register(struct pcmcia_socket *s, unsigned int function, conf_reg_t *reg); 138 + int pccard_get_status(struct pcmcia_socket *s, struct pcmcia_device *p_dev, cs_status_t *status); 134 139 135 140 136 141 struct pcmcia_callback{
+163 -86
drivers/pcmcia/ds.c
··· 10 10 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. 11 11 * 12 12 * (C) 1999 David A. Hinds 13 - * (C) 2003 - 2005 Dominik Brodowski 13 + * (C) 2003 - 2006 Dominik Brodowski 14 14 */ 15 15 16 - #include <linux/config.h> 17 16 #include <linux/kernel.h> 18 17 #include <linux/module.h> 19 18 #include <linux/init.h> ··· 22 23 #include <linux/workqueue.h> 23 24 #include <linux/crc32.h> 24 25 #include <linux/firmware.h> 26 + #include <linux/kref.h> 25 27 26 28 #define IN_CARD_SERVICES 27 29 #include <pcmcia/cs_types.h> ··· 343 343 put_device(&p_dev->dev); 344 344 } 345 345 346 + static void pcmcia_release_function(struct kref *ref) 347 + { 348 + struct config_t *c = container_of(ref, struct config_t, ref); 349 + kfree(c); 350 + } 351 + 346 352 static void pcmcia_release_dev(struct device *dev) 347 353 { 348 354 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 349 355 ds_dbg(1, "releasing dev %p\n", p_dev); 350 356 pcmcia_put_socket(p_dev->socket); 351 357 kfree(p_dev->devname); 358 + kref_put(&p_dev->function_config->ref, pcmcia_release_function); 352 359 kfree(p_dev); 353 360 } 354 361 ··· 384 377 p_drv = to_pcmcia_drv(dev->driver); 385 378 s = p_dev->socket; 386 379 387 - if ((!p_drv->probe) || (!try_module_get(p_drv->owner))) { 380 + if ((!p_drv->probe) || (!p_dev->function_config) || 381 + (!try_module_get(p_drv->owner))) { 388 382 ret = -EINVAL; 389 383 goto put_dev; 390 - } 391 - 392 - p_dev->state &= ~CLIENT_UNBOUND; 393 - 394 - /* set up the device configuration, if it hasn't been done before */ 395 - if (!s->functions) { 396 - cistpl_longlink_mfc_t mfc; 397 - if (pccard_read_tuple(s, p_dev->func, CISTPL_LONGLINK_MFC, 398 - &mfc) == CS_SUCCESS) 399 - s->functions = mfc.nfn; 400 - else 401 - s->functions = 1; 402 - s->config = kzalloc(sizeof(config_t) * s->functions, 403 - GFP_KERNEL); 404 - if (!s->config) { 405 - ret = -ENOMEM; 406 - goto put_module; 407 - } 408 384 } 409 385 410 386 ret = p_drv->probe(p_dev); ··· 415 425 } 416 426 417 427 428 + /* 429 + * Removes a PCMCIA card from the device tree and socket list. 430 + */ 431 + static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *leftover) 432 + { 433 + struct pcmcia_device *p_dev; 434 + struct pcmcia_device *tmp; 435 + unsigned long flags; 436 + 437 + ds_dbg(2, "unbind_request(%d)\n", s->sock); 438 + 439 + 440 + if (!leftover) 441 + s->device_count = 0; 442 + else 443 + s->device_count = 1; 444 + 445 + /* unregister all pcmcia_devices registered with this socket, except leftover */ 446 + list_for_each_entry_safe(p_dev, tmp, &s->devices_list, socket_device_list) { 447 + if (p_dev == leftover) 448 + continue; 449 + 450 + spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 451 + list_del(&p_dev->socket_device_list); 452 + p_dev->_removed=1; 453 + spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 454 + 455 + device_unregister(&p_dev->dev); 456 + } 457 + 458 + return; 459 + } 460 + 461 + 418 462 static int pcmcia_device_remove(struct device * dev) 419 463 { 420 464 struct pcmcia_device *p_dev; 421 465 struct pcmcia_driver *p_drv; 466 + struct pcmcia_device_id *did; 422 467 int i; 423 468 424 - /* detach the "instance" */ 425 469 p_dev = to_pcmcia_dev(dev); 426 470 p_drv = to_pcmcia_drv(dev->driver); 471 + 472 + /* If we're removing the primary module driving a 473 + * pseudo multi-function card, we need to unbind 474 + * all devices 475 + */ 476 + did = (struct pcmcia_device_id *) p_dev->dev.driver_data; 477 + if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) && 478 + (p_dev->socket->device_count != 0) && 479 + (p_dev->device_no == 0)) 480 + pcmcia_card_remove(p_dev->socket, p_dev); 481 + 482 + /* detach the "instance" */ 427 483 if (!p_drv) 428 484 return 0; 429 485 ··· 477 441 p_drv->remove(p_dev); 478 442 479 443 /* check for proper unloading */ 480 - if (p_dev->state & (CLIENT_IRQ_REQ|CLIENT_IO_REQ|CLIENT_CONFIG_LOCKED)) 444 + if (p_dev->_irq || p_dev->_io || p_dev->_locked) 481 445 printk(KERN_INFO "pcmcia: driver %s did not release config properly\n", 482 446 p_drv->drv.name); 483 447 484 448 for (i = 0; i < MAX_WIN; i++) 485 - if (p_dev->state & CLIENT_WIN_REQ(i)) 449 + if (p_dev->_win & CLIENT_WIN_REQ(i)) 486 450 printk(KERN_INFO "pcmcia: driver %s did not release windows properly\n", 487 451 p_drv->drv.name); 488 452 489 453 /* references from pcmcia_probe_device */ 490 - p_dev->state = CLIENT_UNBOUND; 491 454 pcmcia_put_dev(p_dev); 492 455 module_put(p_drv->owner); 493 456 494 457 return 0; 495 458 } 496 - 497 - 498 - /* 499 - * Removes a PCMCIA card from the device tree and socket list. 500 - */ 501 - static void pcmcia_card_remove(struct pcmcia_socket *s) 502 - { 503 - struct pcmcia_device *p_dev; 504 - unsigned long flags; 505 - 506 - ds_dbg(2, "unbind_request(%d)\n", s->sock); 507 - 508 - s->device_count = 0; 509 - 510 - for (;;) { 511 - /* unregister all pcmcia_devices registered with this socket*/ 512 - spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 513 - if (list_empty(&s->devices_list)) { 514 - spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 515 - return; 516 - } 517 - p_dev = list_entry((&s->devices_list)->next, struct pcmcia_device, socket_device_list); 518 - list_del(&p_dev->socket_device_list); 519 - p_dev->state |= CLIENT_STALE; 520 - spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 521 - 522 - device_unregister(&p_dev->dev); 523 - } 524 - 525 - return; 526 - } /* unbind_request */ 527 459 528 460 529 461 /* ··· 550 546 tmp = vers1->str + vers1->ofs[i]; 551 547 552 548 length = strlen(tmp) + 1; 553 - if ((length < 3) || (length > 255)) 549 + if ((length < 2) || (length > 255)) 554 550 continue; 555 551 556 552 p_dev->prod_id[i] = kmalloc(sizeof(char) * length, ··· 575 571 * won't work, this doesn't matter much at the moment: the driver core doesn't 576 572 * support it either. 577 573 */ 578 - static DECLARE_MUTEX(device_add_lock); 574 + static DEFINE_MUTEX(device_add_lock); 579 575 580 576 struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int function) 581 577 { 582 - struct pcmcia_device *p_dev; 578 + struct pcmcia_device *p_dev, *tmp_dev; 583 579 unsigned long flags; 584 580 int bus_id_len; 585 581 ··· 587 583 if (!s) 588 584 return NULL; 589 585 590 - down(&device_add_lock); 586 + mutex_lock(&device_add_lock); 591 587 592 588 /* max of 2 devices per card */ 593 589 if (s->device_count == 2) ··· 600 596 p_dev->socket = s; 601 597 p_dev->device_no = (s->device_count++); 602 598 p_dev->func = function; 599 + if (s->functions <= function) 600 + s->functions = function + 1; 603 601 604 602 p_dev->dev.bus = &pcmcia_bus_type; 605 603 p_dev->dev.parent = s->dev.dev; ··· 614 608 sprintf (p_dev->devname, "pcmcia%s", p_dev->dev.bus_id); 615 609 616 610 /* compat */ 617 - p_dev->state = CLIENT_UNBOUND; 611 + spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 612 + 613 + /* 614 + * p_dev->function_config must be the same for all card functions. 615 + * Note that this is serialized by the device_add_lock, so that 616 + * only one such struct will be created. 617 + */ 618 + list_for_each_entry(tmp_dev, &s->devices_list, socket_device_list) 619 + if (p_dev->func == tmp_dev->func) { 620 + p_dev->function_config = tmp_dev->function_config; 621 + kref_get(&p_dev->function_config->ref); 622 + } 618 623 619 624 /* Add to the list in pcmcia_bus_socket */ 620 - spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 621 625 list_add_tail(&p_dev->socket_device_list, &s->devices_list); 626 + 622 627 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 628 + 629 + if (!p_dev->function_config) { 630 + p_dev->function_config = kzalloc(sizeof(struct config_t), 631 + GFP_KERNEL); 632 + if (!p_dev->function_config) 633 + goto err_unreg; 634 + kref_init(&p_dev->function_config->ref); 635 + } 623 636 624 637 printk(KERN_NOTICE "pcmcia: registering new device %s\n", 625 638 p_dev->devname); 626 639 627 640 pcmcia_device_query(p_dev); 628 641 629 - if (device_register(&p_dev->dev)) { 630 - spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 631 - list_del(&p_dev->socket_device_list); 632 - spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 642 + if (device_register(&p_dev->dev)) 643 + goto err_unreg; 633 644 634 - goto err_free; 635 - } 636 - 637 - up(&device_add_lock); 645 + mutex_unlock(&device_add_lock); 638 646 639 647 return p_dev; 648 + 649 + err_unreg: 650 + spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 651 + list_del(&p_dev->socket_device_list); 652 + spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 640 653 641 654 err_free: 642 655 kfree(p_dev->devname); 643 656 kfree(p_dev); 644 657 s->device_count--; 645 658 err_put: 646 - up(&device_add_lock); 659 + mutex_unlock(&device_add_lock); 647 660 pcmcia_put_socket(s); 648 661 649 662 return NULL; ··· 721 696 int no_devices=0; 722 697 unsigned long flags; 723 698 724 - /* must be called with skt_sem held */ 699 + /* must be called with skt_mutex held */ 725 700 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 726 701 if (list_empty(&skt->devices_list)) 727 702 no_devices=1; ··· 844 819 struct pcmcia_driver * p_drv = to_pcmcia_drv(drv); 845 820 struct pcmcia_device_id *did = p_drv->id_table; 846 821 822 + #ifdef CONFIG_PCMCIA_IOCTL 847 823 /* matching by cardmgr */ 848 824 if (p_dev->cardmgr == p_drv) 849 825 return 1; 826 + #endif 850 827 851 828 while (did && did->match_flags) { 852 829 if (pcmcia_devmatch(p_dev, did)) ··· 954 927 { 955 928 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 956 929 957 - if (p_dev->dev.power.power_state.event != PM_EVENT_ON) 930 + if (p_dev->suspended) 958 931 return sprintf(buf, "off\n"); 959 932 else 960 933 return sprintf(buf, "on\n"); ··· 969 942 if (!count) 970 943 return -EINVAL; 971 944 972 - if ((p_dev->dev.power.power_state.event == PM_EVENT_ON) && 973 - (!strncmp(buf, "off", 3))) 945 + if ((!p_dev->suspended) && !strncmp(buf, "off", 3)) 974 946 ret = dpm_runtime_suspend(dev, PMSG_SUSPEND); 975 - else if ((p_dev->dev.power.power_state.event != PM_EVENT_ON) && 976 - (!strncmp(buf, "on", 2))) 947 + else if (p_dev->suspended && !strncmp(buf, "on", 2)) 977 948 dpm_runtime_resume(dev); 978 949 979 950 return ret ? ret : count; ··· 1007 982 if (!count) 1008 983 return -EINVAL; 1009 984 1010 - down(&p_dev->socket->skt_sem); 985 + mutex_lock(&p_dev->socket->skt_mutex); 1011 986 p_dev->allow_func_id_match = 1; 1012 - up(&p_dev->socket->skt_sem); 987 + mutex_unlock(&p_dev->socket->skt_mutex); 1013 988 1014 989 bus_rescan_devices(&pcmcia_bus_type); 1015 990 ··· 1037 1012 { 1038 1013 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 1039 1014 struct pcmcia_driver *p_drv = NULL; 1015 + int ret = 0; 1040 1016 1041 1017 if (dev->driver) 1042 1018 p_drv = to_pcmcia_drv(dev->driver); 1043 1019 1044 - if (p_drv && p_drv->suspend) 1045 - return p_drv->suspend(p_dev); 1020 + if (!p_drv) 1021 + goto out; 1046 1022 1047 - return 0; 1023 + if (p_drv->suspend) { 1024 + ret = p_drv->suspend(p_dev); 1025 + if (ret) 1026 + goto out; 1027 + } 1028 + 1029 + if (p_dev->device_no == p_dev->func) 1030 + pcmcia_release_configuration(p_dev); 1031 + 1032 + out: 1033 + if (!ret) 1034 + p_dev->suspended = 1; 1035 + return ret; 1048 1036 } 1049 1037 1050 1038 ··· 1065 1027 { 1066 1028 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 1067 1029 struct pcmcia_driver *p_drv = NULL; 1030 + int ret = 0; 1068 1031 1069 1032 if (dev->driver) 1070 1033 p_drv = to_pcmcia_drv(dev->driver); 1071 1034 1072 - if (p_drv && p_drv->resume) 1073 - return p_drv->resume(p_dev); 1035 + if (!p_drv) 1036 + goto out; 1074 1037 1075 - return 0; 1038 + if (p_dev->device_no == p_dev->func) { 1039 + ret = pcmcia_request_configuration(p_dev, &p_dev->conf); 1040 + if (ret) 1041 + goto out; 1042 + } 1043 + 1044 + if (p_drv->resume) 1045 + ret = p_drv->resume(p_dev); 1046 + 1047 + out: 1048 + if (!ret) 1049 + p_dev->suspended = 0; 1050 + return ret; 1076 1051 } 1077 1052 1078 1053 ··· 1151 1100 switch (event) { 1152 1101 case CS_EVENT_CARD_REMOVAL: 1153 1102 s->pcmcia_state.present = 0; 1154 - pcmcia_card_remove(skt); 1103 + pcmcia_card_remove(skt, NULL); 1155 1104 handle_event(skt, event); 1156 1105 break; 1157 1106 ··· 1177 1126 1178 1127 return 0; 1179 1128 } /* ds_event */ 1129 + 1130 + 1131 + struct pcmcia_device * pcmcia_dev_present(struct pcmcia_device *_p_dev) 1132 + { 1133 + struct pcmcia_device *p_dev; 1134 + struct pcmcia_device *ret = NULL; 1135 + 1136 + p_dev = pcmcia_get_dev(_p_dev); 1137 + if (!p_dev) 1138 + return NULL; 1139 + 1140 + if (!p_dev->socket->pcmcia_state.present) 1141 + goto out; 1142 + 1143 + if (p_dev->_removed) 1144 + goto out; 1145 + 1146 + if (p_dev->suspended) 1147 + goto out; 1148 + 1149 + ret = p_dev; 1150 + out: 1151 + pcmcia_put_dev(p_dev); 1152 + return ret; 1153 + } 1154 + EXPORT_SYMBOL(pcmcia_dev_present); 1180 1155 1181 1156 1182 1157 static struct pcmcia_callback pcmcia_bus_callback = {
+3 -1
drivers/pcmcia/ds_internal.h
··· 8 8 9 9 struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int function); 10 10 11 + extern int pcmcia_release_configuration(struct pcmcia_device *p_dev); 12 + 11 13 #ifdef CONFIG_PCMCIA_IOCTL 12 14 extern void __init pcmcia_setup_ioctl(void); 13 15 extern void __exit pcmcia_cleanup_ioctl(void); ··· 17 15 extern int handle_request(struct pcmcia_socket *s, event_t event); 18 16 #else 19 17 static inline void __init pcmcia_setup_ioctl(void) { return; } 20 - static inline void __init pcmcia_cleanup_ioctl(void) { return; } 18 + static inline void __exit pcmcia_cleanup_ioctl(void) { return; } 21 19 static inline void handle_event(struct pcmcia_socket *s, event_t event) { return; } 22 20 static inline int handle_request(struct pcmcia_socket *s, event_t event) { return CS_SUCCESS; } 23 21 #endif
-1
drivers/pcmcia/i82092.c
··· 10 10 */ 11 11 12 12 #include <linux/kernel.h> 13 - #include <linux/config.h> 14 13 #include <linux/module.h> 15 14 #include <linux/pci.h> 16 15 #include <linux/init.h>
-1
drivers/pcmcia/i82365.c
··· 34 34 #include <linux/module.h> 35 35 #include <linux/moduleparam.h> 36 36 #include <linux/init.h> 37 - #include <linux/config.h> 38 37 #include <linux/types.h> 39 38 #include <linux/fcntl.h> 40 39 #include <linux/string.h>
-65
drivers/pcmcia/pcmcia_compat.c
··· 1 - /* 2 - * PCMCIA 16-bit compatibility functions 3 - * 4 - * The initial developer of the original code is David A. Hinds 5 - * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds 6 - * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. 7 - * 8 - * Copyright (C) 2004 Dominik Brodowski 9 - * 10 - * This program is free software; you can redistribute it and/or modify 11 - * it under the terms of the GNU General Public License version 2 as 12 - * published by the Free Software Foundation. 13 - * 14 - */ 15 - 16 - #include <linux/config.h> 17 - #include <linux/module.h> 18 - #include <linux/init.h> 19 - 20 - #define IN_CARD_SERVICES 21 - #include <pcmcia/cs_types.h> 22 - #include <pcmcia/cs.h> 23 - #include <pcmcia/bulkmem.h> 24 - #include <pcmcia/cistpl.h> 25 - #include <pcmcia/ds.h> 26 - #include <pcmcia/ss.h> 27 - 28 - #include "cs_internal.h" 29 - 30 - int pcmcia_get_first_tuple(struct pcmcia_device *p_dev, tuple_t *tuple) 31 - { 32 - return pccard_get_first_tuple(p_dev->socket, p_dev->func, tuple); 33 - } 34 - EXPORT_SYMBOL(pcmcia_get_first_tuple); 35 - 36 - int pcmcia_get_next_tuple(struct pcmcia_device *p_dev, tuple_t *tuple) 37 - { 38 - return pccard_get_next_tuple(p_dev->socket, p_dev->func, tuple); 39 - } 40 - EXPORT_SYMBOL(pcmcia_get_next_tuple); 41 - 42 - int pcmcia_get_tuple_data(struct pcmcia_device *p_dev, tuple_t *tuple) 43 - { 44 - return pccard_get_tuple_data(p_dev->socket, tuple); 45 - } 46 - EXPORT_SYMBOL(pcmcia_get_tuple_data); 47 - 48 - int pcmcia_parse_tuple(struct pcmcia_device *p_dev, tuple_t *tuple, cisparse_t *parse) 49 - { 50 - return pccard_parse_tuple(tuple, parse); 51 - } 52 - EXPORT_SYMBOL(pcmcia_parse_tuple); 53 - 54 - int pcmcia_validate_cis(struct pcmcia_device *p_dev, cisinfo_t *info) 55 - { 56 - return pccard_validate_cis(p_dev->socket, p_dev->func, info); 57 - } 58 - EXPORT_SYMBOL(pcmcia_validate_cis); 59 - 60 - 61 - int pcmcia_reset_card(struct pcmcia_device *p_dev, client_req_t *req) 62 - { 63 - return pccard_reset_card(p_dev->socket); 64 - } 65 - EXPORT_SYMBOL(pcmcia_reset_card);
+53 -28
drivers/pcmcia/pcmcia_ioctl.c
··· 18 18 */ 19 19 20 20 21 - #include <linux/config.h> 22 21 #include <linux/kernel.h> 23 22 #include <linux/module.h> 24 23 #include <linux/init.h> ··· 69 70 #define ds_dbg(lvl, fmt, arg...) do { } while (0) 70 71 #endif 71 72 73 + static struct pcmcia_device *get_pcmcia_device(struct pcmcia_socket *s, 74 + unsigned int function) 75 + { 76 + struct pcmcia_device *p_dev = NULL; 77 + unsigned long flags; 78 + 79 + spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 80 + list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { 81 + if (p_dev->func == function) { 82 + spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 83 + return pcmcia_get_dev(p_dev); 84 + } 85 + } 86 + spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 87 + return NULL; 88 + } 72 89 73 90 /* backwards-compatible accessing of driver --- by name! */ 74 91 75 - static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info) 92 + static struct pcmcia_driver *get_pcmcia_driver(dev_info_t *dev_info) 76 93 { 77 94 struct device_driver *drv; 78 95 struct pcmcia_driver *p_drv; ··· 229 214 * by userspace before, we need to 230 215 * return the "instance". */ 231 216 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 232 - bind_info->instance = p_dev->instance; 217 + bind_info->instance = p_dev; 233 218 ret = -EBUSY; 234 219 goto err_put_module; 235 220 } else { ··· 268 253 /* 269 254 * Prevent this racing with a card insertion. 270 255 */ 271 - down(&s->skt_sem); 256 + mutex_lock(&s->skt_mutex); 272 257 bus_rescan_devices(&pcmcia_bus_type); 273 - up(&s->skt_sem); 258 + mutex_unlock(&s->skt_mutex); 274 259 275 260 /* check whether the driver indeed matched. I don't care if this 276 261 * is racy or not, because it can only happen on cardmgr access ··· 304 289 { 305 290 dev_node_t *node; 306 291 struct pcmcia_device *p_dev; 292 + struct pcmcia_driver *p_drv; 307 293 unsigned long flags; 308 294 int ret = 0; 309 295 ··· 359 343 found: 360 344 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 361 345 362 - if ((!p_dev->instance) || 363 - (p_dev->instance->state & DEV_CONFIG_PENDING)) { 346 + p_drv = to_pcmcia_drv(p_dev->dev.driver); 347 + if (p_drv && !p_dev->_locked) { 364 348 ret = -EAGAIN; 365 349 goto err_put; 366 350 } 367 351 368 352 if (first) 369 - node = p_dev->instance->dev; 353 + node = p_dev->dev_node; 370 354 else 371 - for (node = p_dev->instance->dev; node; node = node->next) 355 + for (node = p_dev->dev_node; node; node = node->next) 372 356 if (node == bind_info->next) 373 357 break; 374 358 if (!node) { ··· 599 583 if (buf->config.Function && 600 584 (buf->config.Function >= s->functions)) 601 585 ret = CS_BAD_ARGS; 602 - else 603 - ret = pccard_get_configuration_info(s, 604 - buf->config.Function, &buf->config); 586 + else { 587 + struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->config.Function); 588 + ret = pccard_get_configuration_info(s, p_dev, &buf->config); 589 + pcmcia_put_dev(p_dev); 590 + } 605 591 break; 606 592 case DS_GET_FIRST_TUPLE: 607 - down(&s->skt_sem); 593 + mutex_lock(&s->skt_mutex); 608 594 pcmcia_validate_mem(s); 609 - up(&s->skt_sem); 595 + mutex_unlock(&s->skt_mutex); 610 596 ret = pccard_get_first_tuple(s, BIND_FN_ALL, &buf->tuple); 611 597 break; 612 598 case DS_GET_NEXT_TUPLE: ··· 627 609 ret = pccard_reset_card(s); 628 610 break; 629 611 case DS_GET_STATUS: 630 - if (buf->status.Function && 631 - (buf->status.Function >= s->functions)) 632 - ret = CS_BAD_ARGS; 633 - else 634 - ret = pccard_get_status(s, buf->status.Function, &buf->status); 635 - break; 612 + if (buf->status.Function && 613 + (buf->status.Function >= s->functions)) 614 + ret = CS_BAD_ARGS; 615 + else { 616 + struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->status.Function); 617 + ret = pccard_get_status(s, p_dev, &buf->status); 618 + pcmcia_put_dev(p_dev); 619 + } 620 + break; 636 621 case DS_VALIDATE_CIS: 637 - down(&s->skt_sem); 622 + mutex_lock(&s->skt_mutex); 638 623 pcmcia_validate_mem(s); 639 - up(&s->skt_sem); 624 + mutex_unlock(&s->skt_mutex); 640 625 ret = pccard_validate_cis(s, BIND_FN_ALL, &buf->cisinfo); 641 626 break; 642 627 case DS_SUSPEND_CARD: ··· 659 638 err = -EPERM; 660 639 goto free_out; 661 640 } 662 - if (buf->conf_reg.Function && 663 - (buf->conf_reg.Function >= s->functions)) 664 - ret = CS_BAD_ARGS; 665 - else 666 - ret = pccard_access_configuration_register(s, 667 - buf->conf_reg.Function, &buf->conf_reg); 641 + 642 + ret = CS_BAD_ARGS; 643 + 644 + if (!(buf->conf_reg.Function && 645 + (buf->conf_reg.Function >= s->functions))) { 646 + struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->conf_reg.Function); 647 + if (p_dev) 648 + ret = pcmcia_access_configuration_register(p_dev, &buf->conf_reg); 649 + pcmcia_put_dev(p_dev); 650 + } 668 651 break; 669 652 case DS_GET_FIRST_REGION: 670 653 case DS_GET_NEXT_REGION:
+118 -108
drivers/pcmcia/pcmcia_resource.c
··· 14 14 * 15 15 */ 16 16 17 - #include <linux/config.h> 18 17 #include <linux/module.h> 19 18 #include <linux/kernel.h> 20 19 #include <linux/interrupt.h> ··· 88 89 } 89 90 if ((s->features & SS_CAP_STATIC_MAP) && s->io_offset) { 90 91 *base = s->io_offset | (*base & 0x0fff); 91 - s->io[0].Attributes = attr; 92 + s->io[0].res->flags = (s->io[0].res->flags & ~IORESOURCE_BITS) | (attr & IORESOURCE_BITS); 92 93 return 0; 93 94 } 94 95 /* Check for an already-allocated window that must conflict with ··· 96 97 * potential conflicts, just the most obvious ones. 97 98 */ 98 99 for (i = 0; i < MAX_IO_WIN; i++) 99 - if ((s->io[i].NumPorts != 0) && 100 - ((s->io[i].BasePort & (align-1)) == *base)) 100 + if ((s->io[i].res) && 101 + ((s->io[i].res->start & (align-1)) == *base)) 101 102 return 1; 102 103 for (i = 0; i < MAX_IO_WIN; i++) { 103 - if (s->io[i].NumPorts == 0) { 104 + if (!s->io[i].res) { 104 105 s->io[i].res = pcmcia_find_io_region(*base, num, align, s); 105 106 if (s->io[i].res) { 106 - s->io[i].Attributes = attr; 107 - s->io[i].BasePort = *base = s->io[i].res->start; 108 - s->io[i].NumPorts = s->io[i].InUse = num; 107 + *base = s->io[i].res->start; 108 + s->io[i].res->flags = (s->io[i].res->flags & ~IORESOURCE_BITS) | (attr & IORESOURCE_BITS); 109 + s->io[i].InUse = num; 109 110 break; 110 111 } else 111 112 return 1; 112 - } else if (s->io[i].Attributes != attr) 113 + } else if ((s->io[i].res->flags & IORESOURCE_BITS) != (attr & IORESOURCE_BITS)) 113 114 continue; 114 115 /* Try to extend top of window */ 115 - try = s->io[i].BasePort + s->io[i].NumPorts; 116 + try = s->io[i].res->end + 1; 116 117 if ((*base == 0) || (*base == try)) 117 118 if (pcmcia_adjust_io_region(s->io[i].res, s->io[i].res->start, 118 119 s->io[i].res->end + num, s) == 0) { 119 120 *base = try; 120 - s->io[i].NumPorts += num; 121 121 s->io[i].InUse += num; 122 122 break; 123 123 } 124 124 /* Try to extend bottom of window */ 125 - try = s->io[i].BasePort - num; 125 + try = s->io[i].res->start - num; 126 126 if ((*base == 0) || (*base == try)) 127 127 if (pcmcia_adjust_io_region(s->io[i].res, s->io[i].res->start - num, 128 128 s->io[i].res->end, s) == 0) { 129 - s->io[i].BasePort = *base = try; 130 - s->io[i].NumPorts += num; 129 + *base = try; 131 130 s->io[i].InUse += num; 132 131 break; 133 132 } ··· 140 143 int i; 141 144 142 145 for (i = 0; i < MAX_IO_WIN; i++) { 143 - if ((s->io[i].BasePort <= base) && 144 - (s->io[i].BasePort+s->io[i].NumPorts >= base+num)) { 146 + if (!s->io[i].res) 147 + continue; 148 + if ((s->io[i].res->start <= base) && 149 + (s->io[i].res->end >= base+num-1)) { 145 150 s->io[i].InUse -= num; 146 151 /* Free the window if no one else is using it */ 147 152 if (s->io[i].InUse == 0) { 148 - s->io[i].NumPorts = 0; 149 153 release_resource(s->io[i].res); 150 154 kfree(s->io[i].res); 151 155 s->io[i].res = NULL; ··· 163 165 * this and the tuple reading services. 164 166 */ 165 167 166 - int pccard_access_configuration_register(struct pcmcia_socket *s, 167 - unsigned int function, 168 + int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, 168 169 conf_reg_t *reg) 169 170 { 171 + struct pcmcia_socket *s; 170 172 config_t *c; 171 173 int addr; 172 174 u_char val; 173 175 174 - if (!s || !s->config) 176 + if (!p_dev || !p_dev->function_config) 175 177 return CS_NO_CARD; 176 178 177 - c = &s->config[function]; 178 - 179 - if (c == NULL) 180 - return CS_NO_CARD; 179 + s = p_dev->socket; 180 + c = p_dev->function_config; 181 181 182 182 if (!(c->state & CONFIG_LOCKED)) 183 183 return CS_CONFIGURATION_LOCKED; ··· 196 200 break; 197 201 } 198 202 return CS_SUCCESS; 199 - } /* pccard_access_configuration_register */ 200 - 201 - int pcmcia_access_configuration_register(struct pcmcia_device *p_dev, 202 - conf_reg_t *reg) 203 - { 204 - return pccard_access_configuration_register(p_dev->socket, 205 - p_dev->func, reg); 206 - } 203 + } /* pcmcia_access_configuration_register */ 207 204 EXPORT_SYMBOL(pcmcia_access_configuration_register); 208 205 209 206 210 - 211 207 int pccard_get_configuration_info(struct pcmcia_socket *s, 212 - unsigned int function, 208 + struct pcmcia_device *p_dev, 213 209 config_info_t *config) 214 210 { 215 211 config_t *c; ··· 209 221 if (!(s->state & SOCKET_PRESENT)) 210 222 return CS_NO_CARD; 211 223 212 - config->Function = function; 224 + config->Function = p_dev->func; 213 225 214 226 #ifdef CONFIG_CARDBUS 215 227 if (s->state & SOCKET_CARDBUS) { ··· 223 235 config->AssignedIRQ = s->irq.AssignedIRQ; 224 236 if (config->AssignedIRQ) 225 237 config->Attributes |= CONF_ENABLE_IRQ; 226 - config->BasePort1 = s->io[0].BasePort; 227 - config->NumPorts1 = s->io[0].NumPorts; 238 + config->BasePort1 = s->io[0].res->start; 239 + config->NumPorts1 = s->io[0].res->end - config->BasePort1 + 1; 228 240 } 229 241 return CS_SUCCESS; 230 242 } 231 243 #endif 232 244 233 - c = (s->config != NULL) ? &s->config[function] : NULL; 245 + c = (p_dev) ? p_dev->function_config : NULL; 234 246 235 247 if ((c == NULL) || !(c->state & CONFIG_LOCKED)) { 236 248 config->Attributes = 0; ··· 259 271 int pcmcia_get_configuration_info(struct pcmcia_device *p_dev, 260 272 config_info_t *config) 261 273 { 262 - return pccard_get_configuration_info(p_dev->socket, p_dev->func, 274 + return pccard_get_configuration_info(p_dev->socket, p_dev, 263 275 config); 264 276 } 265 277 EXPORT_SYMBOL(pcmcia_get_configuration_info); ··· 305 317 * SocketState yet: I haven't seen any point for it. 306 318 */ 307 319 308 - int pccard_get_status(struct pcmcia_socket *s, unsigned int function, 320 + int pccard_get_status(struct pcmcia_socket *s, struct pcmcia_device *p_dev, 309 321 cs_status_t *status) 310 322 { 311 323 config_t *c; ··· 322 334 if (!(s->state & SOCKET_PRESENT)) 323 335 return CS_NO_CARD; 324 336 325 - c = (s->config != NULL) ? &s->config[function] : NULL; 337 + c = (p_dev) ? p_dev->function_config : NULL; 338 + 326 339 if ((c != NULL) && (c->state & CONFIG_LOCKED) && 327 340 (c->IntType & (INT_MEMORY_AND_IO | INT_ZOOMED_VIDEO))) { 328 341 u_char reg; 329 - if (c->Present & PRESENT_PIN_REPLACE) { 342 + if (c->CardValues & PRESENT_PIN_REPLACE) { 330 343 pcmcia_read_cis_mem(s, 1, (c->ConfigBase+CISREG_PRR)>>1, 1, &reg); 331 344 status->CardState |= 332 345 (reg & PRR_WP_STATUS) ? CS_EVENT_WRITE_PROTECT : 0; ··· 341 352 /* No PRR? Then assume we're always ready */ 342 353 status->CardState |= CS_EVENT_READY_CHANGE; 343 354 } 344 - if (c->Present & PRESENT_EXT_STATUS) { 355 + if (c->CardValues & PRESENT_EXT_STATUS) { 345 356 pcmcia_read_cis_mem(s, 1, (c->ConfigBase+CISREG_ESR)>>1, 1, &reg); 346 357 status->CardState |= 347 358 (reg & ESR_REQ_ATTN) ? CS_EVENT_REQUEST_ATTENTION : 0; ··· 359 370 return CS_SUCCESS; 360 371 } /* pccard_get_status */ 361 372 362 - int pcmcia_get_status(client_handle_t handle, cs_status_t *status) 373 + int pcmcia_get_status(struct pcmcia_device *p_dev, cs_status_t *status) 363 374 { 364 - struct pcmcia_socket *s; 365 - s = SOCKET(handle); 366 - return pccard_get_status(s, handle->func, status); 375 + return pccard_get_status(p_dev->socket, p_dev, status); 367 376 } 368 377 EXPORT_SYMBOL(pcmcia_get_status); 369 378 ··· 409 422 config_t *c; 410 423 411 424 s = p_dev->socket; 412 - c = CONFIG(p_dev); 425 + c = p_dev->function_config; 426 + 413 427 if (!(s->state & SOCKET_PRESENT)) 414 428 return CS_NO_CARD; 415 429 if (!(c->state & CONFIG_LOCKED)) ··· 442 454 (mod->Attributes & CONF_VPP2_CHANGE_VALID)) 443 455 return CS_BAD_VPP; 444 456 457 + if (mod->Attributes & CONF_IO_CHANGE_WIDTH) { 458 + pccard_io_map io_off = { 0, 0, 0, 0, 1 }; 459 + pccard_io_map io_on; 460 + int i; 461 + 462 + io_on.speed = io_speed; 463 + for (i = 0; i < MAX_IO_WIN; i++) { 464 + if (!s->io[i].res) 465 + continue; 466 + io_off.map = i; 467 + io_on.map = i; 468 + 469 + io_on.flags = MAP_ACTIVE | IO_DATA_PATH_WIDTH_8; 470 + io_on.start = s->io[i].res->start; 471 + io_on.stop = s->io[i].res->end; 472 + 473 + s->ops->set_io_map(s, &io_off); 474 + mdelay(40); 475 + s->ops->set_io_map(s, &io_on); 476 + } 477 + } 478 + 445 479 return CS_SUCCESS; 446 480 } /* modify_configuration */ 447 481 EXPORT_SYMBOL(pcmcia_modify_configuration); ··· 473 463 { 474 464 pccard_io_map io = { 0, 0, 0, 0, 1 }; 475 465 struct pcmcia_socket *s = p_dev->socket; 466 + config_t *c = p_dev->function_config; 476 467 int i; 477 468 478 - if (!(p_dev->state & CLIENT_CONFIG_LOCKED)) 479 - return CS_BAD_HANDLE; 480 - p_dev->state &= ~CLIENT_CONFIG_LOCKED; 481 - 482 - if (!(p_dev->state & CLIENT_STALE)) { 483 - config_t *c = CONFIG(p_dev); 469 + if (p_dev->_locked) { 470 + p_dev->_locked = 0; 484 471 if (--(s->lock_count) == 0) { 485 472 s->socket.flags = SS_OUTPUT_ENA; /* Is this correct? */ 486 473 s->socket.Vpp = 0; 487 474 s->socket.io_irq = 0; 488 475 s->ops->set_socket(s, &s->socket); 489 476 } 477 + } 478 + if (c->state & CONFIG_LOCKED) { 479 + c->state &= ~CONFIG_LOCKED; 490 480 if (c->state & CONFIG_IO_REQ) 491 481 for (i = 0; i < MAX_IO_WIN; i++) { 492 - if (s->io[i].NumPorts == 0) 482 + if (!s->io[i].res) 493 483 continue; 494 484 s->io[i].Config--; 495 485 if (s->io[i].Config != 0) ··· 497 487 io.map = i; 498 488 s->ops->set_io_map(s, &io); 499 489 } 500 - c->state &= ~CONFIG_LOCKED; 501 490 } 502 491 503 492 return CS_SUCCESS; 504 493 } /* pcmcia_release_configuration */ 505 - EXPORT_SYMBOL(pcmcia_release_configuration); 506 494 507 495 508 496 /** pcmcia_release_io ··· 511 503 * don't bother checking the port ranges against the current socket 512 504 * values. 513 505 */ 514 - int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req) 506 + static int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req) 515 507 { 516 508 struct pcmcia_socket *s = p_dev->socket; 509 + config_t *c = p_dev->function_config; 517 510 518 - if (!(p_dev->state & CLIENT_IO_REQ)) 511 + if (!p_dev->_io ) 519 512 return CS_BAD_HANDLE; 520 - p_dev->state &= ~CLIENT_IO_REQ; 521 513 522 - if (!(p_dev->state & CLIENT_STALE)) { 523 - config_t *c = CONFIG(p_dev); 524 - if (c->state & CONFIG_LOCKED) 525 - return CS_CONFIGURATION_LOCKED; 526 - if ((c->io.BasePort1 != req->BasePort1) || 527 - (c->io.NumPorts1 != req->NumPorts1) || 528 - (c->io.BasePort2 != req->BasePort2) || 529 - (c->io.NumPorts2 != req->NumPorts2)) 530 - return CS_BAD_ARGS; 531 - c->state &= ~CONFIG_IO_REQ; 532 - } 514 + p_dev->_io = 0; 515 + 516 + if ((c->io.BasePort1 != req->BasePort1) || 517 + (c->io.NumPorts1 != req->NumPorts1) || 518 + (c->io.BasePort2 != req->BasePort2) || 519 + (c->io.NumPorts2 != req->NumPorts2)) 520 + return CS_BAD_ARGS; 521 + 522 + c->state &= ~CONFIG_IO_REQ; 533 523 534 524 release_io_space(s, req->BasePort1, req->NumPorts1); 535 525 if (req->NumPorts2) ··· 535 529 536 530 return CS_SUCCESS; 537 531 } /* pcmcia_release_io */ 538 - EXPORT_SYMBOL(pcmcia_release_io); 539 532 540 533 541 - int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req) 534 + static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req) 542 535 { 543 536 struct pcmcia_socket *s = p_dev->socket; 544 - if (!(p_dev->state & CLIENT_IRQ_REQ)) 545 - return CS_BAD_HANDLE; 546 - p_dev->state &= ~CLIENT_IRQ_REQ; 537 + config_t *c= p_dev->function_config; 547 538 548 - if (!(p_dev->state & CLIENT_STALE)) { 549 - config_t *c = CONFIG(p_dev); 550 - if (c->state & CONFIG_LOCKED) 551 - return CS_CONFIGURATION_LOCKED; 552 - if (c->irq.Attributes != req->Attributes) 553 - return CS_BAD_ATTRIBUTE; 554 - if (s->irq.AssignedIRQ != req->AssignedIRQ) 555 - return CS_BAD_IRQ; 556 - if (--s->irq.Config == 0) { 557 - c->state &= ~CONFIG_IRQ_REQ; 558 - s->irq.AssignedIRQ = 0; 559 - } 539 + if (!p_dev->_irq) 540 + return CS_BAD_HANDLE; 541 + p_dev->_irq = 0; 542 + 543 + if (c->state & CONFIG_LOCKED) 544 + return CS_CONFIGURATION_LOCKED; 545 + if (c->irq.Attributes != req->Attributes) 546 + return CS_BAD_ATTRIBUTE; 547 + if (s->irq.AssignedIRQ != req->AssignedIRQ) 548 + return CS_BAD_IRQ; 549 + if (--s->irq.Config == 0) { 550 + c->state &= ~CONFIG_IRQ_REQ; 551 + s->irq.AssignedIRQ = 0; 560 552 } 561 553 562 554 if (req->Attributes & IRQ_HANDLE_PRESENT) { ··· 567 563 568 564 return CS_SUCCESS; 569 565 } /* pcmcia_release_irq */ 570 - EXPORT_SYMBOL(pcmcia_release_irq); 571 566 572 567 573 568 int pcmcia_release_window(window_handle_t win) ··· 576 573 if ((win == NULL) || (win->magic != WINDOW_MAGIC)) 577 574 return CS_BAD_HANDLE; 578 575 s = win->sock; 579 - if (!(win->handle->state & CLIENT_WIN_REQ(win->index))) 576 + if (!(win->handle->_win & CLIENT_WIN_REQ(win->index))) 580 577 return CS_BAD_HANDLE; 581 578 582 579 /* Shut down memory window */ ··· 590 587 kfree(win->ctl.res); 591 588 win->ctl.res = NULL; 592 589 } 593 - win->handle->state &= ~CLIENT_WIN_REQ(win->index); 590 + win->handle->_win &= ~CLIENT_WIN_REQ(win->index); 594 591 595 592 win->magic = 0; 596 593 ··· 613 610 614 611 if (req->IntType & INT_CARDBUS) 615 612 return CS_UNSUPPORTED_MODE; 616 - c = CONFIG(p_dev); 613 + c = p_dev->function_config; 617 614 if (c->state & CONFIG_LOCKED) 618 615 return CS_CONFIGURATION_LOCKED; 619 616 620 617 /* Do power control. We don't allow changes in Vcc. */ 621 - if (s->socket.Vcc != req->Vcc) 622 - return CS_BAD_VCC; 623 - if (req->Vpp1 != req->Vpp2) 624 - return CS_BAD_VPP; 625 - s->socket.Vpp = req->Vpp1; 618 + s->socket.Vpp = req->Vpp; 626 619 if (s->ops->set_socket(s, &s->socket)) 627 620 return CS_BAD_VPP; 628 621 ··· 642 643 643 644 /* Set up CIS configuration registers */ 644 645 base = c->ConfigBase = req->ConfigBase; 645 - c->Present = c->CardValues = req->Present; 646 + c->CardValues = req->Present; 646 647 if (req->Present & PRESENT_COPY) { 647 648 c->Copy = req->Copy; 648 649 pcmcia_write_cis_mem(s, 1, (base + CISREG_SCR)>>1, 1, &c->Copy); ··· 689 690 if (c->state & CONFIG_IO_REQ) { 690 691 iomap.speed = io_speed; 691 692 for (i = 0; i < MAX_IO_WIN; i++) 692 - if (s->io[i].NumPorts != 0) { 693 + if (s->io[i].res) { 693 694 iomap.map = i; 694 695 iomap.flags = MAP_ACTIVE; 695 - switch (s->io[i].Attributes & IO_DATA_PATH_WIDTH) { 696 + switch (s->io[i].res->flags & IO_DATA_PATH_WIDTH) { 696 697 case IO_DATA_PATH_WIDTH_16: 697 698 iomap.flags |= MAP_16BIT; break; 698 699 case IO_DATA_PATH_WIDTH_AUTO: ··· 700 701 default: 701 702 break; 702 703 } 703 - iomap.start = s->io[i].BasePort; 704 - iomap.stop = iomap.start + s->io[i].NumPorts - 1; 704 + iomap.start = s->io[i].res->start; 705 + iomap.stop = s->io[i].res->end; 705 706 s->ops->set_io_map(s, &iomap); 706 707 s->io[i].Config++; 707 708 } 708 709 } 709 710 710 711 c->state |= CONFIG_LOCKED; 711 - p_dev->state |= CLIENT_CONFIG_LOCKED; 712 + p_dev->_locked = 1; 712 713 return CS_SUCCESS; 713 714 } /* pcmcia_request_configuration */ 714 715 EXPORT_SYMBOL(pcmcia_request_configuration); ··· 729 730 730 731 if (!req) 731 732 return CS_UNSUPPORTED_MODE; 732 - c = CONFIG(p_dev); 733 + c = p_dev->function_config; 733 734 if (c->state & CONFIG_LOCKED) 734 735 return CS_CONFIGURATION_LOCKED; 735 736 if (c->state & CONFIG_IO_REQ) ··· 754 755 755 756 c->io = *req; 756 757 c->state |= CONFIG_IO_REQ; 757 - p_dev->state |= CLIENT_IO_REQ; 758 + p_dev->_io = 1; 758 759 return CS_SUCCESS; 759 760 } /* pcmcia_request_io */ 760 761 EXPORT_SYMBOL(pcmcia_request_io); ··· 785 786 786 787 if (!(s->state & SOCKET_PRESENT)) 787 788 return CS_NO_CARD; 788 - c = CONFIG(p_dev); 789 + c = p_dev->function_config; 789 790 if (c->state & CONFIG_LOCKED) 790 791 return CS_CONFIGURATION_LOCKED; 791 792 if (c->state & CONFIG_IRQ_REQ) ··· 850 851 s->irq.Config++; 851 852 852 853 c->state |= CONFIG_IRQ_REQ; 853 - p_dev->state |= CLIENT_IRQ_REQ; 854 + p_dev->_irq = 1; 854 855 855 856 #ifdef CONFIG_PCMCIA_PROBE 856 857 pcmcia_used_irq[irq]++; ··· 910 911 if (!win->ctl.res) 911 912 return CS_IN_USE; 912 913 } 913 - (*p_dev)->state |= CLIENT_WIN_REQ(w); 914 + (*p_dev)->_win |= CLIENT_WIN_REQ(w); 914 915 915 916 /* Configure the socket controller */ 916 917 win->ctl.map = w+1; ··· 940 941 return CS_SUCCESS; 941 942 } /* pcmcia_request_window */ 942 943 EXPORT_SYMBOL(pcmcia_request_window); 944 + 945 + void pcmcia_disable_device(struct pcmcia_device *p_dev) { 946 + pcmcia_release_configuration(p_dev); 947 + pcmcia_release_io(p_dev, &p_dev->io); 948 + pcmcia_release_irq(p_dev, &p_dev->irq); 949 + if (&p_dev->win) 950 + pcmcia_release_window(p_dev->win); 951 + 952 + p_dev->dev_node = NULL; 953 + } 954 + EXPORT_SYMBOL(pcmcia_disable_device);
-1
drivers/pcmcia/pd6729.c
··· 8 8 */ 9 9 10 10 #include <linux/kernel.h> 11 - #include <linux/config.h> 12 11 #include <linux/module.h> 13 12 #include <linux/pci.h> 14 13 #include <linux/init.h>
+4 -1
drivers/pcmcia/rsrc_mgr.c
··· 12 12 * (C) 1999 David A. Hinds 13 13 */ 14 14 15 - #include <linux/config.h> 16 15 #include <linux/module.h> 17 16 #include <linux/kernel.h> 18 17 ··· 20 21 #include <pcmcia/cs.h> 21 22 #include "cs_internal.h" 22 23 24 + 25 + #ifdef CONFIG_PCMCIA_IOCTL 23 26 24 27 #ifdef CONFIG_PCMCIA_PROBE 25 28 ··· 98 97 return (ret); 99 98 } 100 99 EXPORT_SYMBOL(pcmcia_adjust_resource_info); 100 + 101 + #endif 101 102 102 103 int pcmcia_validate_mem(struct pcmcia_socket *s) 103 104 {
+20 -21
drivers/pcmcia/rsrc_nonstatic.c
··· 12 12 * (C) 1999 David A. Hinds 13 13 */ 14 14 15 - #include <linux/config.h> 16 15 #include <linux/module.h> 17 16 #include <linux/moduleparam.h> 18 17 #include <linux/init.h> ··· 60 61 unsigned int rsrc_mem_probe; 61 62 }; 62 63 63 - static DECLARE_MUTEX(rsrc_sem); 64 + static DEFINE_MUTEX(rsrc_mutex); 64 65 #define MEM_PROBE_LOW (1 << 0) 65 66 #define MEM_PROBE_HIGH (1 << 1) 66 67 ··· 483 484 484 485 485 486 /* 486 - * Locking note: Must be called with skt_sem held! 487 + * Locking note: Must be called with skt_mutex held! 487 488 */ 488 489 static int pcmcia_nonstatic_validate_mem(struct pcmcia_socket *s) 489 490 { ··· 494 495 if (!probe_mem) 495 496 return 0; 496 497 497 - down(&rsrc_sem); 498 + mutex_lock(&rsrc_mutex); 498 499 499 500 if (s->features & SS_CAP_PAGE_REGS) 500 501 probe_mask = MEM_PROBE_HIGH; ··· 506 507 s_data->rsrc_mem_probe |= probe_mask; 507 508 } 508 509 509 - up(&rsrc_sem); 510 + mutex_unlock(&rsrc_mutex); 510 511 511 512 return ret; 512 513 } ··· 584 585 struct socket_data *s_data = s->resource_data; 585 586 int ret = -ENOMEM; 586 587 587 - down(&rsrc_sem); 588 + mutex_lock(&rsrc_mutex); 588 589 for (m = s_data->io_db.next; m != &s_data->io_db; m = m->next) { 589 590 unsigned long start = m->base; 590 591 unsigned long end = m->base + m->num - 1; ··· 595 596 ret = adjust_resource(res, r_start, r_end - r_start + 1); 596 597 break; 597 598 } 598 - up(&rsrc_sem); 599 + mutex_unlock(&rsrc_mutex); 599 600 600 601 return ret; 601 602 } ··· 629 630 data.offset = base & data.mask; 630 631 data.map = &s_data->io_db; 631 632 632 - down(&rsrc_sem); 633 + mutex_lock(&rsrc_mutex); 633 634 #ifdef CONFIG_PCI 634 635 if (s->cb_dev) { 635 636 ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num, 1, ··· 638 639 #endif 639 640 ret = allocate_resource(&ioport_resource, res, num, min, ~0UL, 640 641 1, pcmcia_align, &data); 641 - up(&rsrc_sem); 642 + mutex_unlock(&rsrc_mutex); 642 643 643 644 if (ret != 0) { 644 645 kfree(res); ··· 671 672 min = 0x100000UL + base; 672 673 } 673 674 674 - down(&rsrc_sem); 675 + mutex_lock(&rsrc_mutex); 675 676 #ifdef CONFIG_PCI 676 677 if (s->cb_dev) { 677 678 ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num, ··· 681 682 #endif 682 683 ret = allocate_resource(&iomem_resource, res, num, min, 683 684 max, 1, pcmcia_align, &data); 684 - up(&rsrc_sem); 685 + mutex_unlock(&rsrc_mutex); 685 686 if (ret == 0 || low) 686 687 break; 687 688 low = 1; ··· 704 705 if (end < start) 705 706 return -EINVAL; 706 707 707 - down(&rsrc_sem); 708 + mutex_lock(&rsrc_mutex); 708 709 switch (action) { 709 710 case ADD_MANAGED_RESOURCE: 710 711 ret = add_interval(&data->mem_db, start, size); ··· 722 723 default: 723 724 ret = -EINVAL; 724 725 } 725 - up(&rsrc_sem); 726 + mutex_unlock(&rsrc_mutex); 726 727 727 728 return ret; 728 729 } ··· 740 741 if (end > IO_SPACE_LIMIT) 741 742 return -EINVAL; 742 743 743 - down(&rsrc_sem); 744 + mutex_lock(&rsrc_mutex); 744 745 switch (action) { 745 746 case ADD_MANAGED_RESOURCE: 746 747 if (add_interval(&data->io_db, start, size) != 0) { ··· 759 760 ret = -EINVAL; 760 761 break; 761 762 } 762 - up(&rsrc_sem); 763 + mutex_unlock(&rsrc_mutex); 763 764 764 765 return ret; 765 766 } ··· 866 867 struct socket_data *data = s->resource_data; 867 868 struct resource_map *p, *q; 868 869 869 - down(&rsrc_sem); 870 + mutex_lock(&rsrc_mutex); 870 871 for (p = data->mem_db.next; p != &data->mem_db; p = q) { 871 872 q = p->next; 872 873 kfree(p); ··· 875 876 q = p->next; 876 877 kfree(p); 877 878 } 878 - up(&rsrc_sem); 879 + mutex_unlock(&rsrc_mutex); 879 880 } 880 881 881 882 ··· 900 901 struct resource_map *p; 901 902 ssize_t ret = 0; 902 903 903 - down(&rsrc_sem); 904 + mutex_lock(&rsrc_mutex); 904 905 data = s->resource_data; 905 906 906 907 for (p = data->io_db.next; p != &data->io_db; p = p->next) { ··· 912 913 ((unsigned long) p->base + p->num - 1)); 913 914 } 914 915 915 - up(&rsrc_sem); 916 + mutex_unlock(&rsrc_mutex); 916 917 return (ret); 917 918 } 918 919 ··· 952 953 struct resource_map *p; 953 954 ssize_t ret = 0; 954 955 955 - down(&rsrc_sem); 956 + mutex_lock(&rsrc_mutex); 956 957 data = s->resource_data; 957 958 958 959 for (p = data->mem_db.next; p != &data->mem_db; p = p->next) { ··· 964 965 ((unsigned long) p->base + p->num - 1)); 965 966 } 966 967 967 - up(&rsrc_sem); 968 + mutex_unlock(&rsrc_mutex); 968 969 return (ret); 969 970 } 970 971
-1
drivers/pcmcia/sa1100_cerf.c
··· 5 5 * Based off the Assabet. 6 6 * 7 7 */ 8 - #include <linux/config.h> 9 8 #include <linux/module.h> 10 9 #include <linux/kernel.h> 11 10 #include <linux/sched.h>
+5 -5
drivers/pcmcia/socket_sysfs.c
··· 12 12 #include <linux/moduleparam.h> 13 13 #include <linux/init.h> 14 14 #include <linux/kernel.h> 15 - #include <linux/config.h> 16 15 #include <linux/string.h> 17 16 #include <linux/major.h> 18 17 #include <linux/errno.h> ··· 24 25 #include <linux/pm.h> 25 26 #include <linux/pci.h> 26 27 #include <linux/device.h> 28 + #include <linux/mutex.h> 27 29 #include <asm/system.h> 28 30 #include <asm/irq.h> 29 31 ··· 183 183 s->resource_setup_done = 1; 184 184 spin_unlock_irqrestore(&s->lock, flags); 185 185 186 - down(&s->skt_sem); 186 + mutex_lock(&s->skt_mutex); 187 187 if ((s->callback) && 188 188 (s->state & SOCKET_PRESENT) && 189 189 !(s->state & SOCKET_CARDBUS)) { ··· 192 192 module_put(s->callback->owner); 193 193 } 194 194 } 195 - up(&s->skt_sem); 195 + mutex_unlock(&s->skt_mutex); 196 196 197 197 return count; 198 198 } ··· 322 322 kfree(cis); 323 323 324 324 if (!ret) { 325 - down(&s->skt_sem); 325 + mutex_lock(&s->skt_mutex); 326 326 if ((s->callback) && (s->state & SOCKET_PRESENT) && 327 327 !(s->state & SOCKET_CARDBUS)) { 328 328 if (try_module_get(s->callback->owner)) { ··· 330 330 module_put(s->callback->owner); 331 331 } 332 332 } 333 - up(&s->skt_sem); 333 + mutex_unlock(&s->skt_mutex); 334 334 } 335 335 336 336
-1
drivers/pcmcia/ti113x.h
··· 30 30 #ifndef _LINUX_TI113X_H 31 31 #define _LINUX_TI113X_H 32 32 33 - #include <linux/config.h> 34 33 35 34 /* Register definitions for TI 113X PCI-to-CardBus bridges */ 36 35
+32 -80
drivers/scsi/pcmcia/aha152x_stub.c
··· 89 89 /*====================================================================*/ 90 90 91 91 typedef struct scsi_info_t { 92 - dev_link_t link; 92 + struct pcmcia_device *p_dev; 93 93 dev_node_t node; 94 94 struct Scsi_Host *host; 95 95 } scsi_info_t; 96 96 97 - static void aha152x_release_cs(dev_link_t *link); 97 + static void aha152x_release_cs(struct pcmcia_device *link); 98 98 static void aha152x_detach(struct pcmcia_device *p_dev); 99 - static void aha152x_config_cs(dev_link_t *link); 99 + static int aha152x_config_cs(struct pcmcia_device *link); 100 100 101 - static dev_link_t *dev_list; 101 + static struct pcmcia_device *dev_list; 102 102 103 - static int aha152x_attach(struct pcmcia_device *p_dev) 103 + static int aha152x_probe(struct pcmcia_device *link) 104 104 { 105 105 scsi_info_t *info; 106 - dev_link_t *link; 107 - 106 + 108 107 DEBUG(0, "aha152x_attach()\n"); 109 108 110 109 /* Create new SCSI device */ 111 110 info = kmalloc(sizeof(*info), GFP_KERNEL); 112 111 if (!info) return -ENOMEM; 113 112 memset(info, 0, sizeof(*info)); 114 - link = &info->link; link->priv = info; 113 + info->p_dev = link; 114 + link->priv = info; 115 115 116 116 link->io.NumPorts1 = 0x20; 117 117 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; ··· 119 119 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 120 120 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 121 121 link->conf.Attributes = CONF_ENABLE_IRQ; 122 - link->conf.Vcc = 50; 123 122 link->conf.IntType = INT_MEMORY_AND_IO; 124 123 link->conf.Present = PRESENT_OPTION; 125 124 126 - link->handle = p_dev; 127 - p_dev->instance = link; 128 - 129 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 130 - aha152x_config_cs(link); 131 - 132 - return 0; 125 + return aha152x_config_cs(link); 133 126 } /* aha152x_attach */ 134 127 135 128 /*====================================================================*/ 136 129 137 - static void aha152x_detach(struct pcmcia_device *p_dev) 130 + static void aha152x_detach(struct pcmcia_device *link) 138 131 { 139 - dev_link_t *link = dev_to_instance(p_dev); 140 - dev_link_t **linkp; 141 - 142 132 DEBUG(0, "aha152x_detach(0x%p)\n", link); 143 - 144 - /* Locate device structure */ 145 - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) 146 - if (*linkp == link) break; 147 - if (*linkp == NULL) 148 - return; 149 133 150 - if (link->state & DEV_CONFIG) 151 - aha152x_release_cs(link); 134 + aha152x_release_cs(link); 152 135 153 136 /* Unlink device structure, free bits */ 154 - *linkp = link->next; 155 137 kfree(link->priv); 156 - 157 138 } /* aha152x_detach */ 158 139 159 140 /*====================================================================*/ ··· 142 161 #define CS_CHECK(fn, ret) \ 143 162 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 144 163 145 - static void aha152x_config_cs(dev_link_t *link) 164 + static int aha152x_config_cs(struct pcmcia_device *link) 146 165 { 147 - client_handle_t handle = link->handle; 148 166 scsi_info_t *info = link->priv; 149 167 struct aha152x_setup s; 150 168 tuple_t tuple; ··· 158 178 tuple.TupleData = tuple_data; 159 179 tuple.TupleDataMax = 64; 160 180 tuple.TupleOffset = 0; 161 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 162 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 163 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 181 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 182 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 183 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 164 184 link->conf.ConfigBase = parse.config.base; 165 185 166 - /* Configure card */ 167 - link->state |= DEV_CONFIG; 168 - 169 186 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 170 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 187 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 171 188 while (1) { 172 - if (pcmcia_get_tuple_data(handle, &tuple) != 0 || 173 - pcmcia_parse_tuple(handle, &tuple, &parse) != 0) 189 + if (pcmcia_get_tuple_data(link, &tuple) != 0 || 190 + pcmcia_parse_tuple(link, &tuple, &parse) != 0) 174 191 goto next_entry; 175 192 /* For New Media T&J, look for a SCSI window */ 176 193 if (parse.cftable_entry.io.win[0].len >= 0x20) ··· 178 201 if ((parse.cftable_entry.io.nwin > 0) && 179 202 (link->io.BasePort1 < 0xffff)) { 180 203 link->conf.ConfigIndex = parse.cftable_entry.index; 181 - i = pcmcia_request_io(handle, &link->io); 204 + i = pcmcia_request_io(link, &link->io); 182 205 if (i == CS_SUCCESS) break; 183 206 } 184 207 next_entry: 185 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); 208 + CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 186 209 } 187 210 188 - CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq)); 189 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); 211 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 212 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 190 213 191 214 /* Set configuration options for the aha152x driver */ 192 215 memset(&s, 0, sizeof(s)); ··· 208 231 } 209 232 210 233 sprintf(info->node.dev_name, "scsi%d", host->host_no); 211 - link->dev = &info->node; 234 + link->dev_node = &info->node; 212 235 info->host = host; 213 236 214 - link->state &= ~DEV_CONFIG_PENDING; 215 - return; 216 - 237 + return 0; 238 + 217 239 cs_failed: 218 - cs_error(link->handle, last_fn, last_ret); 240 + cs_error(link, last_fn, last_ret); 219 241 aha152x_release_cs(link); 220 - return; 242 + return -ENODEV; 221 243 } 222 244 223 - static void aha152x_release_cs(dev_link_t *link) 245 + static void aha152x_release_cs(struct pcmcia_device *link) 224 246 { 225 247 scsi_info_t *info = link->priv; 226 248 227 249 aha152x_release(info->host); 228 - link->dev = NULL; 229 - 230 - pcmcia_release_configuration(link->handle); 231 - pcmcia_release_io(link->handle, &link->io); 232 - pcmcia_release_irq(link->handle, &link->irq); 233 - 234 - link->state &= ~DEV_CONFIG; 250 + pcmcia_disable_device(link); 235 251 } 236 252 237 - static int aha152x_suspend(struct pcmcia_device *dev) 253 + static int aha152x_resume(struct pcmcia_device *link) 238 254 { 239 - dev_link_t *link = dev_to_instance(dev); 240 - 241 - link->state |= DEV_SUSPEND; 242 - if (link->state & DEV_CONFIG) 243 - pcmcia_release_configuration(link->handle); 244 - 245 - return 0; 246 - } 247 - 248 - static int aha152x_resume(struct pcmcia_device *dev) 249 - { 250 - dev_link_t *link = dev_to_instance(dev); 251 255 scsi_info_t *info = link->priv; 252 256 253 - link->state &= ~DEV_SUSPEND; 254 - if (link->state & DEV_CONFIG) { 255 - pcmcia_request_configuration(link->handle, &link->conf); 256 - aha152x_host_reset_host(info->host); 257 - } 257 + aha152x_host_reset_host(info->host); 258 258 259 259 return 0; 260 260 } ··· 251 297 .drv = { 252 298 .name = "aha152x_cs", 253 299 }, 254 - .probe = aha152x_attach, 300 + .probe = aha152x_probe, 255 301 .remove = aha152x_detach, 256 302 .id_table = aha152x_ids, 257 - .suspend = aha152x_suspend, 258 303 .resume = aha152x_resume, 259 304 }; 260 305 ··· 270 317 271 318 module_init(init_aha152x_cs); 272 319 module_exit(exit_aha152x_cs); 273 -
+54 -93
drivers/scsi/pcmcia/fdomain_stub.c
··· 73 73 /*====================================================================*/ 74 74 75 75 typedef struct scsi_info_t { 76 - dev_link_t link; 76 + struct pcmcia_device *p_dev; 77 77 dev_node_t node; 78 78 struct Scsi_Host *host; 79 79 } scsi_info_t; 80 80 81 81 82 - static void fdomain_release(dev_link_t *link); 82 + static void fdomain_release(struct pcmcia_device *link); 83 83 static void fdomain_detach(struct pcmcia_device *p_dev); 84 - static void fdomain_config(dev_link_t *link); 84 + static int fdomain_config(struct pcmcia_device *link); 85 85 86 - static int fdomain_attach(struct pcmcia_device *p_dev) 86 + static int fdomain_probe(struct pcmcia_device *link) 87 87 { 88 - scsi_info_t *info; 89 - dev_link_t *link; 88 + scsi_info_t *info; 90 89 91 - DEBUG(0, "fdomain_attach()\n"); 90 + DEBUG(0, "fdomain_attach()\n"); 92 91 93 - /* Create new SCSI device */ 94 - info = kmalloc(sizeof(*info), GFP_KERNEL); 95 - if (!info) return -ENOMEM; 96 - memset(info, 0, sizeof(*info)); 97 - link = &info->link; link->priv = info; 98 - link->io.NumPorts1 = 0x10; 99 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 100 - link->io.IOAddrLines = 10; 101 - link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 102 - link->irq.IRQInfo1 = IRQ_LEVEL_ID; 103 - link->conf.Attributes = CONF_ENABLE_IRQ; 104 - link->conf.Vcc = 50; 105 - link->conf.IntType = INT_MEMORY_AND_IO; 106 - link->conf.Present = PRESENT_OPTION; 92 + /* Create new SCSI device */ 93 + info = kzalloc(sizeof(*info), GFP_KERNEL); 94 + if (!info) 95 + return -ENOMEM; 107 96 108 - link->handle = p_dev; 109 - p_dev->instance = link; 97 + info->p_dev = link; 98 + link->priv = info; 99 + link->io.NumPorts1 = 0x10; 100 + link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 101 + link->io.IOAddrLines = 10; 102 + link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 103 + link->irq.IRQInfo1 = IRQ_LEVEL_ID; 104 + link->conf.Attributes = CONF_ENABLE_IRQ; 105 + link->conf.IntType = INT_MEMORY_AND_IO; 106 + link->conf.Present = PRESENT_OPTION; 110 107 111 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 112 - fdomain_config(link); 113 - 114 - return 0; 108 + return fdomain_config(link); 115 109 } /* fdomain_attach */ 116 110 117 111 /*====================================================================*/ 118 112 119 - static void fdomain_detach(struct pcmcia_device *p_dev) 113 + static void fdomain_detach(struct pcmcia_device *link) 120 114 { 121 - dev_link_t *link = dev_to_instance(p_dev); 122 - 123 115 DEBUG(0, "fdomain_detach(0x%p)\n", link); 124 116 125 - if (link->state & DEV_CONFIG) 126 - fdomain_release(link); 117 + fdomain_release(link); 127 118 128 119 kfree(link->priv); 129 120 } /* fdomain_detach */ ··· 124 133 #define CS_CHECK(fn, ret) \ 125 134 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 126 135 127 - static void fdomain_config(dev_link_t *link) 136 + static int fdomain_config(struct pcmcia_device *link) 128 137 { 129 - client_handle_t handle = link->handle; 130 138 scsi_info_t *info = link->priv; 131 139 tuple_t tuple; 132 140 cisparse_t parse; ··· 140 150 tuple.TupleData = tuple_data; 141 151 tuple.TupleDataMax = 64; 142 152 tuple.TupleOffset = 0; 143 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 144 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 145 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 153 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 154 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 155 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 146 156 link->conf.ConfigBase = parse.config.base; 147 157 148 - /* Configure card */ 149 - link->state |= DEV_CONFIG; 150 - 151 158 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 152 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 159 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 153 160 while (1) { 154 - if (pcmcia_get_tuple_data(handle, &tuple) != 0 || 155 - pcmcia_parse_tuple(handle, &tuple, &parse) != 0) 161 + if (pcmcia_get_tuple_data(link, &tuple) != 0 || 162 + pcmcia_parse_tuple(link, &tuple, &parse) != 0) 156 163 goto next_entry; 157 164 link->conf.ConfigIndex = parse.cftable_entry.index; 158 165 link->io.BasePort1 = parse.cftable_entry.io.win[0].base; 159 - i = pcmcia_request_io(handle, &link->io); 166 + i = pcmcia_request_io(link, &link->io); 160 167 if (i == CS_SUCCESS) break; 161 168 next_entry: 162 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); 169 + CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 163 170 } 164 171 165 - CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq)); 166 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); 167 - 172 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 173 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 174 + 168 175 /* A bad hack... */ 169 176 release_region(link->io.BasePort1, link->io.NumPorts1); 170 177 171 178 /* Set configuration options for the fdomain driver */ 172 179 sprintf(str, "%d,%d", link->io.BasePort1, link->irq.AssignedIRQ); 173 180 fdomain_setup(str); 174 - 181 + 175 182 host = __fdomain_16x0_detect(&fdomain_driver_template); 176 183 if (!host) { 177 184 printk(KERN_INFO "fdomain_cs: no SCSI devices found\n"); 178 185 goto cs_failed; 179 186 } 180 - 181 - scsi_add_host(host, NULL); /* XXX handle failure */ 187 + 188 + if (scsi_add_host(host, NULL)) 189 + goto cs_failed; 182 190 scsi_scan_host(host); 183 191 184 192 sprintf(info->node.dev_name, "scsi%d", host->host_no); 185 - link->dev = &info->node; 193 + link->dev_node = &info->node; 186 194 info->host = host; 187 - 188 - link->state &= ~DEV_CONFIG_PENDING; 189 - return; 190 - 195 + 196 + return 0; 197 + 191 198 cs_failed: 192 - cs_error(link->handle, last_fn, last_ret); 199 + cs_error(link, last_fn, last_ret); 193 200 fdomain_release(link); 194 - return; 195 - 201 + return -ENODEV; 196 202 } /* fdomain_config */ 197 203 198 204 /*====================================================================*/ 199 205 200 - static void fdomain_release(dev_link_t *link) 206 + static void fdomain_release(struct pcmcia_device *link) 201 207 { 202 - scsi_info_t *info = link->priv; 208 + scsi_info_t *info = link->priv; 203 209 204 - DEBUG(0, "fdomain_release(0x%p)\n", link); 210 + DEBUG(0, "fdomain_release(0x%p)\n", link); 205 211 206 - scsi_remove_host(info->host); 207 - link->dev = NULL; 208 - 209 - pcmcia_release_configuration(link->handle); 210 - pcmcia_release_io(link->handle, &link->io); 211 - pcmcia_release_irq(link->handle, &link->irq); 212 - 213 - scsi_unregister(info->host); 214 - 215 - link->state &= ~DEV_CONFIG; 212 + scsi_remove_host(info->host); 213 + pcmcia_disable_device(link); 214 + scsi_unregister(info->host); 216 215 } 217 216 218 217 /*====================================================================*/ 219 218 220 - static int fdomain_suspend(struct pcmcia_device *dev) 219 + static int fdomain_resume(struct pcmcia_device *link) 221 220 { 222 - dev_link_t *link = dev_to_instance(dev); 223 - 224 - link->state |= DEV_SUSPEND; 225 - if (link->state & DEV_CONFIG) 226 - pcmcia_release_configuration(link->handle); 227 - 228 - return 0; 229 - } 230 - 231 - static int fdomain_resume(struct pcmcia_device *dev) 232 - { 233 - dev_link_t *link = dev_to_instance(dev); 234 - 235 - link->state &= ~DEV_SUSPEND; 236 - if (link->state & DEV_CONFIG) { 237 - pcmcia_request_configuration(link->handle, &link->conf); 238 - fdomain_16x0_bus_reset(NULL); 239 - } 221 + fdomain_16x0_bus_reset(NULL); 240 222 241 223 return 0; 242 224 } ··· 226 264 .drv = { 227 265 .name = "fdomain_cs", 228 266 }, 229 - .probe = fdomain_attach, 267 + .probe = fdomain_probe, 230 268 .remove = fdomain_detach, 231 269 .id_table = fdomain_ids, 232 - .suspend = fdomain_suspend, 233 270 .resume = fdomain_resume, 234 271 }; 235 272
+45 -91
drivers/scsi/pcmcia/nsp_cs.c
··· 1593 1593 configure the card at this point -- we wait until we receive a 1594 1594 card insertion event. 1595 1595 ======================================================================*/ 1596 - static int nsp_cs_attach(struct pcmcia_device *p_dev) 1596 + static int nsp_cs_probe(struct pcmcia_device *link) 1597 1597 { 1598 1598 scsi_info_t *info; 1599 - dev_link_t *link; 1600 1599 nsp_hw_data *data = &nsp_data_base; 1600 + int ret; 1601 1601 1602 1602 nsp_dbg(NSP_DEBUG_INIT, "in"); 1603 1603 ··· 1605 1605 info = kmalloc(sizeof(*info), GFP_KERNEL); 1606 1606 if (info == NULL) { return -ENOMEM; } 1607 1607 memset(info, 0, sizeof(*info)); 1608 - link = &info->link; 1608 + info->p_dev = link; 1609 1609 link->priv = info; 1610 1610 data->ScsiInfo = info; 1611 1611 ··· 1627 1627 1628 1628 /* General socket configuration */ 1629 1629 link->conf.Attributes = CONF_ENABLE_IRQ; 1630 - link->conf.Vcc = 50; 1631 1630 link->conf.IntType = INT_MEMORY_AND_IO; 1632 1631 link->conf.Present = PRESENT_OPTION; 1633 1632 1634 - link->handle = p_dev; 1635 - p_dev->instance = link; 1636 - 1637 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 1638 - nsp_cs_config(link); 1633 + ret = nsp_cs_config(link); 1639 1634 1640 1635 nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link); 1641 - return 0; 1636 + return ret; 1642 1637 } /* nsp_cs_attach */ 1643 1638 1644 1639 ··· 1643 1648 structures are freed. Otherwise, the structures will be freed 1644 1649 when the device is released. 1645 1650 ======================================================================*/ 1646 - static void nsp_cs_detach(struct pcmcia_device *p_dev) 1651 + static void nsp_cs_detach(struct pcmcia_device *link) 1647 1652 { 1648 - dev_link_t *link = dev_to_instance(p_dev); 1649 - 1650 1653 nsp_dbg(NSP_DEBUG_INIT, "in, link=0x%p", link); 1651 1654 1652 - if (link->state & DEV_CONFIG) { 1653 - ((scsi_info_t *)link->priv)->stop = 1; 1654 - nsp_cs_release(link); 1655 - } 1655 + ((scsi_info_t *)link->priv)->stop = 1; 1656 + nsp_cs_release(link); 1656 1657 1657 1658 kfree(link->priv); 1658 1659 link->priv = NULL; ··· 1663 1672 #define CS_CHECK(fn, ret) \ 1664 1673 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 1665 1674 /*====================================================================*/ 1666 - static void nsp_cs_config(dev_link_t *link) 1675 + static int nsp_cs_config(struct pcmcia_device *link) 1667 1676 { 1668 - client_handle_t handle = link->handle; 1677 + int ret; 1669 1678 scsi_info_t *info = link->priv; 1670 1679 tuple_t tuple; 1671 1680 cisparse_t parse; ··· 1689 1698 tuple.TupleData = tuple_data; 1690 1699 tuple.TupleDataMax = sizeof(tuple_data); 1691 1700 tuple.TupleOffset = 0; 1692 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 1693 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 1694 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 1701 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 1702 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 1703 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 1695 1704 link->conf.ConfigBase = parse.config.base; 1696 1705 link->conf.Present = parse.config.rmask[0]; 1697 1706 1698 - /* Configure card */ 1699 - link->state |= DEV_CONFIG; 1700 - 1701 1707 /* Look up the current Vcc */ 1702 - CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf)); 1703 - link->conf.Vcc = conf.Vcc; 1708 + CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &conf)); 1704 1709 1705 1710 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 1706 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 1711 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 1707 1712 while (1) { 1708 1713 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 1709 1714 1710 - if (pcmcia_get_tuple_data(handle, &tuple) != 0 || 1711 - pcmcia_parse_tuple(handle, &tuple, &parse) != 0) 1715 + if (pcmcia_get_tuple_data(link, &tuple) != 0 || 1716 + pcmcia_parse_tuple(link, &tuple, &parse) != 0) 1712 1717 goto next_entry; 1713 1718 1714 1719 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) { dflt = *cfg; } ··· 1730 1743 } 1731 1744 1732 1745 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) { 1733 - link->conf.Vpp1 = link->conf.Vpp2 = 1746 + link->conf.Vpp = 1734 1747 cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 1735 1748 } else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) { 1736 - link->conf.Vpp1 = link->conf.Vpp2 = 1749 + link->conf.Vpp = 1737 1750 dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; 1738 1751 } 1739 1752 ··· 1760 1773 link->io.NumPorts2 = io->win[1].len; 1761 1774 } 1762 1775 /* This reserves IO space but doesn't actually enable it */ 1763 - if (pcmcia_request_io(link->handle, &link->io) != 0) 1776 + if (pcmcia_request_io(link, &link->io) != 0) 1764 1777 goto next_entry; 1765 1778 } 1766 1779 ··· 1775 1788 req.Size = 0x1000; 1776 1789 } 1777 1790 req.AccessSpeed = 0; 1778 - if (pcmcia_request_window(&link->handle, &req, &link->win) != 0) 1791 + if (pcmcia_request_window(&link, &req, &link->win) != 0) 1779 1792 goto next_entry; 1780 1793 map.Page = 0; map.CardOffset = mem->win[0].card_addr; 1781 1794 if (pcmcia_map_mem_page(link->win, &map) != 0) ··· 1789 1802 1790 1803 next_entry: 1791 1804 nsp_dbg(NSP_DEBUG_INIT, "next"); 1792 - 1793 - if (link->io.NumPorts1) { 1794 - pcmcia_release_io(link->handle, &link->io); 1795 - } 1796 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); 1805 + pcmcia_disable_device(link); 1806 + CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 1797 1807 } 1798 1808 1799 1809 if (link->conf.Attributes & CONF_ENABLE_IRQ) { 1800 - CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 1810 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 1801 1811 } 1802 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); 1812 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 1803 1813 1804 1814 if (free_ports) { 1805 1815 if (link->io.BasePort1) { ··· 1838 1854 1839 1855 1840 1856 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,74)) 1841 - scsi_add_host (host, NULL); 1857 + ret = scsi_add_host (host, NULL); 1858 + if (ret) 1859 + goto cs_failed; 1860 + 1842 1861 scsi_scan_host(host); 1843 1862 1844 1863 snprintf(info->node.dev_name, sizeof(info->node.dev_name), "scsi%d", host->host_no); 1845 - link->dev = &info->node; 1864 + link->dev_node = &info->node; 1846 1865 info->host = host; 1847 1866 1848 1867 #else 1849 1868 nsp_dbg(NSP_DEBUG_INIT, "GET_SCSI_INFO"); 1850 - tail = &link->dev; 1869 + tail = &link->dev_node; 1851 1870 info->ndev = 0; 1852 1871 1853 1872 nsp_dbg(NSP_DEBUG_INIT, "host=0x%p", host); ··· 1895 1908 #endif 1896 1909 1897 1910 /* Finally, report what we've done */ 1898 - printk(KERN_INFO "nsp_cs: index 0x%02x: Vcc %d.%d", 1899 - link->conf.ConfigIndex, 1900 - link->conf.Vcc/10, link->conf.Vcc%10); 1901 - if (link->conf.Vpp1) { 1902 - printk(", Vpp %d.%d", link->conf.Vpp1/10, link->conf.Vpp1%10); 1911 + printk(KERN_INFO "nsp_cs: index 0x%02x: ", 1912 + link->conf.ConfigIndex); 1913 + if (link->conf.Vpp) { 1914 + printk(", Vpp %d.%d", link->conf.Vpp/10, link->conf.Vpp%10); 1903 1915 } 1904 1916 if (link->conf.Attributes & CONF_ENABLE_IRQ) { 1905 1917 printk(", irq %d", link->irq.AssignedIRQ); ··· 1915 1929 req.Base+req.Size-1); 1916 1930 printk("\n"); 1917 1931 1918 - link->state &= ~DEV_CONFIG_PENDING; 1919 - return; 1932 + return 0; 1920 1933 1921 1934 cs_failed: 1922 1935 nsp_dbg(NSP_DEBUG_INIT, "config fail"); 1923 - cs_error(link->handle, last_fn, last_ret); 1936 + cs_error(link, last_fn, last_ret); 1924 1937 nsp_cs_release(link); 1925 1938 1926 - return; 1939 + return -ENODEV; 1927 1940 } /* nsp_cs_config */ 1928 1941 #undef CS_CHECK 1929 1942 ··· 1932 1947 device, and release the PCMCIA configuration. If the device is 1933 1948 still open, this will be postponed until it is closed. 1934 1949 ======================================================================*/ 1935 - static void nsp_cs_release(dev_link_t *link) 1950 + static void nsp_cs_release(struct pcmcia_device *link) 1936 1951 { 1937 1952 scsi_info_t *info = link->priv; 1938 1953 nsp_hw_data *data = NULL; ··· 1953 1968 #else 1954 1969 scsi_unregister_host(&nsp_driver_template); 1955 1970 #endif 1956 - link->dev = NULL; 1971 + link->dev_node = NULL; 1957 1972 1958 1973 if (link->win) { 1959 1974 if (data != NULL) { 1960 1975 iounmap((void *)(data->MmioAddress)); 1961 1976 } 1962 - pcmcia_release_window(link->win); 1963 1977 } 1964 - pcmcia_release_configuration(link->handle); 1965 - if (link->io.NumPorts1) { 1966 - pcmcia_release_io(link->handle, &link->io); 1967 - } 1968 - if (link->irq.AssignedIRQ) { 1969 - pcmcia_release_irq(link->handle, &link->irq); 1970 - } 1971 - link->state &= ~DEV_CONFIG; 1978 + pcmcia_disable_device(link); 1979 + 1972 1980 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,2)) 1973 1981 if (info->host != NULL) { 1974 1982 scsi_host_put(info->host); ··· 1969 1991 #endif 1970 1992 } /* nsp_cs_release */ 1971 1993 1972 - static int nsp_cs_suspend(struct pcmcia_device *dev) 1994 + static int nsp_cs_suspend(struct pcmcia_device *link) 1973 1995 { 1974 - dev_link_t *link = dev_to_instance(dev); 1975 1996 scsi_info_t *info = link->priv; 1976 1997 nsp_hw_data *data; 1977 - 1978 - link->state |= DEV_SUSPEND; 1979 1998 1980 1999 nsp_dbg(NSP_DEBUG_INIT, "event: suspend"); 1981 2000 ··· 1986 2011 1987 2012 info->stop = 1; 1988 2013 1989 - if (link->state & DEV_CONFIG) 1990 - pcmcia_release_configuration(link->handle); 1991 - 1992 2014 return 0; 1993 2015 } 1994 2016 1995 - static int nsp_cs_resume(struct pcmcia_device *dev) 2017 + static int nsp_cs_resume(struct pcmcia_device *link) 1996 2018 { 1997 - dev_link_t *link = dev_to_instance(dev); 1998 2019 scsi_info_t *info = link->priv; 1999 2020 nsp_hw_data *data; 2000 2021 2001 2022 nsp_dbg(NSP_DEBUG_INIT, "event: resume"); 2002 - 2003 - link->state &= ~DEV_SUSPEND; 2004 - 2005 - if (link->state & DEV_CONFIG) 2006 - pcmcia_request_configuration(link->handle, &link->conf); 2007 2023 2008 2024 info->stop = 0; 2009 2025 ··· 2031 2065 .drv = { 2032 2066 .name = "nsp_cs", 2033 2067 }, 2034 - .probe = nsp_cs_attach, 2068 + .probe = nsp_cs_probe, 2035 2069 .remove = nsp_cs_detach, 2036 2070 .id_table = nsp_cs_ids, 2037 2071 .suspend = nsp_cs_suspend, ··· 2064 2098 static void __exit nsp_cs_exit(void) 2065 2099 { 2066 2100 nsp_msg(KERN_INFO, "unloading..."); 2067 - 2068 - #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,68)) 2069 2101 pcmcia_unregister_driver(&nsp_driver); 2070 - #else 2071 - unregister_pcmcia_driver(&dev_info); 2072 - /* XXX: this really needs to move into generic code.. */ 2073 - while (dev_list != NULL) { 2074 - if (dev_list->state & DEV_CONFIG) { 2075 - nsp_cs_release(dev_list); 2076 - } 2077 - nsp_cs_detach(dev_list); 2078 - } 2079 - #endif 2080 2102 } 2081 2103 2082 2104
+4 -4
drivers/scsi/pcmcia/nsp_cs.h
··· 225 225 /*====================================================================*/ 226 226 227 227 typedef struct scsi_info_t { 228 - dev_link_t link; 228 + struct pcmcia_device *p_dev; 229 229 struct Scsi_Host *host; 230 230 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,74)) 231 231 dev_node_t node; ··· 297 297 298 298 /* Card service functions */ 299 299 static void nsp_cs_detach (struct pcmcia_device *p_dev); 300 - static void nsp_cs_release(dev_link_t *link); 301 - static void nsp_cs_config (dev_link_t *link); 300 + static void nsp_cs_release(struct pcmcia_device *link); 301 + static int nsp_cs_config (struct pcmcia_device *link); 302 302 303 303 /* Linux SCSI subsystem specific functions */ 304 304 static struct Scsi_Host *nsp_detect (struct scsi_host_template *sht); ··· 450 450 return host; 451 451 } 452 452 453 - static void cs_error(client_handle_t handle, int func, int ret) 453 + static void cs_error(struct pcmcia_device *handle, int func, int ret) 454 454 { 455 455 error_info_t err = { func, ret }; 456 456 pcmcia_report_error(handle, &err);
+41 -86
drivers/scsi/pcmcia/qlogic_stub.c
··· 91 91 /*====================================================================*/ 92 92 93 93 typedef struct scsi_info_t { 94 - dev_link_t link; 94 + struct pcmcia_device *p_dev; 95 95 dev_node_t node; 96 96 struct Scsi_Host *host; 97 97 unsigned short manf_id; 98 98 } scsi_info_t; 99 99 100 - static void qlogic_release(dev_link_t *link); 100 + static void qlogic_release(struct pcmcia_device *link); 101 101 static void qlogic_detach(struct pcmcia_device *p_dev); 102 - static void qlogic_config(dev_link_t * link); 102 + static int qlogic_config(struct pcmcia_device * link); 103 103 104 104 static struct Scsi_Host *qlogic_detect(struct scsi_host_template *host, 105 - dev_link_t *link, int qbase, int qlirq) 105 + struct pcmcia_device *link, int qbase, int qlirq) 106 106 { 107 107 int qltyp; /* type of chip */ 108 108 int qinitid; ··· 156 156 err: 157 157 return NULL; 158 158 } 159 - static int qlogic_attach(struct pcmcia_device *p_dev) 159 + static int qlogic_probe(struct pcmcia_device *link) 160 160 { 161 161 scsi_info_t *info; 162 - dev_link_t *link; 163 162 164 163 DEBUG(0, "qlogic_attach()\n"); 165 164 ··· 167 168 if (!info) 168 169 return -ENOMEM; 169 170 memset(info, 0, sizeof(*info)); 170 - link = &info->link; 171 + info->p_dev = link; 171 172 link->priv = info; 172 173 link->io.NumPorts1 = 16; 173 174 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; ··· 175 176 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 176 177 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 177 178 link->conf.Attributes = CONF_ENABLE_IRQ; 178 - link->conf.Vcc = 50; 179 179 link->conf.IntType = INT_MEMORY_AND_IO; 180 180 link->conf.Present = PRESENT_OPTION; 181 181 182 - link->handle = p_dev; 183 - p_dev->instance = link; 184 - 185 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 186 - qlogic_config(link); 187 - 188 - return 0; 182 + return qlogic_config(link); 189 183 } /* qlogic_attach */ 190 184 191 185 /*====================================================================*/ 192 186 193 - static void qlogic_detach(struct pcmcia_device *p_dev) 187 + static void qlogic_detach(struct pcmcia_device *link) 194 188 { 195 - dev_link_t *link = dev_to_instance(p_dev); 196 - 197 189 DEBUG(0, "qlogic_detach(0x%p)\n", link); 198 190 199 - if (link->state & DEV_CONFIG) 200 - qlogic_release(link); 201 - 191 + qlogic_release(link); 202 192 kfree(link->priv); 203 193 204 194 } /* qlogic_detach */ ··· 197 209 #define CS_CHECK(fn, ret) \ 198 210 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 199 211 200 - static void qlogic_config(dev_link_t * link) 212 + static int qlogic_config(struct pcmcia_device * link) 201 213 { 202 - client_handle_t handle = link->handle; 203 214 scsi_info_t *info = link->priv; 204 215 tuple_t tuple; 205 216 cisparse_t parse; ··· 212 225 tuple.TupleDataMax = 64; 213 226 tuple.TupleOffset = 0; 214 227 tuple.DesiredTuple = CISTPL_CONFIG; 215 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 216 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 217 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 228 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 229 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 230 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 218 231 link->conf.ConfigBase = parse.config.base; 219 232 220 233 tuple.DesiredTuple = CISTPL_MANFID; 221 - if ((pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) && (pcmcia_get_tuple_data(handle, &tuple) == CS_SUCCESS)) 234 + if ((pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) && (pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS)) 222 235 info->manf_id = le16_to_cpu(tuple.TupleData[0]); 223 236 224 - /* Configure card */ 225 - link->state |= DEV_CONFIG; 226 - 227 237 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 228 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 238 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 229 239 while (1) { 230 - if (pcmcia_get_tuple_data(handle, &tuple) != 0 || 231 - pcmcia_parse_tuple(handle, &tuple, &parse) != 0) 240 + if (pcmcia_get_tuple_data(link, &tuple) != 0 || 241 + pcmcia_parse_tuple(link, &tuple, &parse) != 0) 232 242 goto next_entry; 233 243 link->conf.ConfigIndex = parse.cftable_entry.index; 234 244 link->io.BasePort1 = parse.cftable_entry.io.win[0].base; 235 245 link->io.NumPorts1 = parse.cftable_entry.io.win[0].len; 236 246 if (link->io.BasePort1 != 0) { 237 - i = pcmcia_request_io(handle, &link->io); 247 + i = pcmcia_request_io(link, &link->io); 238 248 if (i == CS_SUCCESS) 239 249 break; 240 250 } 241 251 next_entry: 242 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); 252 + CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 243 253 } 244 254 245 - CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq)); 246 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); 255 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 256 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 247 257 248 258 if ((info->manf_id == MANFID_MACNICA) || (info->manf_id == MANFID_PIONEER) || (info->manf_id == 0x0098)) { 249 259 /* set ATAcmd */ ··· 259 275 260 276 if (!host) { 261 277 printk(KERN_INFO "%s: no SCSI devices found\n", qlogic_name); 262 - goto out; 278 + goto cs_failed; 263 279 } 264 280 265 281 sprintf(info->node.dev_name, "scsi%d", host->host_no); 266 - link->dev = &info->node; 282 + link->dev_node = &info->node; 267 283 info->host = host; 268 284 269 - out: 270 - link->state &= ~DEV_CONFIG_PENDING; 271 - return; 285 + return 0; 272 286 273 287 cs_failed: 274 - cs_error(link->handle, last_fn, last_ret); 275 - link->dev = NULL; 276 - pcmcia_release_configuration(link->handle); 277 - pcmcia_release_io(link->handle, &link->io); 278 - pcmcia_release_irq(link->handle, &link->irq); 279 - link->state &= ~DEV_CONFIG; 280 - return; 288 + cs_error(link, last_fn, last_ret); 289 + pcmcia_disable_device(link); 290 + return -ENODEV; 281 291 282 292 } /* qlogic_config */ 283 293 284 294 /*====================================================================*/ 285 295 286 - static void qlogic_release(dev_link_t *link) 296 + static void qlogic_release(struct pcmcia_device *link) 287 297 { 288 298 scsi_info_t *info = link->priv; 289 299 290 300 DEBUG(0, "qlogic_release(0x%p)\n", link); 291 301 292 302 scsi_remove_host(info->host); 293 - link->dev = NULL; 294 303 295 304 free_irq(link->irq.AssignedIRQ, info->host); 296 - 297 - pcmcia_release_configuration(link->handle); 298 - pcmcia_release_io(link->handle, &link->io); 299 - pcmcia_release_irq(link->handle, &link->irq); 305 + pcmcia_disable_device(link); 300 306 301 307 scsi_host_put(info->host); 302 - 303 - link->state &= ~DEV_CONFIG; 304 308 } 305 309 306 310 /*====================================================================*/ 307 311 308 - static int qlogic_suspend(struct pcmcia_device *dev) 312 + static int qlogic_resume(struct pcmcia_device *link) 309 313 { 310 - dev_link_t *link = dev_to_instance(dev); 314 + scsi_info_t *info = link->priv; 311 315 312 - link->state |= DEV_SUSPEND; 313 - if (link->state & DEV_CONFIG) 314 - pcmcia_release_configuration(link->handle); 315 - 316 - return 0; 317 - } 318 - 319 - static int qlogic_resume(struct pcmcia_device *dev) 320 - { 321 - dev_link_t *link = dev_to_instance(dev); 322 - 323 - link->state &= ~DEV_SUSPEND; 324 - if (link->state & DEV_CONFIG) { 325 - scsi_info_t *info = link->priv; 326 - 327 - pcmcia_request_configuration(link->handle, &link->conf); 328 - if ((info->manf_id == MANFID_MACNICA) || 329 - (info->manf_id == MANFID_PIONEER) || 330 - (info->manf_id == 0x0098)) { 331 - outb(0x80, link->io.BasePort1 + 0xd); 332 - outb(0x24, link->io.BasePort1 + 0x9); 333 - outb(0x04, link->io.BasePort1 + 0xd); 334 - } 335 - /* Ugggglllyyyy!!! */ 336 - qlogicfas408_bus_reset(NULL); 316 + pcmcia_request_configuration(link, &link->conf); 317 + if ((info->manf_id == MANFID_MACNICA) || 318 + (info->manf_id == MANFID_PIONEER) || 319 + (info->manf_id == 0x0098)) { 320 + outb(0x80, link->io.BasePort1 + 0xd); 321 + outb(0x24, link->io.BasePort1 + 0x9); 322 + outb(0x04, link->io.BasePort1 + 0xd); 337 323 } 324 + /* Ugggglllyyyy!!! */ 325 + qlogicfas408_bus_reset(NULL); 338 326 339 327 return 0; 340 328 } ··· 338 382 .drv = { 339 383 .name = "qlogic_cs", 340 384 }, 341 - .probe = qlogic_attach, 385 + .probe = qlogic_probe, 342 386 .remove = qlogic_detach, 343 387 .id_table = qlogic_ids, 344 - .suspend = qlogic_suspend, 345 388 .resume = qlogic_resume, 346 389 }; 347 390
+41 -83
drivers/scsi/pcmcia/sym53c500_cs.c
··· 202 202 /* ================================================================== */ 203 203 204 204 struct scsi_info_t { 205 - dev_link_t link; 205 + struct pcmcia_device *p_dev; 206 206 dev_node_t node; 207 207 struct Scsi_Host *host; 208 208 unsigned short manf_id; ··· 527 527 } 528 528 529 529 static void 530 - SYM53C500_release(dev_link_t *link) 530 + SYM53C500_release(struct pcmcia_device *link) 531 531 { 532 532 struct scsi_info_t *info = link->priv; 533 533 struct Scsi_Host *shost = info->host; ··· 550 550 if (shost->io_port && shost->n_io_port) 551 551 release_region(shost->io_port, shost->n_io_port); 552 552 553 - link->dev = NULL; 554 - 555 - pcmcia_release_configuration(link->handle); 556 - pcmcia_release_io(link->handle, &link->io); 557 - pcmcia_release_irq(link->handle, &link->irq); 558 - 559 - link->state &= ~DEV_CONFIG; 553 + pcmcia_disable_device(link); 560 554 561 555 scsi_host_put(shost); 562 556 } /* SYM53C500_release */ ··· 707 713 #define CS_CHECK(fn, ret) \ 708 714 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 709 715 710 - static void 711 - SYM53C500_config(dev_link_t *link) 716 + static int 717 + SYM53C500_config(struct pcmcia_device *link) 712 718 { 713 - client_handle_t handle = link->handle; 714 719 struct scsi_info_t *info = link->priv; 715 720 tuple_t tuple; 716 721 cisparse_t parse; ··· 726 733 tuple.TupleDataMax = 64; 727 734 tuple.TupleOffset = 0; 728 735 tuple.DesiredTuple = CISTPL_CONFIG; 729 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 730 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 731 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 736 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 737 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 738 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 732 739 link->conf.ConfigBase = parse.config.base; 733 740 734 741 tuple.DesiredTuple = CISTPL_MANFID; 735 - if ((pcmcia_get_first_tuple(handle, &tuple) == CS_SUCCESS) && 736 - (pcmcia_get_tuple_data(handle, &tuple) == CS_SUCCESS)) 742 + if ((pcmcia_get_first_tuple(link, &tuple) == CS_SUCCESS) && 743 + (pcmcia_get_tuple_data(link, &tuple) == CS_SUCCESS)) 737 744 info->manf_id = le16_to_cpu(tuple.TupleData[0]); 738 745 739 - /* Configure card */ 740 - link->state |= DEV_CONFIG; 741 - 742 746 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 743 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 747 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 744 748 while (1) { 745 - if (pcmcia_get_tuple_data(handle, &tuple) != 0 || 746 - pcmcia_parse_tuple(handle, &tuple, &parse) != 0) 749 + if (pcmcia_get_tuple_data(link, &tuple) != 0 || 750 + pcmcia_parse_tuple(link, &tuple, &parse) != 0) 747 751 goto next_entry; 748 752 link->conf.ConfigIndex = parse.cftable_entry.index; 749 753 link->io.BasePort1 = parse.cftable_entry.io.win[0].base; 750 754 link->io.NumPorts1 = parse.cftable_entry.io.win[0].len; 751 755 752 756 if (link->io.BasePort1 != 0) { 753 - i = pcmcia_request_io(handle, &link->io); 757 + i = pcmcia_request_io(link, &link->io); 754 758 if (i == CS_SUCCESS) 755 759 break; 756 760 } 757 761 next_entry: 758 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); 762 + CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 759 763 } 760 764 761 - CS_CHECK(RequestIRQ, pcmcia_request_irq(handle, &link->irq)); 762 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); 765 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 766 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 763 767 764 768 /* 765 769 * That's the trouble with copying liberally from another driver. ··· 825 835 data->fast_pio = USE_FAST_PIO; 826 836 827 837 sprintf(info->node.dev_name, "scsi%d", host->host_no); 828 - link->dev = &info->node; 838 + link->dev_node = &info->node; 829 839 info->host = host; 830 840 831 841 if (scsi_add_host(host, NULL)) ··· 833 843 834 844 scsi_scan_host(host); 835 845 836 - goto out; /* SUCCESS */ 846 + return 0; 837 847 838 848 err_free_irq: 839 849 free_irq(irq_level, host); ··· 842 852 err_release: 843 853 release_region(port_base, 0x10); 844 854 printk(KERN_INFO "sym53c500_cs: no SCSI devices found\n"); 845 - 846 - out: 847 - link->state &= ~DEV_CONFIG_PENDING; 848 - return; 855 + return -ENODEV; 849 856 850 857 cs_failed: 851 - cs_error(link->handle, last_fn, last_ret); 858 + cs_error(link, last_fn, last_ret); 852 859 SYM53C500_release(link); 853 - return; 860 + return -ENODEV; 854 861 } /* SYM53C500_config */ 855 862 856 - static int sym53c500_suspend(struct pcmcia_device *dev) 863 + static int sym53c500_resume(struct pcmcia_device *link) 857 864 { 858 - dev_link_t *link = dev_to_instance(dev); 859 - 860 - link->state |= DEV_SUSPEND; 861 - if (link->state & DEV_CONFIG) 862 - pcmcia_release_configuration(link->handle); 863 - 864 - return 0; 865 - } 866 - 867 - static int sym53c500_resume(struct pcmcia_device *dev) 868 - { 869 - dev_link_t *link = dev_to_instance(dev); 870 865 struct scsi_info_t *info = link->priv; 871 866 872 - link->state &= ~DEV_SUSPEND; 873 - if (link->state & DEV_CONFIG) { 874 - pcmcia_request_configuration(link->handle, &link->conf); 875 - 876 - /* See earlier comment about manufacturer IDs. */ 877 - if ((info->manf_id == MANFID_MACNICA) || 878 - (info->manf_id == MANFID_PIONEER) || 879 - (info->manf_id == 0x0098)) { 880 - outb(0x80, link->io.BasePort1 + 0xd); 881 - outb(0x24, link->io.BasePort1 + 0x9); 882 - outb(0x04, link->io.BasePort1 + 0xd); 883 - } 884 - /* 885 - * If things don't work after a "resume", 886 - * this is a good place to start looking. 887 - */ 888 - SYM53C500_int_host_reset(link->io.BasePort1); 867 + /* See earlier comment about manufacturer IDs. */ 868 + if ((info->manf_id == MANFID_MACNICA) || 869 + (info->manf_id == MANFID_PIONEER) || 870 + (info->manf_id == 0x0098)) { 871 + outb(0x80, link->io.BasePort1 + 0xd); 872 + outb(0x24, link->io.BasePort1 + 0x9); 873 + outb(0x04, link->io.BasePort1 + 0xd); 889 874 } 875 + /* 876 + * If things don't work after a "resume", 877 + * this is a good place to start looking. 878 + */ 879 + SYM53C500_int_host_reset(link->io.BasePort1); 890 880 891 881 return 0; 892 882 } 893 883 894 884 static void 895 - SYM53C500_detach(struct pcmcia_device *p_dev) 885 + SYM53C500_detach(struct pcmcia_device *link) 896 886 { 897 - dev_link_t *link = dev_to_instance(p_dev); 898 - 899 887 DEBUG(0, "SYM53C500_detach(0x%p)\n", link); 900 888 901 - if (link->state & DEV_CONFIG) 902 - SYM53C500_release(link); 889 + SYM53C500_release(link); 903 890 904 891 kfree(link->priv); 905 892 link->priv = NULL; 906 893 } /* SYM53C500_detach */ 907 894 908 895 static int 909 - SYM53C500_attach(struct pcmcia_device *p_dev) 896 + SYM53C500_probe(struct pcmcia_device *link) 910 897 { 911 898 struct scsi_info_t *info; 912 - dev_link_t *link; 913 899 914 900 DEBUG(0, "SYM53C500_attach()\n"); 915 901 ··· 894 928 if (!info) 895 929 return -ENOMEM; 896 930 memset(info, 0, sizeof(*info)); 897 - link = &info->link; 931 + info->p_dev = link; 898 932 link->priv = info; 899 933 link->io.NumPorts1 = 16; 900 934 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; ··· 902 936 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 903 937 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 904 938 link->conf.Attributes = CONF_ENABLE_IRQ; 905 - link->conf.Vcc = 50; 906 939 link->conf.IntType = INT_MEMORY_AND_IO; 907 940 link->conf.Present = PRESENT_OPTION; 908 941 909 - link->handle = p_dev; 910 - p_dev->instance = link; 911 - 912 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 913 - SYM53C500_config(link); 914 - 915 - return 0; 942 + return SYM53C500_config(link); 916 943 } /* SYM53C500_attach */ 917 944 918 945 MODULE_AUTHOR("Bob Tracy <rct@frus.com>"); ··· 925 966 .drv = { 926 967 .name = "sym53c500_cs", 927 968 }, 928 - .probe = SYM53C500_attach, 969 + .probe = SYM53C500_probe, 929 970 .remove = SYM53C500_detach, 930 971 .id_table = sym53c500_ids, 931 - .suspend = sym53c500_suspend, 932 972 .resume = sym53c500_resume, 933 973 }; 934 974
+112 -117
drivers/serial/serial_cs.c
··· 41 41 #include <linux/string.h> 42 42 #include <linux/timer.h> 43 43 #include <linux/serial_core.h> 44 + #include <linux/delay.h> 44 45 #include <linux/major.h> 45 46 #include <asm/io.h> 46 47 #include <asm/system.h> ··· 98 97 #define MULTI_COUNT (sizeof(multi_id)/sizeof(struct multi_id)) 99 98 100 99 struct serial_info { 101 - dev_link_t link; 100 + struct pcmcia_device *p_dev; 102 101 int ndev; 103 102 int multi; 104 103 int slave; 105 104 int manfid; 105 + int prodid; 106 + int c950ctrl; 106 107 dev_node_t node[4]; 107 108 int line[4]; 108 109 }; ··· 116 113 }; 117 114 118 115 119 - static void serial_config(dev_link_t * link); 116 + static int serial_config(struct pcmcia_device * link); 120 117 118 + 119 + static void wakeup_card(struct serial_info *info) 120 + { 121 + int ctrl = info->c950ctrl; 122 + 123 + if (info->manfid == MANFID_OXSEMI) { 124 + outb(12, ctrl + 1); 125 + } else if (info->manfid == MANFID_POSSIO && info->prodid == PRODID_POSSIO_GCC) { 126 + /* request_region? oxsemi branch does no request_region too... */ 127 + /* This sequence is needed to properly initialize MC45 attached to OXCF950. 128 + * I tried decreasing these msleep()s, but it worked properly (survived 129 + * 1000 stop/start operations) with these timeouts (or bigger). */ 130 + outb(0xA, ctrl + 1); 131 + msleep(100); 132 + outb(0xE, ctrl + 1); 133 + msleep(300); 134 + outb(0xC, ctrl + 1); 135 + msleep(100); 136 + outb(0xE, ctrl + 1); 137 + msleep(200); 138 + outb(0xF, ctrl + 1); 139 + msleep(100); 140 + outb(0xE, ctrl + 1); 141 + msleep(100); 142 + outb(0xC, ctrl + 1); 143 + } 144 + } 121 145 122 146 /*====================================================================== 123 147 ··· 153 123 154 124 ======================================================================*/ 155 125 156 - static void serial_remove(dev_link_t *link) 126 + static void serial_remove(struct pcmcia_device *link) 157 127 { 158 128 struct serial_info *info = link->priv; 159 129 int i; 160 - 161 - link->state &= ~DEV_PRESENT; 162 130 163 131 DEBUG(0, "serial_release(0x%p)\n", link); 164 132 165 133 /* 166 134 * Recheck to see if the device is still configured. 167 135 */ 168 - if (info->link.state & DEV_CONFIG) { 169 - for (i = 0; i < info->ndev; i++) 170 - serial8250_unregister_port(info->line[i]); 136 + for (i = 0; i < info->ndev; i++) 137 + serial8250_unregister_port(info->line[i]); 171 138 172 - info->link.dev = NULL; 139 + info->p_dev->dev_node = NULL; 173 140 174 - if (!info->slave) { 175 - pcmcia_release_configuration(info->link.handle); 176 - pcmcia_release_io(info->link.handle, &info->link.io); 177 - pcmcia_release_irq(info->link.handle, &info->link.irq); 178 - } 179 - 180 - info->link.state &= ~DEV_CONFIG; 181 - } 141 + if (!info->slave) 142 + pcmcia_disable_device(link); 182 143 } 183 144 184 - static int serial_suspend(struct pcmcia_device *dev) 145 + static int serial_suspend(struct pcmcia_device *link) 185 146 { 186 - dev_link_t *link = dev_to_instance(dev); 187 - link->state |= DEV_SUSPEND; 147 + struct serial_info *info = link->priv; 148 + int i; 188 149 189 - if (link->state & DEV_CONFIG) { 190 - struct serial_info *info = link->priv; 191 - int i; 192 - 193 - for (i = 0; i < info->ndev; i++) 194 - serial8250_suspend_port(info->line[i]); 195 - 196 - if (!info->slave) 197 - pcmcia_release_configuration(link->handle); 198 - } 150 + for (i = 0; i < info->ndev; i++) 151 + serial8250_suspend_port(info->line[i]); 199 152 200 153 return 0; 201 154 } 202 155 203 - static int serial_resume(struct pcmcia_device *dev) 156 + static int serial_resume(struct pcmcia_device *link) 204 157 { 205 - dev_link_t *link = dev_to_instance(dev); 206 - link->state &= ~DEV_SUSPEND; 207 - 208 - if (DEV_OK(link)) { 158 + if (pcmcia_dev_present(link)) { 209 159 struct serial_info *info = link->priv; 210 160 int i; 211 161 212 - if (!info->slave) 213 - pcmcia_request_configuration(link->handle, &link->conf); 214 - 215 162 for (i = 0; i < info->ndev; i++) 216 163 serial8250_resume_port(info->line[i]); 164 + wakeup_card(info); 217 165 } 218 166 219 167 return 0; ··· 205 197 206 198 ======================================================================*/ 207 199 208 - static int serial_probe(struct pcmcia_device *p_dev) 200 + static int serial_probe(struct pcmcia_device *link) 209 201 { 210 202 struct serial_info *info; 211 - dev_link_t *link; 212 203 213 204 DEBUG(0, "serial_attach()\n"); 214 205 ··· 216 209 if (!info) 217 210 return -ENOMEM; 218 211 memset(info, 0, sizeof (*info)); 219 - link = &info->link; 212 + info->p_dev = link; 220 213 link->priv = info; 221 214 222 215 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; ··· 230 223 } 231 224 link->conf.IntType = INT_MEMORY_AND_IO; 232 225 233 - link->handle = p_dev; 234 - p_dev->instance = link; 235 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 236 - serial_config(link); 237 - 238 - return 0; 226 + return serial_config(link); 239 227 } 240 228 241 229 /*====================================================================== ··· 242 240 243 241 ======================================================================*/ 244 242 245 - static void serial_detach(struct pcmcia_device *p_dev) 243 + static void serial_detach(struct pcmcia_device *link) 246 244 { 247 - dev_link_t *link = dev_to_instance(p_dev); 248 245 struct serial_info *info = link->priv; 249 246 250 247 DEBUG(0, "serial_detach(0x%p)\n", link); ··· 264 263 265 264 /*====================================================================*/ 266 265 267 - static int setup_serial(client_handle_t handle, struct serial_info * info, 266 + static int setup_serial(struct pcmcia_device *handle, struct serial_info * info, 268 267 kio_addr_t iobase, int irq) 269 268 { 270 269 struct uart_port port; ··· 299 298 /*====================================================================*/ 300 299 301 300 static int 302 - first_tuple(client_handle_t handle, tuple_t * tuple, cisparse_t * parse) 301 + first_tuple(struct pcmcia_device *handle, tuple_t * tuple, cisparse_t * parse) 303 302 { 304 303 int i; 305 304 i = pcmcia_get_first_tuple(handle, tuple); ··· 312 311 } 313 312 314 313 static int 315 - next_tuple(client_handle_t handle, tuple_t * tuple, cisparse_t * parse) 314 + next_tuple(struct pcmcia_device *handle, tuple_t * tuple, cisparse_t * parse) 316 315 { 317 316 int i; 318 317 i = pcmcia_get_next_tuple(handle, tuple); ··· 326 325 327 326 /*====================================================================*/ 328 327 329 - static int simple_config(dev_link_t *link) 328 + static int simple_config(struct pcmcia_device *link) 330 329 { 331 330 static const kio_addr_t base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 332 331 static const int size_table[2] = { 8, 16 }; 333 - client_handle_t handle = link->handle; 334 332 struct serial_info *info = link->priv; 335 333 struct serial_cfg_mem *cfg_mem; 336 334 tuple_t *tuple; ··· 350 350 buf = cfg_mem->buf; 351 351 352 352 /* If the card is already configured, look up the port and irq */ 353 - i = pcmcia_get_configuration_info(handle, &config); 353 + i = pcmcia_get_configuration_info(link, &config); 354 354 if ((i == CS_SUCCESS) && (config.Attributes & CONF_VALID_CLIENT)) { 355 355 kio_addr_t port = 0; 356 356 if ((config.BasePort2 != 0) && (config.NumPorts2 == 8)) { ··· 363 363 } 364 364 if (info->slave) { 365 365 kfree(cfg_mem); 366 - return setup_serial(handle, info, port, config.AssignedIRQ); 366 + return setup_serial(link, info, port, config.AssignedIRQ); 367 367 } 368 368 } 369 - link->conf.Vcc = config.Vcc; 370 369 371 370 /* First pass: look for a config entry that looks normal. */ 372 371 tuple->TupleData = (cisdata_t *) buf; ··· 376 377 /* Two tries: without IO aliases, then with aliases */ 377 378 for (s = 0; s < 2; s++) { 378 379 for (try = 0; try < 2; try++) { 379 - i = first_tuple(handle, tuple, parse); 380 + i = first_tuple(link, tuple, parse); 380 381 while (i != CS_NO_MORE_ITEMS) { 381 382 if (i != CS_SUCCESS) 382 383 goto next_entry; 383 384 if (cf->vpp1.present & (1 << CISTPL_POWER_VNOM)) 384 - link->conf.Vpp1 = link->conf.Vpp2 = 385 + link->conf.Vpp = 385 386 cf->vpp1.param[CISTPL_POWER_VNOM] / 10000; 386 387 if ((cf->io.nwin > 0) && (cf->io.win[0].len == size_table[s]) && 387 388 (cf->io.win[0].base != 0)) { ··· 389 390 link->io.BasePort1 = cf->io.win[0].base; 390 391 link->io.IOAddrLines = (try == 0) ? 391 392 16 : cf->io.flags & CISTPL_IO_LINES_MASK; 392 - i = pcmcia_request_io(link->handle, &link->io); 393 + i = pcmcia_request_io(link, &link->io); 393 394 if (i == CS_SUCCESS) 394 395 goto found_port; 395 396 } 396 397 next_entry: 397 - i = next_tuple(handle, tuple, parse); 398 + i = next_tuple(link, tuple, parse); 398 399 } 399 400 } 400 401 } 401 402 /* Second pass: try to find an entry that isn't picky about 402 403 its base address, then try to grab any standard serial port 403 404 address, and finally try to get any free port. */ 404 - i = first_tuple(handle, tuple, parse); 405 + i = first_tuple(link, tuple, parse); 405 406 while (i != CS_NO_MORE_ITEMS) { 406 407 if ((i == CS_SUCCESS) && (cf->io.nwin > 0) && 407 408 ((cf->io.flags & CISTPL_IO_LINES_MASK) <= 3)) { ··· 409 410 for (j = 0; j < 5; j++) { 410 411 link->io.BasePort1 = base[j]; 411 412 link->io.IOAddrLines = base[j] ? 16 : 3; 412 - i = pcmcia_request_io(link->handle, &link->io); 413 + i = pcmcia_request_io(link, &link->io); 413 414 if (i == CS_SUCCESS) 414 415 goto found_port; 415 416 } 416 417 } 417 - i = next_tuple(handle, tuple, parse); 418 + i = next_tuple(link, tuple, parse); 418 419 } 419 420 420 421 found_port: 421 422 if (i != CS_SUCCESS) { 422 423 printk(KERN_NOTICE 423 424 "serial_cs: no usable port range found, giving up\n"); 424 - cs_error(link->handle, RequestIO, i); 425 + cs_error(link, RequestIO, i); 425 426 kfree(cfg_mem); 426 427 return -1; 427 428 } 428 429 429 - i = pcmcia_request_irq(link->handle, &link->irq); 430 + i = pcmcia_request_irq(link, &link->irq); 430 431 if (i != CS_SUCCESS) { 431 - cs_error(link->handle, RequestIRQ, i); 432 + cs_error(link, RequestIRQ, i); 432 433 link->irq.AssignedIRQ = 0; 433 434 } 434 435 if (info->multi && (info->manfid == MANFID_3COM)) 435 436 link->conf.ConfigIndex &= ~(0x08); 436 - i = pcmcia_request_configuration(link->handle, &link->conf); 437 + i = pcmcia_request_configuration(link, &link->conf); 437 438 if (i != CS_SUCCESS) { 438 - cs_error(link->handle, RequestConfiguration, i); 439 + cs_error(link, RequestConfiguration, i); 439 440 kfree(cfg_mem); 440 441 return -1; 441 442 } 442 443 kfree(cfg_mem); 443 - return setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ); 444 + return setup_serial(link, info, link->io.BasePort1, link->irq.AssignedIRQ); 444 445 } 445 446 446 - static int multi_config(dev_link_t * link) 447 + static int multi_config(struct pcmcia_device * link) 447 448 { 448 - client_handle_t handle = link->handle; 449 449 struct serial_info *info = link->priv; 450 450 struct serial_cfg_mem *cfg_mem; 451 451 tuple_t *tuple; 452 452 u_char *buf; 453 453 cisparse_t *parse; 454 454 cistpl_cftable_entry_t *cf; 455 - config_info_t config; 456 455 int i, rc, base2 = 0; 457 456 458 457 cfg_mem = kmalloc(sizeof(struct serial_cfg_mem), GFP_KERNEL); ··· 461 464 cf = &parse->cftable_entry; 462 465 buf = cfg_mem->buf; 463 466 464 - i = pcmcia_get_configuration_info(handle, &config); 465 - if (i != CS_SUCCESS) { 466 - cs_error(handle, GetConfigurationInfo, i); 467 - rc = -1; 468 - goto free_cfg_mem; 469 - } 470 - link->conf.Vcc = config.Vcc; 471 - 472 467 tuple->TupleData = (cisdata_t *) buf; 473 468 tuple->TupleOffset = 0; 474 469 tuple->TupleDataMax = 255; ··· 469 480 470 481 /* First, look for a generic full-sized window */ 471 482 link->io.NumPorts1 = info->multi * 8; 472 - i = first_tuple(handle, tuple, parse); 483 + i = first_tuple(link, tuple, parse); 473 484 while (i != CS_NO_MORE_ITEMS) { 474 485 /* The quad port cards have bad CIS's, so just look for a 475 486 window larger than 8 ports and assume it will be right */ ··· 479 490 link->io.BasePort1 = cf->io.win[0].base; 480 491 link->io.IOAddrLines = 481 492 cf->io.flags & CISTPL_IO_LINES_MASK; 482 - i = pcmcia_request_io(link->handle, &link->io); 493 + i = pcmcia_request_io(link, &link->io); 483 494 base2 = link->io.BasePort1 + 8; 484 495 if (i == CS_SUCCESS) 485 496 break; 486 497 } 487 - i = next_tuple(handle, tuple, parse); 498 + i = next_tuple(link, tuple, parse); 488 499 } 489 500 490 501 /* If that didn't work, look for two windows */ 491 502 if (i != CS_SUCCESS) { 492 503 link->io.NumPorts1 = link->io.NumPorts2 = 8; 493 504 info->multi = 2; 494 - i = first_tuple(handle, tuple, parse); 505 + i = first_tuple(link, tuple, parse); 495 506 while (i != CS_NO_MORE_ITEMS) { 496 507 if ((i == CS_SUCCESS) && (cf->io.nwin == 2)) { 497 508 link->conf.ConfigIndex = cf->index; ··· 499 510 link->io.BasePort2 = cf->io.win[1].base; 500 511 link->io.IOAddrLines = 501 512 cf->io.flags & CISTPL_IO_LINES_MASK; 502 - i = pcmcia_request_io(link->handle, &link->io); 513 + i = pcmcia_request_io(link, &link->io); 503 514 base2 = link->io.BasePort2; 504 515 if (i == CS_SUCCESS) 505 516 break; 506 517 } 507 - i = next_tuple(handle, tuple, parse); 518 + i = next_tuple(link, tuple, parse); 508 519 } 509 520 } 510 521 511 522 if (i != CS_SUCCESS) { 512 - cs_error(link->handle, RequestIO, i); 523 + cs_error(link, RequestIO, i); 513 524 rc = -1; 514 525 goto free_cfg_mem; 515 526 } 516 527 517 - i = pcmcia_request_irq(link->handle, &link->irq); 528 + i = pcmcia_request_irq(link, &link->irq); 518 529 if (i != CS_SUCCESS) { 519 530 printk(KERN_NOTICE 520 531 "serial_cs: no usable port range found, giving up\n"); 521 - cs_error(link->handle, RequestIRQ, i); 532 + cs_error(link, RequestIRQ, i); 522 533 link->irq.AssignedIRQ = 0; 523 534 } 524 535 /* Socket Dual IO: this enables irq's for second port */ ··· 526 537 link->conf.Present |= PRESENT_EXT_STATUS; 527 538 link->conf.ExtStatus = ESR_REQ_ATTN_ENA; 528 539 } 529 - i = pcmcia_request_configuration(link->handle, &link->conf); 540 + i = pcmcia_request_configuration(link, &link->conf); 530 541 if (i != CS_SUCCESS) { 531 - cs_error(link->handle, RequestConfiguration, i); 542 + cs_error(link, RequestConfiguration, i); 532 543 rc = -1; 533 544 goto free_cfg_mem; 534 545 } 535 546 536 547 /* The Oxford Semiconductor OXCF950 cards are in fact single-port: 537 - 8 registers are for the UART, the others are extra registers */ 538 - if (info->manfid == MANFID_OXSEMI) { 548 + * 8 registers are for the UART, the others are extra registers. 549 + * Siemen's MC45 PCMCIA (Possio's GCC) is OXCF950 based too. 550 + */ 551 + if (info->manfid == MANFID_OXSEMI || (info->manfid == MANFID_POSSIO && 552 + info->prodid == PRODID_POSSIO_GCC)) { 553 + int err; 554 + 539 555 if (cf->index == 1 || cf->index == 3) { 540 - setup_serial(handle, info, base2, link->irq.AssignedIRQ); 541 - outb(12, link->io.BasePort1 + 1); 556 + err = setup_serial(link, info, base2, 557 + link->irq.AssignedIRQ); 558 + base2 = link->io.BasePort1; 542 559 } else { 543 - setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ); 544 - outb(12, base2 + 1); 560 + err = setup_serial(link, info, link->io.BasePort1, 561 + link->irq.AssignedIRQ); 545 562 } 563 + info->c950ctrl = base2; 564 + wakeup_card(info); 546 565 rc = 0; 547 566 goto free_cfg_mem; 548 567 } 549 568 550 - setup_serial(handle, info, link->io.BasePort1, link->irq.AssignedIRQ); 569 + setup_serial(link, info, link->io.BasePort1, link->irq.AssignedIRQ); 551 570 /* The Nokia cards are not really multiport cards */ 552 571 if (info->manfid == MANFID_NOKIA) { 553 572 rc = 0; 554 573 goto free_cfg_mem; 555 574 } 556 575 for (i = 0; i < info->multi - 1; i++) 557 - setup_serial(handle, info, base2 + (8 * i), 576 + setup_serial(link, info, base2 + (8 * i), 558 577 link->irq.AssignedIRQ); 559 578 rc = 0; 560 579 free_cfg_mem: ··· 578 581 579 582 ======================================================================*/ 580 583 581 - void serial_config(dev_link_t * link) 584 + static int serial_config(struct pcmcia_device * link) 582 585 { 583 - client_handle_t handle = link->handle; 584 586 struct serial_info *info = link->priv; 585 587 struct serial_cfg_mem *cfg_mem; 586 588 tuple_t *tuple; ··· 605 609 tuple->Attributes = 0; 606 610 /* Get configuration register information */ 607 611 tuple->DesiredTuple = CISTPL_CONFIG; 608 - last_ret = first_tuple(handle, tuple, parse); 612 + last_ret = first_tuple(link, tuple, parse); 609 613 if (last_ret != CS_SUCCESS) { 610 614 last_fn = ParseTuple; 611 615 goto cs_failed; ··· 613 617 link->conf.ConfigBase = parse->config.base; 614 618 link->conf.Present = parse->config.rmask[0]; 615 619 616 - /* Configure card */ 617 - link->state |= DEV_CONFIG; 618 - 619 620 /* Is this a compliant multifunction card? */ 620 621 tuple->DesiredTuple = CISTPL_LONGLINK_MFC; 621 622 tuple->Attributes = TUPLE_RETURN_COMMON | TUPLE_RETURN_LINK; 622 - info->multi = (first_tuple(handle, tuple, parse) == CS_SUCCESS); 623 + info->multi = (first_tuple(link, tuple, parse) == CS_SUCCESS); 623 624 624 625 /* Is this a multiport card? */ 625 626 tuple->DesiredTuple = CISTPL_MANFID; 626 - if (first_tuple(handle, tuple, parse) == CS_SUCCESS) { 627 + if (first_tuple(link, tuple, parse) == CS_SUCCESS) { 627 628 info->manfid = parse->manfid.manf; 629 + info->prodid = le16_to_cpu(buf[1]); 628 630 for (i = 0; i < MULTI_COUNT; i++) 629 631 if ((info->manfid == multi_id[i].manfid) && 630 632 (parse->manfid.card == multi_id[i].prodid)) ··· 635 641 multifunction cards that ask for appropriate IO port ranges */ 636 642 tuple->DesiredTuple = CISTPL_FUNCID; 637 643 if ((info->multi == 0) && 638 - ((first_tuple(handle, tuple, parse) != CS_SUCCESS) || 644 + ((first_tuple(link, tuple, parse) != CS_SUCCESS) || 639 645 (parse->funcid.func == CISTPL_FUNCID_MULTI) || 640 646 (parse->funcid.func == CISTPL_FUNCID_SERIAL))) { 641 647 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; 642 - if (first_tuple(handle, tuple, parse) == CS_SUCCESS) { 648 + if (first_tuple(link, tuple, parse) == CS_SUCCESS) { 643 649 if ((cf->io.nwin == 1) && (cf->io.win[0].len % 8 == 0)) 644 650 info->multi = cf->io.win[0].len >> 3; 645 651 if ((cf->io.nwin == 2) && (cf->io.win[0].len == 8) && ··· 658 664 659 665 if (info->manfid == MANFID_IBM) { 660 666 conf_reg_t reg = { 0, CS_READ, 0x800, 0 }; 661 - last_ret = pcmcia_access_configuration_register(link->handle, &reg); 667 + last_ret = pcmcia_access_configuration_register(link, &reg); 662 668 if (last_ret) { 663 669 last_fn = AccessConfigurationRegister; 664 670 goto cs_failed; 665 671 } 666 672 reg.Action = CS_WRITE; 667 673 reg.Value = reg.Value | 1; 668 - last_ret = pcmcia_access_configuration_register(link->handle, &reg); 674 + last_ret = pcmcia_access_configuration_register(link, &reg); 669 675 if (last_ret) { 670 676 last_fn = AccessConfigurationRegister; 671 677 goto cs_failed; 672 678 } 673 679 } 674 680 675 - link->dev = &info->node[0]; 676 - link->state &= ~DEV_CONFIG_PENDING; 681 + link->dev_node = &info->node[0]; 677 682 kfree(cfg_mem); 678 - return; 683 + return 0; 679 684 680 685 cs_failed: 681 - cs_error(link->handle, last_fn, last_ret); 686 + cs_error(link, last_fn, last_ret); 682 687 failed: 683 688 serial_remove(link); 684 - link->state &= ~DEV_CONFIG_PENDING; 685 689 kfree(cfg_mem); 690 + return -ENODEV; 686 691 } 687 692 688 693 static struct pcmcia_device_id serial_ids[] = { ··· 732 739 PCMCIA_MFC_DEVICE_PROD_ID1(1, "Motorola MARQUIS", 0xf03e4e77), 733 740 PCMCIA_MFC_DEVICE_PROD_ID2(1, "FAX/Modem/Ethernet Combo Card ", 0x1ed59302), 734 741 PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0301), 742 + PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x0276), 735 743 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0039), 736 744 PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0006), 737 745 PCMCIA_DEVICE_MANF_CARD(0x0105, 0x410a), ··· 751 757 PCMCIA_DEVICE_PROD_ID14("MEGAHERTZ", "PCMCIA MODEM", 0xf510db04, 0xbd6c43ef), 752 758 PCMCIA_DEVICE_PROD_ID124("TOSHIBA", "T144PF", "PCMCIA MODEM", 0xb4585a1a, 0x7271409c, 0xbd6c43ef), 753 759 PCMCIA_DEVICE_PROD_ID123("FUJITSU", "FC14F ", "MBH10213", 0x6ee5a3d8, 0x30ead12b, 0xb00f05a0), 760 + PCMCIA_DEVICE_PROD_ID123("Novatel Wireless", "Merlin UMTS Modem", "U630", 0x32607776, 0xd9e73b13, 0xe87332e), 754 761 PCMCIA_DEVICE_PROD_ID13("MEGAHERTZ", "V.34 PCMCIA MODEM", 0xf510db04, 0xbb2cce4a), 755 762 PCMCIA_DEVICE_PROD_ID12("Brain Boxes", "Bluetooth PC Card", 0xee138382, 0xd4ce9b02), 756 763 PCMCIA_DEVICE_PROD_ID12("CIRRUS LOGIC", "FAX MODEM", 0xe625f451, 0xcecd6dfa),
+33 -86
drivers/telephony/ixj_pcmcia.c
··· 35 35 } ixj_info_t; 36 36 37 37 static void ixj_detach(struct pcmcia_device *p_dev); 38 - static void ixj_config(dev_link_t * link); 39 - static void ixj_cs_release(dev_link_t * link); 38 + static int ixj_config(struct pcmcia_device * link); 39 + static void ixj_cs_release(struct pcmcia_device * link); 40 40 41 - static int ixj_attach(struct pcmcia_device *p_dev) 41 + static int ixj_probe(struct pcmcia_device *p_dev) 42 42 { 43 - dev_link_t *link; 44 - 45 43 DEBUG(0, "ixj_attach()\n"); 46 44 /* Create new ixj device */ 47 - link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); 48 - if (!link) 49 - return -ENOMEM; 50 - memset(link, 0, sizeof(struct dev_link_t)); 51 - link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 52 - link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 53 - link->io.IOAddrLines = 3; 54 - link->conf.Vcc = 50; 55 - link->conf.IntType = INT_MEMORY_AND_IO; 56 - link->priv = kmalloc(sizeof(struct ixj_info_t), GFP_KERNEL); 57 - if (!link->priv) { 58 - kfree(link); 45 + p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 46 + p_dev->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 47 + p_dev->io.IOAddrLines = 3; 48 + p_dev->conf.IntType = INT_MEMORY_AND_IO; 49 + p_dev->priv = kmalloc(sizeof(struct ixj_info_t), GFP_KERNEL); 50 + if (!p_dev->priv) { 59 51 return -ENOMEM; 60 52 } 61 - memset(link->priv, 0, sizeof(struct ixj_info_t)); 53 + memset(p_dev->priv, 0, sizeof(struct ixj_info_t)); 62 54 63 - link->handle = p_dev; 64 - p_dev->instance = link; 65 - 66 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 67 - ixj_config(link); 68 - 69 - return 0; 55 + return ixj_config(p_dev); 70 56 } 71 57 72 - static void ixj_detach(struct pcmcia_device *p_dev) 58 + static void ixj_detach(struct pcmcia_device *link) 73 59 { 74 - dev_link_t *link = dev_to_instance(p_dev); 75 - 76 60 DEBUG(0, "ixj_detach(0x%p)\n", link); 77 61 78 - link->state &= ~DEV_RELEASE_PENDING; 79 - if (link->state & DEV_CONFIG) 80 - ixj_cs_release(link); 62 + ixj_cs_release(link); 81 63 82 64 kfree(link->priv); 83 - kfree(link); 84 65 } 85 66 86 67 #define CS_CHECK(fn, ret) \ 87 68 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 88 69 89 - static void ixj_get_serial(dev_link_t * link, IXJ * j) 70 + static void ixj_get_serial(struct pcmcia_device * link, IXJ * j) 90 71 { 91 - client_handle_t handle; 92 72 tuple_t tuple; 93 73 u_short buf[128]; 94 74 char *str; 95 75 int last_ret, last_fn, i, place; 96 - handle = link->handle; 97 76 DEBUG(0, "ixj_get_serial(0x%p)\n", link); 98 77 tuple.TupleData = (cisdata_t *) buf; 99 78 tuple.TupleOffset = 0; 100 79 tuple.TupleDataMax = 80; 101 80 tuple.Attributes = 0; 102 81 tuple.DesiredTuple = CISTPL_VERS_1; 103 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 104 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 82 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 83 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 105 84 str = (char *) buf; 106 85 printk("PCMCIA Version %d.%d\n", str[0], str[1]); 107 86 str += 2; ··· 128 149 return; 129 150 } 130 151 131 - static void ixj_config(dev_link_t * link) 152 + static int ixj_config(struct pcmcia_device * link) 132 153 { 133 154 IXJ *j; 134 - client_handle_t handle; 135 155 ixj_info_t *info; 136 156 tuple_t tuple; 137 157 u_short buf[128]; 138 158 cisparse_t parse; 139 - config_info_t conf; 140 159 cistpl_cftable_entry_t *cfg = &parse.cftable_entry; 141 160 cistpl_cftable_entry_t dflt = 142 161 { 143 162 0 144 163 }; 145 164 int last_ret, last_fn; 146 - handle = link->handle; 147 165 info = link->priv; 148 166 DEBUG(0, "ixj_config(0x%p)\n", link); 149 167 tuple.TupleData = (cisdata_t *) buf; ··· 148 172 tuple.TupleDataMax = 255; 149 173 tuple.Attributes = 0; 150 174 tuple.DesiredTuple = CISTPL_CONFIG; 151 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 152 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 153 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 175 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 176 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 177 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 154 178 link->conf.ConfigBase = parse.config.base; 155 179 link->conf.Present = parse.config.rmask[0]; 156 - link->state |= DEV_CONFIG; 157 - CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf)); 158 180 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 159 181 tuple.Attributes = 0; 160 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 182 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 161 183 while (1) { 162 - if (pcmcia_get_tuple_data(handle, &tuple) != 0 || 163 - pcmcia_parse_tuple(handle, &tuple, &parse) != 0) 184 + if (pcmcia_get_tuple_data(link, &tuple) != 0 || 185 + pcmcia_parse_tuple(link, &tuple, &parse) != 0) 164 186 goto next_entry; 165 187 if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) { 166 188 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io; ··· 169 195 link->io.BasePort2 = io->win[1].base; 170 196 link->io.NumPorts2 = io->win[1].len; 171 197 } 172 - if (pcmcia_request_io(link->handle, &link->io) != 0) 198 + if (pcmcia_request_io(link, &link->io) != 0) 173 199 goto next_entry; 174 200 /* If we've got this far, we're done */ 175 201 break; ··· 177 203 next_entry: 178 204 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) 179 205 dflt = *cfg; 180 - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); 206 + CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); 181 207 } 182 208 183 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); 209 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 184 210 185 211 /* 186 212 * Register the card with the core. ··· 189 215 190 216 info->ndev = 1; 191 217 info->node.major = PHONE_MAJOR; 192 - link->dev = &info->node; 218 + link->dev_node = &info->node; 193 219 ixj_get_serial(link, j); 194 - link->state &= ~DEV_CONFIG_PENDING; 195 - return; 220 + return 0; 196 221 cs_failed: 197 - cs_error(link->handle, last_fn, last_ret); 222 + cs_error(link, last_fn, last_ret); 198 223 ixj_cs_release(link); 224 + return -ENODEV; 199 225 } 200 226 201 - static void ixj_cs_release(dev_link_t *link) 227 + static void ixj_cs_release(struct pcmcia_device *link) 202 228 { 203 229 ixj_info_t *info = link->priv; 204 230 DEBUG(0, "ixj_cs_release(0x%p)\n", link); 205 231 info->ndev = 0; 206 - link->dev = NULL; 207 - pcmcia_release_configuration(link->handle); 208 - pcmcia_release_io(link->handle, &link->io); 209 - link->state &= ~DEV_CONFIG; 210 - } 211 - 212 - static int ixj_suspend(struct pcmcia_device *dev) 213 - { 214 - dev_link_t *link = dev_to_instance(dev); 215 - 216 - link->state |= DEV_SUSPEND; 217 - if (link->state & DEV_CONFIG) 218 - pcmcia_release_configuration(link->handle); 219 - 220 - return 0; 221 - } 222 - 223 - static int ixj_resume(struct pcmcia_device *dev) 224 - { 225 - dev_link_t *link = dev_to_instance(dev); 226 - 227 - link->state &= ~DEV_SUSPEND; 228 - if (DEV_OK(link)) 229 - pcmcia_request_configuration(link->handle, &link->conf); 230 - 231 - return 0; 232 + pcmcia_disable_device(link); 232 233 } 233 234 234 235 static struct pcmcia_device_id ixj_ids[] = { ··· 217 268 .drv = { 218 269 .name = "ixj_cs", 219 270 }, 220 - .probe = ixj_attach, 271 + .probe = ixj_probe, 221 272 .remove = ixj_detach, 222 273 .id_table = ixj_ids, 223 - .suspend = ixj_suspend, 224 - .resume = ixj_resume, 225 274 }; 226 275 227 276 static int __init ixj_pcmcia_init(void)
+33 -86
drivers/usb/host/sl811_cs.c
··· 67 67 static const char driver_name[DEV_NAME_LEN] = "sl811_cs"; 68 68 69 69 typedef struct local_info_t { 70 - dev_link_t link; 70 + struct pcmcia_device *p_dev; 71 71 dev_node_t node; 72 72 } local_info_t; 73 73 74 - static void sl811_cs_release(dev_link_t * link); 74 + static void sl811_cs_release(struct pcmcia_device * link); 75 75 76 76 /*====================================================================*/ 77 77 ··· 138 138 139 139 /*====================================================================*/ 140 140 141 - static void sl811_cs_detach(struct pcmcia_device *p_dev) 141 + static void sl811_cs_detach(struct pcmcia_device *link) 142 142 { 143 - dev_link_t *link = dev_to_instance(p_dev); 144 - 145 143 DBG(0, "sl811_cs_detach(0x%p)\n", link); 146 144 147 - link->state &= ~DEV_PRESENT; 148 - if (link->state & DEV_CONFIG) 149 - sl811_cs_release(link); 145 + sl811_cs_release(link); 150 146 151 147 /* This points to the parent local_info_t struct */ 152 148 kfree(link->priv); 153 149 } 154 150 155 - static void sl811_cs_release(dev_link_t * link) 151 + static void sl811_cs_release(struct pcmcia_device * link) 156 152 { 157 - 158 153 DBG(0, "sl811_cs_release(0x%p)\n", link); 159 154 160 - /* Unlink the device chain */ 161 - link->dev = NULL; 162 - 155 + pcmcia_disable_device(link); 163 156 platform_device_unregister(&platform_dev); 164 - pcmcia_release_configuration(link->handle); 165 - if (link->io.NumPorts1) 166 - pcmcia_release_io(link->handle, &link->io); 167 - if (link->irq.AssignedIRQ) 168 - pcmcia_release_irq(link->handle, &link->irq); 169 - link->state &= ~DEV_CONFIG; 170 157 } 171 158 172 - static void sl811_cs_config(dev_link_t *link) 159 + static int sl811_cs_config(struct pcmcia_device *link) 173 160 { 174 - client_handle_t handle = link->handle; 175 - struct device *parent = &handle_to_dev(handle); 161 + struct device *parent = &handle_to_dev(link); 176 162 local_info_t *dev = link->priv; 177 163 tuple_t tuple; 178 164 cisparse_t parse; ··· 174 188 tuple.TupleData = buf; 175 189 tuple.TupleDataMax = sizeof(buf); 176 190 tuple.TupleOffset = 0; 177 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 178 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 179 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 191 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 192 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 193 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); 180 194 link->conf.ConfigBase = parse.config.base; 181 195 link->conf.Present = parse.config.rmask[0]; 182 196 183 - /* Configure card */ 184 - link->state |= DEV_CONFIG; 185 - 186 197 /* Look up the current Vcc */ 187 198 CS_CHECK(GetConfigurationInfo, 188 - pcmcia_get_configuration_info(handle, &conf)); 189 - link->conf.Vcc = conf.Vcc; 199 + pcmcia_get_configuration_info(link, &conf)); 190 200 191 201 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 192 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 202 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 193 203 while (1) { 194 204 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 195 205 196 - if (pcmcia_get_tuple_data(handle, &tuple) != 0 197 - || pcmcia_parse_tuple(handle, &tuple, &parse) 206 + if (pcmcia_get_tuple_data(link, &tuple) != 0 207 + || pcmcia_parse_tuple(link, &tuple, &parse) 198 208 != 0) 199 209 goto next_entry; 200 210 ··· 216 234 } 217 235 218 236 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) 219 - link->conf.Vpp1 = link->conf.Vpp2 = 237 + link->conf.Vpp = 220 238 cfg->vpp1.param[CISTPL_POWER_VNOM]/10000; 221 239 else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM)) 222 - link->conf.Vpp1 = link->conf.Vpp2 = 240 + link->conf.Vpp = 223 241 dflt.vpp1.param[CISTPL_POWER_VNOM]/10000; 224 242 225 243 /* we need an interrupt */ ··· 236 254 link->io.BasePort1 = io->win[0].base; 237 255 link->io.NumPorts1 = io->win[0].len; 238 256 239 - if (pcmcia_request_io(link->handle, &link->io) != 0) 257 + if (pcmcia_request_io(link, &link->io) != 0) 240 258 goto next_entry; 241 259 } 242 260 break; 243 261 244 262 next_entry: 245 - if (link->io.NumPorts1) 246 - pcmcia_release_io(link->handle, &link->io); 247 - last_ret = pcmcia_get_next_tuple(handle, &tuple); 263 + pcmcia_disable_device(link); 264 + last_ret = pcmcia_get_next_tuple(link, &tuple); 248 265 } 249 266 250 267 /* require an IRQ and two registers */ ··· 251 270 goto cs_failed; 252 271 if (link->conf.Attributes & CONF_ENABLE_IRQ) 253 272 CS_CHECK(RequestIRQ, 254 - pcmcia_request_irq(link->handle, &link->irq)); 273 + pcmcia_request_irq(link, &link->irq)); 255 274 else 256 275 goto cs_failed; 257 276 258 277 CS_CHECK(RequestConfiguration, 259 - pcmcia_request_configuration(link->handle, &link->conf)); 278 + pcmcia_request_configuration(link, &link->conf)); 260 279 261 280 sprintf(dev->node.dev_name, driver_name); 262 281 dev->node.major = dev->node.minor = 0; 263 - link->dev = &dev->node; 282 + link->dev_node = &dev->node; 264 283 265 - printk(KERN_INFO "%s: index 0x%02x: Vcc %d.%d", 266 - dev->node.dev_name, link->conf.ConfigIndex, 267 - link->conf.Vcc/10, link->conf.Vcc%10); 268 - if (link->conf.Vpp1) 269 - printk(", Vpp %d.%d", link->conf.Vpp1/10, link->conf.Vpp1%10); 284 + printk(KERN_INFO "%s: index 0x%02x: ", 285 + dev->node.dev_name, link->conf.ConfigIndex); 286 + if (link->conf.Vpp) 287 + printk(", Vpp %d.%d", link->conf.Vpp/10, link->conf.Vpp%10); 270 288 printk(", irq %d", link->irq.AssignedIRQ); 271 289 printk(", io 0x%04x-0x%04x", link->io.BasePort1, 272 290 link->io.BasePort1+link->io.NumPorts1-1); 273 291 printk("\n"); 274 292 275 - link->state &= ~DEV_CONFIG_PENDING; 276 - 277 293 if (sl811_hc_init(parent, link->io.BasePort1, link->irq.AssignedIRQ) 278 294 < 0) { 279 295 cs_failed: 280 296 printk("sl811_cs_config failed\n"); 281 - cs_error(link->handle, last_fn, last_ret); 297 + cs_error(link, last_fn, last_ret); 282 298 sl811_cs_release(link); 283 - link->state &= ~DEV_CONFIG_PENDING; 299 + return -ENODEV; 284 300 } 285 - } 286 - 287 - static int sl811_suspend(struct pcmcia_device *dev) 288 - { 289 - dev_link_t *link = dev_to_instance(dev); 290 - 291 - link->state |= DEV_SUSPEND; 292 - if (link->state & DEV_CONFIG) 293 - pcmcia_release_configuration(link->handle); 294 - 295 301 return 0; 296 302 } 297 303 298 - static int sl811_resume(struct pcmcia_device *dev) 299 - { 300 - dev_link_t *link = dev_to_instance(dev); 301 - 302 - link->state &= ~DEV_SUSPEND; 303 - if (link->state & DEV_CONFIG) 304 - pcmcia_request_configuration(link->handle, &link->conf); 305 - 306 - return 0; 307 - } 308 - 309 - static int sl811_cs_attach(struct pcmcia_device *p_dev) 304 + static int sl811_cs_probe(struct pcmcia_device *link) 310 305 { 311 306 local_info_t *local; 312 - dev_link_t *link; 313 307 314 308 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 315 309 if (!local) 316 310 return -ENOMEM; 317 311 memset(local, 0, sizeof(local_info_t)); 318 - link = &local->link; 312 + local->p_dev = link; 319 313 link->priv = local; 320 314 321 315 /* Initialize */ ··· 299 343 link->irq.Handler = NULL; 300 344 301 345 link->conf.Attributes = 0; 302 - link->conf.Vcc = 33; 303 346 link->conf.IntType = INT_MEMORY_AND_IO; 304 347 305 - link->handle = p_dev; 306 - p_dev->instance = link; 307 - 308 - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 309 - sl811_cs_config(link); 310 - 311 - return 0; 348 + return sl811_cs_config(link); 312 349 } 313 350 314 351 static struct pcmcia_device_id sl811_ids[] = { ··· 315 366 .drv = { 316 367 .name = (char *)driver_name, 317 368 }, 318 - .probe = sl811_cs_attach, 369 + .probe = sl811_cs_probe, 319 370 .remove = sl811_cs_detach, 320 371 .id_table = sl811_ids, 321 - .suspend = sl811_suspend, 322 - .resume = sl811_resume, 323 372 }; 324 373 325 374 /*====================================================================*/
+3
include/asm-arm/arch-at91rm9200/hardware.h
··· 65 65 /* SmartMedia */ 66 66 #define AT91_SMARTMEDIA_BASE 0x40000000 /* NCS3: Smartmedia physical base address */ 67 67 68 + /* Compact Flash */ 69 + #define AT91_CF_BASE 0x50000000 /* NCS4-NCS6: Compact Flash physical base address */ 70 + 68 71 /* Multi-Master Memory controller */ 69 72 #define AT91_UHP_BASE 0x00300000 /* USB Host controller */ 70 73
+2 -2
include/pcmcia/bulkmem.h
··· 35 35 #define REGION_BAR_MASK 0xe000 36 36 #define REGION_BAR_SHIFT 13 37 37 38 - int pcmcia_get_first_region(client_handle_t handle, region_info_t *rgn); 39 - int pcmcia_get_next_region(client_handle_t handle, region_info_t *rgn); 38 + int pcmcia_get_first_region(struct pcmcia_device *handle, region_info_t *rgn); 39 + int pcmcia_get_next_region(struct pcmcia_device *handle, region_info_t *rgn); 40 40 41 41 #endif /* _LINUX_BULKMEM_H */
+4 -1
include/pcmcia/ciscode.h
··· 1 1 /* 2 - * ciscode.h -- Definitions for bulk memory services 2 + * ciscode.h 3 3 * 4 4 * This program is free software; you can redistribute it and/or modify 5 5 * it under the terms of the GNU General Public License version 2 as ··· 121 121 #define MANFID_UNGERMANN 0x02c0 122 122 123 123 #define MANFID_XIRCOM 0x0105 124 + 125 + #define MANFID_POSSIO 0x030c 126 + #define PRODID_POSSIO_GCC 0x0003 124 127 125 128 #endif /* _LINUX_CISCODE_H */
+16 -5
include/pcmcia/cistpl.h
··· 586 586 cisdata_t Data[CISTPL_MAX_CIS_SIZE]; 587 587 } cisdump_t; 588 588 589 - int pcmcia_get_first_tuple(client_handle_t handle, tuple_t *tuple); 590 - int pcmcia_get_next_tuple(client_handle_t handle, tuple_t *tuple); 591 - int pcmcia_get_tuple_data(client_handle_t handle, tuple_t *tuple); 592 - int pcmcia_parse_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse); 593 589 594 - int pcmcia_validate_cis(client_handle_t handle, cisinfo_t *info); 595 590 int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis); 596 591 597 592 /* don't use outside of PCMCIA core yet */ ··· 596 601 int pccard_parse_tuple(tuple_t *tuple, cisparse_t *parse); 597 602 598 603 int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, cisinfo_t *info); 604 + 605 + /* ... but use these wrappers instead */ 606 + #define pcmcia_get_first_tuple(p_dev, tuple) \ 607 + pccard_get_first_tuple(p_dev->socket, p_dev->func, tuple) 608 + 609 + #define pcmcia_get_next_tuple(p_dev, tuple) \ 610 + pccard_get_next_tuple(p_dev->socket, p_dev->func, tuple) 611 + 612 + #define pcmcia_get_tuple_data(p_dev, tuple) \ 613 + pccard_get_tuple_data(p_dev->socket, tuple) 614 + 615 + #define pcmcia_parse_tuple(p_dev, tuple, parse) \ 616 + pccard_parse_tuple(tuple, parse) 617 + 618 + #define pcmcia_validate_cis(p_dev, info) \ 619 + pccard_validate_cis(p_dev->socket, p_dev->func, info) 599 620 600 621 #endif /* LINUX_CISTPL_H */
+14 -20
include/pcmcia/cs.h
··· 109 109 110 110 #define CLIENT_THIS_SOCKET 0x01 111 111 112 - /* For RegisterClient */ 113 - typedef struct client_reg_t { 114 - dev_info_t *dev_info; 115 - u_int Attributes; /* UNUSED */ 116 - u_int EventMask; 117 - int (*event_handler)(event_t event, int priority, 118 - event_callback_args_t *); 119 - event_callback_args_t event_callback_args; 120 - u_int Version; 121 - } client_reg_t; 122 - 123 112 /* ModifyConfiguration */ 124 113 typedef struct modconf_t { 125 114 u_int Attributes; ··· 116 127 } modconf_t; 117 128 118 129 /* Attributes for ModifyConfiguration */ 119 - #define CONF_IRQ_CHANGE_VALID 0x100 120 - #define CONF_VCC_CHANGE_VALID 0x200 121 - #define CONF_VPP1_CHANGE_VALID 0x400 122 - #define CONF_VPP2_CHANGE_VALID 0x800 130 + #define CONF_IRQ_CHANGE_VALID 0x0100 131 + #define CONF_VCC_CHANGE_VALID 0x0200 132 + #define CONF_VPP1_CHANGE_VALID 0x0400 133 + #define CONF_VPP2_CHANGE_VALID 0x0800 134 + #define CONF_IO_CHANGE_WIDTH 0x1000 123 135 124 136 /* For RequestConfiguration */ 125 137 typedef struct config_req_t { 126 138 u_int Attributes; 127 - u_int Vcc, Vpp1, Vpp2; 139 + u_int Vpp; /* both Vpp1 and Vpp2 */ 128 140 u_int IntType; 129 141 u_int ConfigBase; 130 142 u_char Status, Pin, Copy, ExtStatus; ··· 379 389 int pcmcia_get_mem_page(window_handle_t win, memreq_t *req); 380 390 int pcmcia_map_mem_page(window_handle_t win, memreq_t *req); 381 391 int pcmcia_modify_configuration(struct pcmcia_device *p_dev, modconf_t *mod); 382 - int pcmcia_release_configuration(struct pcmcia_device *p_dev); 383 - int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req); 384 - int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req); 385 392 int pcmcia_release_window(window_handle_t win); 386 393 int pcmcia_request_configuration(struct pcmcia_device *p_dev, config_req_t *req); 387 394 int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req); 388 395 int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req); 389 396 int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_handle_t *wh); 390 - int pcmcia_reset_card(struct pcmcia_device *p_dev, client_req_t *req); 391 397 int pcmcia_suspend_card(struct pcmcia_socket *skt); 392 398 int pcmcia_resume_card(struct pcmcia_socket *skt); 393 399 int pcmcia_eject_card(struct pcmcia_socket *skt); 394 400 int pcmcia_insert_card(struct pcmcia_socket *skt); 401 + int pccard_reset_card(struct pcmcia_socket *skt); 402 + 403 + struct pcmcia_device * pcmcia_dev_present(struct pcmcia_device *p_dev); 404 + void pcmcia_disable_device(struct pcmcia_device *p_dev); 395 405 396 406 struct pcmcia_socket * pcmcia_get_socket(struct pcmcia_socket *skt); 397 407 void pcmcia_put_socket(struct pcmcia_socket *skt); 408 + 409 + /* compatibility functions */ 410 + #define pcmcia_reset_card(p_dev, req) \ 411 + pccard_reset_card(p_dev->socket) 398 412 399 413 #endif /* __KERNEL__ */ 400 414
+39 -41
include/pcmcia/ds.h
··· 39 39 typedef struct bind_info_t { 40 40 dev_info_t dev_info; 41 41 u_char function; 42 - struct dev_link_t *instance; 42 + struct pcmcia_device *instance; 43 43 char name[DEV_NAME_LEN]; 44 44 u_short major, minor; 45 45 void *next; ··· 96 96 97 97 #ifdef __KERNEL__ 98 98 #include <linux/device.h> 99 + #include <pcmcia/ss.h> 99 100 100 101 typedef struct dev_node_t { 101 102 char dev_name[DEV_NAME_LEN]; ··· 104 103 struct dev_node_t *next; 105 104 } dev_node_t; 106 105 107 - typedef struct dev_link_t { 108 - dev_node_t *dev; 109 - u_int state, open; 110 - wait_queue_head_t pending; 111 - client_handle_t handle; 112 - io_req_t io; 113 - irq_req_t irq; 114 - config_req_t conf; 115 - window_handle_t win; 116 - void *priv; 117 - struct dev_link_t *next; 118 - } dev_link_t; 119 - 120 - /* Flags for device state */ 121 - #define DEV_PRESENT 0x01 122 - #define DEV_CONFIG 0x02 123 - #define DEV_STALE_CONFIG 0x04 /* release on close */ 124 - #define DEV_STALE_LINK 0x08 /* detach on release */ 125 - #define DEV_CONFIG_PENDING 0x10 126 - #define DEV_RELEASE_PENDING 0x20 127 - #define DEV_SUSPEND 0x40 128 - #define DEV_BUSY 0x80 129 - 130 - #define DEV_OK(l) \ 131 - ((l) && ((l->state & ~DEV_BUSY) == (DEV_CONFIG|DEV_PRESENT))) 132 - 133 106 134 107 struct pcmcia_socket; 108 + struct config_t; 135 109 136 110 struct pcmcia_driver { 137 111 int (*probe) (struct pcmcia_device *dev); ··· 124 148 int pcmcia_register_driver(struct pcmcia_driver *driver); 125 149 void pcmcia_unregister_driver(struct pcmcia_driver *driver); 126 150 151 + 127 152 struct pcmcia_device { 128 153 /* the socket and the device_no [for multifunction devices] 129 154 uniquely define a pcmcia_device */ ··· 137 160 /* the hardware "function" device; certain subdevices can 138 161 * share one hardware "function" device. */ 139 162 u8 func; 163 + struct config_t* function_config; 140 164 141 165 struct list_head socket_device_list; 142 166 143 - /* deprecated, a cleaned up version will be moved into this 144 - struct soon */ 145 - dev_link_t *instance; 146 - u_int state; 167 + /* deprecated, will be cleaned up soon */ 168 + dev_node_t *dev_node; 169 + u_int open; 170 + io_req_t io; 171 + irq_req_t irq; 172 + config_req_t conf; 173 + window_handle_t win; 174 + 175 + /* Is the device suspended, or in the process of 176 + * being removed? */ 177 + u16 suspended:1; 178 + u16 _removed:1; 179 + 180 + /* Flags whether io, irq, win configurations were 181 + * requested, and whether the configuration is "locked" */ 182 + u16 _irq:1; 183 + u16 _io:1; 184 + u16 _win:4; 185 + u16 _locked:1; 186 + 187 + /* Flag whether a "fuzzy" func_id based match is 188 + * allowed. */ 189 + u16 allow_func_id_match:1; 147 190 148 191 /* information about this device */ 149 - u8 has_manf_id:1; 150 - u8 has_card_id:1; 151 - u8 has_func_id:1; 192 + u16 has_manf_id:1; 193 + u16 has_card_id:1; 194 + u16 has_func_id:1; 152 195 153 - u8 allow_func_id_match:1; 154 - u8 reserved:4; 196 + u16 reserved:3; 155 197 156 198 u8 func_id; 157 199 u16 manf_id; ··· 178 182 179 183 char * prod_id[4]; 180 184 185 + struct device dev; 186 + 187 + #ifdef CONFIG_PCMCIA_IOCTL 181 188 /* device driver wanted by cardmgr */ 182 189 struct pcmcia_driver * cardmgr; 190 + #endif 183 191 184 - struct device dev; 192 + /* data private to drivers */ 193 + void *priv; 185 194 }; 186 195 187 196 #define to_pcmcia_dev(n) container_of(n, struct pcmcia_device, dev) 188 197 #define to_pcmcia_drv(n) container_of(n, struct pcmcia_driver, drv) 189 198 190 - #define handle_to_pdev(handle) (handle) 191 199 #define handle_to_dev(handle) (handle->dev) 192 200 193 - #define dev_to_instance(dev) (dev->instance) 194 - 195 201 /* error reporting */ 196 - void cs_error(client_handle_t handle, int func, int ret); 202 + void cs_error(struct pcmcia_device *handle, int func, int ret); 197 203 198 204 #endif /* __KERNEL__ */ 199 205 #endif /* _LINUX_DS_H */
+6 -5
include/pcmcia/ss.h
··· 18 18 #include <linux/config.h> 19 19 #include <linux/device.h> 20 20 #include <linux/sched.h> /* task_struct, completion */ 21 + #include <linux/mutex.h> 21 22 22 23 #include <pcmcia/cs_types.h> 23 24 #include <pcmcia/cs.h> ··· 147 146 /* !SS_CAP_STATIC_MAP */ 148 147 extern struct pccard_resource_ops pccard_nonstatic_ops; 149 148 149 + /* static mem, dynamic IO sockets */ 150 + extern struct pccard_resource_ops pccard_iodyn_ops; 151 + 150 152 /* 151 153 * Calls to set up low-level "Socket Services" drivers 152 154 */ 153 155 struct pcmcia_socket; 154 156 155 157 typedef struct io_window_t { 156 - u_int Attributes; 157 - kio_addr_t BasePort, NumPorts; 158 158 kio_addr_t InUse, Config; 159 159 struct resource *res; 160 160 } io_window_t; ··· 164 162 typedef struct window_t { 165 163 u_short magic; 166 164 u_short index; 167 - client_handle_t handle; 165 + struct pcmcia_device *handle; 168 166 struct pcmcia_socket *sock; 169 167 pccard_mem_map ctl; 170 168 } window_t; ··· 188 186 u_short lock_count; 189 187 pccard_mem_map cis_mem; 190 188 void __iomem *cis_virt; 191 - struct config_t *config; 192 189 struct { 193 190 u_int AssignedIRQ; 194 191 u_int Config; ··· 242 241 #endif 243 242 244 243 /* state thread */ 245 - struct semaphore skt_sem; /* protects socket h/w state */ 244 + struct mutex skt_mutex; /* protects socket h/w state */ 246 245 247 246 struct task_struct *thread; 248 247 struct completion thread_done;
+25 -61
sound/pcmcia/pdaudiocf/pdaudiocf.c
··· 57 57 /* 58 58 * prototypes 59 59 */ 60 - static void pdacf_config(dev_link_t *link); 60 + static int pdacf_config(struct pcmcia_device *link); 61 61 static void snd_pdacf_detach(struct pcmcia_device *p_dev); 62 62 63 - static void pdacf_release(dev_link_t *link) 63 + static void pdacf_release(struct pcmcia_device *link) 64 64 { 65 - if (link->state & DEV_CONFIG) { 66 - /* release cs resources */ 67 - pcmcia_release_configuration(link->handle); 68 - pcmcia_release_io(link->handle, &link->io); 69 - pcmcia_release_irq(link->handle, &link->irq); 70 - link->state &= ~DEV_CONFIG; 71 - } 65 + pcmcia_disable_device(link); 72 66 } 73 67 74 68 /* ··· 70 76 */ 71 77 static int snd_pdacf_free(struct snd_pdacf *pdacf) 72 78 { 73 - dev_link_t *link = &pdacf->link; 79 + struct pcmcia_device *link = pdacf->p_dev; 74 80 75 81 pdacf_release(link); 76 82 ··· 90 96 /* 91 97 * snd_pdacf_attach - attach callback for cs 92 98 */ 93 - static int snd_pdacf_attach(struct pcmcia_device *p_dev) 99 + static int snd_pdacf_probe(struct pcmcia_device *link) 94 100 { 95 101 int i; 96 - dev_link_t *link; /* Info for cardmgr */ 97 102 struct snd_pdacf *pdacf; 98 103 struct snd_card *card; 99 104 static struct snd_device_ops ops = { ··· 132 139 pdacf->index = i; 133 140 card_list[i] = card; 134 141 135 - link = &pdacf->link; 142 + pdacf->p_dev = link; 136 143 link->priv = pdacf; 137 144 138 145 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; ··· 149 156 link->conf.ConfigIndex = 1; 150 157 link->conf.Present = PRESENT_OPTION; 151 158 152 - /* Chain drivers */ 153 - link->next = NULL; 154 - 155 - link->handle = p_dev; 156 - pdacf_config(link); 157 - 158 - return 0; 159 + return pdacf_config(link); 159 160 } 160 161 161 162 ··· 196 209 /* 197 210 * snd_pdacf_detach - detach callback for cs 198 211 */ 199 - static void snd_pdacf_detach(struct pcmcia_device *p_dev) 212 + static void snd_pdacf_detach(struct pcmcia_device *link) 200 213 { 201 - dev_link_t *link = dev_to_instance(p_dev); 202 214 struct snd_pdacf *chip = link->priv; 203 215 204 216 snd_printdd(KERN_DEBUG "pdacf_detach called\n"); ··· 216 230 #define CS_CHECK(fn, ret) \ 217 231 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 218 232 219 - static void pdacf_config(dev_link_t *link) 233 + static int pdacf_config(struct pcmcia_device *link) 220 234 { 221 - client_handle_t handle = link->handle; 222 235 struct snd_pdacf *pdacf = link->priv; 223 236 tuple_t tuple; 224 237 cisparse_t *parse = NULL; 225 - config_info_t conf; 226 238 u_short buf[32]; 227 239 int last_fn, last_ret; 228 240 ··· 228 244 parse = kmalloc(sizeof(*parse), GFP_KERNEL); 229 245 if (! parse) { 230 246 snd_printk(KERN_ERR "pdacf_config: cannot allocate\n"); 231 - return; 247 + return -ENOMEM; 232 248 } 233 249 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 234 250 tuple.Attributes = 0; ··· 236 252 tuple.TupleDataMax = sizeof(buf); 237 253 tuple.TupleOffset = 0; 238 254 tuple.DesiredTuple = CISTPL_CONFIG; 239 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 240 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 241 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, parse)); 255 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 256 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 257 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, parse)); 242 258 link->conf.ConfigBase = parse->config.base; 243 259 link->conf.ConfigIndex = 0x5; 244 260 kfree(parse); 245 261 246 - CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf)); 247 - link->conf.Vcc = conf.Vcc; 248 - 249 - /* Configure card */ 250 - link->state |= DEV_CONFIG; 251 - 252 - CS_CHECK(RequestIO, pcmcia_request_io(handle, &link->io)); 253 - CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 254 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 262 + CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); 263 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 264 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 255 265 256 266 if (snd_pdacf_assign_resources(pdacf, link->io.BasePort1, link->irq.AssignedIRQ) < 0) 257 267 goto failed; 258 268 259 - link->dev = &pdacf->node; 260 - link->state &= ~DEV_CONFIG_PENDING; 261 - return; 269 + link->dev_node = &pdacf->node; 270 + return 0; 262 271 263 272 cs_failed: 264 - cs_error(link->handle, last_fn, last_ret); 273 + cs_error(link, last_fn, last_ret); 265 274 failed: 266 - pcmcia_release_configuration(link->handle); 267 - pcmcia_release_io(link->handle, &link->io); 268 - pcmcia_release_irq(link->handle, &link->irq); 275 + pcmcia_disable_device(link); 276 + return -ENODEV; 269 277 } 270 278 271 279 #ifdef CONFIG_PM 272 280 273 - static int pdacf_suspend(struct pcmcia_device *dev) 281 + static int pdacf_suspend(struct pcmcia_device *link) 274 282 { 275 - dev_link_t *link = dev_to_instance(dev); 276 283 struct snd_pdacf *chip = link->priv; 277 284 278 285 snd_printdd(KERN_DEBUG "SUSPEND\n"); 279 - link->state |= DEV_SUSPEND; 280 286 if (chip) { 281 287 snd_printdd(KERN_DEBUG "snd_pdacf_suspend calling\n"); 282 288 snd_pdacf_suspend(chip, PMSG_SUSPEND); 283 289 } 284 290 285 - snd_printdd(KERN_DEBUG "RESET_PHYSICAL\n"); 286 - if (link->state & DEV_CONFIG) 287 - pcmcia_release_configuration(link->handle); 288 - 289 291 return 0; 290 292 } 291 293 292 - static int pdacf_resume(struct pcmcia_device *dev) 294 + static int pdacf_resume(struct pcmcia_device *link) 293 295 { 294 - dev_link_t *link = dev_to_instance(dev); 295 296 struct snd_pdacf *chip = link->priv; 296 297 297 298 snd_printdd(KERN_DEBUG "RESUME\n"); 298 - link->state &= ~DEV_SUSPEND; 299 - 300 - snd_printdd(KERN_DEBUG "CARD_RESET\n"); 301 - if (DEV_OK(link)) { 302 - snd_printdd(KERN_DEBUG "requestconfig...\n"); 303 - pcmcia_request_configuration(link->handle, &link->conf); 299 + if (pcmcia_dev_present(link)) { 304 300 if (chip) { 305 301 snd_printdd(KERN_DEBUG "calling snd_pdacf_resume\n"); 306 302 snd_pdacf_resume(chip); ··· 307 343 .drv = { 308 344 .name = "snd-pdaudiocf", 309 345 }, 310 - .probe = snd_pdacf_attach, 346 + .probe = snd_pdacf_probe, 311 347 .remove = snd_pdacf_detach, 312 348 .id_table = snd_pdacf_ids, 313 349 #ifdef CONFIG_PM
+1 -1
sound/pcmcia/pdaudiocf/pdaudiocf.h
··· 116 116 void *pcm_area; 117 117 118 118 /* pcmcia stuff */ 119 - dev_link_t link; 119 + struct pcmcia_device *p_dev; 120 120 dev_node_t node; 121 121 }; 122 122
+31 -63
sound/pcmcia/vx/vxpocket.c
··· 59 59 60 60 /* 61 61 */ 62 - static void vxpocket_release(dev_link_t *link) 62 + static void vxpocket_release(struct pcmcia_device *link) 63 63 { 64 - if (link->state & DEV_CONFIG) { 65 - /* release cs resources */ 66 - pcmcia_release_configuration(link->handle); 67 - pcmcia_release_io(link->handle, &link->io); 68 - pcmcia_release_irq(link->handle, &link->irq); 69 - link->state &= ~DEV_CONFIG; 70 - } 64 + pcmcia_disable_device(link); 71 65 } 72 66 73 67 /* ··· 126 132 /* 127 133 * create vxpocket instance 128 134 */ 129 - static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl) 135 + static struct snd_vxpocket *snd_vxpocket_new(struct snd_card *card, int ibl, 136 + struct pcmcia_device *link) 130 137 { 131 - dev_link_t *link; /* Info for cardmgr */ 132 138 struct vx_core *chip; 133 139 struct snd_vxpocket *vxp; 134 140 static struct snd_device_ops ops = { ··· 148 154 149 155 vxp = (struct snd_vxpocket *)chip; 150 156 151 - link = &vxp->link; 157 + vxp->p_dev = link; 152 158 link->priv = chip; 153 159 154 160 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; ··· 161 167 link->irq.Instance = chip; 162 168 163 169 link->conf.Attributes = CONF_ENABLE_IRQ; 164 - link->conf.Vcc = 50; 165 170 link->conf.IntType = INT_MEMORY_AND_IO; 166 171 link->conf.ConfigIndex = 1; 167 172 link->conf.Present = PRESENT_OPTION; ··· 208 215 #define CS_CHECK(fn, ret) \ 209 216 do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 210 217 211 - static void vxpocket_config(dev_link_t *link) 218 + static int vxpocket_config(struct pcmcia_device *link) 212 219 { 213 - client_handle_t handle = link->handle; 214 220 struct vx_core *chip = link->priv; 215 221 struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; 216 222 tuple_t tuple; ··· 221 229 parse = kmalloc(sizeof(*parse), GFP_KERNEL); 222 230 if (! parse) { 223 231 snd_printk(KERN_ERR "vx: cannot allocate\n"); 224 - return; 232 + return -ENOMEM; 225 233 } 226 234 tuple.Attributes = 0; 227 235 tuple.TupleData = (cisdata_t *)buf; 228 236 tuple.TupleDataMax = sizeof(buf); 229 237 tuple.TupleOffset = 0; 230 238 tuple.DesiredTuple = CISTPL_CONFIG; 231 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 232 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 233 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, parse)); 239 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 240 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 241 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, parse)); 234 242 link->conf.ConfigBase = parse->config.base; 235 243 link->conf.Present = parse->config.rmask[0]; 236 244 237 245 /* redefine hardware record according to the VERSION1 string */ 238 246 tuple.DesiredTuple = CISTPL_VERS_1; 239 - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 240 - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 241 - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, parse)); 247 + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); 248 + CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); 249 + CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, parse)); 242 250 if (! strcmp(parse->version_1.str + parse->version_1.ofs[1], "VX-POCKET")) { 243 251 snd_printdd("VX-pocket is detected\n"); 244 252 } else { ··· 249 257 strcpy(chip->card->driver, vxp440_hw.name); 250 258 } 251 259 252 - /* Configure card */ 253 - link->state |= DEV_CONFIG; 260 + CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); 261 + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 262 + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 254 263 255 - CS_CHECK(RequestIO, pcmcia_request_io(handle, &link->io)); 256 - CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 257 - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 258 - 259 - chip->dev = &handle_to_dev(link->handle); 264 + chip->dev = &handle_to_dev(link); 260 265 snd_card_set_dev(chip->card, chip->dev); 261 266 262 267 if (snd_vxpocket_assign_resources(chip, link->io.BasePort1, link->irq.AssignedIRQ) < 0) 263 268 goto failed; 264 269 265 - link->dev = &vxp->node; 266 - link->state &= ~DEV_CONFIG_PENDING; 270 + link->dev_node = &vxp->node; 267 271 kfree(parse); 268 - return; 272 + return 9; 269 273 270 274 cs_failed: 271 - cs_error(link->handle, last_fn, last_ret); 275 + cs_error(link, last_fn, last_ret); 272 276 failed: 273 - pcmcia_release_configuration(link->handle); 274 - pcmcia_release_io(link->handle, &link->io); 275 - pcmcia_release_irq(link->handle, &link->irq); 276 - link->state &= ~DEV_CONFIG; 277 + pcmcia_disable_device(link); 277 278 kfree(parse); 279 + return -ENODEV; 278 280 } 279 281 280 282 #ifdef CONFIG_PM 281 283 282 - static int vxp_suspend(struct pcmcia_device *dev) 284 + static int vxp_suspend(struct pcmcia_device *link) 283 285 { 284 - dev_link_t *link = dev_to_instance(dev); 285 286 struct vx_core *chip = link->priv; 286 287 287 288 snd_printdd(KERN_DEBUG "SUSPEND\n"); 288 - link->state |= DEV_SUSPEND; 289 289 if (chip) { 290 290 snd_printdd(KERN_DEBUG "snd_vx_suspend calling\n"); 291 291 snd_vx_suspend(chip, PMSG_SUSPEND); 292 292 } 293 - snd_printdd(KERN_DEBUG "RESET_PHYSICAL\n"); 294 - if (link->state & DEV_CONFIG) 295 - pcmcia_release_configuration(link->handle); 296 293 297 294 return 0; 298 295 } 299 296 300 - static int vxp_resume(struct pcmcia_device *dev) 297 + static int vxp_resume(struct pcmcia_device *link) 301 298 { 302 - dev_link_t *link = dev_to_instance(dev); 303 299 struct vx_core *chip = link->priv; 304 300 305 301 snd_printdd(KERN_DEBUG "RESUME\n"); 306 - link->state &= ~DEV_SUSPEND; 307 - 308 - snd_printdd(KERN_DEBUG "CARD_RESET\n"); 309 - if (DEV_OK(link)) { 302 + if (pcmcia_dev_present(link)) { 310 303 //struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; 311 - snd_printdd(KERN_DEBUG "requestconfig...\n"); 312 - pcmcia_request_configuration(link->handle, &link->conf); 313 304 if (chip) { 314 305 snd_printdd(KERN_DEBUG "calling snd_vx_resume\n"); 315 306 snd_vx_resume(chip); ··· 308 333 309 334 /* 310 335 */ 311 - static int vxpocket_attach(struct pcmcia_device *p_dev) 336 + static int vxpocket_probe(struct pcmcia_device *p_dev) 312 337 { 313 338 struct snd_card *card; 314 339 struct snd_vxpocket *vxp; ··· 333 358 return -ENOMEM; 334 359 } 335 360 336 - vxp = snd_vxpocket_new(card, ibl[i]); 361 + vxp = snd_vxpocket_new(card, ibl[i], p_dev); 337 362 if (! vxp) { 338 363 snd_card_free(card); 339 364 return -ENODEV; ··· 343 368 vxp->index = i; 344 369 card_alloc |= 1 << i; 345 370 346 - /* Chain drivers */ 347 - vxp->link.next = NULL; 371 + vxp->p_dev = p_dev; 348 372 349 - vxp->link.handle = p_dev; 350 - vxp->link.state |= DEV_PRESENT | DEV_CONFIG_PENDING; 351 - p_dev->instance = &vxp->link; 352 - vxpocket_config(&vxp->link); 353 - 354 - return 0; 373 + return vxpocket_config(p_dev); 355 374 } 356 375 357 - static void vxpocket_detach(struct pcmcia_device *p_dev) 376 + static void vxpocket_detach(struct pcmcia_device *link) 358 377 { 359 - dev_link_t *link = dev_to_instance(p_dev); 360 378 struct snd_vxpocket *vxp; 361 379 struct vx_core *chip; 362 380 ··· 381 413 .drv = { 382 414 .name = "snd-vxpocket", 383 415 }, 384 - .probe = vxpocket_attach, 416 + .probe = vxpocket_probe, 385 417 .remove = vxpocket_detach, 386 418 .id_table = vxp_ids, 387 419 #ifdef CONFIG_PM
+1 -1
sound/pcmcia/vx/vxpocket.h
··· 42 42 int index; /* card index */ 43 43 44 44 /* pcmcia stuff */ 45 - dev_link_t link; 45 + struct pcmcia_device *p_dev; 46 46 dev_node_t node; 47 47 }; 48 48