Yeah, but as I know, it's a big pain in the butt. Let's make it easy to
do this, don't make writing a driver tougher than it has to be (it's
already much harder than it used to be.) Andries's patch makes it easy,
which is a good thing in my book.
> a) The driver allocates the major itself and opens the real minor device
> in its open function, (e.g. see the misc driver example). Especially tape
> drivers have to do this anyway, because they encoded the open mode in
> higher bits, so regions won't help you here at all.
> b) The driver allocates the major itself and installs the file_operations
> directly in the char_device, e.g. that is something you might want to do
> in the usb driver:
>
> register_usb_device(...)
> {
> ...
> cdev = cdget(dev);
> down(&cdev->sem);
> if (cdev->fops)
> ...;
> cdev->fops = fops;
> up(&cdev->sem);
> }
> (see the misc driver again for a detailed example.)
Look at drivers/usb/core/file.c::usb_open(), it does much the same
thing. Well, functionally the same, not identical in any way :)
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/