lkml.org 
[lkml]   [2003]   [Mar]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] alternative dev patch
On Sat, Mar 22, 2003 at 02:02:00PM +0100, Roman Zippel wrote:
> > So only tty drivers currently do this. But that might just be because
> > it's pretty hard to get a range of minors right now, as the api hasn't
> > been present. Once we expand the range, I bet it will get quite common
> > (most character drivers only want from 1-16 minors normally.)
>
> There are a few options:
> 1. Drivers can implement that themselves:

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/

\
 
 \ /
  Last update: 2005-03-22 13:34    [W:0.096 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site