Re: [RFT/C 2.5.70] Input class hook up to driver model/sysfs

Greg KH (greg@kroah.com)
Thu, 29 May 2003 00:30:16 -0700


On Tue, May 27, 2003 at 06:04:51PM -0700, Hanna Linder wrote:
>
> root@w-hlinder2 root]# tree /sys/class/input
> /sys/class/input
> |-- mouse0
> | `-- dev
> `-- mouse1
> `-- dev

What happened to /sys/class/input/mice? It should be present too.

Looks good, Al's point about not just calling kfree() on the kobject is
correct, but you copied my tty code which has the same bug :)

Another minor comment:
> - devfs_remove("input/event%d", evdev->minor);
> + input_unregister_class_dev("input/event%d", evdev->minor);
> evdev_table[evdev->minor] = NULL;
> kfree(evdev);
> }
> @@ -94,8 +94,10 @@ static int evdev_release(struct inode *
> if (!--list->evdev->open) {
> if (list->evdev->exist)
> input_close_device(&list->evdev->handle);
> - else
> + else{
> + input_unregister_class_dev("input/event%d", list->evdev->minor);
> evdev_free(list->evdev);
> + }
> }
>
> kfree(list);
> @@ -374,6 +376,12 @@ static struct file_operations evdev_fops
> .flush = evdev_flush
> };
>
> +static struct input_class_interface intf = {
> + .name = "input/event%d",
> + .mode = S_IFCHR | S_IRUGO | S_IWUSR,
> + .minor_base = EVDEV_MINOR_BASE,
> +};
> +
> static struct input_handle *evdev_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id)
> {
> struct evdev *evdev;
> @@ -402,8 +410,8 @@ static struct input_handle *evdev_connec
>
> evdev_table[minor] = evdev;
>
> - devfs_mk_cdev(MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
> - S_IFCHR|S_IRUGO|S_IWUSR, "input/event%d", minor);
> + intf.minor = minor;
> + input_register_class_dev(dev, &intf);
>
> return &evdev->handle;
> }
> @@ -417,8 +425,10 @@ static void evdev_disconnect(struct inpu
> if (evdev->open) {
> input_close_device(handle);
> wake_up_interruptible(&evdev->wait);
> - } else
> + } else {
> + input_unregister_class_dev("input/event%d", evdev->minor);
> evdev_free(evdev);
> + }
> }

You use "input/event%d" 4 times in the above code. Any way of just
passing the struct input_class_interface into
input_unregister_class_dev() so that you don't have to specify the name
more than once anywhere?

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/