Confusion in kobjects

Vikram Narayanan vikram186 at gmail.com
Wed May 4 09:56:44 EDT 2011


The kernel doc (kobject.txt) says that

"No structure should EVER have more than one kobject embedded within it.
 If it does, the reference counting for the object is sure to be messed
 up and incorrect, and your code will be buggy.  So do not do this. "

But in the file drivers/uio/uio.c, a structure has two such kobjects.

struct uio_device {
         struct module           *owner;
         struct device           *dev;
         int                     minor;
         atomic_t                event;
         struct fasync_struct    *async_queue;
         wait_queue_head_t       wait;
         int                     vma_count;
         struct uio_info         *info;
         struct kobject          *map_dir;
         struct kobject          *portio_dir;
 };

So, What is the exception for this structure? Is this right? If yes,
can someone explain why it is right, and where should we use it?

Thanks,
Vikram



More information about the Kernelnewbies mailing list