Re: cdev documentation (was Drop second arg of unregister_chrdev())

From: Jonathan Corbet
Date: Fri Aug 18 2006 - 09:00:04 EST

Rolf Eike Beer <eike-kernel@xxxxxxxxx> wrote:

> Nevertheless, I ported my driver to the new interface. I see it cdev_add()
> succeeding, but the device never shows up in sysfs. Do I have to do any more
> tricks with class devices and stuff?

Yes, cdevs do not, themselves, show up in sysfs. A simple class is what
you want for that part of the job.

> While I was sneaking around in the code I found this drivers/char/tty_io:3093
> cdev_init(&driver->cdev, &tty_fops);
> driver->cdev.owner = driver->owner;
> error = cdev_add(&driver->cdev, dev, driver->num);
> if (error) {
> cdev_del(&driver->cdev);
> Isn't the call to cdev_del() just wrong here?

It is correct, in that it returns the reference you hold to the cdev's
internal kobject. If you got the cdev with cdev_alloc(), that's the
only way it will get returned to the system. For a cdev allocated
elsewhere (as is the case here) it probably doesn't make any difference.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at