Skip to contentSkip to conversation

New Omnikey Cardman 4040 driver

PATCH In review Harald Welte 3 participants 5 messages Sep 13, 2005 – Sep 18, 2005 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 New Omnikey Cardman 4040 driver

Hi!

I've now incorporated all requested/suggested changes. Please apply the following patch to the mainline tree, thanks!

Add new Omnikey Cardman 4040 smartcard reader driver

MAINTAINERS +5 -0
@@ -1775,6 +1775,11 @@ L:	[email protected]
 W:	http://www.linuxtr.net
 S:	Maintained
 
+OMNIKEY CARDMAN 4040 DRIVER
+P:	Harald Welte
+M:	[email protected]
+S:	Maintained
+
 ONSTREAM SCSI TAPE DRIVER
 P:	Willem Riede
 M:	[email protected]
drivers/char/pcmcia/Kconfig +13 -0
@@ -18,5 +18,18 @@ config SYNCLINK_CS
 	  The module will be called synclinkmp.  If you want to do that, say M
 	  here.
 
+config CARDMAN_4040
+	tristate "Omnikey CardMan 4040 support"
+	depends on PCMCIA
+	help
+	  Enable support for the Omnikey CardMan 4040 PCMCIA Smartcard
+	  reader.
+	  
+	  This card is basically a USB CCID device connected to a FIFO
+	  in I/O space.  To use the kernel driver, you will need either the
+	  PC/SC ifdhandler provided from the Omnikey homepage
+	  (http://www.omnikey.com/), or a current development version of OpenCT
+	  (http://www.opensc.org/).
+
 endmenu
 
drivers/char/pcmcia/Makefile +1 -0
@@ -5,3 +5,4 @@
 #
 
 obj-$(CONFIG_SYNCLINK_CS) += synclink_cs.o
+obj-$(CONFIG_CARDMAN_4040) += cm4040_cs.o
drivers/char/pcmcia/cm4040_cs.c new file +835 -0

835 lines not on this page · raw message

drivers/char/pcmcia/cm4040_cs.h new file +47 -0

47 lines not on this page · raw message

Signature · 4 lines
- Harald Welte <[email protected]>          	        http://gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
                                                  (ETSI EN 300 175-7 Ch. A6)
#1 lore raw
Quoted 4 lines · Harald Welte

Hi!

I've now incorporated all requested/suggested changes. Please apply the following patch to the mainline tree, thanks!

<snip>

Quoted 1 line
drivers/char/pcmcia/cm4040_cs.c +0 -0

<snip>

Quoted 3 lines
drivers/char/pcmcia/cm4040_cs.c +3 -0
+static ssize_t cm4040_read(struct file *filp, char __user *buf,
+                       size_t count, loff_t *ppos)
+{

<snip>

Quoted 1 line

+ schedule_timeout(1*HZ);

This needs a state set, or it will return immediately. Use either schedule_timeout_interruptible() or schedule_timeout_uninterruptible() (merged in 2.6.14-rc1). Otherwise the patches look good.

Thanks,
Nish

#2 lore raw
Quoted 18 lines · Nish Aravamudan
Quoted 4 lines · Harald Welte

Hi!

I've now incorporated all requested/suggested changes. Please apply the following patch to the mainline tree, thanks!

<snip>

Quoted 1 line
drivers/char/pcmcia/cm4040_cs.c +0 -0

<snip>

Quoted 3 lines
drivers/char/pcmcia/cm4040_cs.c +3 -0
+static ssize_t cm4040_read(struct file *filp, char __user *buf,
+                       size_t count, loff_t *ppos)
+{

<snip>

Quoted 5 lines
Quoted 1 line

+ schedule_timeout(1*HZ);

This needs a state set, or it will return immediately. Use either schedule_timeout_interruptible() or schedule_timeout_uninterruptible() (merged in 2.6.14-rc1). Otherwise the patches look good.

actually, that line can be removed completely. It was introduced to aid debugging, and I forgot to remove it. sorry.

Please use the patch below as [1/2], patch 2 stays unmodified.

thanks!

Add new Omnikey Cardman 4040 smartcard reader driver

MAINTAINERS +5 -0
@@ -1775,6 +1775,11 @@ L:	[email protected]
 W:	http://www.linuxtr.net
 S:	Maintained
 
+OMNIKEY CARDMAN 4040 DRIVER
+P:	Harald Welte
+M:	[email protected]
+S:	Maintained
+
 ONSTREAM SCSI TAPE DRIVER
 P:	Willem Riede
 M:	[email protected]
drivers/char/pcmcia/Kconfig +13 -0
@@ -18,5 +18,18 @@ config SYNCLINK_CS
 	  The module will be called synclinkmp.  If you want to do that, say M
 	  here.
 
+config CARDMAN_4040
+	tristate "Omnikey CardMan 4040 support"
+	depends on PCMCIA
+	help
+	  Enable support for the Omnikey CardMan 4040 PCMCIA Smartcard
+	  reader.
+	  
+	  This card is basically a USB CCID device connected to a FIFO
+	  in I/O space.  To use the kernel driver, you will need either the
+	  PC/SC ifdhandler provided from the Omnikey homepage
+	  (http://www.omnikey.com/), or a current development version of OpenCT
+	  (http://www.opensc.org/).
+
 endmenu
 
drivers/char/pcmcia/Makefile +1 -0
@@ -5,3 +5,4 @@
 #
 
 obj-$(CONFIG_SYNCLINK_CS) += synclink_cs.o
+obj-$(CONFIG_CARDMAN_4040) += cm4040_cs.o
drivers/char/pcmcia/cm4040_cs.c new file +834 -0

834 lines not on this page · raw message

drivers/char/pcmcia/cm4040_cs.h new file +47 -0

47 lines not on this page · raw message

Signature · 4 lines
- Harald Welte <[email protected]>          	        http://gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
                                                  (ETSI EN 300 175-7 Ch. A6)
#3 lore raw
Quoted 3 lines · Harald Welte

Add new Omnikey Cardman 4040 smartcard reader driver

I see a timer, but I see no del_timer_sync() anywhere. Cannot the timer be left pending after device shutdown or rmmod?

Plus:

- Work around gcc-2.95.x macro expansion bug

- unneded void* cast

- use kzalloc()

drivers/char/pcmcia/cm4040_cs.c renamed from drivers/char/pcmcia/cm4040_cs.c~new-omnikey-cardman-4040-driver-fixes +3 -4
diff -puN drivers/char/pcmcia/cm4040_cs.c~new-omnikey-cardman-4040-driver-fixes drivers/char/pcmcia/cm4040_cs.c
@@ -46,7 +46,7 @@ module_param(pc_debug, int, 0600);
 #define DEBUGP(n, rdr, x, args...) do { 				\
 	if (pc_debug >= (n)) 						\
 		dev_printk(KERN_DEBUG, reader_to_dev(rdr), "%s:" x, 	\
-			   __FUNCTION__, ##args); 			\
+			   __FUNCTION__ , ##args); 			\
 	} while (0)
 #else
 #define DEBUGP(n, rdr, x, args...)
@@ -453,7 +453,7 @@ static int cm4040_open(struct inode *ino
 	if (link->open)
 		return -EBUSY;
 
-	dev = (struct reader_dev *)link->priv;
+	dev = link->priv;
 	filp->private_data = dev;
 
 	if (filp->f_flags & O_NONBLOCK) {
@@ -705,11 +705,10 @@ static dev_link_t *reader_attach(void)
 	if (i == CM_MAX_DEV)
 		return NULL;
 
-	dev = kmalloc(sizeof(struct reader_dev), GFP_KERNEL);
+	dev = kzalloc(sizeof(struct reader_dev), GFP_KERNEL);
 	if (dev == NULL)
 		return NULL;
 
-	memset(dev, 0, sizeof(struct reader_dev));
 	dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT;
 	dev->buffer_status = 0;
 

_

#4 lore raw
Quoted 7 lines · Andrew Morton
Quoted 3 lines · Harald Welte

Add new Omnikey Cardman 4040 smartcard reader driver

I see a timer, but I see no del_timer_sync() anywhere. Cannot the timer be left pending after device shutdown or rmmod?

Please see the patch below (against -rc1-mm1):

[CM4040] CardMan 4040 Driver Update

* Don't initialize variable in bss
* Introduce and use function to stop polling timer
* Remove unneeded dev_info variable

drivers/char/pcmcia/cm4040_cs.c +11 -4
@@ -85,8 +85,7 @@
 	struct timer_list 	poll_timer;
 };
 
-static dev_info_t dev_info = MODULE_NAME;
-static dev_link_t *dev_table[CM_MAX_DEV] = { NULL, };
+static dev_link_t *dev_table[CM_MAX_DEV];
 
 #ifndef PCMCIA_DEBUG
 #define	xoutb	outb
@@ -138,6 +137,11 @@
 	mod_timer(&dev->poll_timer, jiffies + POLL_PERIOD);
 }
 
+static void cm4040_stop_poll(struct reader_dev *dev)
+{
+	del_timer_sync(&dev->poll_timer);
+}
+
 static int wait_for_bulk_out_ready(struct reader_dev *dev)
 {
 	int i, rc;
@@ -485,6 +489,8 @@
 	if (link == NULL)
 		return -ENODEV;
 
+	cm4040_stop_poll(dev);
+
 	link->open = 0;
 	wake_up(&dev->devq);
 
@@ -627,7 +633,7 @@
 
 	link->state |= DEV_SUSPEND;
 	if (link->state & DEV_CONFIG)
-		pcmcia_release_configuration(link->handle);
+		pcmcia_release_configuration(p_dev);
 
 	return 0;
 }
@@ -643,7 +649,6 @@
 	return 0;
 }
 
-
 static void reader_release(dev_link_t *link)
 {
 	cm4040_reader_release(link->priv);
@@ -713,6 +718,8 @@
 	if (link->state & DEV_CONFIG)
 		reader_release(link);
 
+	cm4040_stop_poll(dev);
+
 	dev_table[devno] = NULL;
 	kfree(dev);
 
Signature · 4 lines
- Harald Welte <[email protected]>          	        http://gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
                                                  (ETSI EN 300 175-7 Ch. A6)