Re: question about linked list implementation in kernel.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 11 Sep 2010, Bond wrote:

>
>
> On Sat, Sep 11, 2010 at 6:22 PM, Carlo Caione <carlo.caione@xxxxxxxxx>
> wrote:
>
> http://www.kroah.com/log/linux/container_of.html
>
> I am not able to understand a single bit of the explanaition on the
> above link. They have assumed I programmed PCI buses which  I have
> not.

  you're making this too difficult -- all container_of() does is,
given:

  * a structure definition,
  * the name of a member field within that structure, and
  * the address of that internal member field in an instance

what you get back is the address of the enclosing structure.

  this allows you to work with member fields of a structure but, when
you need to, "back up" to the structure they're contained in.  kernel
linked lists are built on this idea.

http://crashcourse.ca/introduction-linux-kernel-programming/intermission-lets-talk-about-linked-lists-and-containerof-free


rday

-- 

========================================================================
Robert P. J. Day                               Waterloo, Ontario, CANADA

        Top-notch, inexpensive online Linux/OSS/kernel courses
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux