diff -Nur lirc-0.7.0pre6-orig/drivers/lirc_dev/lirc_dev.c lirc-0.7.0pre6-work/drivers/lirc_dev/lirc_dev.c --- lirc-0.7.0pre6-orig/drivers/lirc_dev/lirc_dev.c 2004-04-08 23:17:46.000000000 +0200 +++ lirc-0.7.0pre6-work/drivers/lirc_dev/lirc_dev.c 2004-07-13 21:36:37.000000000 +0200 @@ -26,14 +26,13 @@ #endif #include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) -#define LIRC_HAVE_DEVFS -#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -#warning "**********************************************************" -#warning "************ disabling devfs for 2.6 kernels *************" -#warning "**********************************************************" -#undef LIRC_HAVE_DEVFS +#define LIRC_HAVE_DEVFS +#define LIRC_HAVE_DEVFS_26 +#define LIRC_HAVE_SYSFS +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) +#define LIRC_HAVE_DEVFS +#define LIRC_HAVE_DEVFS_24 #endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 18) @@ -53,6 +52,9 @@ #ifdef LIRC_HAVE_DEVFS #include #endif +#ifdef LIRC_HAVE_SYSFS +#include +#endif #include #include #include @@ -92,7 +94,7 @@ int shutdown; long jiffies_to_wait; -#ifdef LIRC_HAVE_DEVFS +#ifdef LIRC_HAVE_DEVFS_24 devfs_handle_t devfs_handle; #endif }; @@ -102,6 +104,9 @@ static struct irctl irctls[MAX_IRCTL_DEVICES]; static struct file_operations fops; +#ifdef LIRC_HAVE_SYSFS +static struct class_simple *lirc_class; +#endif /* helper function * initializes the irctl structure @@ -221,7 +226,7 @@ struct irctl *ir; int minor; int bytes_in_key; -#ifdef LIRC_HAVE_DEVFS +#ifdef LIRC_HAVE_DEVFS_24 char name[16]; #endif DECLARE_MUTEX_LOCKED(tn); @@ -326,14 +331,22 @@ ir->p = *p; ir->p.minor = minor; -#ifdef LIRC_HAVE_DEVFS +#ifdef LIRC_HAVE_DEVFS_24 sprintf (name, DEV_LIRC "/%d", ir->p.minor); ir->devfs_handle = devfs_register(NULL, name, DEVFS_FL_DEFAULT, IRCTL_DEV_MAJOR, ir->p.minor, S_IFCHR | S_IRUSR | S_IWUSR, &fops, NULL); #endif - +#ifdef LIRC_HAVE_DEVFS_26 + devfs_mk_cdev(MKDEV(IRCTL_DEV_MAJOR, ir->p.minor), + S_IFCHR|S_IRUSR|S_IWUSR, + DEV_LIRC "/%u", ir->p.minor); +#endif +#ifdef LIRC_HAVE_SYSFS + class_simple_device_add(lirc_class, MKDEV(IRCTL_DEV_MAJOR, ir->p.minor), + NULL, "lirc%u", ir->p.minor); +#endif if(p->sample_rate || p->get_queue) { /* try to fire up polling thread */ ir->t_notify = &tn; @@ -417,9 +430,15 @@ dprintk("lirc_dev: plugin %s unregistered from minor number = %d\n", ir->p.name, ir->p.minor); -#ifdef LIRC_HAVE_DEVFS +#ifdef LIRC_HAVE_DEVFS_24 devfs_unregister(ir->devfs_handle); #endif +#ifdef LIRC_HAVE_DEVFS_26 + devfs_remove(DEV_LIRC "/%u", ir->p.minor); +#endif +#ifdef LIRC_HAVE_SYSFS + class_simple_device_remove(MKDEV(IRCTL_DEV_MAJOR, ir->p.minor)); +#endif if (ir->buf != ir->p.rbuf){ lirc_buffer_free(ir->buf); kfree(ir->buf); @@ -725,14 +744,16 @@ init_irctl(&irctls[i]); } -#ifndef LIRC_HAVE_DEVFS - i = register_chrdev(IRCTL_DEV_MAJOR, +#ifdef LIRC_HAVE_DEVFS_24 + i = devfs_register_chrdev(IRCTL_DEV_MAJOR, IRCTL_DEV_NAME, &fops); #else - i = devfs_register_chrdev(IRCTL_DEV_MAJOR, + i = register_chrdev(IRCTL_DEV_MAJOR, IRCTL_DEV_NAME, &fops); #endif - IRCTL_DEV_NAME, - &fops); - +#ifdef LIRC_HAVE_SYSFS + if (i == 0) + lirc_class = class_simple_create(THIS_MODULE, "lirc"); +#endif + if (i < 0) { printk ("lirc_dev: device registration failed with %d\n", i); return i; @@ -771,12 +792,15 @@ { int ret; -#ifndef LIRC_HAVE_DEVFS - ret = unregister_chrdev(IRCTL_DEV_MAJOR, IRCTL_DEV_NAME); -#else +#ifdef LIRC_HAVE_DEVFS_24 ret = devfs_unregister_chrdev(IRCTL_DEV_MAJOR, IRCTL_DEV_NAME); +#else + ret = unregister_chrdev(IRCTL_DEV_MAJOR, IRCTL_DEV_NAME); #endif - +#ifdef LIRC_HAVE_SYSFS + class_simple_destroy(lirc_class); +#endif + if (0 > ret){ printk("lirc_dev: error in module_unregister_chrdev: %d\n", ret);