26 #include <linux/kernel.h>
27 #include <linux/module.h>
28 #include <linux/slab.h>
42 #include <linux/cm4000_cs.h>
46 #define reader_to_dev(x) (&x->p_dev->dev)
52 #define DEBUGP(n, rdr, x, args...) do { \
53 dev_dbg(reader_to_dev(rdr), "%s:" x, \
54 __func__ , ## args); \
60 #define T_10MSEC msecs_to_jiffies(10)
61 #define T_20MSEC msecs_to_jiffies(20)
62 #define T_40MSEC msecs_to_jiffies(40)
63 #define T_50MSEC msecs_to_jiffies(50)
64 #define T_100MSEC msecs_to_jiffies(100)
65 #define T_500MSEC msecs_to_jiffies(500)
67 static void cm4000_release(
struct pcmcia_device *
link);
74 #define M_TIMEOUT_WAIT 1
75 #define M_READ_ATR_LEN 2
77 #define M_ATR_PRESENT 4
82 #define LOCK_MONITOR 1
84 #define IS_AUTOPPS_ACT 6
85 #define IS_PROCBYTE_PRESENT 7
89 #define IS_ATR_PRESENT 11
90 #define IS_ATR_VALID 12
91 #define IS_CMM_ABSENT 13
92 #define IS_BAD_LENGTH 14
93 #define IS_BAD_CSUM 15
94 #define IS_BAD_CARD 16
96 #define REG_FLAGS0(x) (x + 0)
97 #define REG_FLAGS1(x) (x + 1)
98 #define REG_NUM_BYTES(x) (x + 2)
99 #define REG_BUF_ADDR(x) (x + 3)
100 #define REG_BUF_DATA(x) (x + 4)
101 #define REG_NUM_SEND(x) (x + 5)
102 #define REG_BAUDRATE(x) (x + 6)
103 #define REG_STOPBITS(x) (x + 7)
145 #define ZERO_DEV(dev) \
146 memset(&dev->atr_csum,0, \
147 sizeof(struct cm4000_dev) - \
148 offsetof(struct cm4000_dev, atr_csum))
151 static struct class *cmm_class;
156 static unsigned char fi_di_table[10][14] = {
159 {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11},
160 {0x01,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x91,0x11,0x11,0x11,0x11},
161 {0x02,0x12,0x22,0x32,0x11,0x11,0x11,0x11,0x11,0x92,0xA2,0xB2,0x11,0x11},
162 {0x03,0x13,0x23,0x33,0x43,0x53,0x63,0x11,0x11,0x93,0xA3,0xB3,0xC3,0xD3},
163 {0x04,0x14,0x24,0x34,0x44,0x54,0x64,0x11,0x11,0x94,0xA4,0xB4,0xC4,0xD4},
164 {0x00,0x15,0x25,0x35,0x45,0x55,0x65,0x11,0x11,0x95,0xA5,0xB5,0xC5,0xD5},
165 {0x06,0x16,0x26,0x36,0x46,0x56,0x66,0x11,0x11,0x96,0xA6,0xB6,0xC6,0xD6},
166 {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11},
167 {0x08,0x11,0x28,0x38,0x48,0x58,0x68,0x11,0x11,0x98,0xA8,0xB8,0xC8,0xD8},
168 {0x09,0x19,0x29,0x39,0x49,0x59,0x69,0x11,0x11,0x99,0xA9,0xB9,0xC9,0xD9}
175 static inline void xoutb(
unsigned char val,
unsigned short port)
177 pr_debug(
"outb(val=%.2x,port=%.4x)\n", val, port);
180 static inline unsigned char xinb(
unsigned short port)
185 pr_debug(
"%.2x=inb(%.4x)\n", val, port);
191 static inline unsigned char invert_revert(
unsigned char ch)
196 static void str_invert_revert(
unsigned char *
b,
int len)
200 for (i = 0; i < len; i++)
201 b[i] = invert_revert(b[i]);
204 #define ATRLENCK(dev,pos) \
205 if (pos>=dev->atr_len || pos>=MAX_ATR) \
208 static unsigned int calc_baudv(
unsigned char fidi)
210 unsigned int wcrcf, wbrcf, fi_rfu, di_rfu;
216 switch ((fidi >> 4) & 0x0F) {
265 switch (fidi & 0x0F) {
301 return (wcrcf / wbrcf);
304 static unsigned short io_read_num_rec_bytes(
unsigned int iobase,
321 unsigned char any_t1, any_t0;
322 unsigned char ch, ifno;
325 DEBUGP(3, dev,
"-> parse_atr: dev->atr_len = %i\n", dev->
atr_len);
328 DEBUGP(5, dev,
"parse_atr: atr_len < 3\n");
332 if (dev->
atr[0] == 0x3f)
340 any_t1 = any_t0 = done = 0;
343 if (ifno == 1 && (ch & 0x10)) {
346 DEBUGP(5, dev,
"Card says FiDi is 0x%.2x\n", dev->
ta1);
348 }
else if ((ifno == 2) && (ch & 0x10)) {
353 DEBUGP(5, dev,
"Yi=%.2x\n", ch & 0xf0);
354 ix += ((ch & 0x10) >> 4)
357 + ((ch & 0x80) >> 7);
363 DEBUGP(5, dev,
"card is capable of T=1\n");
366 DEBUGP(5, dev,
"card is capable of T=0\n");
372 DEBUGP(5, dev,
"ix=%d noHist=%d any_t1=%d\n",
373 ix, dev->
atr[1] & 15, any_t1);
374 if (ix + 1 + (dev->
atr[1] & 0x0f) + any_t1 != dev->
atr_len) {
375 DEBUGP(5, dev,
"length error\n");
384 for (i = 1; i < dev->
atr_len; i++)
388 DEBUGP(5, dev,
"bad checksum\n");
408 .atr = { 0x3b, 0xb3, 0x11, 0x00, 0x00, 0x41, 0x01 },
413 .atr = {0x3b, 0x76, 0x13, 0x00, 0x00, 0x80, 0x62, 0x07,
420 static void set_cardparameter(
struct cm4000_dev *dev)
423 unsigned int iobase = dev->
p_dev->resource[0]->start;
426 DEBUGP(3, dev,
"-> set_cardparameter\n");
435 DEBUGP(5, dev,
"baudv = %i -> write 0x%02x\n", dev->
baudv,
436 ((dev->
baudv - 1) & 0xFF));
439 for (i = 0; i <
ARRAY_SIZE(card_fixups); i++) {
442 stopbits = card_fixups[i].stopbits;
446 DEBUGP(3, dev,
"<- set_cardparameter\n");
452 unsigned long tmp,
i;
453 unsigned short num_bytes_read;
454 unsigned char pts_reply[4];
456 unsigned int iobase = dev->
p_dev->resource[0]->start;
460 DEBUGP(3, dev,
"-> set_protocol\n");
461 DEBUGP(5, dev,
"ptsreq->Protocol = 0x%.8x, ptsreq->Flags=0x%.8x, "
462 "ptsreq->pts1=0x%.2x, ptsreq->pts2=0x%.2x, "
463 "ptsreq->pts3=0x%.2x\n", (
unsigned int)ptsreq->
protocol,
471 while ((tmp = (tmp >> 1)) > 0)
474 dev->
pts[1] = (0x01 << 4) | (dev->
pts[1]);
477 DEBUGP(5, dev,
"Ta(1) from ATR is 0x%.2x\n", dev->
ta1);
479 dev->
pts[2] = fi_di_table[dev->
ta1 & 0x0F][(dev->
ta1 >> 4) & 0x0F];
484 DEBUGP(5, dev,
"pts0=%.2x, pts1=%.2x, pts2=%.2x, pts3=%.2x\n",
489 str_invert_revert(dev->
pts, 4);
495 DEBUGP(5, dev,
"Enable access to the messages buffer\n");
498 | ((dev->
baudv >> 8) & 0x01);
501 DEBUGP(5, dev,
"Enable message buffer -> flags1 = 0x%.2x\n",
505 DEBUGP(5, dev,
"Write challenge to buffer: ");
506 for (i = 0; i < 4; i++) {
518 DEBUGP(5, dev,
"Set number of bytes to write\n");
526 DEBUGP(5, dev,
"Waiting for NumRecBytes getting valid\n");
528 for (i = 0; i < 100; i++) {
530 DEBUGP(5, dev,
"NumRecBytes is valid\n");
536 DEBUGP(5, dev,
"Timeout waiting for NumRecBytes getting "
539 goto exit_setprotocol;
542 DEBUGP(5, dev,
"Reading NumRecBytes\n");
543 for (i = 0; i < 100; i++) {
544 io_read_num_rec_bytes(iobase, &num_bytes_read);
545 if (num_bytes_read >= 4) {
546 DEBUGP(2, dev,
"NumRecBytes = %i\n", num_bytes_read);
553 if (num_bytes_read == 3)
557 DEBUGP(5, dev,
"Timeout reading num_bytes_read\n");
559 goto exit_setprotocol;
562 DEBUGP(5, dev,
"Reset the CARDMAN CONTROLLER\n");
566 DEBUGP(5, dev,
"Read PPS reply\n");
567 for (i = 0; i < num_bytes_read; i++) {
573 DEBUGP(2, dev,
"PTSreply: ");
574 for (i = 0; i < num_bytes_read; i++) {
580 DEBUGP(5, dev,
"Clear Tactive in Flags1\n");
584 if ((dev->
pts[0] == pts_reply[0]) &&
585 (dev->
pts[1] == pts_reply[1]) &&
586 (dev->
pts[2] == pts_reply[2]) && (dev->
pts[3] == pts_reply[3])) {
588 dev->
baudv = calc_baudv(dev->
pts[2]);
589 set_cardparameter(dev);
590 }
else if ((dev->
pts[0] == pts_reply[0]) &&
591 ((dev->
pts[1] & 0xef) == pts_reply[1]) &&
592 ((pts_reply[0] ^ pts_reply[1]) == pts_reply[2])) {
594 dev->
baudv = calc_baudv(0x11);
595 set_cardparameter(dev);
600 DEBUGP(3, dev,
"<- set_protocol\n");
604 static int io_detect_cm4000(
unsigned int iobase,
struct cm4000_dev *dev)
625 static void terminate_monitor(
struct cm4000_dev *dev)
631 DEBUGP(3, dev,
"-> terminate_monitor\n");
634 (
void *)&dev->
flags));
641 DEBUGP(5, dev,
"Now allow last cycle of monitor!\n");
645 DEBUGP(5, dev,
"Delete timer\n");
651 DEBUGP(3, dev,
"<- terminate_monitor\n");
662 static void monitor_card(
unsigned long p)
665 unsigned int iobase = dev->
p_dev->resource[0]->start;
667 struct ptsreq ptsreq;
670 DEBUGP(7, dev,
"-> monitor_card\n");
674 DEBUGP(4, dev,
"About to stop monitor\n");
683 DEBUGP(2, dev,
"<- monitor_card (we are done now)\n");
689 DEBUGP(4, dev,
"Couldn't get IO lock\n");
690 goto return_with_timer;
696 DEBUGP(7, dev,
"smartcard present: %s\n",
697 dev->
flags0 & 1 ?
"yes" :
"no");
698 DEBUGP(7, dev,
"cardman present: %s\n",
699 dev->
flags0 == 0xff ?
"no" :
"yes");
701 if ((dev->
flags0 & 1) == 0
709 dev->
flags &= 0x000000ff;
711 if (dev->
flags0 == 0xff) {
712 DEBUGP(4, dev,
"set IS_CMM_ABSENT bit\n");
715 DEBUGP(4, dev,
"clear IS_CMM_ABSENT bit "
716 "(card is removed)\n");
724 DEBUGP(4, dev,
"clear IS_CMM_ABSENT bit (card is inserted)\n");
729 DEBUGP(7, dev,
"believe ATR is already valid (do nothing)\n");
736 DEBUGP(4, dev,
"M_CARDOFF\n");
759 DEBUGP(4, dev,
"M_FETCH_ATR\n");
761 DEBUGP(4, dev,
"Reset BAUDV to 9600\n");
773 DEBUGP(4, dev,
"M_TIMEOUT_WAIT\n");
775 io_read_num_rec_bytes(iobase, &dev->
atr_len);
780 DEBUGP(4, dev,
"M_READ_ATR_LEN\n");
783 #define MAX_ATR_LEN_RETRY 100
785 if (dev->
atr_len == io_read_num_rec_bytes(iobase, &s)) {
798 DEBUGP(4, dev,
"M_READ_ATR\n");
800 for (i = 0; i < dev->
atr_len; i++) {
805 DEBUGP(4, dev,
"Deactivate T_Active flags\n");
811 if (dev->
atr[0] == 0x03)
813 atrc = parse_atr(dev);
824 DEBUGP(4, dev,
"monitor_card: ATR valid\n");
828 (dev->
ta1 != 0x11) &&
831 DEBUGP(4, dev,
"Perform AUTOPPS\n");
838 if (set_protocol(dev, &ptsreq) == 0) {
839 DEBUGP(4, dev,
"AUTOPPS ret SUCC\n");
843 DEBUGP(4, dev,
"AUTOPPS failed: "
844 "repower using defaults\n");
859 set_cardparameter(dev);
861 DEBUGP(4, dev,
"AUTOPPS already active "
862 "2nd try:use default values\n");
863 if (dev->
ta1 == 0x11)
864 DEBUGP(4, dev,
"No AUTOPPS necessary "
868 DEBUGP(4, dev,
"Do NOT perform AUTOPPS "
869 "with multiprotocol cards\n");
874 DEBUGP(4, dev,
"ATR invalid\n");
879 DEBUGP(4, dev,
"M_BAD_CARD\n");
885 DEBUGP(4, dev,
"ATR checksum (0x%.2x, should "
886 "be zero) failed\n", dev->
atr_csum);
890 DEBUGP(4, dev,
"ATR length error\n");
892 DEBUGP(4, dev,
"card damaged or wrong way "
904 DEBUGP(7, dev,
"Unknown action\n");
909 DEBUGP(7, dev,
"release_io\n");
914 DEBUGP(7, dev,
"<- monitor_card (returns with timer)\n");
925 unsigned int iobase = dev->
p_dev->resource[0]->start;
975 if ((dev->
flags0 & 1) == 0
987 DEBUGP(4, dev,
"begin read answer\n");
992 DEBUGP(4, dev,
"read1 j=%d\n", j);
993 for (i = 0; i <
j; i++) {
999 DEBUGP(4, dev,
"read2 j=%d\n", j);
1002 for (; i <
j; i++) {
1008 if (dev->
proto == 0 && count > dev->
rlen - dev->
rpos && i) {
1009 DEBUGP(4, dev,
"T=0 and count > buffer\n");
1019 DEBUGP(4, dev,
"Clear T1Active\n");
1025 if (!io_detect_cm4000(iobase, dev)) {
1031 str_invert_revert(dev->
rbuf, count);
1040 DEBUGP(2, dev,
"<- cmm_read returns: rc = %Zi\n",
1041 (rc < 0 ? rc : count));
1042 return rc < 0 ? rc :
count;
1045 static ssize_t cmm_write(
struct file *filp,
const char __user *buf,
1046 size_t count, loff_t *ppos)
1049 unsigned int iobase = dev->
p_dev->resource[0]->start;
1052 unsigned char infolen;
1053 unsigned char sendT0;
1054 unsigned short nsend;
1064 if (dev->
proto == 0 && count < 4) {
1066 DEBUGP(4, dev,
"T0 short write\n");
1072 sendT0 = dev->
proto ? 0 : nr > 5 ? 0x08 : 0;
1079 DEBUGP(4, dev,
"bad csum\n");
1104 DEBUGP(4, dev,
"invalid ATR\n");
1123 if ((dev->
flags0 & 1) == 0
1124 || dev->
flags0 == 0xff) {
1130 DEBUGP(4, dev,
"IO error\n");
1138 if (!io_detect_cm4000(iobase, dev)) {
1146 set_cardparameter(dev);
1154 | (((dev->
baudv - 1) & 0x0100) >> 8);
1155 DEBUGP(1, dev,
"set dev->flags1 = 0x%.2x\n", dev->
flags1);
1159 DEBUGP(4, dev,
"Xmit data\n");
1160 for (i = 0; i <
nr; i++) {
1166 | (((dev->
baudv - 1) & 0x0100) >> 8)
1168 DEBUGP(4, dev,
"dev->flags = 0x%.2x - set address "
1173 DEBUGP(4, dev,
"Apply inverse convention for 0x%.2x "
1174 "-> 0x%.2x\n", (
unsigned char)dev->
sbuf[i],
1175 invert_revert(dev->
sbuf[i]));
1184 DEBUGP(4, dev,
"Xmit done\n");
1186 if (dev->
proto == 0) {
1189 DEBUGP(4, dev,
"T=0 assumes 0 byte reply\n");
1204 nsend = 5 + (
unsigned char)dev->
sbuf[4];
1214 DEBUGP(4, dev,
"T=0 set Procedure byte (inverse-reverse) "
1215 "0x%.2x\n", invert_revert(dev->
sbuf[1]));
1218 DEBUGP(4, dev,
"T=0 set Procedure byte 0x%.2x\n", dev->
sbuf[1]);
1222 DEBUGP(1, dev,
"set NumSendBytes = 0x%.2x\n",
1223 (
unsigned char)(nsend & 0xff));
1226 DEBUGP(1, dev,
"Trigger CARDMAN CONTROLLER (0x%.2x)\n",
1228 | (dev->
flags0 & 2 ? 0 : 4)
1229 |(dev->
proto ? 0x10 : 0x08)
1230 |(nsend & 0x100) >> 8 );
1232 | (dev->
flags0 & 2 ? 0 : 4)
1233 |(dev->
proto ? 0x10 : 0x08)
1234 |(nsend & 0x100) >> 8,
1238 if (dev->
proto == 1) {
1239 DEBUGP(4, dev,
"Wait for xmit done\n");
1240 for (i = 0; i < 1000; i++) {
1246 DEBUGP(4, dev,
"timeout waiting for xmit done\n");
1257 for (i = 0; i < 6000; i++) {
1258 io_read_num_rec_bytes(iobase, &s);
1261 DEBUGP(4, dev,
"infolen=%d\n", infolen);
1267 DEBUGP(4, dev,
"timeout waiting for infoLen\n");
1275 io_read_num_rec_bytes(iobase, &dev->
rlen);
1276 for (i = 0; i < 600; i++) {
1278 if (dev->
rlen >= infolen + 4)
1283 io_read_num_rec_bytes(iobase, &s);
1284 if (s > dev->
rlen) {
1285 DEBUGP(1, dev,
"NumRecBytes inc (reset timeout)\n");
1296 else if (dev->
proto == 0) {
1299 DEBUGP(1, dev,
"NoProcedure byte set\n");
1303 DEBUGP(1, dev,
"NoProcedure byte unset "
1304 "(reset timeout)\n");
1306 DEBUGP(1, dev,
"Read procedure byte 0x%.2x\n",
1311 DEBUGP(1, dev,
"T0Done flag (read reply)\n");
1319 DEBUGP(1, dev,
"timeout waiting for numRecBytes\n");
1323 if (dev->
proto == 0) {
1324 DEBUGP(1, dev,
"Wait for T0Done bit to be set\n");
1325 for (i = 0; i < 1000; i++) {
1331 DEBUGP(1, dev,
"timeout waiting for T0Done\n");
1337 DEBUGP(4, dev,
"Read procedure byte 0x%.2x\n",
1340 io_read_num_rec_bytes(iobase, &dev->
rlen);
1341 DEBUGP(4, dev,
"Read NumRecBytes = %i\n", dev->
rlen);
1347 DEBUGP(4, dev,
"dev->rlen = %i, dev->rpos = %i, nr = %i\n",
1351 DEBUGP(4, dev,
"Reset SM\n");
1355 DEBUGP(4, dev,
"Write failed but clear T_Active\n");
1368 DEBUGP(2, dev,
"<- cmm_write\n");
1369 return rc < 0 ? rc :
nr;
1372 static void start_monitor(
struct cm4000_dev *dev)
1374 DEBUGP(3, dev,
"-> start_monitor\n");
1376 DEBUGP(5, dev,
"create, init and add timer\n");
1381 DEBUGP(5, dev,
"monitor already running\n");
1382 DEBUGP(3, dev,
"<- start_monitor\n");
1385 static void stop_monitor(
struct cm4000_dev *dev)
1387 DEBUGP(3, dev,
"-> stop_monitor\n");
1389 DEBUGP(5, dev,
"stopping monitor\n");
1390 terminate_monitor(dev);
1395 DEBUGP(5, dev,
"monitor already stopped\n");
1396 DEBUGP(3, dev,
"<- stop_monitor\n");
1399 static long cmm_ioctl(
struct file *filp,
unsigned int cmd,
unsigned long arg)
1402 unsigned int iobase = dev->
p_dev->resource[0]->start;
1404 struct pcmcia_device *
link;
1416 DEBUGP(3, dev,
"cmm_ioctl(device=%d.%d) %s\n", imajor(inode),
1417 iminor(inode), ioctl_names[
_IOC_NR(cmd)]);
1422 link = dev_table[iminor(inode)];
1424 DEBUGP(4, dev,
"DEV_OK false\n");
1429 DEBUGP(4, dev,
"CMM_ABSENT flag set\n");
1435 DEBUGP(4, dev,
"ioctype mismatch\n");
1439 DEBUGP(4, dev,
"iocnr mismatch\n");
1444 DEBUGP(4, dev,
"iocdir=%.4x iocr=%.4x iocw=%.4x iocsize=%d cmd=%.4x\n",
1459 DEBUGP(4, dev,
" ... in CM_IOCGSTATUS\n");
1465 status = dev->
flags0 & 3;
1479 DEBUGP(4, dev,
"... in CM_IOCGATR\n");
1517 DEBUGP(4, dev,
"... in CM_IOCARDOFF\n");
1518 if (dev->
flags0 & 0x01) {
1519 DEBUGP(4, dev,
" Card inserted\n");
1521 DEBUGP(2, dev,
" No card inserted\n");
1523 if (dev->
flags0 & 0x02) {
1524 DEBUGP(4, dev,
" Card powered\n");
1526 DEBUGP(2, dev,
" Card not powered\n");
1546 DEBUGP(4, dev,
"Set Flags0=0x42 \n");
1572 struct ptsreq krnptsreq;
1575 sizeof(
struct ptsreq))) {
1581 DEBUGP(4, dev,
"... in CM_IOCSPTS\n");
1607 if ((rc = set_protocol(dev, &krnptsreq)) != 0) {
1624 DEBUGP(4, dev,
"... in default (unknown IOCTL code)\n");
1632 static int cmm_open(
struct inode *inode,
struct file *filp)
1635 struct pcmcia_device *
link;
1636 int minor = iminor(inode);
1643 link = dev_table[minor];
1657 DEBUGP(2, dev,
"-> cmm_open(device=%d.%d process=%s,%d)\n",
1684 DEBUGP(2, dev,
"<- cmm_open\n");
1691 static int cmm_close(
struct inode *inode,
struct file *filp)
1694 struct pcmcia_device *
link;
1695 int minor = iminor(inode);
1700 link = dev_table[minor];
1706 DEBUGP(2, dev,
"-> cmm_close(maj/min=%d.%d)\n",
1707 imajor(inode), minor);
1716 DEBUGP(2, dev,
"cmm_close\n");
1720 static void cmm_cm4000_release(
struct pcmcia_device * link)
1727 DEBUGP(3, dev,
"-> cmm_cm4000_release\n");
1728 while (link->open) {
1730 "process has terminated\n");
1738 DEBUGP(3, dev,
"<- cmm_cm4000_release\n");
1744 static int cm4000_config_check(
struct pcmcia_device *
p_dev,
void *priv_data)
1749 static int cm4000_config(
struct pcmcia_device * link,
int devno)
1753 link->config_flags |= CONF_AUTO_SET_IO;
1756 if (pcmcia_loop_config(link, cm4000_config_check,
NULL))
1767 cm4000_release(link);
1771 static int cm4000_suspend(
struct pcmcia_device *link)
1781 static int cm4000_resume(
struct pcmcia_device *link)
1792 static void cm4000_release(
struct pcmcia_device *link)
1794 cmm_cm4000_release(link);
1798 static int cm4000_probe(
struct pcmcia_device *link)
1804 if (dev_table[i] ==
NULL)
1807 if (i == CM4000_MAX_DEV) {
1819 dev_table[
i] =
link;
1826 ret = cm4000_config(link, i);
1828 dev_table[
i] =
NULL;
1838 static void cm4000_detach(
struct pcmcia_device *link)
1845 if (dev_table[devno] == link)
1847 if (devno == CM4000_MAX_DEV)
1852 cm4000_release(link);
1866 .unlocked_ioctl = cmm_ioctl,
1868 .release= cmm_close,
1873 PCMCIA_DEVICE_MANF_CARD(0x0223, 0x0002),
1874 PCMCIA_DEVICE_PROD_ID12(
"CardMan",
"4000", 0x2FB368CA, 0xA2BD8C39),
1879 static struct pcmcia_driver cm4000_driver = {
1881 .name =
"cm4000_cs",
1882 .probe = cm4000_probe,
1883 .remove = cm4000_detach,
1884 .suspend = cm4000_suspend,
1885 .resume = cm4000_resume,
1886 .id_table = cm4000_ids,
1889 static int __init cmm_init(
void)
1894 if (IS_ERR(cmm_class))
1895 return PTR_ERR(cmm_class);
1900 ": could not get major number\n");
1915 static void __exit cmm_exit(
void)