Re: [patch 0/8] Nesting class_device patches that actually work

Greg KH
2005-10-18T06:05:27Z

On Mon, Oct 17, 2005 at 02:44:30PM -0700, Greg KH wrote:
> But, if you think we can't break userspace by adding nested class
> devices just yet, I agree, and can probably just put a symlink in
> /sys/class/input to the nested devices, which will make everything "just
> work". I'll try that out later tonight and let you all know how it
> goes.

Below is a patch that does this for the event portion of input. Good
news is that the symlink shows up just fine in sysfs. Bad news is that
even with your previously posted patch, udev dies a horrible death.

And udev dies today with the nested stuff too, so that's not good
either.

So I could just move the class devices back to the main /sys/input/
directory (instead of the nesting) which will make userspace happy, and
then start working on the class -> device stuff.

Or I'll look at udev in the morning to see if it's just an easy fix...

thanks,

greg k-h

--- gregkh-2.6.orig/drivers/input/evdev.c 2005-10-16 13:09:07.000000000 -0700
+++ gregkh-2.6/drivers/input/evdev.c 2005-10-17 22:47:40.000000000 -0700
@@ -661,6 +661,7 @@ static struct file_operations evdev_fops
static struct input_handle *evdev_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id)
{
struct evdev *evdev;
+ struct class_device *cdev;
int minor;

for (minor = 0; minor < EVDEV_MINORS && evdev_table[minor]; minor++);
@@ -686,10 +687,13 @@ static struct input_handle *evdev_connec

evdev_table[minor] = evdev;

- class_device_create(&input_class, &dev->cdev,
+ cdev = class_device_create(&input_class, &dev->cdev,
MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + minor),
dev->cdev.dev, "event%d", minor);

+ /* temporary symlink to keep userspace happy */
+ sysfs_create_link(&input_class.subsys.kset.kobj, &cdev->kobj, evdev->name);
+
return &evdev->handle;
}

@@ -698,6 +702,7 @@ static void evdev_disconnect(struct inpu
struct evdev *evdev = handle->private;
struct evdev_list *list;

+ sysfs_remove_link(&input_class.subsys.kset.kobj, evdev->name);
class_device_destroy(&input_class,
MKDEV(INPUT_MAJOR, EVDEV_MINOR_BASE + evdev->minor));
evdev->exist = 0;