大家帮我看看clk_get究竟是怎么实现的。谢谢

pcwung pcwung 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

linux-2.6.21.5/arch/arm/plat-s3c24xx/clock.c
/* Clock API calls */

struct clk *(struct device *dev, const char *id)
{
struct clk *p;
struct clk *clk = ERR_PTR(-ENOENT);
int idno;

if (dev == NULL || dev->bus != &platform_bus_type)
idno = -1;
else
idno = to_platform_device(dev)->id;

mutex_lock(&clocks_mutex);

list_for_each_entry(p, & clocks, list) {
if (p->id == idno &&
strcmp(id, p->name) == 0 &&
try_module_get(p->owner)) {
clk = p;
break;
}
}

/* check for the case where a device was supplied, but the
* clock that was being searched for is not device specific */

if (IS_ERR(clk)) {
list_for_each_entry(p, &clocks, list) {
if (p->id == -1 && strcmp(id, p->name) == 0 &&
try_module_get(p->owner)) {
clk = p;
break;
}
}
}

mutex_unlock(&clocks_mutex);
return clk;
}



#define list_for_each_entry(pos, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member); \
prefetch(pos->member.next), &pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))

说白了define list_for_each_entry 就是一个for循环。。。。



怎么和
struct clk clk_xtal = {
.name = "xtal",
.id = -1,
.rate = 0,
.parent = NULL,
.ctrlbit = 0,
};

这些结构体联系起来的呢???
...全文
评论 1
收藏 已收藏
分享
返回顶部
pcwung
Linux_Kernel 4,469 成员 17,458 内容