EmbLogic's Blog

character driver -> scull open ->container_of

the prototype for container_of is as follows:

container_of(pointer,container_type,container_field)

so what exactly does this return?

considering an example,

ptr=container_of(inode->i_cdev,struct scull_dev,cdev)

here the pointer ‘inode->i_cdev’ has a field cdev.’cdev’ is CONTAINED IN struct scull_dev.

so ultimately,’container_of’ takes pointer ‘inode->i_cdev’ to struct scull_dev and returns a pointer containing struct scull_dev.

is it so????

kindly elaborate and add…….

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>