lkml.org 
[lkml]   [2008]   [Apr]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch] detect duplicate drivers
Hello.

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: Stas Sergeev <stsp@aknet.ru>
--- a/drivers/base/driver.c 2008-04-22 20:51:31.000000000 +0400
+++ b/drivers/base/driver.c 2008-04-26 19:43:26.000000000 +0400
@@ -217,12 +217,22 @@
int driver_register(struct device_driver *drv)
{
int ret;
+ struct device_driver *other;

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 -EEXIST;
+ }
+
ret = bus_add_driver(drv);
if (ret)
return ret;
\
 
 \ /
  Last update: 2008-04-26 17:55    [W:0.117 / U:0.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site