LWN.net Logo

Object-oriented design patterns in the kernel, part 1

Object-oriented design patterns in the kernel, part 1

Posted Jun 6, 2011 3:56 UTC (Mon) by jmm82 (guest, #59425)
In reply to: Object-oriented design patterns in the kernel, part 1 by jengelh
Parent article: Object-oriented design patterns in the kernel, part 1

It is also used in many kernel subsystems when the base struct will have a pointer to a private struct where the driver can hold variables Specific to that driver. The base struct is like a super in this case and if all you have is a pointer to the private struct you can use container_of() to get the base struct.

Also, container_of is used with the kref code when deleting the struct which has embedded a kref for refence counting.


(Log in to post comments)

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds