提交 16dc42e0 编写于 作者: S Stas Sergeev 提交者: Greg Kroah-Hartman

driver core: warn about duplicate driver names on the same bus

Currently an attempt to register multiple
drivers with the same name causes the
stack trace with some cryptic error message.
The attached patch adds the necessary check
and the clear error message.
Signed-off-by: NStas Sergeev <stsp@aknet.ru>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 93dd4001
...@@ -217,12 +217,22 @@ static void driver_remove_groups(struct device_driver *drv, ...@@ -217,12 +217,22 @@ static void driver_remove_groups(struct device_driver *drv,
int driver_register(struct device_driver *drv) int driver_register(struct device_driver *drv)
{ {
int ret; int ret;
struct device_driver *other;
if ((drv->bus->probe && drv->probe) || if ((drv->bus->probe && drv->probe) ||
(drv->bus->remove && drv->remove) || (drv->bus->remove && drv->remove) ||
(drv->bus->shutdown && drv->shutdown)) (drv->bus->shutdown && drv->shutdown))
printk(KERN_WARNING "Driver '%s' needs updating - please use " printk(KERN_WARNING "Driver '%s' needs updating - please use "
"bus_type methods\n", drv->name); "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 -EEXIST;
}
ret = bus_add_driver(drv); ret = bus_add_driver(drv);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册