aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
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
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')
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c24
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c23
2 files changed, 41 insertions, 6 deletions
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index 649677b5dc36..5fdf18515433 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -13,11 +13,12 @@
13 * 13 *
14 * (C) 2000,2001,2002,2003,2004 Omnikey AG 14 * (C) 2000,2001,2002,2003,2004 Omnikey AG
15 * 15 *
16 * (C) 2005 Harald Welte <laforge@gnumonks.org> 16 * (C) 2005-2006 Harald Welte <laforge@gnumonks.org>
17 * - Adhere to Kernel CodingStyle 17 * - Adhere to Kernel CodingStyle
18 * - Port to 2.6.13 "new" style PCMCIA 18 * - Port to 2.6.13 "new" style PCMCIA
19 * - Check for copy_{from,to}_user return values 19 * - Check for copy_{from,to}_user return values
20 * - Use nonseekable_open() 20 * - Use nonseekable_open()
21 * - add class interface for udev device creation
21 * 22 *
22 * All rights reserved. Licensed under dual BSD/GPL license. 23 * All rights reserved. Licensed under dual BSD/GPL license.
23 */ 24 */
@@ -56,7 +57,7 @@ module_param(pc_debug, int, 0600);
56#else 57#else
57#define DEBUGP(n, rdr, x, args...) 58#define DEBUGP(n, rdr, x, args...)
58#endif 59#endif
59static char *version = "cm4000_cs.c v2.4.0gm5 - All bugs added by Harald Welte"; 60static char *version = "cm4000_cs.c v2.4.0gm6 - All bugs added by Harald Welte";
60 61
61#define T_1SEC (HZ) 62#define T_1SEC (HZ)
62#define T_10MSEC msecs_to_jiffies(10) 63#define T_10MSEC msecs_to_jiffies(10)
@@ -156,6 +157,7 @@ struct cm4000_dev {
156 /*queue*/ 4*sizeof(wait_queue_head_t)) 157 /*queue*/ 4*sizeof(wait_queue_head_t))
157 158
158static dev_link_t *dev_table[CM4000_MAX_DEV]; 159static dev_link_t *dev_table[CM4000_MAX_DEV];
160static struct class *cmm_class;
159 161
160/* 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
161 * violates CodingStyle. However, I don't really think wrapping it around will 163 * violates CodingStyle. However, I don't really think wrapping it around will
@@ -1937,6 +1939,9 @@ static int cm4000_attach(struct pcmcia_device *p_dev)
1937 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 1939 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1938 cm4000_config(link, i); 1940 cm4000_config(link, i);
1939 1941
1942 class_device_create(cmm_class, NULL, MKDEV(major, i), NULL,
1943 "cmm%d", i);
1944
1940 return 0; 1945 return 0;
1941} 1946}
1942 1947
@@ -1962,6 +1967,8 @@ static void cm4000_detach(struct pcmcia_device *p_dev)
1962 dev_table[devno] = NULL; 1967 dev_table[devno] = NULL;
1963 kfree(dev); 1968 kfree(dev);
1964 1969
1970 class_device_destroy(cmm_class, MKDEV(major, devno));
1971
1965 return; 1972 return;
1966} 1973}
1967 1974
@@ -1995,8 +2002,18 @@ static struct pcmcia_driver cm4000_driver = {
1995 2002
1996static int __init cmm_init(void) 2003static int __init cmm_init(void)
1997{ 2004{
2005 int rc;
2006
1998 printk(KERN_INFO "%s\n", version); 2007 printk(KERN_INFO "%s\n", version);
1999 pcmcia_register_driver(&cm4000_driver); 2008
2009 cmm_class = class_create(THIS_MODULE, "cardman_4000");
2010 if (!cmm_class)
2011 return -1;
2012
2013 rc = pcmcia_register_driver(&cm4000_driver);
2014 if (rc < 0)
2015 return rc;
2016
2000 major = register_chrdev(0, DEVICE_NAME, &cm4000_fops); 2017 major = register_chrdev(0, DEVICE_NAME, &cm4000_fops);
2001 if (major < 0) { 2018 if (major < 0) {
2002 printk(KERN_WARNING MODULE_NAME 2019 printk(KERN_WARNING MODULE_NAME
@@ -2012,6 +2029,7 @@ static void __exit cmm_exit(void)
2012 printk(KERN_INFO MODULE_NAME ": unloading\n"); 2029 printk(KERN_INFO MODULE_NAME ": unloading\n");
2013 pcmcia_unregister_driver(&cm4000_driver); 2030 pcmcia_unregister_driver(&cm4000_driver);
2014 unregister_chrdev(major, DEVICE_NAME); 2031 unregister_chrdev(major, DEVICE_NAME);
2032 class_destroy(cmm_class);
2015}; 2033};
2016 2034
2017module_init(cmm_init); 2035module_init(cmm_init);
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);