From mboxrd@z Thu Jan 1 00:00:00 1970 From: vikram186@gmail.com (Vikram Narayanan) Date: Wed, 4 May 2011 21:56:37 +0530 Subject: Confusion in kobjects Message-ID: To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org > 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