aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/pcmcia/cm4040_cs.c
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2006-02-14 03:21:26 -0500
committerDominik Brodowski <linux@dominikbrodowski.net>2006-03-01 05:18:30 -0500
commit67bc620006a30cf5dcbf409dbbd4fd93179ddfb1 (patch)
tree166869f4c251da22cd7aca06811250fdaac81ba3 /drivers/char/pcmcia/cm4040_cs.c
parent2fe22a8bba0c3a60db58dfdcaa200f8528c057e4 (diff)
[PATCH] pcmcia: CM4000, CM4040 Driver fixes
Using this patch, Omnikey CardMan 4000 and 4040 devices automatically get their device nodes created by udev. Also, we now check for (and handle) failure of pcmcia_register_driver() Signed-off-by: Harald Welte <laforge@netfilter.org> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/char/pcmcia/cm4040_cs.c')
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 46eb371bf17e..466e33bab029 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -3,12 +3,13 @@
3 * 3 *
4 * (c) 2000-2004 Omnikey AG (http://www.omnikey.com/) 4 * (c) 2000-2004 Omnikey AG (http://www.omnikey.com/)
5 * 5 *
6 * (C) 2005 Harald Welte <laforge@gnumonks.org> 6 * (C) 2005-2006 Harald Welte <laforge@gnumonks.org>
7 * - add support for poll() 7 * - add support for poll()
8 * - driver cleanup 8 * - driver cleanup
9 * - add waitqueues 9 * - add waitqueues
10 * - adhere to linux kernel coding style and policies 10 * - adhere to linux kernel coding style and policies
11 * - support 2.6.13 "new style" pcmcia interface 11 * - support 2.6.13 "new style" pcmcia interface
12 * - add class interface for udev device creation
12 * 13 *
13 * The device basically is a USB CCID compliant device that has been 14 * The device basically is a USB CCID compliant device that has been
14 * attached to an I/O-Mapped FIFO. 15 * attached to an I/O-Mapped FIFO.
@@ -53,7 +54,7 @@ module_param(pc_debug, int, 0600);
53#endif 54#endif
54 55
55static char *version = 56static char *version =
56"OMNIKEY CardMan 4040 v1.1.0gm4 - All bugs added by Harald Welte"; 57"OMNIKEY CardMan 4040 v1.1.0gm5 - All bugs added by Harald Welte";
57 58
58#define CCID_DRIVER_BULK_DEFAULT_TIMEOUT (150*HZ) 59#define CCID_DRIVER_BULK_DEFAULT_TIMEOUT (150*HZ)
59#define CCID_DRIVER_ASYNC_POWERUP_TIMEOUT (35*HZ) 60#define CCID_DRIVER_ASYNC_POWERUP_TIMEOUT (35*HZ)
@@ -67,6 +68,7 @@ static char *version =
67static void reader_release(dev_link_t *link); 68static void reader_release(dev_link_t *link);
68 69
69static int major; 70static int major;
71static struct class *cmx_class;
70 72
71#define BS_READABLE 0x01 73#define BS_READABLE 0x01
72#define BS_WRITABLE 0x02 74#define BS_WRITABLE 0x02
@@ -696,6 +698,9 @@ static int reader_attach(struct pcmcia_device *p_dev)
696 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 698 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
697 reader_config(link, i); 699 reader_config(link, i);
698 700
701 class_device_create(cmx_class, NULL, MKDEV(major, i), NULL,
702 "cmx%d", i);
703
699 return 0; 704 return 0;
700} 705}
701 706
@@ -721,6 +726,8 @@ static void reader_detach(struct pcmcia_device *p_dev)
721 dev_table[devno] = NULL; 726 dev_table[devno] = NULL;
722 kfree(dev); 727 kfree(dev);
723 728
729 class_device_destroy(cmx_class, MKDEV(major, devno));
730
724 return; 731 return;
725} 732}
726 733
@@ -755,8 +762,17 @@ static struct pcmcia_driver reader_driver = {
755 762
756static int __init cm4040_init(void) 763static int __init cm4040_init(void)
757{ 764{
765 int rc;
766
758 printk(KERN_INFO "%s\n", version); 767 printk(KERN_INFO "%s\n", version);
759 pcmcia_register_driver(&reader_driver); 768 cmx_class = class_create(THIS_MODULE, "cardman_4040");
769 if (!cmx_class)
770 return -1;
771
772 rc = pcmcia_register_driver(&reader_driver);
773 if (rc < 0)
774 return rc;
775
760 major = register_chrdev(0, DEVICE_NAME, &reader_fops); 776 major = register_chrdev(0, DEVICE_NAME, &reader_fops);
761 if (major < 0) { 777 if (major < 0) {
762 printk(KERN_WARNING MODULE_NAME 778 printk(KERN_WARNING MODULE_NAME
@@ -771,6 +787,7 @@ static void __exit cm4040_exit(void)
771 printk(KERN_INFO MODULE_NAME ": unloading\n"); 787 printk(KERN_INFO MODULE_NAME ": unloading\n");
772 pcmcia_unregister_driver(&reader_driver); 788 pcmcia_unregister_driver(&reader_driver);
773 unregister_chrdev(major, DEVICE_NAME); 789 unregister_chrdev(major, DEVICE_NAME);
790 class_destroy(cmx_class);
774} 791}
775 792
776module_init(cm4040_init); 793module_init(cm4040_init);