Re: how to fetch value in simple device driver
- From: jt@xxxxxxxxxxx (Jens Thoms Toerring)
- Date: 23 Nov 2006 13:17:46 GMT
Dharmendra <vasadia.linuxdevicedriver@xxxxxxxxx> wrote:
I wanted to know value of inode>i_rdev in my simple hello worl module.
i use following statement
in:
#include <linux/fs.h>
int init_module( void )
{
printk("value is = %d ", inode->i_rdev);
...................
....................
}
but it shows error: 'inode' undeclared.
how do i get out of this problem
You can't. An inode struct pointer is the first argument of the
functions you put into the file_operations structure, giving you
access to some of the properties of the device file the call is
made for. But in init_module() (I assume that that's the function
you have been set up via module_init() to be the function to be in-
voked on initialization of the module) there's no open device file
(or device file in the process of being opened), so no information
about the device file is available at that stage. Moreover, in the
initialization function you are supposed to set the major device
number, so, even if you would be able to get at inode->i_rdev (which
encodes the major and minor device number), it wouldn't be a value
that would make sense, even for the MAJOR part. And, by the way,
inode->i_rdev is of type dev_t and not necessarily an int (it's
more likely to be an unsigned int anyway), so using %d to print it
may lead to trouble.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx
\__________________________ http://toerring.de
.
- References:
- how to fetch value in simple device driver
- From: Dharmendra
- how to fetch value in simple device driver
- Prev by Date: how to fetch value in simple device driver
- Next by Date: Re: How to create a window in C for Linux
- Previous by thread: how to fetch value in simple device driver
- Index(es):