sfc: Don't use enums as a bitmask.
[zen-stable.git] / drivers / media / rc / lirc_dev.c
blobfd237ab120bbbd8a3a753b379f3edddb41079f61
1 /*
2 * LIRC base driver
4 * by Artur Lipowski <alipowski@interia.pl>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <linux/module.h>
23 #include <linux/kernel.h>
24 #include <linux/sched.h>
25 #include <linux/errno.h>
26 #include <linux/ioctl.h>
27 #include <linux/fs.h>
28 #include <linux/poll.h>
29 #include <linux/completion.h>
30 #include <linux/mutex.h>
31 #include <linux/wait.h>
32 #include <linux/unistd.h>
33 #include <linux/kthread.h>
34 #include <linux/bitops.h>
35 #include <linux/device.h>
36 #include <linux/cdev.h>
38 #include <media/lirc.h>
39 #include <media/lirc_dev.h>
41 static int debug;
43 #define IRCTL_DEV_NAME "BaseRemoteCtl"
44 #define NOPLUG -1
45 #define LOGHEAD "lirc_dev (%s[%d]): "
47 static dev_t lirc_base_dev;
49 struct irctl {
50 struct lirc_driver d;
51 int attached;
52 int open;
54 struct mutex irctl_lock;
55 struct lirc_buffer *buf;
56 unsigned int chunk_size;
58 struct task_struct *task;
59 long jiffies_to_wait;
62 static DEFINE_MUTEX(lirc_dev_lock);
64 static struct irctl *irctls[MAX_IRCTL_DEVICES];
65 static struct cdev cdevs[MAX_IRCTL_DEVICES];
67 /* Only used for sysfs but defined to void otherwise */
68 static struct class *lirc_class;
70 /* helper function
71 * initializes the irctl structure
73 static void lirc_irctl_init(struct irctl *ir)
75 mutex_init(&ir->irctl_lock);
76 ir->d.minor = NOPLUG;
79 static void lirc_irctl_cleanup(struct irctl *ir)
81 dev_dbg(ir->d.dev, LOGHEAD "cleaning up\n", ir->d.name, ir->d.minor);
83 device_destroy(lirc_class, MKDEV(MAJOR(lirc_base_dev), ir->d.minor));
85 if (ir->buf != ir->d.rbuf) {
86 lirc_buffer_free(ir->buf);
87 kfree(ir->buf);
89 ir->buf = NULL;
92 /* helper function
93 * reads key codes from driver and puts them into buffer
94 * returns 0 on success
96 static int lirc_add_to_buf(struct irctl *ir)
98 if (ir->d.add_to_buf) {
99 int res = -ENODATA;
100 int got_data = 0;
103 * service the device as long as it is returning
104 * data and we have space
106 get_data:
107 res = ir->d.add_to_buf(ir->d.data, ir->buf);
108 if (res == 0) {
109 got_data++;
110 goto get_data;
113 if (res == -ENODEV)
114 kthread_stop(ir->task);
116 return got_data ? 0 : res;
119 return 0;
122 /* main function of the polling thread
124 static int lirc_thread(void *irctl)
126 struct irctl *ir = irctl;
128 dev_dbg(ir->d.dev, LOGHEAD "poll thread started\n",
129 ir->d.name, ir->d.minor);
131 do {
132 if (ir->open) {
133 if (ir->jiffies_to_wait) {
134 set_current_state(TASK_INTERRUPTIBLE);
135 schedule_timeout(ir->jiffies_to_wait);
137 if (kthread_should_stop())
138 break;
139 if (!lirc_add_to_buf(ir))
140 wake_up_interruptible(&ir->buf->wait_poll);
141 } else {
142 set_current_state(TASK_INTERRUPTIBLE);
143 schedule();
145 } while (!kthread_should_stop());
147 dev_dbg(ir->d.dev, LOGHEAD "poll thread ended\n",
148 ir->d.name, ir->d.minor);
150 return 0;
154 static struct file_operations lirc_dev_fops = {
155 .owner = THIS_MODULE,
156 .read = lirc_dev_fop_read,
157 .write = lirc_dev_fop_write,
158 .poll = lirc_dev_fop_poll,
159 .unlocked_ioctl = lirc_dev_fop_ioctl,
160 #ifdef CONFIG_COMPAT
161 .compat_ioctl = lirc_dev_fop_ioctl,
162 #endif
163 .open = lirc_dev_fop_open,
164 .release = lirc_dev_fop_close,
165 .llseek = noop_llseek,
168 static int lirc_cdev_add(struct irctl *ir)
170 int retval;
171 struct lirc_driver *d = &ir->d;
172 struct cdev *cdev = &cdevs[d->minor];
174 if (d->fops) {
175 cdev_init(cdev, d->fops);
176 cdev->owner = d->owner;
177 } else {
178 cdev_init(cdev, &lirc_dev_fops);
179 cdev->owner = THIS_MODULE;
181 retval = kobject_set_name(&cdev->kobj, "lirc%d", d->minor);
182 if (retval)
183 return retval;
185 retval = cdev_add(cdev, MKDEV(MAJOR(lirc_base_dev), d->minor), 1);
186 if (retval)
187 kobject_put(&cdev->kobj);
189 return retval;
192 int lirc_register_driver(struct lirc_driver *d)
194 struct irctl *ir;
195 int minor;
196 int bytes_in_key;
197 unsigned int chunk_size;
198 unsigned int buffer_size;
199 int err;
201 if (!d) {
202 printk(KERN_ERR "lirc_dev: lirc_register_driver: "
203 "driver pointer must be not NULL!\n");
204 err = -EBADRQC;
205 goto out;
208 if (!d->dev) {
209 printk(KERN_ERR "%s: dev pointer not filled in!\n", __func__);
210 err = -EINVAL;
211 goto out;
214 if (MAX_IRCTL_DEVICES <= d->minor) {
215 dev_err(d->dev, "lirc_dev: lirc_register_driver: "
216 "\"minor\" must be between 0 and %d (%d)!\n",
217 MAX_IRCTL_DEVICES-1, d->minor);
218 err = -EBADRQC;
219 goto out;
222 if (1 > d->code_length || (BUFLEN * 8) < d->code_length) {
223 dev_err(d->dev, "lirc_dev: lirc_register_driver: "
224 "code length in bits for minor (%d) "
225 "must be less than %d!\n",
226 d->minor, BUFLEN * 8);
227 err = -EBADRQC;
228 goto out;
231 dev_dbg(d->dev, "lirc_dev: lirc_register_driver: sample_rate: %d\n",
232 d->sample_rate);
233 if (d->sample_rate) {
234 if (2 > d->sample_rate || HZ < d->sample_rate) {
235 dev_err(d->dev, "lirc_dev: lirc_register_driver: "
236 "sample_rate must be between 2 and %d!\n", HZ);
237 err = -EBADRQC;
238 goto out;
240 if (!d->add_to_buf) {
241 dev_err(d->dev, "lirc_dev: lirc_register_driver: "
242 "add_to_buf cannot be NULL when "
243 "sample_rate is set\n");
244 err = -EBADRQC;
245 goto out;
247 } else if (!(d->fops && d->fops->read) && !d->rbuf) {
248 dev_err(d->dev, "lirc_dev: lirc_register_driver: "
249 "fops->read and rbuf cannot all be NULL!\n");
250 err = -EBADRQC;
251 goto out;
252 } else if (!d->rbuf) {
253 if (!(d->fops && d->fops->read && d->fops->poll &&
254 d->fops->unlocked_ioctl)) {
255 dev_err(d->dev, "lirc_dev: lirc_register_driver: "
256 "neither read, poll nor unlocked_ioctl can be NULL!\n");
257 err = -EBADRQC;
258 goto out;
262 mutex_lock(&lirc_dev_lock);
264 minor = d->minor;
266 if (minor < 0) {
267 /* find first free slot for driver */
268 for (minor = 0; minor < MAX_IRCTL_DEVICES; minor++)
269 if (!irctls[minor])
270 break;
271 if (MAX_IRCTL_DEVICES == minor) {
272 dev_err(d->dev, "lirc_dev: lirc_register_driver: "
273 "no free slots for drivers!\n");
274 err = -ENOMEM;
275 goto out_lock;
277 } else if (irctls[minor]) {
278 dev_err(d->dev, "lirc_dev: lirc_register_driver: "
279 "minor (%d) just registered!\n", minor);
280 err = -EBUSY;
281 goto out_lock;
284 ir = kzalloc(sizeof(struct irctl), GFP_KERNEL);
285 if (!ir) {
286 err = -ENOMEM;
287 goto out_lock;
289 lirc_irctl_init(ir);
290 irctls[minor] = ir;
291 d->minor = minor;
293 if (d->sample_rate) {
294 ir->jiffies_to_wait = HZ / d->sample_rate;
295 } else {
296 /* it means - wait for external event in task queue */
297 ir->jiffies_to_wait = 0;
300 /* some safety check 8-) */
301 d->name[sizeof(d->name)-1] = '\0';
303 bytes_in_key = BITS_TO_LONGS(d->code_length) +
304 (d->code_length % 8 ? 1 : 0);
305 buffer_size = d->buffer_size ? d->buffer_size : BUFLEN / bytes_in_key;
306 chunk_size = d->chunk_size ? d->chunk_size : bytes_in_key;
308 if (d->rbuf) {
309 ir->buf = d->rbuf;
310 } else {
311 ir->buf = kmalloc(sizeof(struct lirc_buffer), GFP_KERNEL);
312 if (!ir->buf) {
313 err = -ENOMEM;
314 goto out_lock;
316 err = lirc_buffer_init(ir->buf, chunk_size, buffer_size);
317 if (err) {
318 kfree(ir->buf);
319 goto out_lock;
322 ir->chunk_size = ir->buf->chunk_size;
324 if (d->features == 0)
325 d->features = LIRC_CAN_REC_LIRCCODE;
327 ir->d = *d;
329 device_create(lirc_class, ir->d.dev,
330 MKDEV(MAJOR(lirc_base_dev), ir->d.minor), NULL,
331 "lirc%u", ir->d.minor);
333 if (d->sample_rate) {
334 /* try to fire up polling thread */
335 ir->task = kthread_run(lirc_thread, (void *)ir, "lirc_dev");
336 if (IS_ERR(ir->task)) {
337 dev_err(d->dev, "lirc_dev: lirc_register_driver: "
338 "cannot run poll thread for minor = %d\n",
339 d->minor);
340 err = -ECHILD;
341 goto out_sysfs;
345 err = lirc_cdev_add(ir);
346 if (err)
347 goto out_sysfs;
349 ir->attached = 1;
350 mutex_unlock(&lirc_dev_lock);
352 dev_info(ir->d.dev, "lirc_dev: driver %s registered at minor = %d\n",
353 ir->d.name, ir->d.minor);
354 return minor;
356 out_sysfs:
357 device_destroy(lirc_class, MKDEV(MAJOR(lirc_base_dev), ir->d.minor));
358 out_lock:
359 mutex_unlock(&lirc_dev_lock);
360 out:
361 return err;
363 EXPORT_SYMBOL(lirc_register_driver);
365 int lirc_unregister_driver(int minor)
367 struct irctl *ir;
368 struct cdev *cdev;
370 if (minor < 0 || minor >= MAX_IRCTL_DEVICES) {
371 printk(KERN_ERR "lirc_dev: %s: minor (%d) must be between "
372 "0 and %d!\n", __func__, minor, MAX_IRCTL_DEVICES-1);
373 return -EBADRQC;
376 ir = irctls[minor];
377 if (!ir) {
378 printk(KERN_ERR "lirc_dev: %s: failed to get irctl struct "
379 "for minor %d!\n", __func__, minor);
380 return -ENOENT;
383 cdev = &cdevs[minor];
385 mutex_lock(&lirc_dev_lock);
387 if (ir->d.minor != minor) {
388 printk(KERN_ERR "lirc_dev: %s: minor (%d) device not "
389 "registered!\n", __func__, minor);
390 mutex_unlock(&lirc_dev_lock);
391 return -ENOENT;
394 /* end up polling thread */
395 if (ir->task)
396 kthread_stop(ir->task);
398 dev_dbg(ir->d.dev, "lirc_dev: driver %s unregistered from minor = %d\n",
399 ir->d.name, ir->d.minor);
401 ir->attached = 0;
402 if (ir->open) {
403 dev_dbg(ir->d.dev, LOGHEAD "releasing opened driver\n",
404 ir->d.name, ir->d.minor);
405 wake_up_interruptible(&ir->buf->wait_poll);
406 mutex_lock(&ir->irctl_lock);
407 ir->d.set_use_dec(ir->d.data);
408 module_put(cdev->owner);
409 mutex_unlock(&ir->irctl_lock);
410 } else {
411 lirc_irctl_cleanup(ir);
412 cdev_del(cdev);
413 kfree(ir);
414 irctls[minor] = NULL;
417 mutex_unlock(&lirc_dev_lock);
419 return 0;
421 EXPORT_SYMBOL(lirc_unregister_driver);
423 int lirc_dev_fop_open(struct inode *inode, struct file *file)
425 struct irctl *ir;
426 struct cdev *cdev;
427 int retval = 0;
429 if (iminor(inode) >= MAX_IRCTL_DEVICES) {
430 printk(KERN_WARNING "lirc_dev [%d]: open result = -ENODEV\n",
431 iminor(inode));
432 return -ENODEV;
435 if (mutex_lock_interruptible(&lirc_dev_lock))
436 return -ERESTARTSYS;
438 ir = irctls[iminor(inode)];
439 if (!ir) {
440 retval = -ENODEV;
441 goto error;
444 dev_dbg(ir->d.dev, LOGHEAD "open called\n", ir->d.name, ir->d.minor);
446 if (ir->d.minor == NOPLUG) {
447 retval = -ENODEV;
448 goto error;
451 if (ir->open) {
452 retval = -EBUSY;
453 goto error;
456 cdev = &cdevs[iminor(inode)];
457 if (try_module_get(cdev->owner)) {
458 ir->open++;
459 retval = ir->d.set_use_inc(ir->d.data);
461 if (retval) {
462 module_put(cdev->owner);
463 ir->open--;
464 } else {
465 lirc_buffer_clear(ir->buf);
467 if (ir->task)
468 wake_up_process(ir->task);
471 error:
472 if (ir)
473 dev_dbg(ir->d.dev, LOGHEAD "open result = %d\n",
474 ir->d.name, ir->d.minor, retval);
476 mutex_unlock(&lirc_dev_lock);
478 nonseekable_open(inode, file);
480 return retval;
482 EXPORT_SYMBOL(lirc_dev_fop_open);
484 int lirc_dev_fop_close(struct inode *inode, struct file *file)
486 struct irctl *ir = irctls[iminor(inode)];
487 struct cdev *cdev = &cdevs[iminor(inode)];
489 if (!ir) {
490 printk(KERN_ERR "%s: called with invalid irctl\n", __func__);
491 return -EINVAL;
494 dev_dbg(ir->d.dev, LOGHEAD "close called\n", ir->d.name, ir->d.minor);
496 WARN_ON(mutex_lock_killable(&lirc_dev_lock));
498 ir->open--;
499 if (ir->attached) {
500 ir->d.set_use_dec(ir->d.data);
501 module_put(cdev->owner);
502 } else {
503 lirc_irctl_cleanup(ir);
504 cdev_del(cdev);
505 irctls[ir->d.minor] = NULL;
506 kfree(ir);
509 mutex_unlock(&lirc_dev_lock);
511 return 0;
513 EXPORT_SYMBOL(lirc_dev_fop_close);
515 unsigned int lirc_dev_fop_poll(struct file *file, poll_table *wait)
517 struct irctl *ir = irctls[iminor(file->f_dentry->d_inode)];
518 unsigned int ret;
520 if (!ir) {
521 printk(KERN_ERR "%s: called with invalid irctl\n", __func__);
522 return POLLERR;
525 dev_dbg(ir->d.dev, LOGHEAD "poll called\n", ir->d.name, ir->d.minor);
527 if (!ir->attached)
528 return POLLERR;
530 poll_wait(file, &ir->buf->wait_poll, wait);
532 if (ir->buf)
533 if (lirc_buffer_empty(ir->buf))
534 ret = 0;
535 else
536 ret = POLLIN | POLLRDNORM;
537 else
538 ret = POLLERR;
540 dev_dbg(ir->d.dev, LOGHEAD "poll result = %d\n",
541 ir->d.name, ir->d.minor, ret);
543 return ret;
545 EXPORT_SYMBOL(lirc_dev_fop_poll);
547 long lirc_dev_fop_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
549 __u32 mode;
550 int result = 0;
551 struct irctl *ir = irctls[iminor(file->f_dentry->d_inode)];
553 if (!ir) {
554 printk(KERN_ERR "lirc_dev: %s: no irctl found!\n", __func__);
555 return -ENODEV;
558 dev_dbg(ir->d.dev, LOGHEAD "ioctl called (0x%x)\n",
559 ir->d.name, ir->d.minor, cmd);
561 if (ir->d.minor == NOPLUG || !ir->attached) {
562 dev_dbg(ir->d.dev, LOGHEAD "ioctl result = -ENODEV\n",
563 ir->d.name, ir->d.minor);
564 return -ENODEV;
567 mutex_lock(&ir->irctl_lock);
569 switch (cmd) {
570 case LIRC_GET_FEATURES:
571 result = put_user(ir->d.features, (__u32 *)arg);
572 break;
573 case LIRC_GET_REC_MODE:
574 if (!(ir->d.features & LIRC_CAN_REC_MASK)) {
575 result = -ENOSYS;
576 break;
579 result = put_user(LIRC_REC2MODE
580 (ir->d.features & LIRC_CAN_REC_MASK),
581 (__u32 *)arg);
582 break;
583 case LIRC_SET_REC_MODE:
584 if (!(ir->d.features & LIRC_CAN_REC_MASK)) {
585 result = -ENOSYS;
586 break;
589 result = get_user(mode, (__u32 *)arg);
590 if (!result && !(LIRC_MODE2REC(mode) & ir->d.features))
591 result = -EINVAL;
593 * FIXME: We should actually set the mode somehow but
594 * for now, lirc_serial doesn't support mode changing either
596 break;
597 case LIRC_GET_LENGTH:
598 result = put_user(ir->d.code_length, (__u32 *)arg);
599 break;
600 case LIRC_GET_MIN_TIMEOUT:
601 if (!(ir->d.features & LIRC_CAN_SET_REC_TIMEOUT) ||
602 ir->d.min_timeout == 0) {
603 result = -ENOSYS;
604 break;
607 result = put_user(ir->d.min_timeout, (__u32 *)arg);
608 break;
609 case LIRC_GET_MAX_TIMEOUT:
610 if (!(ir->d.features & LIRC_CAN_SET_REC_TIMEOUT) ||
611 ir->d.max_timeout == 0) {
612 result = -ENOSYS;
613 break;
616 result = put_user(ir->d.max_timeout, (__u32 *)arg);
617 break;
618 default:
619 result = -EINVAL;
622 dev_dbg(ir->d.dev, LOGHEAD "ioctl result = %d\n",
623 ir->d.name, ir->d.minor, result);
625 mutex_unlock(&ir->irctl_lock);
627 return result;
629 EXPORT_SYMBOL(lirc_dev_fop_ioctl);
631 ssize_t lirc_dev_fop_read(struct file *file,
632 char __user *buffer,
633 size_t length,
634 loff_t *ppos)
636 struct irctl *ir = irctls[iminor(file->f_dentry->d_inode)];
637 unsigned char *buf;
638 int ret = 0, written = 0;
639 DECLARE_WAITQUEUE(wait, current);
641 if (!ir) {
642 printk(KERN_ERR "%s: called with invalid irctl\n", __func__);
643 return -ENODEV;
646 dev_dbg(ir->d.dev, LOGHEAD "read called\n", ir->d.name, ir->d.minor);
648 buf = kzalloc(ir->chunk_size, GFP_KERNEL);
649 if (!buf)
650 return -ENOMEM;
652 if (mutex_lock_interruptible(&ir->irctl_lock)) {
653 ret = -ERESTARTSYS;
654 goto out_unlocked;
656 if (!ir->attached) {
657 ret = -ENODEV;
658 goto out_locked;
661 if (length % ir->chunk_size) {
662 ret = -EINVAL;
663 goto out_locked;
667 * we add ourselves to the task queue before buffer check
668 * to avoid losing scan code (in case when queue is awaken somewhere
669 * between while condition checking and scheduling)
671 add_wait_queue(&ir->buf->wait_poll, &wait);
672 set_current_state(TASK_INTERRUPTIBLE);
675 * while we didn't provide 'length' bytes, device is opened in blocking
676 * mode and 'copy_to_user' is happy, wait for data.
678 while (written < length && ret == 0) {
679 if (lirc_buffer_empty(ir->buf)) {
680 /* According to the read(2) man page, 'written' can be
681 * returned as less than 'length', instead of blocking
682 * again, returning -EWOULDBLOCK, or returning
683 * -ERESTARTSYS */
684 if (written)
685 break;
686 if (file->f_flags & O_NONBLOCK) {
687 ret = -EWOULDBLOCK;
688 break;
690 if (signal_pending(current)) {
691 ret = -ERESTARTSYS;
692 break;
695 mutex_unlock(&ir->irctl_lock);
696 schedule();
697 set_current_state(TASK_INTERRUPTIBLE);
699 if (mutex_lock_interruptible(&ir->irctl_lock)) {
700 ret = -ERESTARTSYS;
701 remove_wait_queue(&ir->buf->wait_poll, &wait);
702 set_current_state(TASK_RUNNING);
703 goto out_unlocked;
706 if (!ir->attached) {
707 ret = -ENODEV;
708 break;
710 } else {
711 lirc_buffer_read(ir->buf, buf);
712 ret = copy_to_user((void *)buffer+written, buf,
713 ir->buf->chunk_size);
714 if (!ret)
715 written += ir->buf->chunk_size;
716 else
717 ret = -EFAULT;
721 remove_wait_queue(&ir->buf->wait_poll, &wait);
722 set_current_state(TASK_RUNNING);
724 out_locked:
725 mutex_unlock(&ir->irctl_lock);
727 out_unlocked:
728 kfree(buf);
729 dev_dbg(ir->d.dev, LOGHEAD "read result = %s (%d)\n",
730 ir->d.name, ir->d.minor, ret ? "<fail>" : "<ok>", ret);
732 return ret ? ret : written;
734 EXPORT_SYMBOL(lirc_dev_fop_read);
736 void *lirc_get_pdata(struct file *file)
738 void *data = NULL;
740 if (file && file->f_dentry && file->f_dentry->d_inode &&
741 file->f_dentry->d_inode->i_rdev) {
742 struct irctl *ir;
743 ir = irctls[iminor(file->f_dentry->d_inode)];
744 data = ir->d.data;
747 return data;
749 EXPORT_SYMBOL(lirc_get_pdata);
752 ssize_t lirc_dev_fop_write(struct file *file, const char __user *buffer,
753 size_t length, loff_t *ppos)
755 struct irctl *ir = irctls[iminor(file->f_dentry->d_inode)];
757 if (!ir) {
758 printk(KERN_ERR "%s: called with invalid irctl\n", __func__);
759 return -ENODEV;
762 dev_dbg(ir->d.dev, LOGHEAD "write called\n", ir->d.name, ir->d.minor);
764 if (!ir->attached)
765 return -ENODEV;
767 return -EINVAL;
769 EXPORT_SYMBOL(lirc_dev_fop_write);
772 static int __init lirc_dev_init(void)
774 int retval;
776 lirc_class = class_create(THIS_MODULE, "lirc");
777 if (IS_ERR(lirc_class)) {
778 retval = PTR_ERR(lirc_class);
779 printk(KERN_ERR "lirc_dev: class_create failed\n");
780 goto error;
783 retval = alloc_chrdev_region(&lirc_base_dev, 0, MAX_IRCTL_DEVICES,
784 IRCTL_DEV_NAME);
785 if (retval) {
786 class_destroy(lirc_class);
787 printk(KERN_ERR "lirc_dev: alloc_chrdev_region failed\n");
788 goto error;
792 printk(KERN_INFO "lirc_dev: IR Remote Control driver registered, "
793 "major %d \n", MAJOR(lirc_base_dev));
795 error:
796 return retval;
801 static void __exit lirc_dev_exit(void)
803 class_destroy(lirc_class);
804 unregister_chrdev_region(lirc_base_dev, MAX_IRCTL_DEVICES);
805 printk(KERN_INFO "lirc_dev: module unloaded\n");
808 module_init(lirc_dev_init);
809 module_exit(lirc_dev_exit);
811 MODULE_DESCRIPTION("LIRC base driver module");
812 MODULE_AUTHOR("Artur Lipowski");
813 MODULE_LICENSE("GPL");
815 module_param(debug, bool, S_IRUGO | S_IWUSR);
816 MODULE_PARM_DESC(debug, "Enable debugging messages");