基于linux3.0.8内核,
s5pv210 芯片,
source insight软件,
struct bus_type my_bus = {
.name = "mybus", // /sys/bus/mybus/
.match = my_bus_match,
};
struct my_driver mydrv = {
.drv_id = 9,
.probe = mydrv_child_probe,
.driver = {
.name = "mydrv", //一定初始化--/sys/bus/mybus/drivers/mydrv
.probe = mydrv_parent_probe,
},
};
详细就跟着下面的函数一级一级的网下找对应函数:
driver_register(&mydrv.driver);
driver_register(struct device_driver *drv)
ret = bus_add_driver(drv);
error = driver_attach(drv);
return bus_for_each_dev(drv->bus, NULL, drv, __driver_attach);
error = fn(dev, data);
//fn = __driver_attach
static int __driver_attach(struct device *dev, void *data)
if (!driver_match_device(drv, dev))
//即执行match方法
return drv->bus->match ? drv->bus->match(dev, drv) : 1;
driver_probe_device(drv, dev);
ret = really_probe(dev, drv);
ret = dev->bus->probe(dev);//执行父类probe方法
ret = drv->probe(dev);//执行子类probe方法