Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 1 | /* |
| 2 | * A driver for the Omnikey PCMCIA smartcard reader CardMan 4040 |
| 3 | * |
| 4 | * (c) 2000-2004 Omnikey AG (http://www.omnikey.com/) |
| 5 | * |
Harald Welte | 67bc620 | 2006-02-14 09:21:26 +0100 | [diff] [blame] | 6 | * (C) 2005-2006 Harald Welte <laforge@gnumonks.org> |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 7 | * - add support for poll() |
| 8 | * - driver cleanup |
| 9 | * - add waitqueues |
| 10 | * - adhere to linux kernel coding style and policies |
| 11 | * - support 2.6.13 "new style" pcmcia interface |
Harald Welte | 67bc620 | 2006-02-14 09:21:26 +0100 | [diff] [blame] | 12 | * - add class interface for udev device creation |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 13 | * |
| 14 | * The device basically is a USB CCID compliant device that has been |
| 15 | * attached to an I/O-Mapped FIFO. |
| 16 | * |
| 17 | * All rights reserved, Dual BSD/GPL Licensed. |
| 18 | */ |
| 19 | |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 20 | #include <linux/kernel.h> |
| 21 | #include <linux/module.h> |
| 22 | #include <linux/slab.h> |
| 23 | #include <linux/init.h> |
| 24 | #include <linux/fs.h> |
| 25 | #include <linux/delay.h> |
| 26 | #include <linux/poll.h> |
Jonathan Corbet | 8b5332f | 2008-06-19 14:34:41 -0600 | [diff] [blame] | 27 | #include <linux/smp_lock.h> |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 28 | #include <linux/wait.h> |
| 29 | #include <asm/uaccess.h> |
| 30 | #include <asm/io.h> |
| 31 | |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 32 | #include <pcmcia/cs.h> |
| 33 | #include <pcmcia/cistpl.h> |
| 34 | #include <pcmcia/cisreg.h> |
| 35 | #include <pcmcia/ciscode.h> |
| 36 | #include <pcmcia/ds.h> |
| 37 | |
| 38 | #include "cm4040_cs.h" |
| 39 | |
| 40 | |
Dominik Brodowski | dd2e5a1 | 2009-11-03 10:27:34 +0100 | [diff] [blame] | 41 | #define reader_to_dev(x) (&x->p_dev->dev) |
Dominik Brodowski | cbf624f | 2009-10-24 15:47:29 +0200 | [diff] [blame] | 42 | |
| 43 | /* n (debug level) is ignored */ |
| 44 | /* additional debug output may be enabled by re-compiling with |
| 45 | * CM4040_DEBUG set */ |
| 46 | /* #define CM4040_DEBUG */ |
| 47 | #define DEBUGP(n, rdr, x, args...) do { \ |
| 48 | dev_dbg(reader_to_dev(rdr), "%s:" x, \ |
| 49 | __func__ , ## args); \ |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 50 | } while (0) |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 51 | |
| 52 | static char *version = |
Harald Welte | 67bc620 | 2006-02-14 09:21:26 +0100 | [diff] [blame] | 53 | "OMNIKEY CardMan 4040 v1.1.0gm5 - All bugs added by Harald Welte"; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 54 | |
| 55 | #define CCID_DRIVER_BULK_DEFAULT_TIMEOUT (150*HZ) |
| 56 | #define CCID_DRIVER_ASYNC_POWERUP_TIMEOUT (35*HZ) |
| 57 | #define CCID_DRIVER_MINIMUM_TIMEOUT (3*HZ) |
| 58 | #define READ_WRITE_BUFFER_SIZE 512 |
| 59 | #define POLL_LOOP_COUNT 1000 |
| 60 | |
| 61 | /* how often to poll for fifo status change */ |
| 62 | #define POLL_PERIOD msecs_to_jiffies(10) |
| 63 | |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 64 | static void reader_release(struct pcmcia_device *link); |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 65 | |
| 66 | static int major; |
Harald Welte | 67bc620 | 2006-02-14 09:21:26 +0100 | [diff] [blame] | 67 | static struct class *cmx_class; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 68 | |
| 69 | #define BS_READABLE 0x01 |
| 70 | #define BS_WRITABLE 0x02 |
| 71 | |
| 72 | struct reader_dev { |
Dominik Brodowski | fd23823 | 2006-03-05 10:45:09 +0100 | [diff] [blame] | 73 | struct pcmcia_device *p_dev; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 74 | wait_queue_head_t devq; |
| 75 | wait_queue_head_t poll_wait; |
| 76 | wait_queue_head_t read_wait; |
| 77 | wait_queue_head_t write_wait; |
| 78 | unsigned long buffer_status; |
| 79 | unsigned long timeout; |
| 80 | unsigned char s_buf[READ_WRITE_BUFFER_SIZE]; |
| 81 | unsigned char r_buf[READ_WRITE_BUFFER_SIZE]; |
| 82 | struct timer_list poll_timer; |
| 83 | }; |
| 84 | |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 85 | static struct pcmcia_device *dev_table[CM_MAX_DEV]; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 86 | |
Dominik Brodowski | cbf624f | 2009-10-24 15:47:29 +0200 | [diff] [blame] | 87 | #ifndef CM4040_DEBUG |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 88 | #define xoutb outb |
| 89 | #define xinb inb |
| 90 | #else |
| 91 | static inline void xoutb(unsigned char val, unsigned short port) |
| 92 | { |
Dominik Brodowski | cbf624f | 2009-10-24 15:47:29 +0200 | [diff] [blame] | 93 | pr_debug("outb(val=%.2x,port=%.4x)\n", val, port); |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 94 | outb(val, port); |
| 95 | } |
| 96 | |
| 97 | static inline unsigned char xinb(unsigned short port) |
| 98 | { |
| 99 | unsigned char val; |
| 100 | |
| 101 | val = inb(port); |
Dominik Brodowski | cbf624f | 2009-10-24 15:47:29 +0200 | [diff] [blame] | 102 | pr_debug("%.2x=inb(%.4x)\n", val, port); |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 103 | return val; |
| 104 | } |
| 105 | #endif |
| 106 | |
| 107 | /* poll the device fifo status register. not to be confused with |
| 108 | * the poll syscall. */ |
| 109 | static void cm4040_do_poll(unsigned long dummy) |
| 110 | { |
| 111 | struct reader_dev *dev = (struct reader_dev *) dummy; |
Dominik Brodowski | 9a017a9 | 2010-07-24 15:58:54 +0200 | [diff] [blame^] | 112 | unsigned int obs = xinb(dev->p_dev->resource[0]->start |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 113 | + REG_OFFSET_BUFFER_STATUS); |
| 114 | |
| 115 | if ((obs & BSR_BULK_IN_FULL)) { |
| 116 | set_bit(BS_READABLE, &dev->buffer_status); |
| 117 | DEBUGP(4, dev, "waking up read_wait\n"); |
| 118 | wake_up_interruptible(&dev->read_wait); |
| 119 | } else |
| 120 | clear_bit(BS_READABLE, &dev->buffer_status); |
| 121 | |
| 122 | if (!(obs & BSR_BULK_OUT_FULL)) { |
| 123 | set_bit(BS_WRITABLE, &dev->buffer_status); |
| 124 | DEBUGP(4, dev, "waking up write_wait\n"); |
| 125 | wake_up_interruptible(&dev->write_wait); |
| 126 | } else |
| 127 | clear_bit(BS_WRITABLE, &dev->buffer_status); |
| 128 | |
| 129 | if (dev->buffer_status) |
| 130 | wake_up_interruptible(&dev->poll_wait); |
| 131 | |
| 132 | mod_timer(&dev->poll_timer, jiffies + POLL_PERIOD); |
| 133 | } |
| 134 | |
| 135 | static void cm4040_stop_poll(struct reader_dev *dev) |
| 136 | { |
| 137 | del_timer_sync(&dev->poll_timer); |
| 138 | } |
| 139 | |
| 140 | static int wait_for_bulk_out_ready(struct reader_dev *dev) |
| 141 | { |
| 142 | int i, rc; |
Dominik Brodowski | 9a017a9 | 2010-07-24 15:58:54 +0200 | [diff] [blame^] | 143 | int iobase = dev->p_dev->resource[0]->start; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 144 | |
| 145 | for (i = 0; i < POLL_LOOP_COUNT; i++) { |
| 146 | if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS) |
| 147 | & BSR_BULK_OUT_FULL) == 0) { |
| 148 | DEBUGP(4, dev, "BulkOut empty (i=%d)\n", i); |
| 149 | return 1; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | DEBUGP(4, dev, "wait_event_interruptible_timeout(timeout=%ld\n", |
| 154 | dev->timeout); |
| 155 | rc = wait_event_interruptible_timeout(dev->write_wait, |
| 156 | test_and_clear_bit(BS_WRITABLE, |
| 157 | &dev->buffer_status), |
| 158 | dev->timeout); |
| 159 | |
| 160 | if (rc > 0) |
| 161 | DEBUGP(4, dev, "woke up: BulkOut empty\n"); |
| 162 | else if (rc == 0) |
| 163 | DEBUGP(4, dev, "woke up: BulkOut full, returning 0 :(\n"); |
| 164 | else if (rc < 0) |
| 165 | DEBUGP(4, dev, "woke up: signal arrived\n"); |
| 166 | |
| 167 | return rc; |
| 168 | } |
| 169 | |
| 170 | /* Write to Sync Control Register */ |
| 171 | static int write_sync_reg(unsigned char val, struct reader_dev *dev) |
| 172 | { |
Dominik Brodowski | 9a017a9 | 2010-07-24 15:58:54 +0200 | [diff] [blame^] | 173 | int iobase = dev->p_dev->resource[0]->start; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 174 | int rc; |
| 175 | |
| 176 | rc = wait_for_bulk_out_ready(dev); |
| 177 | if (rc <= 0) |
| 178 | return rc; |
| 179 | |
| 180 | xoutb(val, iobase + REG_OFFSET_SYNC_CONTROL); |
| 181 | rc = wait_for_bulk_out_ready(dev); |
| 182 | if (rc <= 0) |
| 183 | return rc; |
| 184 | |
| 185 | return 1; |
| 186 | } |
| 187 | |
| 188 | static int wait_for_bulk_in_ready(struct reader_dev *dev) |
| 189 | { |
| 190 | int i, rc; |
Dominik Brodowski | 9a017a9 | 2010-07-24 15:58:54 +0200 | [diff] [blame^] | 191 | int iobase = dev->p_dev->resource[0]->start; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 192 | |
| 193 | for (i = 0; i < POLL_LOOP_COUNT; i++) { |
| 194 | if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS) |
| 195 | & BSR_BULK_IN_FULL) == BSR_BULK_IN_FULL) { |
| 196 | DEBUGP(3, dev, "BulkIn full (i=%d)\n", i); |
| 197 | return 1; |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | DEBUGP(4, dev, "wait_event_interruptible_timeout(timeout=%ld\n", |
| 202 | dev->timeout); |
| 203 | rc = wait_event_interruptible_timeout(dev->read_wait, |
| 204 | test_and_clear_bit(BS_READABLE, |
| 205 | &dev->buffer_status), |
| 206 | dev->timeout); |
| 207 | if (rc > 0) |
| 208 | DEBUGP(4, dev, "woke up: BulkIn full\n"); |
| 209 | else if (rc == 0) |
| 210 | DEBUGP(4, dev, "woke up: BulkIn not full, returning 0 :(\n"); |
| 211 | else if (rc < 0) |
| 212 | DEBUGP(4, dev, "woke up: signal arrived\n"); |
| 213 | |
| 214 | return rc; |
| 215 | } |
| 216 | |
| 217 | static ssize_t cm4040_read(struct file *filp, char __user *buf, |
| 218 | size_t count, loff_t *ppos) |
| 219 | { |
| 220 | struct reader_dev *dev = filp->private_data; |
Dominik Brodowski | 9a017a9 | 2010-07-24 15:58:54 +0200 | [diff] [blame^] | 221 | int iobase = dev->p_dev->resource[0]->start; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 222 | size_t bytes_to_read; |
| 223 | unsigned long i; |
| 224 | size_t min_bytes_to_read; |
| 225 | int rc; |
| 226 | unsigned char uc; |
| 227 | |
| 228 | DEBUGP(2, dev, "-> cm4040_read(%s,%d)\n", current->comm, current->pid); |
| 229 | |
| 230 | if (count == 0) |
| 231 | return 0; |
| 232 | |
| 233 | if (count < 10) |
| 234 | return -EFAULT; |
| 235 | |
| 236 | if (filp->f_flags & O_NONBLOCK) { |
| 237 | DEBUGP(4, dev, "filep->f_flags O_NONBLOCK set\n"); |
| 238 | DEBUGP(2, dev, "<- cm4040_read (failure)\n"); |
| 239 | return -EAGAIN; |
| 240 | } |
| 241 | |
Dominik Brodowski | e2d4096 | 2006-03-02 00:09:29 +0100 | [diff] [blame] | 242 | if (!pcmcia_dev_present(dev->p_dev)) |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 243 | return -ENODEV; |
| 244 | |
| 245 | for (i = 0; i < 5; i++) { |
| 246 | rc = wait_for_bulk_in_ready(dev); |
| 247 | if (rc <= 0) { |
| 248 | DEBUGP(5, dev, "wait_for_bulk_in_ready rc=%.2x\n", rc); |
| 249 | DEBUGP(2, dev, "<- cm4040_read (failed)\n"); |
| 250 | if (rc == -ERESTARTSYS) |
| 251 | return rc; |
| 252 | return -EIO; |
| 253 | } |
| 254 | dev->r_buf[i] = xinb(iobase + REG_OFFSET_BULK_IN); |
Dominik Brodowski | cbf624f | 2009-10-24 15:47:29 +0200 | [diff] [blame] | 255 | #ifdef CM4040_DEBUG |
| 256 | pr_debug("%lu:%2x ", i, dev->r_buf[i]); |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 257 | } |
Dominik Brodowski | cbf624f | 2009-10-24 15:47:29 +0200 | [diff] [blame] | 258 | pr_debug("\n"); |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 259 | #else |
| 260 | } |
| 261 | #endif |
| 262 | |
| 263 | bytes_to_read = 5 + le32_to_cpu(*(__le32 *)&dev->r_buf[1]); |
| 264 | |
Randy Dunlap | e657ea1 | 2009-11-11 09:31:07 -0800 | [diff] [blame] | 265 | DEBUGP(6, dev, "BytesToRead=%zu\n", bytes_to_read); |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 266 | |
| 267 | min_bytes_to_read = min(count, bytes_to_read + 5); |
Marcel Holtmann | 059819a | 2007-03-06 22:12:00 +0100 | [diff] [blame] | 268 | min_bytes_to_read = min_t(size_t, min_bytes_to_read, READ_WRITE_BUFFER_SIZE); |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 269 | |
Randy Dunlap | e657ea1 | 2009-11-11 09:31:07 -0800 | [diff] [blame] | 270 | DEBUGP(6, dev, "Min=%zu\n", min_bytes_to_read); |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 271 | |
| 272 | for (i = 0; i < (min_bytes_to_read-5); i++) { |
| 273 | rc = wait_for_bulk_in_ready(dev); |
| 274 | if (rc <= 0) { |
| 275 | DEBUGP(5, dev, "wait_for_bulk_in_ready rc=%.2x\n", rc); |
| 276 | DEBUGP(2, dev, "<- cm4040_read (failed)\n"); |
| 277 | if (rc == -ERESTARTSYS) |
| 278 | return rc; |
| 279 | return -EIO; |
| 280 | } |
| 281 | dev->r_buf[i+5] = xinb(iobase + REG_OFFSET_BULK_IN); |
Dominik Brodowski | cbf624f | 2009-10-24 15:47:29 +0200 | [diff] [blame] | 282 | #ifdef CM4040_DEBUG |
| 283 | pr_debug("%lu:%2x ", i, dev->r_buf[i]); |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 284 | } |
Dominik Brodowski | cbf624f | 2009-10-24 15:47:29 +0200 | [diff] [blame] | 285 | pr_debug("\n"); |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 286 | #else |
| 287 | } |
| 288 | #endif |
| 289 | |
| 290 | *ppos = min_bytes_to_read; |
| 291 | if (copy_to_user(buf, dev->r_buf, min_bytes_to_read)) |
| 292 | return -EFAULT; |
| 293 | |
| 294 | rc = wait_for_bulk_in_ready(dev); |
| 295 | if (rc <= 0) { |
| 296 | DEBUGP(5, dev, "wait_for_bulk_in_ready rc=%.2x\n", rc); |
| 297 | DEBUGP(2, dev, "<- cm4040_read (failed)\n"); |
| 298 | if (rc == -ERESTARTSYS) |
| 299 | return rc; |
| 300 | return -EIO; |
| 301 | } |
| 302 | |
| 303 | rc = write_sync_reg(SCR_READER_TO_HOST_DONE, dev); |
| 304 | if (rc <= 0) { |
| 305 | DEBUGP(5, dev, "write_sync_reg c=%.2x\n", rc); |
| 306 | DEBUGP(2, dev, "<- cm4040_read (failed)\n"); |
| 307 | if (rc == -ERESTARTSYS) |
| 308 | return rc; |
| 309 | else |
| 310 | return -EIO; |
| 311 | } |
| 312 | |
| 313 | uc = xinb(iobase + REG_OFFSET_BULK_IN); |
| 314 | |
| 315 | DEBUGP(2, dev, "<- cm4040_read (successfully)\n"); |
| 316 | return min_bytes_to_read; |
| 317 | } |
| 318 | |
| 319 | static ssize_t cm4040_write(struct file *filp, const char __user *buf, |
| 320 | size_t count, loff_t *ppos) |
| 321 | { |
| 322 | struct reader_dev *dev = filp->private_data; |
Dominik Brodowski | 9a017a9 | 2010-07-24 15:58:54 +0200 | [diff] [blame^] | 323 | int iobase = dev->p_dev->resource[0]->start; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 324 | ssize_t rc; |
| 325 | int i; |
| 326 | unsigned int bytes_to_write; |
| 327 | |
| 328 | DEBUGP(2, dev, "-> cm4040_write(%s,%d)\n", current->comm, current->pid); |
| 329 | |
| 330 | if (count == 0) { |
| 331 | DEBUGP(2, dev, "<- cm4040_write empty read (successfully)\n"); |
| 332 | return 0; |
| 333 | } |
| 334 | |
Marcel Holtmann | 059819a | 2007-03-06 22:12:00 +0100 | [diff] [blame] | 335 | if ((count < 5) || (count > READ_WRITE_BUFFER_SIZE)) { |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 336 | DEBUGP(2, dev, "<- cm4040_write buffersize=%Zd < 5\n", count); |
| 337 | return -EIO; |
| 338 | } |
| 339 | |
| 340 | if (filp->f_flags & O_NONBLOCK) { |
| 341 | DEBUGP(4, dev, "filep->f_flags O_NONBLOCK set\n"); |
| 342 | DEBUGP(4, dev, "<- cm4040_write (failure)\n"); |
| 343 | return -EAGAIN; |
| 344 | } |
| 345 | |
Dominik Brodowski | e2d4096 | 2006-03-02 00:09:29 +0100 | [diff] [blame] | 346 | if (!pcmcia_dev_present(dev->p_dev)) |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 347 | return -ENODEV; |
| 348 | |
| 349 | bytes_to_write = count; |
| 350 | if (copy_from_user(dev->s_buf, buf, bytes_to_write)) |
| 351 | return -EFAULT; |
| 352 | |
| 353 | switch (dev->s_buf[0]) { |
| 354 | case CMD_PC_TO_RDR_XFRBLOCK: |
| 355 | case CMD_PC_TO_RDR_SECURE: |
| 356 | case CMD_PC_TO_RDR_TEST_SECURE: |
| 357 | case CMD_PC_TO_RDR_OK_SECURE: |
| 358 | dev->timeout = CCID_DRIVER_BULK_DEFAULT_TIMEOUT; |
| 359 | break; |
| 360 | |
| 361 | case CMD_PC_TO_RDR_ICCPOWERON: |
| 362 | dev->timeout = CCID_DRIVER_ASYNC_POWERUP_TIMEOUT; |
| 363 | break; |
| 364 | |
| 365 | case CMD_PC_TO_RDR_GETSLOTSTATUS: |
| 366 | case CMD_PC_TO_RDR_ICCPOWEROFF: |
| 367 | case CMD_PC_TO_RDR_GETPARAMETERS: |
| 368 | case CMD_PC_TO_RDR_RESETPARAMETERS: |
| 369 | case CMD_PC_TO_RDR_SETPARAMETERS: |
| 370 | case CMD_PC_TO_RDR_ESCAPE: |
| 371 | case CMD_PC_TO_RDR_ICCCLOCK: |
| 372 | default: |
| 373 | dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT; |
| 374 | break; |
| 375 | } |
| 376 | |
| 377 | rc = write_sync_reg(SCR_HOST_TO_READER_START, dev); |
| 378 | if (rc <= 0) { |
| 379 | DEBUGP(5, dev, "write_sync_reg c=%.2Zx\n", rc); |
| 380 | DEBUGP(2, dev, "<- cm4040_write (failed)\n"); |
| 381 | if (rc == -ERESTARTSYS) |
| 382 | return rc; |
| 383 | else |
| 384 | return -EIO; |
| 385 | } |
| 386 | |
| 387 | DEBUGP(4, dev, "start \n"); |
| 388 | |
| 389 | for (i = 0; i < bytes_to_write; i++) { |
| 390 | rc = wait_for_bulk_out_ready(dev); |
| 391 | if (rc <= 0) { |
| 392 | DEBUGP(5, dev, "wait_for_bulk_out_ready rc=%.2Zx\n", |
| 393 | rc); |
| 394 | DEBUGP(2, dev, "<- cm4040_write (failed)\n"); |
| 395 | if (rc == -ERESTARTSYS) |
| 396 | return rc; |
| 397 | else |
| 398 | return -EIO; |
| 399 | } |
| 400 | |
| 401 | xoutb(dev->s_buf[i],iobase + REG_OFFSET_BULK_OUT); |
| 402 | } |
| 403 | DEBUGP(4, dev, "end\n"); |
| 404 | |
| 405 | rc = write_sync_reg(SCR_HOST_TO_READER_DONE, dev); |
| 406 | |
| 407 | if (rc <= 0) { |
| 408 | DEBUGP(5, dev, "write_sync_reg c=%.2Zx\n", rc); |
| 409 | DEBUGP(2, dev, "<- cm4040_write (failed)\n"); |
| 410 | if (rc == -ERESTARTSYS) |
| 411 | return rc; |
| 412 | else |
| 413 | return -EIO; |
| 414 | } |
| 415 | |
| 416 | DEBUGP(2, dev, "<- cm4040_write (successfully)\n"); |
| 417 | return count; |
| 418 | } |
| 419 | |
| 420 | static unsigned int cm4040_poll(struct file *filp, poll_table *wait) |
| 421 | { |
| 422 | struct reader_dev *dev = filp->private_data; |
| 423 | unsigned int mask = 0; |
| 424 | |
| 425 | poll_wait(filp, &dev->poll_wait, wait); |
| 426 | |
| 427 | if (test_and_clear_bit(BS_READABLE, &dev->buffer_status)) |
| 428 | mask |= POLLIN | POLLRDNORM; |
| 429 | if (test_and_clear_bit(BS_WRITABLE, &dev->buffer_status)) |
| 430 | mask |= POLLOUT | POLLWRNORM; |
| 431 | |
| 432 | DEBUGP(2, dev, "<- cm4040_poll(%u)\n", mask); |
| 433 | |
| 434 | return mask; |
| 435 | } |
| 436 | |
| 437 | static int cm4040_open(struct inode *inode, struct file *filp) |
| 438 | { |
| 439 | struct reader_dev *dev; |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 440 | struct pcmcia_device *link; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 441 | int minor = iminor(inode); |
Jonathan Corbet | 8b5332f | 2008-06-19 14:34:41 -0600 | [diff] [blame] | 442 | int ret; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 443 | |
| 444 | if (minor >= CM_MAX_DEV) |
| 445 | return -ENODEV; |
| 446 | |
Jonathan Corbet | 8b5332f | 2008-06-19 14:34:41 -0600 | [diff] [blame] | 447 | lock_kernel(); |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 448 | link = dev_table[minor]; |
Jonathan Corbet | 8b5332f | 2008-06-19 14:34:41 -0600 | [diff] [blame] | 449 | if (link == NULL || !pcmcia_dev_present(link)) { |
| 450 | ret = -ENODEV; |
| 451 | goto out; |
| 452 | } |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 453 | |
Jonathan Corbet | 8b5332f | 2008-06-19 14:34:41 -0600 | [diff] [blame] | 454 | if (link->open) { |
| 455 | ret = -EBUSY; |
| 456 | goto out; |
| 457 | } |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 458 | |
| 459 | dev = link->priv; |
| 460 | filp->private_data = dev; |
| 461 | |
| 462 | if (filp->f_flags & O_NONBLOCK) { |
| 463 | DEBUGP(4, dev, "filep->f_flags O_NONBLOCK set\n"); |
Jonathan Corbet | 8b5332f | 2008-06-19 14:34:41 -0600 | [diff] [blame] | 464 | ret = -EAGAIN; |
| 465 | goto out; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | link->open = 1; |
| 469 | |
| 470 | dev->poll_timer.data = (unsigned long) dev; |
| 471 | mod_timer(&dev->poll_timer, jiffies + POLL_PERIOD); |
| 472 | |
| 473 | DEBUGP(2, dev, "<- cm4040_open (successfully)\n"); |
Jonathan Corbet | 8b5332f | 2008-06-19 14:34:41 -0600 | [diff] [blame] | 474 | ret = nonseekable_open(inode, filp); |
| 475 | out: |
| 476 | unlock_kernel(); |
| 477 | return ret; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | static int cm4040_close(struct inode *inode, struct file *filp) |
| 481 | { |
| 482 | struct reader_dev *dev = filp->private_data; |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 483 | struct pcmcia_device *link; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 484 | int minor = iminor(inode); |
| 485 | |
| 486 | DEBUGP(2, dev, "-> cm4040_close(maj/min=%d.%d)\n", imajor(inode), |
| 487 | iminor(inode)); |
| 488 | |
| 489 | if (minor >= CM_MAX_DEV) |
| 490 | return -ENODEV; |
| 491 | |
| 492 | link = dev_table[minor]; |
| 493 | if (link == NULL) |
| 494 | return -ENODEV; |
| 495 | |
| 496 | cm4040_stop_poll(dev); |
| 497 | |
| 498 | link->open = 0; |
| 499 | wake_up(&dev->devq); |
| 500 | |
| 501 | DEBUGP(2, dev, "<- cm4040_close\n"); |
| 502 | return 0; |
| 503 | } |
| 504 | |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 505 | static void cm4040_reader_release(struct pcmcia_device *link) |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 506 | { |
| 507 | struct reader_dev *dev = link->priv; |
| 508 | |
| 509 | DEBUGP(3, dev, "-> cm4040_reader_release\n"); |
| 510 | while (link->open) { |
| 511 | DEBUGP(3, dev, KERN_INFO MODULE_NAME ": delaying release " |
| 512 | "until process has terminated\n"); |
| 513 | wait_event(dev->devq, (link->open == 0)); |
| 514 | } |
| 515 | DEBUGP(3, dev, "<- cm4040_reader_release\n"); |
| 516 | return; |
| 517 | } |
| 518 | |
Dominik Brodowski | 84e2d34 | 2008-07-29 08:38:55 +0200 | [diff] [blame] | 519 | static int cm4040_config_check(struct pcmcia_device *p_dev, |
| 520 | cistpl_cftable_entry_t *cfg, |
Dominik Brodowski | 8e2fc39 | 2008-08-02 15:30:31 +0200 | [diff] [blame] | 521 | cistpl_cftable_entry_t *dflt, |
Dominik Brodowski | ad913c1 | 2008-08-02 16:12:00 +0200 | [diff] [blame] | 522 | unsigned int vcc, |
Dominik Brodowski | 84e2d34 | 2008-07-29 08:38:55 +0200 | [diff] [blame] | 523 | void *priv_data) |
| 524 | { |
| 525 | int rc; |
Dominik Brodowski | 84e2d34 | 2008-07-29 08:38:55 +0200 | [diff] [blame] | 526 | if (!cfg->io.nwin) |
| 527 | return -ENODEV; |
| 528 | |
| 529 | /* Get the IOaddr */ |
| 530 | p_dev->io.BasePort1 = cfg->io.win[0].base; |
| 531 | p_dev->io.NumPorts1 = cfg->io.win[0].len; |
| 532 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; |
| 533 | if (!(cfg->io.flags & CISTPL_IO_8BIT)) |
| 534 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_16; |
| 535 | if (!(cfg->io.flags & CISTPL_IO_16BIT)) |
| 536 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; |
| 537 | p_dev->io.IOAddrLines = cfg->io.flags & CISTPL_IO_LINES_MASK; |
| 538 | |
| 539 | rc = pcmcia_request_io(p_dev, &p_dev->io); |
Dominik Brodowski | dd2e5a1 | 2009-11-03 10:27:34 +0100 | [diff] [blame] | 540 | dev_printk(KERN_INFO, &p_dev->dev, |
Dominik Brodowski | 84e2d34 | 2008-07-29 08:38:55 +0200 | [diff] [blame] | 541 | "pcmcia_request_io returned 0x%x\n", rc); |
| 542 | return rc; |
| 543 | } |
| 544 | |
| 545 | |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 546 | static int reader_config(struct pcmcia_device *link, int devno) |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 547 | { |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 548 | struct reader_dev *dev; |
Dominik Brodowski | 84e2d34 | 2008-07-29 08:38:55 +0200 | [diff] [blame] | 549 | int fail_rc; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 550 | |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 551 | link->io.BasePort2 = 0; |
| 552 | link->io.NumPorts2 = 0; |
| 553 | link->io.Attributes2 = 0; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 554 | |
Dominik Brodowski | 84e2d34 | 2008-07-29 08:38:55 +0200 | [diff] [blame] | 555 | if (pcmcia_loop_config(link, cm4040_config_check, NULL)) |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 556 | goto cs_release; |
| 557 | |
| 558 | link->conf.IntType = 00000002; |
| 559 | |
Dominik Brodowski | 4c89e88 | 2008-08-03 10:07:45 +0200 | [diff] [blame] | 560 | fail_rc = pcmcia_request_configuration(link, &link->conf); |
| 561 | if (fail_rc != 0) { |
Dominik Brodowski | dd2e5a1 | 2009-11-03 10:27:34 +0100 | [diff] [blame] | 562 | dev_printk(KERN_INFO, &link->dev, |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 563 | "pcmcia_request_configuration failed 0x%x\n", |
| 564 | fail_rc); |
| 565 | goto cs_release; |
| 566 | } |
| 567 | |
| 568 | dev = link->priv; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 569 | |
Dominik Brodowski | 9a017a9 | 2010-07-24 15:58:54 +0200 | [diff] [blame^] | 570 | DEBUGP(2, dev, "device " DEVICE_NAME "%d at %pR\n", devno, |
| 571 | link->resource[0]); |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 572 | DEBUGP(2, dev, "<- reader_config (succ)\n"); |
| 573 | |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 574 | return 0; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 575 | |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 576 | cs_release: |
| 577 | reader_release(link); |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 578 | return -ENODEV; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 579 | } |
| 580 | |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 581 | static void reader_release(struct pcmcia_device *link) |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 582 | { |
Daniel Ritz | 925796e | 2007-08-10 13:00:58 -0700 | [diff] [blame] | 583 | cm4040_reader_release(link); |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 584 | pcmcia_disable_device(link); |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 585 | } |
| 586 | |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 587 | static int reader_probe(struct pcmcia_device *link) |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 588 | { |
| 589 | struct reader_dev *dev; |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 590 | int i, ret; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 591 | |
| 592 | for (i = 0; i < CM_MAX_DEV; i++) { |
| 593 | if (dev_table[i] == NULL) |
| 594 | break; |
| 595 | } |
| 596 | |
| 597 | if (i == CM_MAX_DEV) |
Dominik Brodowski | f8cfa61 | 2005-11-14 21:25:51 +0100 | [diff] [blame] | 598 | return -ENODEV; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 599 | |
| 600 | dev = kzalloc(sizeof(struct reader_dev), GFP_KERNEL); |
| 601 | if (dev == NULL) |
Dominik Brodowski | f8cfa61 | 2005-11-14 21:25:51 +0100 | [diff] [blame] | 602 | return -ENOMEM; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 603 | |
| 604 | dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT; |
| 605 | dev->buffer_status = 0; |
| 606 | |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 607 | link->priv = dev; |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 608 | dev->p_dev = link; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 609 | |
| 610 | link->conf.IntType = INT_MEMORY_AND_IO; |
| 611 | dev_table[i] = link; |
| 612 | |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 613 | init_waitqueue_head(&dev->devq); |
| 614 | init_waitqueue_head(&dev->poll_wait); |
| 615 | init_waitqueue_head(&dev->read_wait); |
| 616 | init_waitqueue_head(&dev->write_wait); |
Jiri Slaby | 40565f1 | 2007-02-12 00:52:31 -0800 | [diff] [blame] | 617 | setup_timer(&dev->poll_timer, cm4040_do_poll, 0); |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 618 | |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 619 | ret = reader_config(link, i); |
Akinobu Mita | 54493c1 | 2007-05-09 02:33:31 -0700 | [diff] [blame] | 620 | if (ret) { |
| 621 | dev_table[i] = NULL; |
| 622 | kfree(dev); |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 623 | return ret; |
Akinobu Mita | 54493c1 | 2007-05-09 02:33:31 -0700 | [diff] [blame] | 624 | } |
Dominik Brodowski | f8cfa61 | 2005-11-14 21:25:51 +0100 | [diff] [blame] | 625 | |
Greg Kroah-Hartman | 03457cd | 2008-07-21 20:03:34 -0700 | [diff] [blame] | 626 | device_create(cmx_class, NULL, MKDEV(major, i), NULL, "cmx%d", i); |
Harald Welte | 67bc620 | 2006-02-14 09:21:26 +0100 | [diff] [blame] | 627 | |
Dominik Brodowski | f8cfa61 | 2005-11-14 21:25:51 +0100 | [diff] [blame] | 628 | return 0; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 629 | } |
| 630 | |
Dominik Brodowski | fba395e | 2006-03-31 17:21:06 +0200 | [diff] [blame] | 631 | static void reader_detach(struct pcmcia_device *link) |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 632 | { |
| 633 | struct reader_dev *dev = link->priv; |
Dominik Brodowski | cc3b486 | 2005-11-14 21:23:14 +0100 | [diff] [blame] | 634 | int devno; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 635 | |
| 636 | /* find device */ |
Dominik Brodowski | cc3b486 | 2005-11-14 21:23:14 +0100 | [diff] [blame] | 637 | for (devno = 0; devno < CM_MAX_DEV; devno++) { |
| 638 | if (dev_table[devno] == link) |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 639 | break; |
| 640 | } |
Dominik Brodowski | cc3b486 | 2005-11-14 21:23:14 +0100 | [diff] [blame] | 641 | if (devno == CM_MAX_DEV) |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 642 | return; |
| 643 | |
Dominik Brodowski | e2d4096 | 2006-03-02 00:09:29 +0100 | [diff] [blame] | 644 | reader_release(link); |
Dominik Brodowski | cc3b486 | 2005-11-14 21:23:14 +0100 | [diff] [blame] | 645 | |
| 646 | dev_table[devno] = NULL; |
| 647 | kfree(dev); |
| 648 | |
tonyj@suse.de | 07c015e | 2007-08-07 22:28:44 -0700 | [diff] [blame] | 649 | device_destroy(cmx_class, MKDEV(major, devno)); |
Harald Welte | 67bc620 | 2006-02-14 09:21:26 +0100 | [diff] [blame] | 650 | |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 651 | return; |
| 652 | } |
| 653 | |
Arjan van de Ven | 62322d2 | 2006-07-03 00:24:21 -0700 | [diff] [blame] | 654 | static const struct file_operations reader_fops = { |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 655 | .owner = THIS_MODULE, |
| 656 | .read = cm4040_read, |
| 657 | .write = cm4040_write, |
| 658 | .open = cm4040_open, |
| 659 | .release = cm4040_close, |
| 660 | .poll = cm4040_poll, |
| 661 | }; |
| 662 | |
| 663 | static struct pcmcia_device_id cm4040_ids[] = { |
| 664 | PCMCIA_DEVICE_MANF_CARD(0x0223, 0x0200), |
| 665 | PCMCIA_DEVICE_PROD_ID12("OMNIKEY", "CardMan 4040", |
| 666 | 0xE32CDD8C, 0x8F23318B), |
| 667 | PCMCIA_DEVICE_NULL, |
| 668 | }; |
| 669 | MODULE_DEVICE_TABLE(pcmcia, cm4040_ids); |
| 670 | |
| 671 | static struct pcmcia_driver reader_driver = { |
| 672 | .owner = THIS_MODULE, |
| 673 | .drv = { |
| 674 | .name = "cm4040_cs", |
| 675 | }, |
Dominik Brodowski | 15b99ac | 2006-03-31 17:26:06 +0200 | [diff] [blame] | 676 | .probe = reader_probe, |
Dominik Brodowski | cc3b486 | 2005-11-14 21:23:14 +0100 | [diff] [blame] | 677 | .remove = reader_detach, |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 678 | .id_table = cm4040_ids, |
| 679 | }; |
| 680 | |
| 681 | static int __init cm4040_init(void) |
| 682 | { |
Harald Welte | 67bc620 | 2006-02-14 09:21:26 +0100 | [diff] [blame] | 683 | int rc; |
| 684 | |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 685 | printk(KERN_INFO "%s\n", version); |
Harald Welte | 67bc620 | 2006-02-14 09:21:26 +0100 | [diff] [blame] | 686 | cmx_class = class_create(THIS_MODULE, "cardman_4040"); |
Akinobu Mita | 5eb5fc9 | 2006-10-17 15:25:59 +0900 | [diff] [blame] | 687 | if (IS_ERR(cmx_class)) |
| 688 | return PTR_ERR(cmx_class); |
Harald Welte | 67bc620 | 2006-02-14 09:21:26 +0100 | [diff] [blame] | 689 | |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 690 | major = register_chrdev(0, DEVICE_NAME, &reader_fops); |
| 691 | if (major < 0) { |
| 692 | printk(KERN_WARNING MODULE_NAME |
| 693 | ": could not get major number\n"); |
Akinobu Mita | 54493c1 | 2007-05-09 02:33:31 -0700 | [diff] [blame] | 694 | class_destroy(cmx_class); |
Akinobu Mita | 5eb5fc9 | 2006-10-17 15:25:59 +0900 | [diff] [blame] | 695 | return major; |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 696 | } |
Harald Welte | 7fc5b1e | 2006-05-10 13:28:52 +0200 | [diff] [blame] | 697 | |
| 698 | rc = pcmcia_register_driver(&reader_driver); |
| 699 | if (rc < 0) { |
| 700 | unregister_chrdev(major, DEVICE_NAME); |
Akinobu Mita | 54493c1 | 2007-05-09 02:33:31 -0700 | [diff] [blame] | 701 | class_destroy(cmx_class); |
Harald Welte | 7fc5b1e | 2006-05-10 13:28:52 +0200 | [diff] [blame] | 702 | return rc; |
| 703 | } |
| 704 | |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 705 | return 0; |
| 706 | } |
| 707 | |
| 708 | static void __exit cm4040_exit(void) |
| 709 | { |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 710 | printk(KERN_INFO MODULE_NAME ": unloading\n"); |
| 711 | pcmcia_unregister_driver(&reader_driver); |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 712 | unregister_chrdev(major, DEVICE_NAME); |
Harald Welte | 67bc620 | 2006-02-14 09:21:26 +0100 | [diff] [blame] | 713 | class_destroy(cmx_class); |
Harald Welte | 77c44ab | 2005-11-13 16:06:26 -0800 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | module_init(cm4040_init); |
| 717 | module_exit(cm4040_exit); |
| 718 | MODULE_LICENSE("Dual BSD/GPL"); |