* Confusion in kobjects
@ 2011-05-04 13:56 Vikram Narayanan
2011-05-04 14:59 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Vikram Narayanan @ 2011-05-04 13:56 UTC (permalink / raw)
To: kernelnewbies
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
^ permalink raw reply [flat|nested] 3+ messages in thread* Confusion in kobjects
2011-05-04 13:56 Confusion in kobjects Vikram Narayanan
@ 2011-05-04 14:59 ` Greg KH
0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2011-05-04 14:59 UTC (permalink / raw)
To: kernelnewbies
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.
Hope this helps,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Confusion in kobjects
@ 2011-05-04 16:26 Vikram Narayanan
0 siblings, 0 replies; 3+ messages in thread
From: Vikram Narayanan @ 2011-05-04 16:26 UTC (permalink / raw)
To: kernelnewbies
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-05-04 16:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-04 13:56 Confusion in kobjects Vikram Narayanan
2011-05-04 14:59 ` Greg KH
-- strict thread matches above, loose matches on Subject: below --
2011-05-04 16:26 Vikram Narayanan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).