//驱动登记到自己的总线上; /**
* driver_register - register driver with bus
* @drv: driver to register
*
* We pass off most of the work to the bus_add_driver() call,
* since most of the things we have to do deal with the bus
* structures.
*/ int driver_register(struct device_driver *drv)//将驱动注册到指定的总线(bus); { int ret;
struct device_driver *other;
BUG_ON(!drv->bus->p);
if ((drv->bus->probe && drv->probe) || (drv->bus->remove && drv->remove) ||
(drv->bus->shutdown && drv->shutdown)) printk(KERN_WARNING "Driver '%s' needs updating - please use " "bus_type methods\n", drv->name);
other = driver_find(drv->name,
drv->bus);//通过对比,确认总线上之前没有注册过;
if (other) { put_driver(other);
printk(KERN_ERR "Error: Driver '%s' is already registered, " "aborting...\n", drv->name); return -EBUSY; }
ret = bus_add_driver(drv);//将驱动注册到总线上;
if (ret) return ret; ret = driver_add_groups(drv, drv->groups);
if (ret) bus_remove_driver(drv); return ret; }
阅读(1641) | 评论(0) | 转发(0) |