Re: usage count

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

 



On Mon, Sep 05, 2005 at 04:23:01PM +0530, manish rangankar wrote:
>  
> struct file_operations char_fops =
>         {
>                 .open = char_open,
>                 .release = char_release
>         };

Add:
		.owner = THIS_MODULE,
	
to that file_operations structure and the module reference count will be
properly incremented.

> int major;

That's not a nice global variable name...

> static int
> char_open(
>                 struct inode *inode,    /*What Inode is this ?*/
>                 struct file * file              /*What File is this ? */
>                 ) {

What kind of coding style is this?  :)

>         int mjr, mnr;
>  
>         mjr = MAJOR(inode->i_rdev);
>         mnr = MINOR(inode->i_rdev);
>  
>         printk(KERN_ALERT"So you want to open: %d \n", mnr);
>         MOD_INC_USE_COUNT;

No, don't do this on 2.6 please.

Hope this helps,

greg k-h

--
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