LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-26-2009, 12:51 PM   #1
avyadavnitw
LQ Newbie
 
Registered: Apr 2009
Posts: 16

Rep: Reputation: 0
character drivers


i am studying orielly book .............i found that container_of()function i am not able to understand that..........can any one explain this...............
 
Old 04-26-2009, 06:04 PM   #2
soleilarw
Member
 
Registered: Apr 2009
Posts: 107

Rep: Reputation: 19
O'Reilly has published tons of books over the years, so it's difficult to tell which one you are reading. Patrick McManus on Kerneltrap.org has made some comment about a similar question some time ago. Some snippets:

container_of - cast a member of a structure out to the containing structure
container_of (ptr, type, member);

The macro lets you derive * struct a from * b if you know that b is a member of struct a..
this is a good example of the strong object orientation of the kernel - without any c++

http://bec-systems.com/web/content/view/94/9/ provides the basis for a pretty clear example:

Quote:
struct device_x {
int device_x_specific_param_a;
struct bus_device bd;
};

void device_x_callback(struct bus_device * bd)
{
struct device_x * devx = container_of(bd, struct device_x, bd);
do_something (x);
}
As for how it works, Greg Kroah-Hartman's blog has a bookmark worthy explanation:
http://www.kroah.com/log/linux/container_of.html

Linux Archive

Last edited by soleilarw; 06-18-2009 at 04:43 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
To know the function on checking whether a character is ascii or unicode character. murugesan Programming 2 01-23-2009 02:07 PM
special character tostay2003 Programming 5 01-06-2009 01:39 PM
Why I always have unreadable character? duyuyang Linux - Newbie 3 11-03-2008 08:29 AM
about wide character and multiple byte character George2 Programming 5 05-23-2006 02:03 AM
^M character david_wliu Linux - General 6 03-17-2003 12:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration