[i2c] [PATCH] i2c-core: Warn on i2c client creation failure
Jean Delvare
khali at linux-fr.org
Thu Aug 31 09:15:02 CEST 2006
Hi all,
With all the work currently going on to handle errors more cleanly in
various i2c chip drivers, it appeared to me that it would be nice if
the i2c-core would at least warn when an i2c client fails to be
created. Right now, this unlikely event is plain ignored. In the
current i2c subsystem model, we can't actually fail here, but a log
message with the client address and error value may come in handy for
later debugging.
* * * * *
Warn when an i2c client creation fails. If we don't, the user will
never know something wrong happened, as i2c client creation is
typically called through an attach_adapter callback, those return value
we currently ignore for technical reasons.
Signed-off-by: Jean Delvare <khali at linux-fr.org>
---
drivers/i2c/i2c-core.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
--- linux-2.6.18-rc5.orig/drivers/i2c/i2c-core.c 2006-08-30 20:49:07.000000000 +0200
+++ linux-2.6.18-rc5/drivers/i2c/i2c-core.c 2006-08-31 08:47:43.000000000 +0200
@@ -707,11 +707,16 @@
/* Finally call the custom detection function */
err = found_proc(adapter, addr, kind);
-
/* -ENODEV can be returned if there is a chip at the given address
but it isn't supported by this chip driver. We catch it here as
this isn't an error. */
- return (err == -ENODEV) ? 0 : err;
+ if (err == -ENODEV)
+ err = 0;
+
+ if (err)
+ dev_warn(&adapter->dev, "Client creation failed at 0x%x (%d)\n",
+ addr, err);
+ return err;
}
int i2c_probe(struct i2c_adapter *adapter,
--
Jean Delvare
More information about the i2c
mailing list