1、container_of(ptr, type, member)

使用方法:根据指向结构体type的成员member的指针ptr,获取指向改结构体的指针

/**

* container_of - cast a member of a structure out to the containing structure

* @ptr:        the pointer to the member. (指向member的指针)

* @type:       the type of the container struct this is embedded in. (该成员所属的结构体名称) 

* @member:     the name of the member within the struct.  (该成员在结构体中的名称)

* */

参考文章:

container_of宏

container_of分析

例子(来自于incluce/linux/virtio.h):

该函数的作用是:通过具体的设备驱动drv,获取其所属的virtio_driver指针

<span style="font-size:18px;">static inline struct virtio_driver *drv_to_virtio(struct device_driver *drv)
{
return container_of(drv, struct virtio_driver, driver)}</span>

2、probe()函数何时调用?  当系统启动时,设备device先注册到总线bus上,然后bus负责调用对应的probe()函数,这个probe()函数是预先编写好的回调函数,BUS架构通过便利其所管理的driver链表并进行“字符串匹配”,然后它就知道该调用哪个driver的probe函数,来处理目前探测到的设备。在调用probe函数的时候,传入的参数是描述该设备的结构体。

Linux内核学习散知识整理的更多相关文章

  1. 关于Linux内核学习的误区以及相关书籍介绍

    http://www.hzlitai.com.cn/article/ARM9-article/system/1605.html 写给Linux内核新手-关于Linux内核学习的误区 先说句正经的:其实 ...

  2. linux内核学习之一:环境搭建--安装Debian7.3

    本系列文章假设读者已对linux有一定的了解,其实学习linux内核不需要有很深的关于linux的知识,只需要了解以下内容:linux基础知识及基本shell命令:现代操作系统的基本概念:C语言和gc ...

  3. Linux内核学习趣谈

    本文原创是freas_1990,转载请标明出处:http://blog.csdn.net/freas_1990/article/details/9304991 从大二开始学习Linux内核,到现在已经 ...

  4. Linux内核分析——Linux内核学习总结

    马悦+原创作品转载请注明出处+<Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 Linux内核学习总结 一 ...

  5. Linux内核学习总结(final)

    Linux内核学习总结 符钰婧 原创作品转载请注明出处 <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 ...

  6. Linux 内核学习的经典书籍及途径

    from:http://www.zhihu.com/question/19606660 知乎 Linux 内核学习的经典书籍及途径?修改 修改 写补充说明 举报   添加评论 分享 • 邀请回答   ...

  7. linux内核学习之二:编译内核

    在linux内核学习系列的第一课中讲述了搭建学习环境的过程(http://www.cnblogs.com/xiongyuanxiong/p/3523306.html),环境搭好后,马上就进入到下一环节 ...

  8. Linux内核学习笔记-2.进程管理

    原创文章,转载请注明:Linux内核学习笔记-2.进程管理) By Lucio.Yang 部分内容来自:Linux Kernel Development(Third Edition),Robert L ...

  9. Linux内核学习笔记-1.简介和入门

    原创文章,转载请注明:Linux内核学习笔记-1.简介和入门 By Lucio.Yang 部分内容来自:Linux Kernel Development(Third Edition),Robert L ...

随机推荐

  1. vue form表单上传文件

    <script src="https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js">< ...

  2. Annotation-based argument resolution 部分2

    HandlerMethodArgumentResolver的抽象實現AbstractNamedValueMethodArgumentResolver下的子类  部分1 RequestParamMapM ...

  3. MSYS 工具和TOOLCHAIN的配置

    博客转载:https://blog.csdn.net/hunterhuang2013/article/details/70880569 1. MSYS2 自带的开发环境,安装的包叫 msys2-dev ...

  4. 利用nvidia-smi 管理和监控NVIDIA GPU设备

    NVIDIA系统管理界面介绍 原文来源:https://developer.nvidia.com/nvidia-system-management-interface NVIDIA系统管理界面(nvi ...

  5. zxing解析生成一维码二维码

    @web界面实现扫一扫 二维码工具类 package util; import java.awt.BasicStroke; import java.awt.Graphics; import java. ...

  6. 为什么地址空间分配粒度为64K?Why is address space allocation granularity 64K?

    您可能想知道为什么VirtualAlloc在64K边界分配内存,即使页面粒度为4K. 你有Alpha AXP处理器,感谢你. 在Alpha AXP上,没有“加载32位整数”指令.要加载32位整数,实际 ...

  7. 1-3docker commit定制镜像

    以定制⼀个 Web 服务器为例⼦ 1.commit定制镜像 docker pull nginx:1.17   运行容器 --name:容器名字 -d:后台 -p本地端口:容器内端口 docker ru ...

  8. [ARM-Linux开发]linux dmesg命令参数及用法详解(linux显示开机信息命令)

    功能说明:显示开机信息.语 法:dmesg [-cn][-s <缓冲区大小>]补充说明:kernel会将开机信息存储在ring buffer中.您若是开机时来不及查看信息,可利用dmesg ...

  9. [LOJ3053]希望

    对于一组$s_{1\cdots k}$,合法的$u$构成一个连通块,满足$\left\lvert V\right\rvert-\left\lvert E\right\rvert=1$ 考虑算出算$f_ ...

  10. git merge合并分支; already up to date 现象, merger算法

    https://git-scm.com/book/zh/v2/Git-%E5%88%86%E6%94%AF-%E5%88%86%E6%94%AF%E7%9A%84%E6%96%B0%E5%BB%BA% ...