On Aug 24, 2006, at 19:48:28, Chandra Seetharaman wrote:
On Thu, 2006-08-24 at 12:10 +0100, Alan Cox wrote:All you need is struct wombat_controller { struct user_beancounter counter; void (*wombat_pest_control)(struct wombat *w); atomic_t wombat_population; int (*wombat_destructor)(struct wombat *w); };This may not solve the problem, as- we won't be able get the controller data structure given the beancounter data structure.
Of course you can! This is what we do for linked lists too. Here's an example of how to get a pointer to your wombat_controller given the user_beancounter pointer: struct wombat_controller *wombat = containerof (ptr_to_user_beancounter, struct wombat_controller, counter);
The containerof(PTR, TYPE, MEMBER) returns a pointer to the parent object of type "TYPE" whose member "MEMBER" has address "PTR".
Cheers, Kyle Moffett - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
- Follow-Ups:
- Re: [ckrm-tech] [RFC][PATCH] UBC: user resource beancounters
- From: Chandra Seetharaman <[email protected]>
- Re: [ckrm-tech] [RFC][PATCH] UBC: user resource beancounters
- References:
- [RFC][PATCH] UBC: user resource beancounters
- From: Kirill Korotaev <[email protected]>
- Re: [ckrm-tech] [RFC][PATCH] UBC: user resource beancounters
- From: Chandra Seetharaman <[email protected]>
- Re: [ckrm-tech] [RFC][PATCH] UBC: user resource beancounters
- From: Kirill Korotaev <[email protected]>
- Re: [ckrm-tech] [RFC][PATCH] UBC: user resource beancounters
- From: Chandra Seetharaman <[email protected]>
- Re: [ckrm-tech] [RFC][PATCH] UBC: user resource beancounters
- From: Rohit Seth <[email protected]>
- Re: [ckrm-tech] [RFC][PATCH] UBC: user resource beancounters
- From: Chandra Seetharaman <[email protected]>
- Re: [ckrm-tech] [RFC][PATCH] UBC: user resource beancounters
- From: Rohit Seth <[email protected]>
- Re: [ckrm-tech] [RFC][PATCH] UBC: user resource beancounters
- From: Chandra Seetharaman <[email protected]>
- Re: [ckrm-tech] [RFC][PATCH] UBC: user resource beancounters
- From: Alan Cox <[email protected]>
- Re: [ckrm-tech] [RFC][PATCH] UBC: user resource beancounters
- From: Chandra Seetharaman <[email protected]>
- [RFC][PATCH] UBC: user resource beancounters
- Prev by Date: Re: [ckrm-tech] [RFC][PATCH] UBC: user resource beancounters
- Next by Date: Re: Generic Disk Driver in Linux
- Previous by thread: Re: [ckrm-tech] [RFC][PATCH] UBC: user resource beancounters
- Next by thread: Re: [ckrm-tech] [RFC][PATCH] UBC: user resource beancounters
- Index(es):