drivers/mfd/Mfd-core.c
来源:互联网 发布:ipad怎么清除应用数据 编辑:程序博客网 时间:2024/06/15 04:17
mfd: multifunction device drivers---多功能设备驱动开发;
A product or device that has multiple functions. An example of this might be a printer that also makes copies, faxes, and scans. Another example is a CD or DVD that might contain multiple applications on the same disk; this may be a Mac and PC version of the same software or media meant to be played on more than one platform. Also called multi function product (MFP), all-in-one.
A product or device that has multiple functions. An example of this might be a printer that also makes copies, faxes, and scans. Another example is a CD or DVD that might contain multiple applications on the same disk; this may be a Mac and PC version of the same software or media meant to be played on more than one platform. Also called multi function product (MFP), all-in-one.
源码主要是做了一些platform_device的注册和添加删除工作。
int mfd_add_devices(struct device *parent, int id, struct mfd_cell *cells, int n_devs, struct resource *mem_base, int irq_base){int i;int ret = 0;atomic_t *cnts;/* initialize reference counting for all cells */cnts = kcalloc(n_devs, sizeof(*cnts), GFP_KERNEL);if (!cnts)return -ENOMEM;for (i = 0; i < n_devs; i++) {atomic_set(&cnts[i], 0);cells[i].usage_count = &cnts[i];ret = mfd_add_device(parent, id, cells + i, mem_base, irq_base); 调用mfd_add_device()if (ret)break;}if (ret)mfd_remove_devices(parent);return ret;}EXPORT_SYMBOL(mfd_add_devices);在这个函数中,参数cells是数组,个数为参数n_devs。用户调用此函数前初始化了cells部分内容,但其中成员由本函数初始化:
/* * This struct describes the MFD part ("cell"). * After registration the copy of this structure will become the platform data * of the resulting platform_device */struct mfd_cell {const char*name; intid; /* refcounting for multiple drivers to use a single cell */atomic_t*usage_count; //本函数初始化int(*enable)(struct platform_device *dev);int(*disable)(struct platform_device *dev);int(*suspend)(struct platform_device *dev);int(*resume)(struct platform_device *dev);/* platform data passed to the sub devices drivers */void*platform_data;size_tpdata_size;/* * These resources can be specified relative to the parent device. * For accessing hardware you should use resources from the platform dev */intnum_resources;const struct resource*resources;/* don't check for resource conflicts */boolignore_resource_conflicts;/* * Disable runtime PM callbacks for this subdevice - see * pm_runtime_no_callbacks(). */boolpm_runtime_no_callbacks;};再来看mfd_add_device()
static int mfd_add_device(struct device *parent, int id, const struct mfd_cell *cell, struct resource *mem_base, int irq_base){struct resource *res;struct platform_device *pdev;int ret = -ENOMEM;int r;pdev = platform_device_alloc(cell->name, id + cell->id); //申请pdev内存并初始化name和idif (!pdev)goto fail_alloc;res = kzalloc(sizeof(*res) * cell->num_resources, GFP_KERNEL);if (!res)goto fail_device;pdev->dev.parent = parent;pdev->dev.type = &mfd_dev_type;if (cell->pdata_size) { //重新分配pdev->dev. platform_data内存并将cell->platform_data赋给它。ret = platform_device_add_data(pdev,cell->platform_data, cell->pdata_size);if (ret)goto fail_res;}ret = mfd_platform_add_cell(pdev, cell); //重新分配pdev->mfd_cell内存并将cell赋给它。if (ret)goto fail_res;//初始化cell->num_resources 个数量的res将它赋给pdev->resourcefor (r = 0; r < cell->num_resources; r++) {res[r].name = cell->resources[r].name;res[r].flags = cell->resources[r].flags;/* Find out base to use */if ((cell->resources[r].flags & IORESOURCE_MEM) && mem_base) {res[r].parent = mem_base;res[r].start = mem_base->start + //cell中的每个内存start都要加上mem_base->startcell->resources[r].start;res[r].end = mem_base->start +cell->resources[r].end;} else if (cell->resources[r].flags & IORESOURCE_IRQ) {res[r].start = irq_base + //每个cell中的irq都要加上irq_base。cell->resources[r].start;res[r].end = irq_base +cell->resources[r].end;} else {res[r].parent = cell->resources[r].parent;res[r].start = cell->resources[r].start;res[r].end = cell->resources[r].end;}if (!cell->ignore_resource_conflicts) {ret = acpi_check_resource_conflict(&res[r]);if (ret)goto fail_res;}}ret = platform_device_add_resources(pdev, res, cell->num_resources);//将多个res赋给pdevif (ret)goto fail_res;ret = platform_device_add(pdev); //添加一个platform_device到系统,这时在dev的驱动中会使用这些res数据。if (ret)goto fail_res;if (cell->pm_runtime_no_callbacks)pm_runtime_no_callbacks(&pdev->dev);kfree(res);return 0;fail_res:kfree(res);fail_device:platform_device_put(pdev);fail_alloc:return ret;}
0 0
- drivers/mfd/Mfd-core.c
- drivers/mfd/ezx-pcap.c:214: error: implicit declaration of function 'irq_to_gpio'
- hi3520d开发板内核编译出现drivers/mfd/ezx-pcap.c:213: error: implicit declaration of function 'irq_to_gpio'
- MFD还原和备份
- 编译海思3520内核时候报错drivers/mfd/ezx-pcap.c:205:2: error: implicit declaration of function 'irq_to_gpio' [-
- 编译飞凌ok335D开发板内核时出现drivers/mfd/ezx-pcap.c:205:2: error: implicit declaration of function 'irq_to_gpio
- Super.Mp3.Download.v3.3.4.6-MFD\
- drivers\base\core.c
- 我的内核学习笔记8:多功能设备mfd驱动
- /drivers/usb/core/File.c
- usb_control_msg(drivers/usb/core/message.c)
- drivers\base\sys.c
- drivers\base\bus.c
- drivers\base\dd.c
- drivers\base\driver.c
- drivers\base\class.c
- drivers\base\platform.c
- drivers\base\cpu.c
- Linux内核
- 编程之美斐波那契数列
- 如何让Anddroid手机访问电脑的Tomcat服务
- 写了一个方便抓Android系统日志的BAT脚本
- Android学习分享-常见控件01-TextView详解
- drivers/mfd/Mfd-core.c
- Linux内核模块的概念和基本的编程方法
- Node.js开发入门(六)——使用jade模板引擎
- 《阿甘正传》影评
- bzoj 1467: Pku3243 clever Y (扩展BSGS)
- 100.[LeetTree]Same Tree
- 【总结】C++、C#、Java、Javascript、Python中引用的区别
- Java项目开发规范参考
- Node.js开发入门(七)——使用AngularJS