- 论坛徽章:
- 0
|
本帖最后由 hidiy 于 2010-05-13 11:39 编辑
回复 8# Godbach
这个是linux驱动模型源码,
int device_add(struct device *dev)
{
struct device *parent = NULL;
struct class_interface *class_intf;
int error = -EINVAL;
dev = get_device(dev);//
if (!dev)
goto done;
/* Temporarily support init_name if it is set. * It will override bus_id for now */
if (dev->init_name)//此指针变量未初始化,他就在使用。我想肯定要么是gcc初始化了全局变量为NULL,或者其他地方初始化了他,我没看见到底在那初始化了他,这个函数中 有 很多类似情况
dev_set_name(dev, "%s", dev->init_name);
if (!strlen(dev->bus_id))
goto done;
pr_debug("device: '%s': %s\n", dev->bus_id, __func__);
parent = get_device(dev->parent);//此处的dev_>parent 同样为初始化
setup_parent(dev, parent);
/* use parent numa_node */
if (parent)
set_dev_node(dev, dev_to_node(parent));
/* first, register with generic layer. */
error = kobject_add(&dev->kobj, dev->kobj.parent, "%s", dev->bus_id);
if (error)
goto Error;
/* notify platform of device entry */
if (platform_notify)
platform_notify(dev);
/* notify clients of device entry (new way) */
。。。。。。。。。。。。。。。。。。。。。。
同时感谢你的回复,这个问题一直困扰我,希望得到求证 |
|