diff options
author | Jean Delvare <khali@linux-fr.org> | 2005-07-31 13:02:53 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-09-05 12:14:16 -0400 |
commit | b6d7b3d1b5a388b7e9af2629a9ecccedee064078 (patch) | |
tree | 8961c6ee76ddf00c613308322472346c886a27e6 | |
parent | 014e45380a3b96f2ebd8ff0d115b7a33c06d06d1 (diff) |
[PATCH] I2C: Improve core debugging messages
The debugging messages in i2c-core are more confusing than helpful. Some
lack their trailing newline, some lack a prefix, some are redundant,
some lack precious information. Here is my attempt to introduce some
standardization in there.
I also changed two messages in i2c-dev to make it clear they come from
i2c-dev.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/i2c/i2c-core.c | 63 | ||||
-rw-r--r-- | drivers/i2c/i2c-dev.c | 5 |
2 files changed, 29 insertions, 39 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 20f92e355f56..19d8a994b3b7 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -188,6 +188,8 @@ int i2c_add_adapter(struct i2c_adapter *adap) | |||
188 | strlcpy(adap->class_dev.class_id, adap->dev.bus_id, BUS_ID_SIZE); | 188 | strlcpy(adap->class_dev.class_id, adap->dev.bus_id, BUS_ID_SIZE); |
189 | class_device_register(&adap->class_dev); | 189 | class_device_register(&adap->class_dev); |
190 | 190 | ||
191 | dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name); | ||
192 | |||
191 | /* inform drivers of new adapters */ | 193 | /* inform drivers of new adapters */ |
192 | list_for_each(item,&drivers) { | 194 | list_for_each(item,&drivers) { |
193 | driver = list_entry(item, struct i2c_driver, list); | 195 | driver = list_entry(item, struct i2c_driver, list); |
@@ -196,8 +198,6 @@ int i2c_add_adapter(struct i2c_adapter *adap) | |||
196 | driver->attach_adapter(adap); | 198 | driver->attach_adapter(adap); |
197 | } | 199 | } |
198 | 200 | ||
199 | dev_dbg(&adap->dev, "registered as adapter #%d\n", adap->nr); | ||
200 | |||
201 | out_unlock: | 201 | out_unlock: |
202 | up(&core_lists); | 202 | up(&core_lists); |
203 | return res; | 203 | return res; |
@@ -220,8 +220,8 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
220 | break; | 220 | break; |
221 | } | 221 | } |
222 | if (adap_from_list != adap) { | 222 | if (adap_from_list != adap) { |
223 | pr_debug("I2C: Attempting to delete an unregistered " | 223 | pr_debug("i2c-core: attempting to delete unregistered " |
224 | "adapter\n"); | 224 | "adapter [%s]\n", adap->name); |
225 | res = -EINVAL; | 225 | res = -EINVAL; |
226 | goto out_unlock; | 226 | goto out_unlock; |
227 | } | 227 | } |
@@ -230,9 +230,8 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
230 | driver = list_entry(item, struct i2c_driver, list); | 230 | driver = list_entry(item, struct i2c_driver, list); |
231 | if (driver->detach_adapter) | 231 | if (driver->detach_adapter) |
232 | if ((res = driver->detach_adapter(adap))) { | 232 | if ((res = driver->detach_adapter(adap))) { |
233 | dev_warn(&adap->dev, "can't detach adapter " | 233 | dev_err(&adap->dev, "detach_adapter failed " |
234 | "while detaching driver %s: driver " | 234 | "for driver [%s]\n", driver->name); |
235 | "not detached!\n", driver->name); | ||
236 | goto out_unlock; | 235 | goto out_unlock; |
237 | } | 236 | } |
238 | } | 237 | } |
@@ -247,9 +246,8 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
247 | * must be deleted, as this would cause invalid states. | 246 | * must be deleted, as this would cause invalid states. |
248 | */ | 247 | */ |
249 | if ((res=client->driver->detach_client(client))) { | 248 | if ((res=client->driver->detach_client(client))) { |
250 | dev_err(&adap->dev, "adapter not " | 249 | dev_err(&adap->dev, "detach_client failed for client " |
251 | "unregistered, because client at " | 250 | "[%s] at address 0x%02x\n", client->name, |
252 | "address %02x can't be detached. ", | ||
253 | client->addr); | 251 | client->addr); |
254 | goto out_unlock; | 252 | goto out_unlock; |
255 | } | 253 | } |
@@ -270,7 +268,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) | |||
270 | /* free dynamically allocated bus id */ | 268 | /* free dynamically allocated bus id */ |
271 | idr_remove(&i2c_adapter_idr, adap->nr); | 269 | idr_remove(&i2c_adapter_idr, adap->nr); |
272 | 270 | ||
273 | dev_dbg(&adap->dev, "adapter unregistered\n"); | 271 | dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name); |
274 | 272 | ||
275 | out_unlock: | 273 | out_unlock: |
276 | up(&core_lists); | 274 | up(&core_lists); |
@@ -303,7 +301,7 @@ int i2c_add_driver(struct i2c_driver *driver) | |||
303 | goto out_unlock; | 301 | goto out_unlock; |
304 | 302 | ||
305 | list_add_tail(&driver->list,&drivers); | 303 | list_add_tail(&driver->list,&drivers); |
306 | pr_debug("i2c-core: driver %s registered.\n", driver->name); | 304 | pr_debug("i2c-core: driver [%s] registered\n", driver->name); |
307 | 305 | ||
308 | /* now look for instances of driver on our adapters */ | 306 | /* now look for instances of driver on our adapters */ |
309 | if (driver->flags & I2C_DF_NOTIFY) { | 307 | if (driver->flags & I2C_DF_NOTIFY) { |
@@ -331,21 +329,17 @@ int i2c_del_driver(struct i2c_driver *driver) | |||
331 | /* Have a look at each adapter, if clients of this driver are still | 329 | /* Have a look at each adapter, if clients of this driver are still |
332 | * attached. If so, detach them to be able to kill the driver | 330 | * attached. If so, detach them to be able to kill the driver |
333 | * afterwards. | 331 | * afterwards. |
334 | */ | 332 | * |
335 | pr_debug("i2c-core: unregister_driver - looking for clients.\n"); | 333 | * Removing clients does not depend on the notify flag, else |
336 | /* removing clients does not depend on the notify flag, else | ||
337 | * invalid operation might (will!) result, when using stale client | 334 | * invalid operation might (will!) result, when using stale client |
338 | * pointers. | 335 | * pointers. |
339 | */ | 336 | */ |
340 | list_for_each(item1,&adapters) { | 337 | list_for_each(item1,&adapters) { |
341 | adap = list_entry(item1, struct i2c_adapter, list); | 338 | adap = list_entry(item1, struct i2c_adapter, list); |
342 | dev_dbg(&adap->dev, "examining adapter\n"); | ||
343 | if (driver->detach_adapter) { | 339 | if (driver->detach_adapter) { |
344 | if ((res = driver->detach_adapter(adap))) { | 340 | if ((res = driver->detach_adapter(adap))) { |
345 | dev_warn(&adap->dev, "while unregistering " | 341 | dev_err(&adap->dev, "detach_adapter failed " |
346 | "dummy driver %s, adapter could " | 342 | "for driver [%s]\n", driver->name); |
347 | "not be detached properly; driver " | ||
348 | "not unloaded!",driver->name); | ||
349 | goto out_unlock; | 343 | goto out_unlock; |
350 | } | 344 | } |
351 | } else { | 345 | } else { |
@@ -353,16 +347,13 @@ int i2c_del_driver(struct i2c_driver *driver) | |||
353 | client = list_entry(item2, struct i2c_client, list); | 347 | client = list_entry(item2, struct i2c_client, list); |
354 | if (client->driver != driver) | 348 | if (client->driver != driver) |
355 | continue; | 349 | continue; |
356 | pr_debug("i2c-core.o: detaching client %s:\n", client->name); | 350 | dev_dbg(&adap->dev, "detaching client [%s] " |
351 | "at 0x%02x\n", client->name, | ||
352 | client->addr); | ||
357 | if ((res = driver->detach_client(client))) { | 353 | if ((res = driver->detach_client(client))) { |
358 | dev_err(&adap->dev, "while " | 354 | dev_err(&adap->dev, "detach_client " |
359 | "unregistering driver " | 355 | "failed for client [%s] at " |
360 | "`%s', the client at " | 356 | "0x%02x\n", client->name, |
361 | "address %02x of " | ||
362 | "adapter could not " | ||
363 | "be detached; driver " | ||
364 | "not unloaded!", | ||
365 | driver->name, | ||
366 | client->addr); | 357 | client->addr); |
367 | goto out_unlock; | 358 | goto out_unlock; |
368 | } | 359 | } |
@@ -372,7 +363,7 @@ int i2c_del_driver(struct i2c_driver *driver) | |||
372 | 363 | ||
373 | driver_unregister(&driver->driver); | 364 | driver_unregister(&driver->driver); |
374 | list_del(&driver->list); | 365 | list_del(&driver->list); |
375 | pr_debug("i2c-core: driver unregistered: %s\n", driver->name); | 366 | pr_debug("i2c-core: driver [%s] unregistered\n", driver->name); |
376 | 367 | ||
377 | out_unlock: | 368 | out_unlock: |
378 | up(&core_lists); | 369 | up(&core_lists); |
@@ -417,15 +408,12 @@ int i2c_attach_client(struct i2c_client *client) | |||
417 | 408 | ||
418 | if (adapter->client_register) { | 409 | if (adapter->client_register) { |
419 | if (adapter->client_register(client)) { | 410 | if (adapter->client_register(client)) { |
420 | dev_warn(&adapter->dev, "warning: client_register " | 411 | dev_dbg(&adapter->dev, "client_register " |
421 | "seems to have failed for client %02x\n", | 412 | "failed for client [%s] at 0x%02x\n", |
422 | client->addr); | 413 | client->name, client->addr); |
423 | } | 414 | } |
424 | } | 415 | } |
425 | 416 | ||
426 | dev_dbg(&adapter->dev, "client [%s] registered to adapter\n", | ||
427 | client->name); | ||
428 | |||
429 | if (client->flags & I2C_CLIENT_ALLOW_USE) | 417 | if (client->flags & I2C_CLIENT_ALLOW_USE) |
430 | client->usage_count = 0; | 418 | client->usage_count = 0; |
431 | 419 | ||
@@ -436,7 +424,8 @@ int i2c_attach_client(struct i2c_client *client) | |||
436 | 424 | ||
437 | snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), | 425 | snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id), |
438 | "%d-%04x", i2c_adapter_id(adapter), client->addr); | 426 | "%d-%04x", i2c_adapter_id(adapter), client->addr); |
439 | pr_debug("registering %s\n", client->dev.bus_id); | 427 | dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n", |
428 | client->name, client->dev.bus_id); | ||
440 | device_register(&client->dev); | 429 | device_register(&client->dev); |
441 | device_create_file(&client->dev, &dev_attr_client_name); | 430 | device_create_file(&client->dev, &dev_attr_client_name); |
442 | 431 | ||
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index bc5d557e5dd9..aa7a4fadef64 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -434,7 +434,8 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap) | |||
434 | 434 | ||
435 | devfs_mk_cdev(MKDEV(I2C_MAJOR, i2c_dev->minor), | 435 | devfs_mk_cdev(MKDEV(I2C_MAJOR, i2c_dev->minor), |
436 | S_IFCHR|S_IRUSR|S_IWUSR, "i2c/%d", i2c_dev->minor); | 436 | S_IFCHR|S_IRUSR|S_IWUSR, "i2c/%d", i2c_dev->minor); |
437 | dev_dbg(&adap->dev, "Registered as minor %d\n", i2c_dev->minor); | 437 | pr_debug("i2c-dev: adapter [%s] registered as minor %d\n", |
438 | adap->name, i2c_dev->minor); | ||
438 | 439 | ||
439 | /* register this i2c device with the driver core */ | 440 | /* register this i2c device with the driver core */ |
440 | i2c_dev->adap = adap; | 441 | i2c_dev->adap = adap; |
@@ -471,7 +472,7 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap) | |||
471 | wait_for_completion(&i2c_dev->released); | 472 | wait_for_completion(&i2c_dev->released); |
472 | kfree(i2c_dev); | 473 | kfree(i2c_dev); |
473 | 474 | ||
474 | dev_dbg(&adap->dev, "Adapter unregistered\n"); | 475 | pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name); |
475 | return 0; | 476 | return 0; |
476 | } | 477 | } |
477 | 478 | ||