aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/hvcs.c2
-rw-r--r--drivers/char/keyboard.c118
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c121
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c133
-rw-r--r--drivers/char/pcmcia/synclink_cs.c116
5 files changed, 233 insertions, 257 deletions
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c
index 327b00c3c45e..8d97b3911293 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/char/hvcs.c
@@ -904,7 +904,7 @@ static int hvcs_enable_device(struct hvcs_struct *hvcsd, uint32_t unit_address,
904 * It is possible the vty-server was removed after the irq was 904 * It is possible the vty-server was removed after the irq was
905 * requested but before we have time to enable interrupts. 905 * requested but before we have time to enable interrupts.
906 */ 906 */
907 if (vio_enable_interrupts(vdev) == H_Success) 907 if (vio_enable_interrupts(vdev) == H_SUCCESS)
908 return 0; 908 return 0;
909 else { 909 else {
910 printk(KERN_ERR "HVCS: int enable failed for" 910 printk(KERN_ERR "HVCS: int enable failed for"
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 8b603b2d1c42..935670a3cd98 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -74,7 +74,7 @@ void compute_shiftstate(void);
74 k_self, k_fn, k_spec, k_pad,\ 74 k_self, k_fn, k_spec, k_pad,\
75 k_dead, k_cons, k_cur, k_shift,\ 75 k_dead, k_cons, k_cur, k_shift,\
76 k_meta, k_ascii, k_lock, k_lowercase,\ 76 k_meta, k_ascii, k_lock, k_lowercase,\
77 k_slock, k_dead2, k_ignore, k_ignore 77 k_slock, k_dead2, k_brl, k_ignore
78 78
79typedef void (k_handler_fn)(struct vc_data *vc, unsigned char value, 79typedef void (k_handler_fn)(struct vc_data *vc, unsigned char value,
80 char up_flag, struct pt_regs *regs); 80 char up_flag, struct pt_regs *regs);
@@ -100,7 +100,7 @@ static fn_handler_fn *fn_handler[] = { FN_HANDLERS };
100const int max_vals[] = { 100const int max_vals[] = {
101 255, ARRAY_SIZE(func_table) - 1, ARRAY_SIZE(fn_handler) - 1, NR_PAD - 1, 101 255, ARRAY_SIZE(func_table) - 1, ARRAY_SIZE(fn_handler) - 1, NR_PAD - 1,
102 NR_DEAD - 1, 255, 3, NR_SHIFT - 1, 255, NR_ASCII - 1, NR_LOCK - 1, 102 NR_DEAD - 1, 255, 3, NR_SHIFT - 1, 255, NR_ASCII - 1, NR_LOCK - 1,
103 255, NR_LOCK - 1, 255 103 255, NR_LOCK - 1, 255, NR_BRL - 1
104}; 104};
105 105
106const int NR_TYPES = ARRAY_SIZE(max_vals); 106const int NR_TYPES = ARRAY_SIZE(max_vals);
@@ -126,7 +126,7 @@ static unsigned long key_down[NBITS(KEY_MAX)]; /* keyboard key bitmap */
126static unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */ 126static unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */
127static int dead_key_next; 127static int dead_key_next;
128static int npadch = -1; /* -1 or number assembled on pad */ 128static int npadch = -1; /* -1 or number assembled on pad */
129static unsigned char diacr; 129static unsigned int diacr;
130static char rep; /* flag telling character repeat */ 130static char rep; /* flag telling character repeat */
131 131
132static unsigned char ledstate = 0xff; /* undefined */ 132static unsigned char ledstate = 0xff; /* undefined */
@@ -394,22 +394,30 @@ void compute_shiftstate(void)
394 * Otherwise, conclude that DIACR was not combining after all, 394 * Otherwise, conclude that DIACR was not combining after all,
395 * queue it and return CH. 395 * queue it and return CH.
396 */ 396 */
397static unsigned char handle_diacr(struct vc_data *vc, unsigned char ch) 397static unsigned int handle_diacr(struct vc_data *vc, unsigned int ch)
398{ 398{
399 int d = diacr; 399 unsigned int d = diacr;
400 unsigned int i; 400 unsigned int i;
401 401
402 diacr = 0; 402 diacr = 0;
403 403
404 for (i = 0; i < accent_table_size; i++) { 404 if ((d & ~0xff) == BRL_UC_ROW) {
405 if (accent_table[i].diacr == d && accent_table[i].base == ch) 405 if ((ch & ~0xff) == BRL_UC_ROW)
406 return accent_table[i].result; 406 return d | ch;
407 } else {
408 for (i = 0; i < accent_table_size; i++)
409 if (accent_table[i].diacr == d && accent_table[i].base == ch)
410 return accent_table[i].result;
407 } 411 }
408 412
409 if (ch == ' ' || ch == d) 413 if (ch == ' ' || ch == (BRL_UC_ROW|0) || ch == d)
410 return d; 414 return d;
411 415
412 put_queue(vc, d); 416 if (kbd->kbdmode == VC_UNICODE)
417 to_utf8(vc, d);
418 else if (d < 0x100)
419 put_queue(vc, d);
420
413 return ch; 421 return ch;
414} 422}
415 423
@@ -419,7 +427,10 @@ static unsigned char handle_diacr(struct vc_data *vc, unsigned char ch)
419static void fn_enter(struct vc_data *vc, struct pt_regs *regs) 427static void fn_enter(struct vc_data *vc, struct pt_regs *regs)
420{ 428{
421 if (diacr) { 429 if (diacr) {
422 put_queue(vc, diacr); 430 if (kbd->kbdmode == VC_UNICODE)
431 to_utf8(vc, diacr);
432 else if (diacr < 0x100)
433 put_queue(vc, diacr);
423 diacr = 0; 434 diacr = 0;
424 } 435 }
425 put_queue(vc, 13); 436 put_queue(vc, 13);
@@ -615,7 +626,7 @@ static void k_lowercase(struct vc_data *vc, unsigned char value, char up_flag, s
615 printk(KERN_ERR "keyboard.c: k_lowercase was called - impossible\n"); 626 printk(KERN_ERR "keyboard.c: k_lowercase was called - impossible\n");
616} 627}
617 628
618static void k_self(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs) 629static void k_unicode(struct vc_data *vc, unsigned int value, char up_flag, struct pt_regs *regs)
619{ 630{
620 if (up_flag) 631 if (up_flag)
621 return; /* no action, if this is a key release */ 632 return; /* no action, if this is a key release */
@@ -628,7 +639,10 @@ static void k_self(struct vc_data *vc, unsigned char value, char up_flag, struct
628 diacr = value; 639 diacr = value;
629 return; 640 return;
630 } 641 }
631 put_queue(vc, value); 642 if (kbd->kbdmode == VC_UNICODE)
643 to_utf8(vc, value);
644 else if (value < 0x100)
645 put_queue(vc, value);
632} 646}
633 647
634/* 648/*
@@ -636,13 +650,23 @@ static void k_self(struct vc_data *vc, unsigned char value, char up_flag, struct
636 * dead keys modifying the same character. Very useful 650 * dead keys modifying the same character. Very useful
637 * for Vietnamese. 651 * for Vietnamese.
638 */ 652 */
639static void k_dead2(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs) 653static void k_deadunicode(struct vc_data *vc, unsigned int value, char up_flag, struct pt_regs *regs)
640{ 654{
641 if (up_flag) 655 if (up_flag)
642 return; 656 return;
643 diacr = (diacr ? handle_diacr(vc, value) : value); 657 diacr = (diacr ? handle_diacr(vc, value) : value);
644} 658}
645 659
660static void k_self(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs)
661{
662 k_unicode(vc, value, up_flag, regs);
663}
664
665static void k_dead2(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs)
666{
667 k_deadunicode(vc, value, up_flag, regs);
668}
669
646/* 670/*
647 * Obsolete - for backwards compatibility only 671 * Obsolete - for backwards compatibility only
648 */ 672 */
@@ -650,7 +674,7 @@ static void k_dead(struct vc_data *vc, unsigned char value, char up_flag, struct
650{ 674{
651 static unsigned char ret_diacr[NR_DEAD] = {'`', '\'', '^', '~', '"', ',' }; 675 static unsigned char ret_diacr[NR_DEAD] = {'`', '\'', '^', '~', '"', ',' };
652 value = ret_diacr[value]; 676 value = ret_diacr[value];
653 k_dead2(vc, value, up_flag, regs); 677 k_deadunicode(vc, value, up_flag, regs);
654} 678}
655 679
656static void k_cons(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs) 680static void k_cons(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs)
@@ -835,6 +859,62 @@ static void k_slock(struct vc_data *vc, unsigned char value, char up_flag, struc
835 } 859 }
836} 860}
837 861
862/* by default, 300ms interval for combination release */
863static long brl_timeout = 300;
864MODULE_PARM_DESC(brl_timeout, "Braille keys release delay in ms (0 for combination on first release, < 0 for dead characters)");
865module_param(brl_timeout, long, 0644);
866static void k_brl(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs)
867{
868 static unsigned pressed,committing;
869 static unsigned long releasestart;
870
871 if (kbd->kbdmode != VC_UNICODE) {
872 if (!up_flag)
873 printk("keyboard mode must be unicode for braille patterns\n");
874 return;
875 }
876
877 if (!value) {
878 k_unicode(vc, BRL_UC_ROW, up_flag, regs);
879 return;
880 }
881
882 if (value > 8)
883 return;
884
885 if (brl_timeout < 0) {
886 k_deadunicode(vc, BRL_UC_ROW | (1 << (value - 1)), up_flag, regs);
887 return;
888 }
889
890 if (up_flag) {
891 if (brl_timeout) {
892 if (!committing ||
893 jiffies - releasestart > (brl_timeout * HZ) / 1000) {
894 committing = pressed;
895 releasestart = jiffies;
896 }
897 pressed &= ~(1 << (value - 1));
898 if (!pressed) {
899 if (committing) {
900 k_unicode(vc, BRL_UC_ROW | committing, 0, regs);
901 committing = 0;
902 }
903 }
904 } else {
905 if (committing) {
906 k_unicode(vc, BRL_UC_ROW | committing, 0, regs);
907 committing = 0;
908 }
909 pressed &= ~(1 << (value - 1));
910 }
911 } else {
912 pressed |= 1 << (value - 1);
913 if (!brl_timeout)
914 committing = pressed;
915 }
916}
917
838/* 918/*
839 * The leds display either (i) the status of NumLock, CapsLock, ScrollLock, 919 * The leds display either (i) the status of NumLock, CapsLock, ScrollLock,
840 * or (ii) whatever pattern of lights people want to show using KDSETLED, 920 * or (ii) whatever pattern of lights people want to show using KDSETLED,
@@ -1125,9 +1205,13 @@ static void kbd_keycode(unsigned int keycode, int down,
1125 } 1205 }
1126 1206
1127 if (keycode > NR_KEYS) 1207 if (keycode > NR_KEYS)
1128 return; 1208 if (keycode >= KEY_BRL_DOT1 && keycode <= KEY_BRL_DOT8)
1209 keysym = K(KT_BRL, keycode - KEY_BRL_DOT1 + 1);
1210 else
1211 return;
1212 else
1213 keysym = key_map[keycode];
1129 1214
1130 keysym = key_map[keycode];
1131 type = KTYP(keysym); 1215 type = KTYP(keysym);
1132 1216
1133 if (type < 0xf0) { 1217 if (type < 0xf0) {
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index 5fdf18515433..02114a0bd0d9 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -46,7 +46,7 @@
46/* #define ATR_CSUM */ 46/* #define ATR_CSUM */
47 47
48#ifdef PCMCIA_DEBUG 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))
50static int pc_debug = PCMCIA_DEBUG; 50static int pc_debug = PCMCIA_DEBUG;
51module_param(pc_debug, int, 0600); 51module_param(pc_debug, int, 0600);
52#define DEBUGP(n, rdr, x, args...) do { \ 52#define DEBUGP(n, rdr, x, args...) do { \
@@ -67,7 +67,7 @@ static char *version = "cm4000_cs.c v2.4.0gm6 - All bugs added by Harald Welte";
67#define T_100MSEC msecs_to_jiffies(100) 67#define T_100MSEC msecs_to_jiffies(100)
68#define T_500MSEC msecs_to_jiffies(500) 68#define T_500MSEC msecs_to_jiffies(500)
69 69
70static void cm4000_release(dev_link_t *link); 70static void cm4000_release(struct pcmcia_device *link);
71 71
72static int major; /* major number we get from the kernel */ 72static int major; /* major number we get from the kernel */
73 73
@@ -106,7 +106,7 @@ static int major; /* major number we get from the kernel */
106#define REG_STOPBITS(x) (x + 7) 106#define REG_STOPBITS(x) (x + 7)
107 107
108struct cm4000_dev { 108struct cm4000_dev {
109 dev_link_t link; /* pcmcia link */ 109 struct pcmcia_device *p_dev;
110 dev_node_t node; /* OS node (major,minor) */ 110 dev_node_t node; /* OS node (major,minor) */
111 111
112 unsigned char atr[MAX_ATR]; 112 unsigned char atr[MAX_ATR];
@@ -149,14 +149,14 @@ struct cm4000_dev {
149#define ZERO_DEV(dev) \ 149#define ZERO_DEV(dev) \
150 memset(&dev->atr_csum,0, \ 150 memset(&dev->atr_csum,0, \
151 sizeof(struct cm4000_dev) - \ 151 sizeof(struct cm4000_dev) - \
152 /*link*/ sizeof(dev_link_t) - \ 152 /*link*/ sizeof(struct pcmcia_device) - \
153 /*node*/ sizeof(dev_node_t) - \ 153 /*node*/ sizeof(dev_node_t) - \
154 /*atr*/ MAX_ATR*sizeof(char) - \ 154 /*atr*/ MAX_ATR*sizeof(char) - \
155 /*rbuf*/ 512*sizeof(char) - \ 155 /*rbuf*/ 512*sizeof(char) - \
156 /*sbuf*/ 512*sizeof(char) - \ 156 /*sbuf*/ 512*sizeof(char) - \
157 /*queue*/ 4*sizeof(wait_queue_head_t)) 157 /*queue*/ 4*sizeof(wait_queue_head_t))
158 158
159static dev_link_t *dev_table[CM4000_MAX_DEV]; 159static struct pcmcia_device *dev_table[CM4000_MAX_DEV];
160static struct class *cmm_class; 160static struct class *cmm_class;
161 161
162/* This table doesn't use spaces after the comma between fields and thus 162/* This table doesn't use spaces after the comma between fields and thus
@@ -454,7 +454,7 @@ static struct card_fixup card_fixups[] = {
454static void set_cardparameter(struct cm4000_dev *dev) 454static void set_cardparameter(struct cm4000_dev *dev)
455{ 455{
456 int i; 456 int i;
457 ioaddr_t iobase = dev->link.io.BasePort1; 457 ioaddr_t iobase = dev->p_dev->io.BasePort1;
458 u_int8_t stopbits = 0x02; /* ISO default */ 458 u_int8_t stopbits = 0x02; /* ISO default */
459 459
460 DEBUGP(3, dev, "-> set_cardparameter\n"); 460 DEBUGP(3, dev, "-> set_cardparameter\n");
@@ -487,7 +487,7 @@ static int set_protocol(struct cm4000_dev *dev, struct ptsreq *ptsreq)
487 unsigned short num_bytes_read; 487 unsigned short num_bytes_read;
488 unsigned char pts_reply[4]; 488 unsigned char pts_reply[4];
489 ssize_t rc; 489 ssize_t rc;
490 ioaddr_t iobase = dev->link.io.BasePort1; 490 ioaddr_t iobase = dev->p_dev->io.BasePort1;
491 491
492 rc = 0; 492 rc = 0;
493 493
@@ -699,7 +699,7 @@ static void terminate_monitor(struct cm4000_dev *dev)
699static void monitor_card(unsigned long p) 699static void monitor_card(unsigned long p)
700{ 700{
701 struct cm4000_dev *dev = (struct cm4000_dev *) p; 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 unsigned short s; 703 unsigned short s;
704 struct ptsreq ptsreq; 704 struct ptsreq ptsreq;
705 int i, atrc; 705 int i, atrc;
@@ -962,7 +962,7 @@ static ssize_t cmm_read(struct file *filp, __user char *buf, size_t count,
962 loff_t *ppos) 962 loff_t *ppos)
963{ 963{
964 struct cm4000_dev *dev = filp->private_data; 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 ssize_t rc; 966 ssize_t rc;
967 int i, j, k; 967 int i, j, k;
968 968
@@ -971,7 +971,7 @@ static ssize_t cmm_read(struct file *filp, __user char *buf, size_t count,
971 if (count == 0) /* according to manpage */ 971 if (count == 0) /* according to manpage */
972 return 0; 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 test_bit(IS_CMM_ABSENT, &dev->flags)) 975 test_bit(IS_CMM_ABSENT, &dev->flags))
976 return -ENODEV; 976 return -ENODEV;
977 977
@@ -1083,7 +1083,7 @@ static ssize_t cmm_write(struct file *filp, const char __user *buf,
1083 size_t count, loff_t *ppos) 1083 size_t count, loff_t *ppos)
1084{ 1084{
1085 struct cm4000_dev *dev = (struct cm4000_dev *) filp->private_data; 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 unsigned short s; 1087 unsigned short s;
1088 unsigned char tmp; 1088 unsigned char tmp;
1089 unsigned char infolen; 1089 unsigned char infolen;
@@ -1108,7 +1108,7 @@ static ssize_t cmm_write(struct file *filp, const char __user *buf,
1108 1108
1109 sendT0 = dev->proto ? 0 : nr > 5 ? 0x08 : 0; 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 test_bit(IS_CMM_ABSENT, &dev->flags)) 1112 test_bit(IS_CMM_ABSENT, &dev->flags))
1113 return -ENODEV; 1113 return -ENODEV;
1114 1114
@@ -1440,8 +1440,8 @@ static int cmm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
1440 unsigned long arg) 1440 unsigned long arg)
1441{ 1441{
1442 struct cm4000_dev *dev = filp->private_data; 1442 struct cm4000_dev *dev = filp->private_data;
1443 ioaddr_t iobase = dev->link.io.BasePort1; 1443 ioaddr_t iobase = dev->p_dev->io.BasePort1;
1444 dev_link_t *link; 1444 struct pcmcia_device *link;
1445 int size; 1445 int size;
1446 int rc; 1446 int rc;
1447 void __user *argp = (void __user *)arg; 1447 void __user *argp = (void __user *)arg;
@@ -1458,7 +1458,7 @@ static int cmm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
1458 iminor(inode), ioctl_names[_IOC_NR(cmd)]); 1458 iminor(inode), ioctl_names[_IOC_NR(cmd)]);
1459 1459
1460 link = dev_table[iminor(inode)]; 1460 link = dev_table[iminor(inode)];
1461 if (!(DEV_OK(link))) { 1461 if (!pcmcia_dev_present(link)) {
1462 DEBUGP(4, dev, "DEV_OK false\n"); 1462 DEBUGP(4, dev, "DEV_OK false\n");
1463 return -ENODEV; 1463 return -ENODEV;
1464 } 1464 }
@@ -1660,14 +1660,14 @@ static int cmm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
1660static int cmm_open(struct inode *inode, struct file *filp) 1660static int cmm_open(struct inode *inode, struct file *filp)
1661{ 1661{
1662 struct cm4000_dev *dev; 1662 struct cm4000_dev *dev;
1663 dev_link_t *link; 1663 struct pcmcia_device *link;
1664 int rc, minor = iminor(inode); 1664 int rc, minor = iminor(inode);
1665 1665
1666 if (minor >= CM4000_MAX_DEV) 1666 if (minor >= CM4000_MAX_DEV)
1667 return -ENODEV; 1667 return -ENODEV;
1668 1668
1669 link = dev_table[minor]; 1669 link = dev_table[minor];
1670 if (link == NULL || !(DEV_OK(link))) 1670 if (link == NULL || !pcmcia_dev_present(link))
1671 return -ENODEV; 1671 return -ENODEV;
1672 1672
1673 if (link->open) 1673 if (link->open)
@@ -1709,7 +1709,7 @@ static int cmm_open(struct inode *inode, struct file *filp)
1709static int cmm_close(struct inode *inode, struct file *filp) 1709static int cmm_close(struct inode *inode, struct file *filp)
1710{ 1710{
1711 struct cm4000_dev *dev; 1711 struct cm4000_dev *dev;
1712 dev_link_t *link; 1712 struct pcmcia_device *link;
1713 int minor = iminor(inode); 1713 int minor = iminor(inode);
1714 1714
1715 if (minor >= CM4000_MAX_DEV) 1715 if (minor >= CM4000_MAX_DEV)
@@ -1735,7 +1735,7 @@ static int cmm_close(struct inode *inode, struct file *filp)
1735 return 0; 1735 return 0;
1736} 1736}
1737 1737
1738static void cmm_cm4000_release(dev_link_t * link) 1738static void cmm_cm4000_release(struct pcmcia_device * link)
1739{ 1739{
1740 struct cm4000_dev *dev = link->priv; 1740 struct cm4000_dev *dev = link->priv;
1741 1741
@@ -1759,13 +1759,11 @@ static void cmm_cm4000_release(dev_link_t * link)
1759 1759
1760/*==== Interface to PCMCIA Layer =======================================*/ 1760/*==== Interface to PCMCIA Layer =======================================*/
1761 1761
1762static void cm4000_config(dev_link_t * link, int devno) 1762static int cm4000_config(struct pcmcia_device * link, int devno)
1763{ 1763{
1764 client_handle_t handle = link->handle;
1765 struct cm4000_dev *dev; 1764 struct cm4000_dev *dev;
1766 tuple_t tuple; 1765 tuple_t tuple;
1767 cisparse_t parse; 1766 cisparse_t parse;
1768 config_info_t conf;
1769 u_char buf[64]; 1767 u_char buf[64];
1770 int fail_fn, fail_rc; 1768 int fail_fn, fail_rc;
1771 int rc; 1769 int rc;
@@ -1777,41 +1775,34 @@ static void cm4000_config(dev_link_t * link, int devno)
1777 tuple.TupleDataMax = sizeof(buf); 1775 tuple.TupleDataMax = sizeof(buf);
1778 tuple.TupleOffset = 0; 1776 tuple.TupleOffset = 0;
1779 1777
1780 if ((fail_rc = pcmcia_get_first_tuple(handle, &tuple)) != CS_SUCCESS) { 1778 if ((fail_rc = pcmcia_get_first_tuple(link, &tuple)) != CS_SUCCESS) {
1781 fail_fn = GetFirstTuple; 1779 fail_fn = GetFirstTuple;
1782 goto cs_failed; 1780 goto cs_failed;
1783 } 1781 }
1784 if ((fail_rc = pcmcia_get_tuple_data(handle, &tuple)) != CS_SUCCESS) { 1782 if ((fail_rc = pcmcia_get_tuple_data(link, &tuple)) != CS_SUCCESS) {
1785 fail_fn = GetTupleData; 1783 fail_fn = GetTupleData;
1786 goto cs_failed; 1784 goto cs_failed;
1787 } 1785 }
1788 if ((fail_rc = 1786 if ((fail_rc =
1789 pcmcia_parse_tuple(handle, &tuple, &parse)) != CS_SUCCESS) { 1787 pcmcia_parse_tuple(link, &tuple, &parse)) != CS_SUCCESS) {
1790 fail_fn = ParseTuple; 1788 fail_fn = ParseTuple;
1791 goto cs_failed; 1789 goto cs_failed;
1792 } 1790 }
1793 if ((fail_rc =
1794 pcmcia_get_configuration_info(handle, &conf)) != CS_SUCCESS) {
1795 fail_fn = GetConfigurationInfo;
1796 goto cs_failed;
1797 }
1798 1791
1799 link->state |= DEV_CONFIG;
1800 link->conf.ConfigBase = parse.config.base; 1792 link->conf.ConfigBase = parse.config.base;
1801 link->conf.Present = parse.config.rmask[0]; 1793 link->conf.Present = parse.config.rmask[0];
1802 link->conf.Vcc = conf.Vcc;
1803 1794
1804 link->io.BasePort2 = 0; 1795 link->io.BasePort2 = 0;
1805 link->io.NumPorts2 = 0; 1796 link->io.NumPorts2 = 0;
1806 link->io.Attributes2 = 0; 1797 link->io.Attributes2 = 0;
1807 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 1798 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
1808 for (rc = pcmcia_get_first_tuple(handle, &tuple); 1799 for (rc = pcmcia_get_first_tuple(link, &tuple);
1809 rc == CS_SUCCESS; rc = pcmcia_get_next_tuple(handle, &tuple)) { 1800 rc == CS_SUCCESS; rc = pcmcia_get_next_tuple(link, &tuple)) {
1810 1801
1811 rc = pcmcia_get_tuple_data(handle, &tuple); 1802 rc = pcmcia_get_tuple_data(link, &tuple);
1812 if (rc != CS_SUCCESS) 1803 if (rc != CS_SUCCESS)
1813 continue; 1804 continue;
1814 rc = pcmcia_parse_tuple(handle, &tuple, &parse); 1805 rc = pcmcia_parse_tuple(link, &tuple, &parse);
1815 if (rc != CS_SUCCESS) 1806 if (rc != CS_SUCCESS)
1816 continue; 1807 continue;
1817 1808
@@ -1831,7 +1822,7 @@ static void cm4000_config(dev_link_t * link, int devno)
1831 link->io.IOAddrLines = parse.cftable_entry.io.flags 1822 link->io.IOAddrLines = parse.cftable_entry.io.flags
1832 & CISTPL_IO_LINES_MASK; 1823 & CISTPL_IO_LINES_MASK;
1833 1824
1834 rc = pcmcia_request_io(handle, &link->io); 1825 rc = pcmcia_request_io(link, &link->io);
1835 if (rc == CS_SUCCESS) 1826 if (rc == CS_SUCCESS)
1836 break; /* we are done */ 1827 break; /* we are done */
1837 } 1828 }
@@ -1841,7 +1832,7 @@ static void cm4000_config(dev_link_t * link, int devno)
1841 link->conf.IntType = 00000002; 1832 link->conf.IntType = 00000002;
1842 1833
1843 if ((fail_rc = 1834 if ((fail_rc =
1844 pcmcia_request_configuration(handle, &link->conf)) != CS_SUCCESS) { 1835 pcmcia_request_configuration(link, &link->conf)) != CS_SUCCESS) {
1845 fail_fn = RequestConfiguration; 1836 fail_fn = RequestConfiguration;
1846 goto cs_release; 1837 goto cs_release;
1847 } 1838 }
@@ -1851,63 +1842,48 @@ static void cm4000_config(dev_link_t * link, int devno)
1851 dev->node.major = major; 1842 dev->node.major = major;
1852 dev->node.minor = devno; 1843 dev->node.minor = devno;
1853 dev->node.next = NULL; 1844 dev->node.next = NULL;
1854 link->dev = &dev->node; 1845 link->dev_node = &dev->node;
1855 link->state &= ~DEV_CONFIG_PENDING;
1856 1846
1857 return; 1847 return 0;
1858 1848
1859cs_failed: 1849cs_failed:
1860 cs_error(handle, fail_fn, fail_rc); 1850 cs_error(link, fail_fn, fail_rc);
1861cs_release: 1851cs_release:
1862 cm4000_release(link); 1852 cm4000_release(link);
1863 1853 return -ENODEV;
1864 link->state &= ~DEV_CONFIG_PENDING;
1865} 1854}
1866 1855
1867static int cm4000_suspend(struct pcmcia_device *p_dev) 1856static int cm4000_suspend(struct pcmcia_device *link)
1868{ 1857{
1869 dev_link_t *link = dev_to_instance(p_dev);
1870 struct cm4000_dev *dev; 1858 struct cm4000_dev *dev;
1871 1859
1872 dev = link->priv; 1860 dev = link->priv;
1873
1874 link->state |= DEV_SUSPEND;
1875 if (link->state & DEV_CONFIG)
1876 pcmcia_release_configuration(link->handle);
1877 stop_monitor(dev); 1861 stop_monitor(dev);
1878 1862
1879 return 0; 1863 return 0;
1880} 1864}
1881 1865
1882static int cm4000_resume(struct pcmcia_device *p_dev) 1866static int cm4000_resume(struct pcmcia_device *link)
1883{ 1867{
1884 dev_link_t *link = dev_to_instance(p_dev);
1885 struct cm4000_dev *dev; 1868 struct cm4000_dev *dev;
1886 1869
1887 dev = link->priv; 1870 dev = link->priv;
1888
1889 link->state &= ~DEV_SUSPEND;
1890 if (link->state & DEV_CONFIG)
1891 pcmcia_request_configuration(link->handle, &link->conf);
1892
1893 if (link->open) 1871 if (link->open)
1894 start_monitor(dev); 1872 start_monitor(dev);
1895 1873
1896 return 0; 1874 return 0;
1897} 1875}
1898 1876
1899static void cm4000_release(dev_link_t *link) 1877static void cm4000_release(struct pcmcia_device *link)
1900{ 1878{
1901 cmm_cm4000_release(link->priv); /* delay release until device closed */ 1879 cmm_cm4000_release(link->priv); /* delay release until device closed */
1902 pcmcia_release_configuration(link->handle); 1880 pcmcia_disable_device(link);
1903 pcmcia_release_io(link->handle, &link->io);
1904} 1881}
1905 1882
1906static int cm4000_attach(struct pcmcia_device *p_dev) 1883static int cm4000_probe(struct pcmcia_device *link)
1907{ 1884{
1908 struct cm4000_dev *dev; 1885 struct cm4000_dev *dev;
1909 dev_link_t *link; 1886 int i, ret;
1910 int i;
1911 1887
1912 for (i = 0; i < CM4000_MAX_DEV; i++) 1888 for (i = 0; i < CM4000_MAX_DEV; i++)
1913 if (dev_table[i] == NULL) 1889 if (dev_table[i] == NULL)
@@ -1923,7 +1899,7 @@ static int cm4000_attach(struct pcmcia_device *p_dev)
1923 if (dev == NULL) 1899 if (dev == NULL)
1924 return -ENOMEM; 1900 return -ENOMEM;
1925 1901
1926 link = &dev->link; 1902 dev->p_dev = link;
1927 link->priv = dev; 1903 link->priv = dev;
1928 link->conf.IntType = INT_MEMORY_AND_IO; 1904 link->conf.IntType = INT_MEMORY_AND_IO;
1929 dev_table[i] = link; 1905 dev_table[i] = link;
@@ -1933,11 +1909,9 @@ static int cm4000_attach(struct pcmcia_device *p_dev)
1933 init_waitqueue_head(&dev->atrq); 1909 init_waitqueue_head(&dev->atrq);
1934 init_waitqueue_head(&dev->readq); 1910 init_waitqueue_head(&dev->readq);
1935 1911
1936 link->handle = p_dev; 1912 ret = cm4000_config(link, i);
1937 p_dev->instance = link; 1913 if (ret)
1938 1914 return ret;
1939 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1940 cm4000_config(link, i);
1941 1915
1942 class_device_create(cmm_class, NULL, MKDEV(major, i), NULL, 1916 class_device_create(cmm_class, NULL, MKDEV(major, i), NULL,
1943 "cmm%d", i); 1917 "cmm%d", i);
@@ -1945,9 +1919,8 @@ static int cm4000_attach(struct pcmcia_device *p_dev)
1945 return 0; 1919 return 0;
1946} 1920}
1947 1921
1948static void cm4000_detach(struct pcmcia_device *p_dev) 1922static void cm4000_detach(struct pcmcia_device *link)
1949{ 1923{
1950 dev_link_t *link = dev_to_instance(p_dev);
1951 struct cm4000_dev *dev = link->priv; 1924 struct cm4000_dev *dev = link->priv;
1952 int devno; 1925 int devno;
1953 1926
@@ -1958,11 +1931,9 @@ static void cm4000_detach(struct pcmcia_device *p_dev)
1958 if (devno == CM4000_MAX_DEV) 1931 if (devno == CM4000_MAX_DEV)
1959 return; 1932 return;
1960 1933
1961 link->state &= ~DEV_PRESENT;
1962 stop_monitor(dev); 1934 stop_monitor(dev);
1963 1935
1964 if (link->state & DEV_CONFIG) 1936 cm4000_release(link);
1965 cm4000_release(link);
1966 1937
1967 dev_table[devno] = NULL; 1938 dev_table[devno] = NULL;
1968 kfree(dev); 1939 kfree(dev);
@@ -1993,7 +1964,7 @@ static struct pcmcia_driver cm4000_driver = {
1993 .drv = { 1964 .drv = {
1994 .name = "cm4000_cs", 1965 .name = "cm4000_cs",
1995 }, 1966 },
1996 .probe = cm4000_attach, 1967 .probe = cm4000_probe,
1997 .remove = cm4000_detach, 1968 .remove = cm4000_detach,
1998 .suspend = cm4000_suspend, 1969 .suspend = cm4000_suspend,
1999 .resume = cm4000_resume, 1970 .resume = cm4000_resume,
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 466e33bab029..29efa64580a8 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -41,7 +41,7 @@
41 41
42 42
43#ifdef PCMCIA_DEBUG 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))
45static int pc_debug = PCMCIA_DEBUG; 45static int pc_debug = PCMCIA_DEBUG;
46module_param(pc_debug, int, 0600); 46module_param(pc_debug, int, 0600);
47#define DEBUGP(n, rdr, x, args...) do { \ 47#define DEBUGP(n, rdr, x, args...) do { \
@@ -65,7 +65,7 @@ static char *version =
65/* how often to poll for fifo status change */ 65/* how often to poll for fifo status change */
66#define POLL_PERIOD msecs_to_jiffies(10) 66#define POLL_PERIOD msecs_to_jiffies(10)
67 67
68static void reader_release(dev_link_t *link); 68static void reader_release(struct pcmcia_device *link);
69 69
70static int major; 70static int major;
71static struct class *cmx_class; 71static struct class *cmx_class;
@@ -74,7 +74,7 @@ static struct class *cmx_class;
74#define BS_WRITABLE 0x02 74#define BS_WRITABLE 0x02
75 75
76struct reader_dev { 76struct reader_dev {
77 dev_link_t link; 77 struct pcmcia_device *p_dev;
78 dev_node_t node; 78 dev_node_t node;
79 wait_queue_head_t devq; 79 wait_queue_head_t devq;
80 wait_queue_head_t poll_wait; 80 wait_queue_head_t poll_wait;
@@ -87,7 +87,7 @@ struct reader_dev {
87 struct timer_list poll_timer; 87 struct timer_list poll_timer;
88}; 88};
89 89
90static dev_link_t *dev_table[CM_MAX_DEV]; 90static struct pcmcia_device *dev_table[CM_MAX_DEV];
91 91
92#ifndef PCMCIA_DEBUG 92#ifndef PCMCIA_DEBUG
93#define xoutb outb 93#define xoutb outb
@@ -116,7 +116,7 @@ static inline unsigned char xinb(unsigned short port)
116static void cm4040_do_poll(unsigned long dummy) 116static void cm4040_do_poll(unsigned long dummy)
117{ 117{
118 struct reader_dev *dev = (struct reader_dev *) dummy; 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 + REG_OFFSET_BUFFER_STATUS); 120 + REG_OFFSET_BUFFER_STATUS);
121 121
122 if ((obs & BSR_BULK_IN_FULL)) { 122 if ((obs & BSR_BULK_IN_FULL)) {
@@ -147,7 +147,7 @@ static void cm4040_stop_poll(struct reader_dev *dev)
147static int wait_for_bulk_out_ready(struct reader_dev *dev) 147static int wait_for_bulk_out_ready(struct reader_dev *dev)
148{ 148{
149 int i, rc; 149 int i, rc;
150 int iobase = dev->link.io.BasePort1; 150 int iobase = dev->p_dev->io.BasePort1;
151 151
152 for (i = 0; i < POLL_LOOP_COUNT; i++) { 152 for (i = 0; i < POLL_LOOP_COUNT; i++) {
153 if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS) 153 if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS)
@@ -177,7 +177,7 @@ static int wait_for_bulk_out_ready(struct reader_dev *dev)
177/* Write to Sync Control Register */ 177/* Write to Sync Control Register */
178static int write_sync_reg(unsigned char val, struct reader_dev *dev) 178static 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 int rc; 181 int rc;
182 182
183 rc = wait_for_bulk_out_ready(dev); 183 rc = wait_for_bulk_out_ready(dev);
@@ -195,7 +195,7 @@ static int write_sync_reg(unsigned char val, struct reader_dev *dev)
195static int wait_for_bulk_in_ready(struct reader_dev *dev) 195static int wait_for_bulk_in_ready(struct reader_dev *dev)
196{ 196{
197 int i, rc; 197 int i, rc;
198 int iobase = dev->link.io.BasePort1; 198 int iobase = dev->p_dev->io.BasePort1;
199 199
200 for (i = 0; i < POLL_LOOP_COUNT; i++) { 200 for (i = 0; i < POLL_LOOP_COUNT; i++) {
201 if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS) 201 if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS)
@@ -225,7 +225,7 @@ static ssize_t cm4040_read(struct file *filp, char __user *buf,
225 size_t count, loff_t *ppos) 225 size_t count, loff_t *ppos)
226{ 226{
227 struct reader_dev *dev = filp->private_data; 227 struct reader_dev *dev = filp->private_data;
228 int iobase = dev->link.io.BasePort1; 228 int iobase = dev->p_dev->io.BasePort1;
229 size_t bytes_to_read; 229 size_t bytes_to_read;
230 unsigned long i; 230 unsigned long i;
231 size_t min_bytes_to_read; 231 size_t min_bytes_to_read;
@@ -246,7 +246,7 @@ static ssize_t cm4040_read(struct file *filp, char __user *buf,
246 return -EAGAIN; 246 return -EAGAIN;
247 } 247 }
248 248
249 if ((dev->link.state & DEV_PRESENT)==0) 249 if (!pcmcia_dev_present(dev->p_dev))
250 return -ENODEV; 250 return -ENODEV;
251 251
252 for (i = 0; i < 5; i++) { 252 for (i = 0; i < 5; i++) {
@@ -328,7 +328,7 @@ static ssize_t cm4040_write(struct file *filp, const char __user *buf,
328 size_t count, loff_t *ppos) 328 size_t count, loff_t *ppos)
329{ 329{
330 struct reader_dev *dev = filp->private_data; 330 struct reader_dev *dev = filp->private_data;
331 int iobase = dev->link.io.BasePort1; 331 int iobase = dev->p_dev->io.BasePort1;
332 ssize_t rc; 332 ssize_t rc;
333 int i; 333 int i;
334 unsigned int bytes_to_write; 334 unsigned int bytes_to_write;
@@ -351,7 +351,7 @@ static ssize_t cm4040_write(struct file *filp, const char __user *buf,
351 return -EAGAIN; 351 return -EAGAIN;
352 } 352 }
353 353
354 if ((dev->link.state & DEV_PRESENT) == 0) 354 if (!pcmcia_dev_present(dev->p_dev))
355 return -ENODEV; 355 return -ENODEV;
356 356
357 bytes_to_write = count; 357 bytes_to_write = count;
@@ -445,14 +445,14 @@ static unsigned int cm4040_poll(struct file *filp, poll_table *wait)
445static int cm4040_open(struct inode *inode, struct file *filp) 445static int cm4040_open(struct inode *inode, struct file *filp)
446{ 446{
447 struct reader_dev *dev; 447 struct reader_dev *dev;
448 dev_link_t *link; 448 struct pcmcia_device *link;
449 int minor = iminor(inode); 449 int minor = iminor(inode);
450 450
451 if (minor >= CM_MAX_DEV) 451 if (minor >= CM_MAX_DEV)
452 return -ENODEV; 452 return -ENODEV;
453 453
454 link = dev_table[minor]; 454 link = dev_table[minor];
455 if (link == NULL || !(DEV_OK(link))) 455 if (link == NULL || !pcmcia_dev_present(link))
456 return -ENODEV; 456 return -ENODEV;
457 457
458 if (link->open) 458 if (link->open)
@@ -478,7 +478,7 @@ static int cm4040_open(struct inode *inode, struct file *filp)
478static int cm4040_close(struct inode *inode, struct file *filp) 478static int cm4040_close(struct inode *inode, struct file *filp)
479{ 479{
480 struct reader_dev *dev = filp->private_data; 480 struct reader_dev *dev = filp->private_data;
481 dev_link_t *link; 481 struct pcmcia_device *link;
482 int minor = iminor(inode); 482 int minor = iminor(inode);
483 483
484 DEBUGP(2, dev, "-> cm4040_close(maj/min=%d.%d)\n", imajor(inode), 484 DEBUGP(2, dev, "-> cm4040_close(maj/min=%d.%d)\n", imajor(inode),
@@ -500,7 +500,7 @@ static int cm4040_close(struct inode *inode, struct file *filp)
500 return 0; 500 return 0;
501} 501}
502 502
503static void cm4040_reader_release(dev_link_t *link) 503static void cm4040_reader_release(struct pcmcia_device *link)
504{ 504{
505 struct reader_dev *dev = link->priv; 505 struct reader_dev *dev = link->priv;
506 506
@@ -514,60 +514,49 @@ static void cm4040_reader_release(dev_link_t *link)
514 return; 514 return;
515} 515}
516 516
517static void reader_config(dev_link_t *link, int devno) 517static int reader_config(struct pcmcia_device *link, int devno)
518{ 518{
519 client_handle_t handle;
520 struct reader_dev *dev; 519 struct reader_dev *dev;
521 tuple_t tuple; 520 tuple_t tuple;
522 cisparse_t parse; 521 cisparse_t parse;
523 config_info_t conf;
524 u_char buf[64]; 522 u_char buf[64];
525 int fail_fn, fail_rc; 523 int fail_fn, fail_rc;
526 int rc; 524 int rc;
527 525
528 handle = link->handle;
529
530 tuple.DesiredTuple = CISTPL_CONFIG; 526 tuple.DesiredTuple = CISTPL_CONFIG;
531 tuple.Attributes = 0; 527 tuple.Attributes = 0;
532 tuple.TupleData = buf; 528 tuple.TupleData = buf;
533 tuple.TupleDataMax = sizeof(buf); 529 tuple.TupleDataMax = sizeof(buf);
534 tuple.TupleOffset = 0; 530 tuple.TupleOffset = 0;
535 531
536 if ((fail_rc = pcmcia_get_first_tuple(handle, &tuple)) != CS_SUCCESS) { 532 if ((fail_rc = pcmcia_get_first_tuple(link, &tuple)) != CS_SUCCESS) {
537 fail_fn = GetFirstTuple; 533 fail_fn = GetFirstTuple;
538 goto cs_failed; 534 goto cs_failed;
539 } 535 }
540 if ((fail_rc = pcmcia_get_tuple_data(handle, &tuple)) != CS_SUCCESS) { 536 if ((fail_rc = pcmcia_get_tuple_data(link, &tuple)) != CS_SUCCESS) {
541 fail_fn = GetTupleData; 537 fail_fn = GetTupleData;
542 goto cs_failed; 538 goto cs_failed;
543 } 539 }
544 if ((fail_rc = pcmcia_parse_tuple(handle, &tuple, &parse)) 540 if ((fail_rc = pcmcia_parse_tuple(link, &tuple, &parse))
545 != CS_SUCCESS) { 541 != CS_SUCCESS) {
546 fail_fn = ParseTuple; 542 fail_fn = ParseTuple;
547 goto cs_failed; 543 goto cs_failed;
548 } 544 }
549 if ((fail_rc = pcmcia_get_configuration_info(handle, &conf))
550 != CS_SUCCESS) {
551 fail_fn = GetConfigurationInfo;
552 goto cs_failed;
553 }
554 545
555 link->state |= DEV_CONFIG;
556 link->conf.ConfigBase = parse.config.base; 546 link->conf.ConfigBase = parse.config.base;
557 link->conf.Present = parse.config.rmask[0]; 547 link->conf.Present = parse.config.rmask[0];
558 link->conf.Vcc = conf.Vcc;
559 548
560 link->io.BasePort2 = 0; 549 link->io.BasePort2 = 0;
561 link->io.NumPorts2 = 0; 550 link->io.NumPorts2 = 0;
562 link->io.Attributes2 = 0; 551 link->io.Attributes2 = 0;
563 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 552 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
564 for (rc = pcmcia_get_first_tuple(handle, &tuple); 553 for (rc = pcmcia_get_first_tuple(link, &tuple);
565 rc == CS_SUCCESS; 554 rc == CS_SUCCESS;
566 rc = pcmcia_get_next_tuple(handle, &tuple)) { 555 rc = pcmcia_get_next_tuple(link, &tuple)) {
567 rc = pcmcia_get_tuple_data(handle, &tuple); 556 rc = pcmcia_get_tuple_data(link, &tuple);
568 if (rc != CS_SUCCESS) 557 if (rc != CS_SUCCESS)
569 continue; 558 continue;
570 rc = pcmcia_parse_tuple(handle, &tuple, &parse); 559 rc = pcmcia_parse_tuple(link, &tuple, &parse);
571 if (rc != CS_SUCCESS) 560 if (rc != CS_SUCCESS)
572 continue; 561 continue;
573 562
@@ -585,13 +574,13 @@ static void reader_config(dev_link_t *link, int devno)
585 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 574 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
586 link->io.IOAddrLines = parse.cftable_entry.io.flags 575 link->io.IOAddrLines = parse.cftable_entry.io.flags
587 & CISTPL_IO_LINES_MASK; 576 & CISTPL_IO_LINES_MASK;
588 rc = pcmcia_request_io(handle, &link->io); 577 rc = pcmcia_request_io(link, &link->io);
589 578
590 dev_printk(KERN_INFO, &handle_to_dev(handle), "foo"); 579 dev_printk(KERN_INFO, &handle_to_dev(link), "foo");
591 if (rc == CS_SUCCESS) 580 if (rc == CS_SUCCESS)
592 break; 581 break;
593 else 582 else
594 dev_printk(KERN_INFO, &handle_to_dev(handle), 583 dev_printk(KERN_INFO, &handle_to_dev(link),
595 "pcmcia_request_io failed 0x%x\n", rc); 584 "pcmcia_request_io failed 0x%x\n", rc);
596 } 585 }
597 if (rc != CS_SUCCESS) 586 if (rc != CS_SUCCESS)
@@ -599,10 +588,10 @@ static void reader_config(dev_link_t *link, int devno)
599 588
600 link->conf.IntType = 00000002; 589 link->conf.IntType = 00000002;
601 590
602 if ((fail_rc = pcmcia_request_configuration(handle,&link->conf)) 591 if ((fail_rc = pcmcia_request_configuration(link,&link->conf))
603 !=CS_SUCCESS) { 592 !=CS_SUCCESS) {
604 fail_fn = RequestConfiguration; 593 fail_fn = RequestConfiguration;
605 dev_printk(KERN_INFO, &handle_to_dev(handle), 594 dev_printk(KERN_INFO, &handle_to_dev(link),
606 "pcmcia_request_configuration failed 0x%x\n", 595 "pcmcia_request_configuration failed 0x%x\n",
607 fail_rc); 596 fail_rc);
608 goto cs_release; 597 goto cs_release;
@@ -612,57 +601,31 @@ static void reader_config(dev_link_t *link, int devno)
612 sprintf(dev->node.dev_name, DEVICE_NAME "%d", devno); 601 sprintf(dev->node.dev_name, DEVICE_NAME "%d", devno);
613 dev->node.major = major; 602 dev->node.major = major;
614 dev->node.minor = devno; 603 dev->node.minor = devno;
615 dev->node.next = NULL; 604 dev->node.next = &dev->node;
616 link->dev = &dev->node;
617 link->state &= ~DEV_CONFIG_PENDING;
618 605
619 DEBUGP(2, dev, "device " DEVICE_NAME "%d at 0x%.4x-0x%.4x\n", devno, 606 DEBUGP(2, dev, "device " DEVICE_NAME "%d at 0x%.4x-0x%.4x\n", devno,
620 link->io.BasePort1, link->io.BasePort1+link->io.NumPorts1); 607 link->io.BasePort1, link->io.BasePort1+link->io.NumPorts1);
621 DEBUGP(2, dev, "<- reader_config (succ)\n"); 608 DEBUGP(2, dev, "<- reader_config (succ)\n");
622 609
623 return; 610 return 0;
624 611
625cs_failed: 612cs_failed:
626 cs_error(handle, fail_fn, fail_rc); 613 cs_error(link, fail_fn, fail_rc);
627cs_release: 614cs_release:
628 reader_release(link); 615 reader_release(link);
629 link->state &= ~DEV_CONFIG_PENDING; 616 return -ENODEV;
630}
631
632static int reader_suspend(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_release_configuration(link->handle);
639
640 return 0;
641} 617}
642 618
643static int reader_resume(struct pcmcia_device *p_dev) 619static void reader_release(struct pcmcia_device *link)
644{
645 dev_link_t *link = dev_to_instance(p_dev);
646
647 link->state &= ~DEV_SUSPEND;
648 if (link->state & DEV_CONFIG)
649 pcmcia_request_configuration(link->handle, &link->conf);
650
651 return 0;
652}
653
654static void reader_release(dev_link_t *link)
655{ 620{
656 cm4040_reader_release(link->priv); 621 cm4040_reader_release(link->priv);
657 pcmcia_release_configuration(link->handle); 622 pcmcia_disable_device(link);
658 pcmcia_release_io(link->handle, &link->io);
659} 623}
660 624
661static int reader_attach(struct pcmcia_device *p_dev) 625static int reader_probe(struct pcmcia_device *link)
662{ 626{
663 struct reader_dev *dev; 627 struct reader_dev *dev;
664 dev_link_t *link; 628 int i, ret;
665 int i;
666 629
667 for (i = 0; i < CM_MAX_DEV; i++) { 630 for (i = 0; i < CM_MAX_DEV; i++) {
668 if (dev_table[i] == NULL) 631 if (dev_table[i] == NULL)
@@ -679,8 +642,8 @@ static int reader_attach(struct pcmcia_device *p_dev)
679 dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT; 642 dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT;
680 dev->buffer_status = 0; 643 dev->buffer_status = 0;
681 644
682 link = &dev->link;
683 link->priv = dev; 645 link->priv = dev;
646 dev->p_dev = link;
684 647
685 link->conf.IntType = INT_MEMORY_AND_IO; 648 link->conf.IntType = INT_MEMORY_AND_IO;
686 dev_table[i] = link; 649 dev_table[i] = link;
@@ -692,11 +655,9 @@ static int reader_attach(struct pcmcia_device *p_dev)
692 init_timer(&dev->poll_timer); 655 init_timer(&dev->poll_timer);
693 dev->poll_timer.function = &cm4040_do_poll; 656 dev->poll_timer.function = &cm4040_do_poll;
694 657
695 link->handle = p_dev; 658 ret = reader_config(link, i);
696 p_dev->instance = link; 659 if (ret)
697 660 return ret;
698 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
699 reader_config(link, i);
700 661
701 class_device_create(cmx_class, NULL, MKDEV(major, i), NULL, 662 class_device_create(cmx_class, NULL, MKDEV(major, i), NULL,
702 "cmx%d", i); 663 "cmx%d", i);
@@ -704,9 +665,8 @@ static int reader_attach(struct pcmcia_device *p_dev)
704 return 0; 665 return 0;
705} 666}
706 667
707static void reader_detach(struct pcmcia_device *p_dev) 668static void reader_detach(struct pcmcia_device *link)
708{ 669{
709 dev_link_t *link = dev_to_instance(p_dev);
710 struct reader_dev *dev = link->priv; 670 struct reader_dev *dev = link->priv;
711 int devno; 671 int devno;
712 672
@@ -718,10 +678,7 @@ static void reader_detach(struct pcmcia_device *p_dev)
718 if (devno == CM_MAX_DEV) 678 if (devno == CM_MAX_DEV)
719 return; 679 return;
720 680
721 link->state &= ~DEV_PRESENT; 681 reader_release(link);
722
723 if (link->state & DEV_CONFIG)
724 reader_release(link);
725 682
726 dev_table[devno] = NULL; 683 dev_table[devno] = NULL;
727 kfree(dev); 684 kfree(dev);
@@ -753,10 +710,8 @@ static struct pcmcia_driver reader_driver = {
753 .drv = { 710 .drv = {
754 .name = "cm4040_cs", 711 .name = "cm4040_cs",
755 }, 712 },
756 .probe = reader_attach, 713 .probe = reader_probe,
757 .remove = reader_detach, 714 .remove = reader_detach,
758 .suspend = reader_suspend,
759 .resume = reader_resume,
760 .id_table = cm4040_ids, 715 .id_table = cm4040_ids,
761}; 716};
762 717
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index e6b714b6390d..07213454c458 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -228,7 +228,7 @@ typedef struct _mgslpc_info {
228 struct _input_signal_events input_signal_events; 228 struct _input_signal_events input_signal_events;
229 229
230 /* PCMCIA support */ 230 /* PCMCIA support */
231 dev_link_t link; 231 struct pcmcia_device *p_dev;
232 dev_node_t node; 232 dev_node_t node;
233 int stop; 233 int stop;
234 234
@@ -484,7 +484,7 @@ static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout);
484 484
485/* PCMCIA prototypes */ 485/* PCMCIA prototypes */
486 486
487static void mgslpc_config(dev_link_t *link); 487static int mgslpc_config(struct pcmcia_device *link);
488static void mgslpc_release(u_long arg); 488static void mgslpc_release(u_long arg);
489static void mgslpc_detach(struct pcmcia_device *p_dev); 489static void mgslpc_detach(struct pcmcia_device *p_dev);
490 490
@@ -533,14 +533,14 @@ static void ldisc_receive_buf(struct tty_struct *tty,
533 } 533 }
534} 534}
535 535
536static int mgslpc_attach(struct pcmcia_device *p_dev) 536static int mgslpc_probe(struct pcmcia_device *link)
537{ 537{
538 MGSLPC_INFO *info; 538 MGSLPC_INFO *info;
539 dev_link_t *link; 539 int ret;
540 540
541 if (debug_level >= DEBUG_LEVEL_INFO) 541 if (debug_level >= DEBUG_LEVEL_INFO)
542 printk("mgslpc_attach\n"); 542 printk("mgslpc_attach\n");
543 543
544 info = (MGSLPC_INFO *)kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL); 544 info = (MGSLPC_INFO *)kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL);
545 if (!info) { 545 if (!info) {
546 printk("Error can't allocate device instance data\n"); 546 printk("Error can't allocate device instance data\n");
@@ -565,25 +565,22 @@ static int mgslpc_attach(struct pcmcia_device *p_dev)
565 info->imrb_value = 0xffff; 565 info->imrb_value = 0xffff;
566 info->pim_value = 0xff; 566 info->pim_value = 0xff;
567 567
568 link = &info->link; 568 info->p_dev = link;
569 link->priv = info; 569 link->priv = info;
570 570
571 /* Initialize the dev_link_t structure */ 571 /* Initialize the struct pcmcia_device structure */
572 572
573 /* Interrupt setup */ 573 /* Interrupt setup */
574 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 574 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
575 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 575 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
576 link->irq.Handler = NULL; 576 link->irq.Handler = NULL;
577 577
578 link->conf.Attributes = 0; 578 link->conf.Attributes = 0;
579 link->conf.Vcc = 50;
580 link->conf.IntType = INT_MEMORY_AND_IO; 579 link->conf.IntType = INT_MEMORY_AND_IO;
581 580
582 link->handle = p_dev; 581 ret = mgslpc_config(link);
583 p_dev->instance = link; 582 if (ret)
584 583 return ret;
585 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
586 mgslpc_config(link);
587 584
588 mgslpc_add_device(info); 585 mgslpc_add_device(info);
589 586
@@ -596,15 +593,13 @@ static int mgslpc_attach(struct pcmcia_device *p_dev)
596#define CS_CHECK(fn, ret) \ 593#define CS_CHECK(fn, ret) \
597do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) 594do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
598 595
599static void mgslpc_config(dev_link_t *link) 596static int mgslpc_config(struct pcmcia_device *link)
600{ 597{
601 client_handle_t handle = link->handle;
602 MGSLPC_INFO *info = link->priv; 598 MGSLPC_INFO *info = link->priv;
603 tuple_t tuple; 599 tuple_t tuple;
604 cisparse_t parse; 600 cisparse_t parse;
605 int last_fn, last_ret; 601 int last_fn, last_ret;
606 u_char buf[64]; 602 u_char buf[64];
607 config_info_t conf;
608 cistpl_cftable_entry_t dflt = { 0 }; 603 cistpl_cftable_entry_t dflt = { 0 };
609 cistpl_cftable_entry_t *cfg; 604 cistpl_cftable_entry_t *cfg;
610 605
@@ -617,27 +612,20 @@ static void mgslpc_config(dev_link_t *link)
617 tuple.TupleData = buf; 612 tuple.TupleData = buf;
618 tuple.TupleDataMax = sizeof(buf); 613 tuple.TupleDataMax = sizeof(buf);
619 tuple.TupleOffset = 0; 614 tuple.TupleOffset = 0;
620 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 615 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
621 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 616 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
622 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 617 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
623 link->conf.ConfigBase = parse.config.base; 618 link->conf.ConfigBase = parse.config.base;
624 link->conf.Present = parse.config.rmask[0]; 619 link->conf.Present = parse.config.rmask[0];
625
626 /* Configure card */
627 link->state |= DEV_CONFIG;
628
629 /* Look up the current Vcc */
630 CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf));
631 link->conf.Vcc = conf.Vcc;
632 620
633 /* get CIS configuration entry */ 621 /* get CIS configuration entry */
634 622
635 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; 623 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
636 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); 624 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
637 625
638 cfg = &(parse.cftable_entry); 626 cfg = &(parse.cftable_entry);
639 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); 627 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple));
640 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); 628 CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
641 629
642 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg; 630 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) dflt = *cfg;
643 if (cfg->index == 0) 631 if (cfg->index == 0)
@@ -658,11 +646,10 @@ static void mgslpc_config(dev_link_t *link)
658 link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK; 646 link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
659 link->io.BasePort1 = io->win[0].base; 647 link->io.BasePort1 = io->win[0].base;
660 link->io.NumPorts1 = io->win[0].len; 648 link->io.NumPorts1 = io->win[0].len;
661 CS_CHECK(RequestIO, pcmcia_request_io(link->handle, &link->io)); 649 CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io));
662 } 650 }
663 651
664 link->conf.Attributes = CONF_ENABLE_IRQ; 652 link->conf.Attributes = CONF_ENABLE_IRQ;
665 link->conf.Vcc = 50;
666 link->conf.IntType = INT_MEMORY_AND_IO; 653 link->conf.IntType = INT_MEMORY_AND_IO;
667 link->conf.ConfigIndex = 8; 654 link->conf.ConfigIndex = 8;
668 link->conf.Present = PRESENT_OPTION; 655 link->conf.Present = PRESENT_OPTION;
@@ -670,9 +657,9 @@ static void mgslpc_config(dev_link_t *link)
670 link->irq.Attributes |= IRQ_HANDLE_PRESENT; 657 link->irq.Attributes |= IRQ_HANDLE_PRESENT;
671 link->irq.Handler = mgslpc_isr; 658 link->irq.Handler = mgslpc_isr;
672 link->irq.Instance = info; 659 link->irq.Instance = info;
673 CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); 660 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
674 661
675 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); 662 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
676 663
677 info->io_base = link->io.BasePort1; 664 info->io_base = link->io.BasePort1;
678 info->irq_level = link->irq.AssignedIRQ; 665 info->irq_level = link->irq.AssignedIRQ;
@@ -680,7 +667,7 @@ static void mgslpc_config(dev_link_t *link)
680 /* add to linked list of devices */ 667 /* add to linked list of devices */
681 sprintf(info->node.dev_name, "mgslpc0"); 668 sprintf(info->node.dev_name, "mgslpc0");
682 info->node.major = info->node.minor = 0; 669 info->node.major = info->node.minor = 0;
683 link->dev = &info->node; 670 link->dev_node = &info->node;
684 671
685 printk(KERN_INFO "%s: index 0x%02x:", 672 printk(KERN_INFO "%s: index 0x%02x:",
686 info->node.dev_name, link->conf.ConfigIndex); 673 info->node.dev_name, link->conf.ConfigIndex);
@@ -690,13 +677,12 @@ static void mgslpc_config(dev_link_t *link)
690 printk(", io 0x%04x-0x%04x", link->io.BasePort1, 677 printk(", io 0x%04x-0x%04x", link->io.BasePort1,
691 link->io.BasePort1+link->io.NumPorts1-1); 678 link->io.BasePort1+link->io.NumPorts1-1);
692 printk("\n"); 679 printk("\n");
693 680 return 0;
694 link->state &= ~DEV_CONFIG_PENDING;
695 return;
696 681
697cs_failed: 682cs_failed:
698 cs_error(link->handle, last_fn, last_ret); 683 cs_error(link, last_fn, last_ret);
699 mgslpc_release((u_long)link); 684 mgslpc_release((u_long)link);
685 return -ENODEV;
700} 686}
701 687
702/* Card has been removed. 688/* Card has been removed.
@@ -705,58 +691,38 @@ cs_failed:
705 */ 691 */
706static void mgslpc_release(u_long arg) 692static void mgslpc_release(u_long arg)
707{ 693{
708 dev_link_t *link = (dev_link_t *)arg; 694 struct pcmcia_device *link = (struct pcmcia_device *)arg;
709 695
710 if (debug_level >= DEBUG_LEVEL_INFO) 696 if (debug_level >= DEBUG_LEVEL_INFO)
711 printk("mgslpc_release(0x%p)\n", link); 697 printk("mgslpc_release(0x%p)\n", link);
712
713 /* Unlink the device chain */
714 link->dev = NULL;
715 link->state &= ~DEV_CONFIG;
716 698
717 pcmcia_release_configuration(link->handle); 699 pcmcia_disable_device(link);
718 if (link->io.NumPorts1)
719 pcmcia_release_io(link->handle, &link->io);
720 if (link->irq.AssignedIRQ)
721 pcmcia_release_irq(link->handle, &link->irq);
722} 700}
723 701
724static void mgslpc_detach(struct pcmcia_device *p_dev) 702static void mgslpc_detach(struct pcmcia_device *link)
725{ 703{
726 dev_link_t *link = dev_to_instance(p_dev); 704 if (debug_level >= DEBUG_LEVEL_INFO)
727 705 printk("mgslpc_detach(0x%p)\n", link);
728 if (debug_level >= DEBUG_LEVEL_INFO)
729 printk("mgslpc_detach(0x%p)\n", link);
730 706
731 if (link->state & DEV_CONFIG) { 707 ((MGSLPC_INFO *)link->priv)->stop = 1;
732 ((MGSLPC_INFO *)link->priv)->stop = 1; 708 mgslpc_release((u_long)link);
733 mgslpc_release((u_long)link);
734 }
735 709
736 mgslpc_remove_device((MGSLPC_INFO *)link->priv); 710 mgslpc_remove_device((MGSLPC_INFO *)link->priv);
737} 711}
738 712
739static int mgslpc_suspend(struct pcmcia_device *dev) 713static int mgslpc_suspend(struct pcmcia_device *link)
740{ 714{
741 dev_link_t *link = dev_to_instance(dev);
742 MGSLPC_INFO *info = link->priv; 715 MGSLPC_INFO *info = link->priv;
743 716
744 link->state |= DEV_SUSPEND;
745 info->stop = 1; 717 info->stop = 1;
746 if (link->state & DEV_CONFIG)
747 pcmcia_release_configuration(link->handle);
748 718
749 return 0; 719 return 0;
750} 720}
751 721
752static int mgslpc_resume(struct pcmcia_device *dev) 722static int mgslpc_resume(struct pcmcia_device *link)
753{ 723{
754 dev_link_t *link = dev_to_instance(dev);
755 MGSLPC_INFO *info = link->priv; 724 MGSLPC_INFO *info = link->priv;
756 725
757 link->state &= ~DEV_SUSPEND;
758 if (link->state & DEV_CONFIG)
759 pcmcia_request_configuration(link->handle, &link->conf);
760 info->stop = 0; 726 info->stop = 0;
761 727
762 return 0; 728 return 0;
@@ -1280,7 +1246,7 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id, struct pt_regs * regs)
1280 if (!info) 1246 if (!info)
1281 return IRQ_NONE; 1247 return IRQ_NONE;
1282 1248
1283 if (!(info->link.state & DEV_CONFIG)) 1249 if (!(info->p_dev->_locked))
1284 return IRQ_HANDLED; 1250 return IRQ_HANDLED;
1285 1251
1286 spin_lock(&info->lock); 1252 spin_lock(&info->lock);
@@ -3033,7 +2999,7 @@ static struct pcmcia_driver mgslpc_driver = {
3033 .drv = { 2999 .drv = {
3034 .name = "synclink_cs", 3000 .name = "synclink_cs",
3035 }, 3001 },
3036 .probe = mgslpc_attach, 3002 .probe = mgslpc_probe,
3037 .remove = mgslpc_detach, 3003 .remove = mgslpc_detach,
3038 .id_table = mgslpc_ids, 3004 .id_table = mgslpc_ids,
3039 .suspend = mgslpc_suspend, 3005 .suspend = mgslpc_suspend,