devfs_register and private data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm having trouble using devfs_register() with a driver i'm writing 
for a 2.4.23 kernel. 
Quoting fs/devfs/base.c, the last argument to devfs_register() is

@info: An arbitrary pointer which will be written to the @private_data
       field of the &file structure passed to the device driver. You can set
        this to whatever you like, and change it once the file is opened (the next
        file opened will not see this change).

so, i have a private structure in my driver file, 
struct my_privfile_s {
	int data1;
	int data2;
} my_privinfo ;

my_privinfo.data1 = 5;
my_privinfo.data2 = 25;

and in the devfs_register call, i set the last argument to &my_privinfo;

and in the open call of my driver, i have

static int fop_open (struct inode * inode, struct file * filep){
	struct my_privfile_s *info = (struct my_privfile_s *) filep;
	printk ("testing: data1 is %d, data2 is %d\n", info->data1, info->data2);
	<more code follows>
};

But the kernel doesn't print out the expected results! What am i doing wrong?







--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux