Hi!
And here comes the last of the three major 13 patches - DevFs for input.
Works quite nicely.
--
Vojtech Pavlik
SuSE Labs
diff -urN linux-2.3.99-pre3-old/drivers/usb/evdev.c linux/drivers/usb/evdev.c
--- linux-2.3.99-pre3-old/drivers/usb/evdev.c Wed Mar 29 11:27:25 2000
+++ linux/drivers/usb/evdev.c Wed Mar 29 13:01:02 2000
@@ -43,6 +43,7 @@
int minor;
struct input_handle handle;
wait_queue_head_t wait;
+ devfs_handle_t devfs;
struct evdev_list *list;
};
@@ -99,6 +100,7 @@
*listptr = (*listptr)->next;
if (!--list->evdev->used) {
+ input_unregister_minor(list->evdev->devfs);
evdev_table[list->evdev->minor] = NULL;
kfree(list->evdev);
}
@@ -226,9 +228,9 @@
evdev->used = 1;
input_open_device(&evdev->handle);
+ evdev->devfs = input_register_minor("event%d", minor, EVDEV_MINOR_BASE);
- printk("event%d: Event device for input%d\n",
- minor, dev->number);
+ printk("event%d: Event device for input%d\n", minor, dev->number);
return 0;
}
@@ -240,6 +242,7 @@
input_close_device(handle);
if (!--evdev->used) {
+ input_unregister_minor(evdev->devfs);
evdev_table[evdev->minor] = NULL;
kfree(evdev);
}
diff -urN linux-2.3.99-pre3-old/drivers/usb/input.c linux/drivers/usb/input.c
--- linux-2.3.99-pre3-old/drivers/usb/input.c Wed Mar 29 11:38:35 2000
+++ linux/drivers/usb/input.c Wed Mar 29 13:00:33 2000
@@ -50,6 +50,7 @@
static struct input_dev *input_dev = NULL;
static struct input_handler *input_handler = NULL;
static struct input_handler *input_table[8] = { NULL, /* ... */ };
+static devfs_handle_t input_devfs_handle = NULL;
static int input_number = 0;
void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int
value)
@@ -334,18 +335,34 @@
open: input_open_file,
};
+devfs_handle_t input_register_minor(char *name, int minor, int minor_base)
+{
+ char devfs_name[16];
+ sprintf(devfs_name, name, minor);
+ return devfs_register(input_devfs_handle, devfs_name, 0, DEVFS_FL_DEFAULT,
+INPUT_MAJOR, minor + minor_base,
+ S_IFCHR | S_IRUGO | S_IWUSR, 0, 0, &input_fops, NULL);
+}
+
+void input_unregister_minor(devfs_handle_t handle)
+{
+ devfs_unregister(handle);
+}
+
static int __init input_init(void)
{
- if (register_chrdev(INPUT_MAJOR, "input", &input_fops)) {
+ if (devfs_register_chrdev(INPUT_MAJOR, "input", &input_fops)) {
printk(KERN_ERR "input: unable to register char major %d",
INPUT_MAJOR);
return -EBUSY;
}
+ input_devfs_handle = devfs_mk_dir(NULL, "input", 5, NULL);
return 0;
}
static void __exit input_exit(void)
{
- unregister_chrdev(INPUT_MAJOR, "input");
+ devfs_unregister(input_devfs_handle);
+ if (devfs_unregister_chrdev(INPUT_MAJOR, "input"))
+ printk(KERN_ERR "input: can't unregister char major %d", INPUT_MAJOR);
}
module_init(input_init);
diff -urN linux-2.3.99-pre3-old/drivers/usb/joydev.c linux/drivers/usb/joydev.c
--- linux-2.3.99-pre3-old/drivers/usb/joydev.c Wed Mar 29 11:27:25 2000
+++ linux/drivers/usb/joydev.c Wed Mar 29 13:01:47 2000
@@ -55,6 +55,7 @@
char name[32];
struct input_handle handle;
wait_queue_head_t wait;
+ devfs_handle_t devfs;
struct joydev *next;
struct joydev_list *list;
struct js_corr corr[ABS_MAX];
@@ -166,6 +167,7 @@
*listptr = (*listptr)->next;
if (!--list->joydev->used) {
+ input_unregister_minor(list->joydev->devfs);
joydev_table[list->joydev->minor] = NULL;
kfree(list->joydev);
}
@@ -435,6 +437,7 @@
}
input_open_device(&joydev->handle);
+ joydev->devfs = input_register_minor("js%d", minor, JOYDEV_MINOR_BASE);
printk("js%d: Joystick device for input%d\n", minor, dev->number);
@@ -448,6 +451,7 @@
input_close_device(handle);
if (!--joydev->used) {
+ input_unregister_minor(joydev->devfs);
joydev_table[joydev->minor] = NULL;
kfree(joydev);
}
diff -urN linux-2.3.99-pre3-old/drivers/usb/mousedev.c linux/drivers/usb/mousedev.c
--- linux-2.3.99-pre3-old/drivers/usb/mousedev.c Wed Mar 29 11:38:35 2000
+++ linux/drivers/usb/mousedev.c Wed Mar 29 13:00:51 2000
@@ -50,6 +50,7 @@
int minor;
wait_queue_head_t wait;
struct mousedev_list *list;
+ devfs_handle_t devfs;
};
struct mousedev_list {
@@ -157,6 +158,7 @@
*listptr = (*listptr)->next;
if (!--list->mousedev->used) {
+ input_unregister_minor(list->mousedev->devfs);
mousedev_table[list->mousedev->minor] = NULL;
kfree(list->mousedev);
}
@@ -367,6 +369,8 @@
memset(mousedev, 0, sizeof(struct mousedev));
init_waitqueue_head(&mousedev->wait);
+ mousedev->devfs = input_register_minor("mouse%d", minor,
+MOUSEDEV_MINOR_BASE);
+
#ifdef CONFIG_INPUT_MOUSEDEV_MIX
} else mousedev = mousedev_table[minor];
#endif
@@ -398,6 +402,7 @@
input_close_device(handle);
kfree(handle);
if (!--mousedev->used) {
+ input_unregister_minor(mousedev->devfs);
mousedev_table[mousedev->minor] = NULL;
kfree(mousedev);
}
diff -urN linux-2.3.99-pre3-old/include/linux/input.h linux/include/linux/input.h
--- linux-2.3.99-pre3-old/include/linux/input.h Wed Mar 29 11:27:25 2000
+++ linux/include/linux/input.h Wed Mar 29 13:02:08 2000
@@ -383,6 +383,7 @@
*/
#include <linux/sched.h>
+#include <linux/devfs_fs_kernel.h>
#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
#define BIT(x) (1<<((x)%BITS_PER_LONG))
@@ -459,6 +460,9 @@
void input_open_device(struct input_handle *);
void input_close_device(struct input_handle *);
+
+devfs_handle_t input_register_minor(char *name, int minor, int minor_base);
+void input_unregister_minor(devfs_handle_t handle);
void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int
value);
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]