From: Dmitry Torokhov Date: Thu, 12 Oct 2006 05:06:23 +0000 (-0400) Subject: Input: serio core - handle errors returned by device_bind_driver() X-Git-Tag: v2.6.19-rc3~152^2~2 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a66045bcfd3a7ba5d1253f9f305b78bf636ac57;p=linux-2.6 Input: serio core - handle errors returned by device_bind_driver() Signed-off-by: Dmitry Torokhov --- diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index 480fdc5d20..211943f85c 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c @@ -118,6 +118,8 @@ static int serio_match_port(const struct serio_device_id *ids, struct serio *ser static void serio_bind_driver(struct serio *serio, struct serio_driver *drv) { + int error; + down_write(&serio_bus.subsys.rwsem); if (serio_match_port(drv->id_table, serio)) { @@ -126,9 +128,19 @@ static void serio_bind_driver(struct serio *serio, struct serio_driver *drv) serio->dev.driver = NULL; goto out; } - device_bind_driver(&serio->dev); + error = device_bind_driver(&serio->dev); + if (error) { + printk(KERN_WARNING + "serio: device_bind_driver() failed " + "for %s (%s) and %s, error: %d\n", + serio->phys, serio->name, + drv->description, error); + serio_disconnect_driver(serio); + serio->dev.driver = NULL; + goto out; + } } -out: + out: up_write(&serio_bus.subsys.rwsem); }