X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Finput%2Ftsdev.c;h=d678d144bbf8652b629d23417eda0a58f94518bf;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=18c37d8ac5d6f23cdebeebc74a2cf1fbd559c59c;hpb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;p=linux-2.6.git diff --git a/drivers/input/tsdev.c b/drivers/input/tsdev.c index 18c37d8ac..d678d144b 100644 --- a/drivers/input/tsdev.c +++ b/drivers/input/tsdev.c @@ -1,7 +1,7 @@ /* * $Id: tsdev.c,v 1.15 2002/04/10 16:50:19 jsimmons Exp $ * - * Copyright (c) 2001 "Crazy" james Simmons + * Copyright (c) 2001 "Crazy" james Simmons * * Compaq touchscreen protocol driver. The protocol emulated by this driver * is obsolete; for new programs use the tslib library which can read directly @@ -53,7 +53,6 @@ #include #include #include -#include #ifndef CONFIG_INPUT_TSDEV_SCREEN_X #define CONFIG_INPUT_TSDEV_SCREEN_X 240 @@ -158,9 +157,8 @@ static int tsdev_open(struct inode *inode, struct file *file) if (i >= TSDEV_MINORS || !tsdev_table[i & TSDEV_MINOR_MASK]) return -ENODEV; - if (!(list = kmalloc(sizeof(struct tsdev_list), GFP_KERNEL))) + if (!(list = kzalloc(sizeof(struct tsdev_list), GFP_KERNEL))) return -ENOMEM; - memset(list, 0, sizeof(struct tsdev_list)); list->raw = (i >= TSDEV_MINORS/2) ? 1 : 0; @@ -177,8 +175,6 @@ static int tsdev_open(struct inode *inode, struct file *file) static void tsdev_free(struct tsdev *tsdev) { - devfs_remove("input/ts%d", tsdev->minor); - class_simple_device_remove(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + tsdev->minor)); tsdev_table[tsdev->minor] = NULL; kfree(tsdev); } @@ -234,11 +230,9 @@ static ssize_t tsdev_read(struct file *file, char __user *buffer, size_t count, static unsigned int tsdev_poll(struct file *file, poll_table * wait) { struct tsdev_list *list = file->private_data; - poll_wait(file, &list->tsdev->wait, wait); - if (list->head != list->tail) - return POLLIN | POLLRDNORM; - return 0; + return ((list->head == list->tail) ? 0 : (POLLIN | POLLRDNORM)) | + (list->tsdev->exist ? 0 : (POLLHUP | POLLERR)); } static int tsdev_ioctl(struct inode *inode, struct file *file, @@ -267,7 +261,7 @@ static int tsdev_ioctl(struct inode *inode, struct file *file, return retval; } -struct file_operations tsdev_fops = { +static struct file_operations tsdev_fops = { .owner = THIS_MODULE, .open = tsdev_open, .release = tsdev_release, @@ -373,6 +367,7 @@ static struct input_handle *tsdev_connect(struct input_handler *handler, struct input_device_id *id) { struct tsdev *tsdev; + struct class_device *cdev; int minor, delta; for (minor = 0; minor < TSDEV_MINORS/2 && tsdev_table[minor]; @@ -383,9 +378,8 @@ static struct input_handle *tsdev_connect(struct input_handler *handler, return NULL; } - if (!(tsdev = kmalloc(sizeof(struct tsdev), GFP_KERNEL))) + if (!(tsdev = kzalloc(sizeof(struct tsdev), GFP_KERNEL))) return NULL; - memset(tsdev, 0, sizeof(struct tsdev)); INIT_LIST_HEAD(&tsdev->list); init_waitqueue_head(&tsdev->wait); @@ -414,13 +408,13 @@ static struct input_handle *tsdev_connect(struct input_handler *handler, tsdev_table[minor] = tsdev; - devfs_mk_cdev(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor), - S_IFCHR|S_IRUGO|S_IWUSR, "input/ts%d", minor); - devfs_mk_cdev(MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor + TSDEV_MINORS/2), - S_IFCHR|S_IRUGO|S_IWUSR, "input/tsraw%d", minor); - class_simple_device_add(input_class, - MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor), - dev->dev, "ts%d", minor); + cdev = class_device_create(&input_class, &dev->cdev, + MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + minor), + dev->cdev.dev, tsdev->name); + + /* temporary symlink to keep userspace happy */ + sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj, + tsdev->name); return &tsdev->handle; } @@ -428,15 +422,20 @@ static struct input_handle *tsdev_connect(struct input_handler *handler, static void tsdev_disconnect(struct input_handle *handle) { struct tsdev *tsdev = handle->private; + struct tsdev_list *list; + sysfs_remove_link(&input_class.subsys.kset.kobj, tsdev->name); + class_device_destroy(&input_class, + MKDEV(INPUT_MAJOR, TSDEV_MINOR_BASE + tsdev->minor)); tsdev->exist = 0; if (tsdev->open) { input_close_device(handle); wake_up_interruptible(&tsdev->wait); + list_for_each_entry(list, &tsdev->list, node) + kill_fasync(&list->fasync, SIGIO, POLL_HUP); } else tsdev_free(tsdev); - devfs_remove("input/tsraw%d", tsdev->minor); } static struct input_device_id tsdev_ids[] = {