Confusion in kobjects

Vikram Narayanan vikram186 at gmail.com
Wed May 4 12:26:37 EDT 2011


> On Wed, May 04, 2011 at 07:26:44PM +0530, Vikram Narayanan wrote:
>> 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?
>
> There are not more than one kobject _IN_ the structure.  It merely
> has pointers to more than one kobject (three actually), which is fine to
> do.
Thanks for the clarification. Think I have to go for an eye checkup ;)

Thanks,
Vikram



More information about the Kernelnewbies mailing list