Commit 1c6099ba authored by Christoph Hellwig's avatar Christoph Hellwig

[PATCH] devfs: input

Make sure input always uses devfs_remove.  While at it I've also
remove lots of code duplication - every upper input driver contained
the code surrounding devfs_unregister in two identical copies.
parent b2520649
......@@ -27,7 +27,6 @@ struct evdev{
char name[16];
struct input_handle handle;
wait_queue_head_t wait;
devfs_handle_t devfs;
struct list_head list;
};
......@@ -76,6 +75,13 @@ static int evdev_flush(struct file * file)
return input_flush_device(&list->evdev->handle, file);
}
static void evdev_free(struct evdev *evdev)
{
devfs_remove("input/event%d", evdev->minor);
evdev_table[evdev->minor] = NULL;
kfree(evdev);
}
static int evdev_release(struct inode * inode, struct file * file)
{
struct evdev_list *list = file->private_data;
......@@ -84,17 +90,13 @@ static int evdev_release(struct inode * inode, struct file * file)
list_del(&list->node);
if (!--list->evdev->open) {
if (list->evdev->exist) {
if (list->evdev->exist)
input_close_device(&list->evdev->handle);
} else {
input_unregister_minor(list->evdev->devfs);
evdev_table[list->evdev->minor] = NULL;
kfree(list->evdev);
}
else
evdev_free(list->evdev);
}
kfree(list);
return 0;
}
......@@ -397,7 +399,7 @@ static struct input_handle *evdev_connect(struct input_handler *handler, struct
sprintf(evdev->name, "event%d", minor);
evdev_table[minor] = evdev;
evdev->devfs = input_register_minor("input/event%d", minor, EVDEV_MINOR_BASE);
input_register_minor("input/event%d", minor, EVDEV_MINOR_BASE);
return &evdev->handle;
}
......@@ -411,11 +413,8 @@ static void evdev_disconnect(struct input_handle *handle)
if (evdev->open) {
input_close_device(handle);
wake_up_interruptible(&evdev->wait);
} else {
input_unregister_minor(evdev->devfs);
evdev_table[evdev->minor] = NULL;
kfree(evdev);
}
} else
evdev_free(evdev);
}
static struct input_device_id evdev_ids[] = {
......
......@@ -32,7 +32,6 @@ EXPORT_SYMBOL(input_unregister_device);
EXPORT_SYMBOL(input_register_handler);
EXPORT_SYMBOL(input_unregister_handler);
EXPORT_SYMBOL(input_register_minor);
EXPORT_SYMBOL(input_unregister_minor);
EXPORT_SYMBOL(input_open_device);
EXPORT_SYMBOL(input_close_device);
EXPORT_SYMBOL(input_accept_process);
......@@ -47,7 +46,6 @@ static LIST_HEAD(input_dev_list);
static LIST_HEAD(input_handler_list);
static struct input_handler *input_table[8];
static devfs_handle_t input_devfs_handle;
#ifdef CONFIG_PROC_FS
static struct proc_dir_entry *proc_bus_input_dir;
......@@ -542,20 +540,13 @@ static struct file_operations input_fops = {
.open = input_open_file,
};
devfs_handle_t input_register_minor(char *name, int minor, int minor_base)
void input_register_minor(char *name, int minor, int minor_base)
{
char devfs_name[16];
sprintf(devfs_name, name, minor);
return devfs_register(NULL, devfs_name, 0,
INPUT_MAJOR, minor + minor_base,
S_IFCHR|S_IRUGO|S_IWUSR,
&input_fops, NULL);
}
void input_unregister_minor(devfs_handle_t handle)
{
devfs_unregister(handle);
sprintf(devfs_name, name, minor);
devfs_register(NULL, devfs_name, 0, INPUT_MAJOR, minor_base + minor,
S_IFCHR|S_IRUGO|S_IWUSR, &input_fops, NULL);
}
#ifdef CONFIG_PROC_FS
......@@ -699,8 +690,7 @@ static int __init input_init(void)
return -EBUSY;
}
input_devfs_handle = devfs_mk_dir("input");
devfs_mk_dir("input");
return 0;
}
......@@ -711,7 +701,7 @@ static void __exit input_exit(void)
remove_proc_entry("handlers", proc_bus_input_dir);
remove_proc_entry("input", proc_bus);
#endif
devfs_unregister(input_devfs_handle);
devfs_remove("input");
if (unregister_chrdev(INPUT_MAJOR, "input"))
printk(KERN_ERR "input: can't unregister char major %d", INPUT_MAJOR);
devclass_unregister(&input_devclass);
......
......@@ -45,7 +45,6 @@ struct joydev {
char name[16];
struct input_handle handle;
wait_queue_head_t wait;
devfs_handle_t devfs;
struct list_head list;
struct js_corr corr[ABS_MAX];
struct JS_DATA_SAVE_TYPE glue;
......@@ -141,6 +140,13 @@ static int joydev_fasync(int fd, struct file *file, int on)
return retval < 0 ? retval : 0;
}
static void joydev_free(struct joydev *joydev)
{
devfs_remove("js%d", joydev->minor);
joydev_table[joydev->minor] = NULL;
kfree(joydev);
}
static int joydev_release(struct inode * inode, struct file * file)
{
struct joydev_list *list = file->private_data;
......@@ -150,17 +156,13 @@ static int joydev_release(struct inode * inode, struct file * file)
list_del(&list->node);
if (!--list->joydev->open) {
if (list->joydev->exist) {
if (list->joydev->exist)
input_close_device(&list->joydev->handle);
} else {
input_unregister_minor(list->joydev->devfs);
joydev_table[list->joydev->minor] = NULL;
kfree(list->joydev);
}
else
joydev_free(list->joydev);
}
kfree(list);
return 0;
}
......@@ -442,7 +444,7 @@ static struct input_handle *joydev_connect(struct input_handler *handler, struct
}
joydev_table[minor] = joydev;
joydev->devfs = input_register_minor("js%d", minor, JOYDEV_MINOR_BASE);
input_register_minor("js%d", minor, JOYDEV_MINOR_BASE);
return &joydev->handle;
}
......@@ -453,13 +455,10 @@ static void joydev_disconnect(struct input_handle *handle)
joydev->exist = 0;
if (joydev->open) {
if (joydev->open)
input_close_device(handle);
} else {
input_unregister_minor(joydev->devfs);
joydev_table[joydev->minor] = NULL;
kfree(joydev);
}
else
joydev_free(joydev);
}
static struct input_device_id joydev_ids[] = {
......
......@@ -46,7 +46,6 @@ struct mousedev {
wait_queue_head_t wait;
struct list_head list;
struct input_handle handle;
devfs_handle_t devfs;
};
struct mousedev_list {
......@@ -171,45 +170,52 @@ static int mousedev_fasync(int fd, struct file *file, int on)
return retval < 0 ? retval : 0;
}
static void mousedev_free(struct mousedev *mousedev)
{
devfs_remove("input/mouse%d", mousedev->minor);
mousedev_table[mousedev->minor] = NULL;
kfree(mousedev);
}
static int mixdev_release(void)
{
struct input_handle *handle;
list_for_each_entry(handle, &mousedev_handler.h_list, h_node) {
struct mousedev *mousedev = handle->private;
if (!mousedev->open) {
if (mousedev->exist)
input_close_device(&mousedev->handle);
else
mousedev_free(mousedev);
}
}
return 0;
}
static int mousedev_release(struct inode * inode, struct file * file)
{
struct mousedev_list *list = file->private_data;
struct input_handle *handle;
struct mousedev *mousedev;
mousedev_fasync(-1, file, 0);
list_del(&list->node);
if (!--list->mousedev->open) {
if (list->mousedev->minor == MOUSEDEV_MIX) {
list_for_each_entry(handle, &mousedev_handler.h_list, h_node) {
mousedev = handle->private;
if (!mousedev->open) {
if (mousedev->exist) {
input_close_device(&mousedev->handle);
} else {
input_unregister_minor(mousedev->devfs);
mousedev_table[mousedev->minor] = NULL;
kfree(mousedev);
}
}
}
} else {
if (!mousedev_mix.open) {
if (list->mousedev->exist) {
input_close_device(&list->mousedev->handle);
} else {
input_unregister_minor(list->mousedev->devfs);
mousedev_table[list->mousedev->minor] = NULL;
kfree(list->mousedev);
}
}
if (list->mousedev->minor == MOUSEDEV_MIX)
return mixdev_release();
if (!mousedev_mix.open) {
if (list->mousedev->exist)
input_close_device(&list->mousedev->handle);
else
mousedev_free(list->mousedev);
}
}
kfree(list);
return 0;
}
......@@ -425,7 +431,7 @@ static struct input_handle *mousedev_connect(struct input_handler *handler, stru
input_open_device(&mousedev->handle);
mousedev_table[minor] = mousedev;
mousedev->devfs = input_register_minor("input/mouse%d", minor, MOUSEDEV_MINOR_BASE);
input_register_minor("input/mouse%d", minor, MOUSEDEV_MINOR_BASE);
return &mousedev->handle;
}
......@@ -441,9 +447,7 @@ static void mousedev_disconnect(struct input_handle *handle)
} else {
if (mousedev_mix.open)
input_close_device(handle);
input_unregister_minor(mousedev->devfs);
mousedev_table[mousedev->minor] = NULL;
kfree(mousedev);
mousedev_free(mousedev);
}
}
......@@ -507,7 +511,7 @@ static int __init mousedev_init(void)
mousedev_table[MOUSEDEV_MIX] = &mousedev_mix;
mousedev_mix.exist = 1;
mousedev_mix.minor = MOUSEDEV_MIX;
mousedev_mix.devfs = input_register_minor("input/mice", MOUSEDEV_MIX, MOUSEDEV_MINOR_BASE);
input_register_minor("input/mice", MOUSEDEV_MIX, MOUSEDEV_MINOR_BASE);
#ifdef CONFIG_INPUT_MOUSEDEV_PSAUX
if (!(mousedev_mix.misc = !misc_register(&psaux_mouse)))
......@@ -525,7 +529,7 @@ static void __exit mousedev_exit(void)
if (mousedev_mix.misc)
misc_deregister(&psaux_mouse);
#endif
input_unregister_minor(mousedev_mix.devfs);
devfs_remove("input/mice");
input_unregister_handler(&mousedev_handler);
interface_unregister(&mousedev_intf);
}
......
......@@ -57,7 +57,6 @@ struct tsdev {
wait_queue_head_t wait;
struct list_head list;
struct input_handle handle;
devfs_handle_t devfs;
};
/* From Compaq's Touch Screen Specification version 0.2 (draft) */
......@@ -115,6 +114,13 @@ static int tsdev_open(struct inode *inode, struct file *file)
return 0;
}
static void tsdev_free(struct tsdev *tsdev)
{
devfs_remove("input/ts%d", tsdev->minor);
tsdev_table[tsdev->minor] = NULL;
kfree(tsdev);
}
static int tsdev_release(struct inode *inode, struct file *file)
{
struct tsdev_list *list = file->private_data;
......@@ -123,13 +129,10 @@ static int tsdev_release(struct inode *inode, struct file *file)
list_del(&list->node);
if (!--list->tsdev->open) {
if (list->tsdev->exist) {
if (list->tsdev->exist)
input_close_device(&list->tsdev->handle);
} else {
input_unregister_minor(list->tsdev->devfs);
tsdev_table[list->tsdev->minor] = NULL;
kfree(list->tsdev);
}
else
tsdev_free(list->tsdev);
}
kfree(list);
return 0;
......@@ -325,8 +328,7 @@ static struct input_handle *tsdev_connect(struct input_handler *handler,
tsdev->handle.private = tsdev;
tsdev_table[minor] = tsdev;
tsdev->devfs =
input_register_minor("input/ts%d", minor, TSDEV_MINOR_BASE);
input_register_minor("input/ts%d", minor, TSDEV_MINOR_BASE);
return &tsdev->handle;
......@@ -341,11 +343,8 @@ static void tsdev_disconnect(struct input_handle *handle)
if (tsdev->open) {
input_close_device(handle);
wake_up_interruptible(&tsdev->wait);
} else {
input_unregister_minor(tsdev->devfs);
tsdev_table[tsdev->minor] = NULL;
kfree(tsdev);
}
} else
tsdev_free(tsdev);
}
static struct input_device_id tsdev_ids[] = {
......
......@@ -895,8 +895,8 @@ void input_close_device(struct input_handle *);
int input_accept_process(struct input_handle *handle, struct file *file);
int input_flush_device(struct input_handle* handle, struct file* file);
devfs_handle_t input_register_minor(char *name, int minor, int minor_base);
void input_unregister_minor(devfs_handle_t handle);
/* will go away once devfs_register gets sanitized */
void input_register_minor(char *name, int minor, int minor_base);
void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment