diff options
Diffstat (limited to 'drivers/char/pcmcia/cm4040_cs.c')
-rw-r--r-- | drivers/char/pcmcia/cm4040_cs.c | 49 |
1 files changed, 13 insertions, 36 deletions
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c index 815cde1d0570..8dd48a2be911 100644 --- a/drivers/char/pcmcia/cm4040_cs.c +++ b/drivers/char/pcmcia/cm4040_cs.c | |||
@@ -24,12 +24,11 @@ | |||
24 | #include <linux/fs.h> | 24 | #include <linux/fs.h> |
25 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
26 | #include <linux/poll.h> | 26 | #include <linux/poll.h> |
27 | #include <linux/smp_lock.h> | 27 | #include <linux/mutex.h> |
28 | #include <linux/wait.h> | 28 | #include <linux/wait.h> |
29 | #include <asm/uaccess.h> | 29 | #include <asm/uaccess.h> |
30 | #include <asm/io.h> | 30 | #include <asm/io.h> |
31 | 31 | ||
32 | #include <pcmcia/cs.h> | ||
33 | #include <pcmcia/cistpl.h> | 32 | #include <pcmcia/cistpl.h> |
34 | #include <pcmcia/cisreg.h> | 33 | #include <pcmcia/cisreg.h> |
35 | #include <pcmcia/ciscode.h> | 34 | #include <pcmcia/ciscode.h> |
@@ -49,8 +48,7 @@ | |||
49 | __func__ , ## args); \ | 48 | __func__ , ## args); \ |
50 | } while (0) | 49 | } while (0) |
51 | 50 | ||
52 | static char *version = | 51 | static DEFINE_MUTEX(cm4040_mutex); |
53 | "OMNIKEY CardMan 4040 v1.1.0gm5 - All bugs added by Harald Welte"; | ||
54 | 52 | ||
55 | #define CCID_DRIVER_BULK_DEFAULT_TIMEOUT (150*HZ) | 53 | #define CCID_DRIVER_BULK_DEFAULT_TIMEOUT (150*HZ) |
56 | #define CCID_DRIVER_ASYNC_POWERUP_TIMEOUT (35*HZ) | 54 | #define CCID_DRIVER_ASYNC_POWERUP_TIMEOUT (35*HZ) |
@@ -444,7 +442,7 @@ static int cm4040_open(struct inode *inode, struct file *filp) | |||
444 | if (minor >= CM_MAX_DEV) | 442 | if (minor >= CM_MAX_DEV) |
445 | return -ENODEV; | 443 | return -ENODEV; |
446 | 444 | ||
447 | lock_kernel(); | 445 | mutex_lock(&cm4040_mutex); |
448 | link = dev_table[minor]; | 446 | link = dev_table[minor]; |
449 | if (link == NULL || !pcmcia_dev_present(link)) { | 447 | if (link == NULL || !pcmcia_dev_present(link)) { |
450 | ret = -ENODEV; | 448 | ret = -ENODEV; |
@@ -473,7 +471,7 @@ static int cm4040_open(struct inode *inode, struct file *filp) | |||
473 | DEBUGP(2, dev, "<- cm4040_open (successfully)\n"); | 471 | DEBUGP(2, dev, "<- cm4040_open (successfully)\n"); |
474 | ret = nonseekable_open(inode, filp); | 472 | ret = nonseekable_open(inode, filp); |
475 | out: | 473 | out: |
476 | unlock_kernel(); | 474 | mutex_unlock(&cm4040_mutex); |
477 | return ret; | 475 | return ret; |
478 | } | 476 | } |
479 | 477 | ||
@@ -516,26 +514,9 @@ static void cm4040_reader_release(struct pcmcia_device *link) | |||
516 | return; | 514 | return; |
517 | } | 515 | } |
518 | 516 | ||
519 | static int cm4040_config_check(struct pcmcia_device *p_dev, | 517 | static int cm4040_config_check(struct pcmcia_device *p_dev, void *priv_data) |
520 | cistpl_cftable_entry_t *cfg, | ||
521 | cistpl_cftable_entry_t *dflt, | ||
522 | unsigned int vcc, | ||
523 | void *priv_data) | ||
524 | { | 518 | { |
525 | int rc; | 519 | return pcmcia_request_io(p_dev); |
526 | if (!cfg->io.nwin) | ||
527 | return -ENODEV; | ||
528 | |||
529 | /* Get the IOaddr */ | ||
530 | p_dev->resource[0]->start = cfg->io.win[0].base; | ||
531 | p_dev->resource[0]->end = cfg->io.win[0].len; | ||
532 | p_dev->resource[0]->flags |= pcmcia_io_cfg_data_width(cfg->io.flags); | ||
533 | p_dev->io_lines = cfg->io.flags & CISTPL_IO_LINES_MASK; | ||
534 | rc = pcmcia_request_io(p_dev); | ||
535 | |||
536 | dev_printk(KERN_INFO, &p_dev->dev, | ||
537 | "pcmcia_request_io returned 0x%x\n", rc); | ||
538 | return rc; | ||
539 | } | 520 | } |
540 | 521 | ||
541 | 522 | ||
@@ -544,15 +525,15 @@ static int reader_config(struct pcmcia_device *link, int devno) | |||
544 | struct reader_dev *dev; | 525 | struct reader_dev *dev; |
545 | int fail_rc; | 526 | int fail_rc; |
546 | 527 | ||
528 | link->config_flags |= CONF_AUTO_SET_IO; | ||
529 | |||
547 | if (pcmcia_loop_config(link, cm4040_config_check, NULL)) | 530 | if (pcmcia_loop_config(link, cm4040_config_check, NULL)) |
548 | goto cs_release; | 531 | goto cs_release; |
549 | 532 | ||
550 | link->conf.IntType = 00000002; | 533 | fail_rc = pcmcia_enable_device(link); |
551 | |||
552 | fail_rc = pcmcia_request_configuration(link, &link->conf); | ||
553 | if (fail_rc != 0) { | 534 | if (fail_rc != 0) { |
554 | dev_printk(KERN_INFO, &link->dev, | 535 | dev_printk(KERN_INFO, &link->dev, |
555 | "pcmcia_request_configuration failed 0x%x\n", | 536 | "pcmcia_enable_device failed 0x%x\n", |
556 | fail_rc); | 537 | fail_rc); |
557 | goto cs_release; | 538 | goto cs_release; |
558 | } | 539 | } |
@@ -599,7 +580,6 @@ static int reader_probe(struct pcmcia_device *link) | |||
599 | link->priv = dev; | 580 | link->priv = dev; |
600 | dev->p_dev = link; | 581 | dev->p_dev = link; |
601 | 582 | ||
602 | link->conf.IntType = INT_MEMORY_AND_IO; | ||
603 | dev_table[i] = link; | 583 | dev_table[i] = link; |
604 | 584 | ||
605 | init_waitqueue_head(&dev->devq); | 585 | init_waitqueue_head(&dev->devq); |
@@ -650,9 +630,10 @@ static const struct file_operations reader_fops = { | |||
650 | .open = cm4040_open, | 630 | .open = cm4040_open, |
651 | .release = cm4040_close, | 631 | .release = cm4040_close, |
652 | .poll = cm4040_poll, | 632 | .poll = cm4040_poll, |
633 | .llseek = no_llseek, | ||
653 | }; | 634 | }; |
654 | 635 | ||
655 | static struct pcmcia_device_id cm4040_ids[] = { | 636 | static const struct pcmcia_device_id cm4040_ids[] = { |
656 | PCMCIA_DEVICE_MANF_CARD(0x0223, 0x0200), | 637 | PCMCIA_DEVICE_MANF_CARD(0x0223, 0x0200), |
657 | PCMCIA_DEVICE_PROD_ID12("OMNIKEY", "CardMan 4040", | 638 | PCMCIA_DEVICE_PROD_ID12("OMNIKEY", "CardMan 4040", |
658 | 0xE32CDD8C, 0x8F23318B), | 639 | 0xE32CDD8C, 0x8F23318B), |
@@ -662,9 +643,7 @@ MODULE_DEVICE_TABLE(pcmcia, cm4040_ids); | |||
662 | 643 | ||
663 | static struct pcmcia_driver reader_driver = { | 644 | static struct pcmcia_driver reader_driver = { |
664 | .owner = THIS_MODULE, | 645 | .owner = THIS_MODULE, |
665 | .drv = { | 646 | .name = "cm4040_cs", |
666 | .name = "cm4040_cs", | ||
667 | }, | ||
668 | .probe = reader_probe, | 647 | .probe = reader_probe, |
669 | .remove = reader_detach, | 648 | .remove = reader_detach, |
670 | .id_table = cm4040_ids, | 649 | .id_table = cm4040_ids, |
@@ -674,7 +653,6 @@ static int __init cm4040_init(void) | |||
674 | { | 653 | { |
675 | int rc; | 654 | int rc; |
676 | 655 | ||
677 | printk(KERN_INFO "%s\n", version); | ||
678 | cmx_class = class_create(THIS_MODULE, "cardman_4040"); | 656 | cmx_class = class_create(THIS_MODULE, "cardman_4040"); |
679 | if (IS_ERR(cmx_class)) | 657 | if (IS_ERR(cmx_class)) |
680 | return PTR_ERR(cmx_class); | 658 | return PTR_ERR(cmx_class); |
@@ -699,7 +677,6 @@ static int __init cm4040_init(void) | |||
699 | 677 | ||
700 | static void __exit cm4040_exit(void) | 678 | static void __exit cm4040_exit(void) |
701 | { | 679 | { |
702 | printk(KERN_INFO MODULE_NAME ": unloading\n"); | ||
703 | pcmcia_unregister_driver(&reader_driver); | 680 | pcmcia_unregister_driver(&reader_driver); |
704 | unregister_chrdev(major, DEVICE_NAME); | 681 | unregister_chrdev(major, DEVICE_NAME); |
705 | class_destroy(cmx_class); | 682 | class_destroy(cmx_class); |