struct resource *platform_get_resource(struct platform_device *dev, unsigned int type, unsigned int num)
{ int i;
for (i = 0; i < dev->num_resources; i++)
{ struct resource *r = &dev->resource[i];
if (type == resource_type(r) && num-- == 0)
return r;
}
return NULL;
}
summary point: 1. 从该函数的定义可以看出 num 参数是同一种类型资源下的资源索引,因为 if (type == resource_type(r) && num-- == 0) 这条判断语句的执行是先执行 && 前面的类型判断,然后才执行索引判断。
本文深入解析了platform_get_resource函数的工作原理,该函数用于在设备中根据类型和索引获取特定资源。通过具体代码示例,文章详细阐述了如何遍历设备资源并返回匹配的资源结构。
2262

被折叠的 条评论
为什么被折叠?



