Re: Drivers in 2.2.x: Best way to get minor number from within

Drew Bertola (drew@drewb.com)
Tue, 16 Nov 1999 19:38:17 -0800 (PST)


Theodore Y. Ts'o writes:
> Usually what is done is in open() call, the open call allocates a
> structure, and places a pointer to that structure in filp->private_data.
> This allows the driver to store various bits of state information,
> either pre-calculated at device open time, or for state information
> which is associated with the open file descriptor.

More than I need at the moment, but very noteworthy.

> If you *only* need the I/O port offset, and you're willing to calculate
> it each time in the read() and write() call, you can get access to the
> inode from those functions. Just reference it as filp->f_dentry->d_inode.
> So for example you can get the minor number by calculating
> MINOR(filp->f_dentry->d_inode).
>
> Hope this helps!
>
> - Ted

Great. That's what I was looking for. I saw that a couple days ago
but didn't go down that path. Then, when I needed it, I couldn't
recall where it was and failed to find it again. Thanks.

D->|

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