aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug/acpiphp_ibm.c
diff options
context:
space:
mode:
authorLan Tianyu <tianyu.lan@intel.com>2013-09-24 20:07:28 -0400
committerBjorn Helgaas <bhelgaas@google.com>2013-09-25 19:00:51 -0400
commit43e7aa47a7fc3948304d386780ed3100cb67ddac (patch)
tree6ae6393924ab1f408a9e36faff087d32afeb9472 /drivers/pci/hotplug/acpiphp_ibm.c
parentbd950799d9510cac994fad2ea020767fe878b84b (diff)
PCI: acpiphp_ibm: Convert to dynamic debug
This patch is to use pr_debug/info/warn/err to replace acpiphp_ibm debug functions and remove module's debug param. User interface change: before this patch, boot with the "acpiphp_ibm.debug" kernel parameter to turn on debug. After this patch, set CONFIG_DYNAMIC_DEBUG=y and boot with "acpiphp_ibm.dyndebug=+p" instead. See Documentation/dynamic-debug-howto.txt. [bhelgaas: changelog] Signed-off-by: Lan Tianyu <tianyu.lan@intel.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/hotplug/acpiphp_ibm.c')
-rw-r--r--drivers/pci/hotplug/acpiphp_ibm.c58
1 files changed, 24 insertions, 34 deletions
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
index 2f5786c8522c..0d64c414bf78 100644
--- a/drivers/pci/hotplug/acpiphp_ibm.c
+++ b/drivers/pci/hotplug/acpiphp_ibm.c
@@ -25,6 +25,8 @@
25 * 25 *
26 */ 26 */
27 27
28#define pr_fmt(fmt) "acpiphp_ibm: " fmt
29
28#include <linux/init.h> 30#include <linux/init.h>
29#include <linux/slab.h> 31#include <linux/slab.h>
30#include <linux/module.h> 32#include <linux/module.h>
@@ -43,23 +45,11 @@
43#define DRIVER_AUTHOR "Irene Zubarev <zubarev@us.ibm.com>, Vernon Mauery <vernux@us.ibm.com>" 45#define DRIVER_AUTHOR "Irene Zubarev <zubarev@us.ibm.com>, Vernon Mauery <vernux@us.ibm.com>"
44#define DRIVER_DESC "ACPI Hot Plug PCI Controller Driver IBM extension" 46#define DRIVER_DESC "ACPI Hot Plug PCI Controller Driver IBM extension"
45 47
46static bool debug;
47 48
48MODULE_AUTHOR(DRIVER_AUTHOR); 49MODULE_AUTHOR(DRIVER_AUTHOR);
49MODULE_DESCRIPTION(DRIVER_DESC); 50MODULE_DESCRIPTION(DRIVER_DESC);
50MODULE_LICENSE("GPL"); 51MODULE_LICENSE("GPL");
51MODULE_VERSION(DRIVER_VERSION); 52MODULE_VERSION(DRIVER_VERSION);
52module_param(debug, bool, 0644);
53MODULE_PARM_DESC(debug, " Debugging mode enabled or not");
54#define MY_NAME "acpiphp_ibm"
55
56#undef dbg
57#define dbg(format, arg...) \
58do { \
59 if (debug) \
60 printk(KERN_DEBUG "%s: " format, \
61 MY_NAME , ## arg); \
62} while (0)
63 53
64#define FOUND_APCI 0x61504349 54#define FOUND_APCI 0x61504349
65/* these are the names for the IBM ACPI pseudo-device */ 55/* these are the names for the IBM ACPI pseudo-device */
@@ -189,7 +179,7 @@ static int ibm_set_attention_status(struct hotplug_slot *slot, u8 status)
189 179
190 ibm_slot = ibm_slot_from_id(hpslot_to_sun(slot)); 180 ibm_slot = ibm_slot_from_id(hpslot_to_sun(slot));
191 181
192 dbg("%s: set slot %d (%d) attention status to %d\n", __func__, 182 pr_debug("%s: set slot %d (%d) attention status to %d\n", __func__,
193 ibm_slot->slot.slot_num, ibm_slot->slot.slot_id, 183 ibm_slot->slot.slot_num, ibm_slot->slot.slot_id,
194 (status ? 1 : 0)); 184 (status ? 1 : 0));
195 185
@@ -202,10 +192,10 @@ static int ibm_set_attention_status(struct hotplug_slot *slot, u8 status)
202 192
203 stat = acpi_evaluate_integer(ibm_acpi_handle, "APLS", &params, &rc); 193 stat = acpi_evaluate_integer(ibm_acpi_handle, "APLS", &params, &rc);
204 if (ACPI_FAILURE(stat)) { 194 if (ACPI_FAILURE(stat)) {
205 err("APLS evaluation failed: 0x%08x\n", stat); 195 pr_err("APLS evaluation failed: 0x%08x\n", stat);
206 return -ENODEV; 196 return -ENODEV;
207 } else if (!rc) { 197 } else if (!rc) {
208 err("APLS method failed: 0x%08llx\n", rc); 198 pr_err("APLS method failed: 0x%08llx\n", rc);
209 return -ERANGE; 199 return -ERANGE;
210 } 200 }
211 return 0; 201 return 0;
@@ -234,7 +224,7 @@ static int ibm_get_attention_status(struct hotplug_slot *slot, u8 *status)
234 else 224 else
235 *status = 0; 225 *status = 0;
236 226
237 dbg("%s: get slot %d (%d) attention status is %d\n", __func__, 227 pr_debug("%s: get slot %d (%d) attention status is %d\n", __func__,
238 ibm_slot->slot.slot_num, ibm_slot->slot.slot_id, 228 ibm_slot->slot.slot_num, ibm_slot->slot.slot_id,
239 *status); 229 *status);
240 230
@@ -266,10 +256,10 @@ static void ibm_handle_events(acpi_handle handle, u32 event, void *context)
266 u8 subevent = event & 0xf0; 256 u8 subevent = event & 0xf0;
267 struct notification *note = context; 257 struct notification *note = context;
268 258
269 dbg("%s: Received notification %02x\n", __func__, event); 259 pr_debug("%s: Received notification %02x\n", __func__, event);
270 260
271 if (subevent == 0x80) { 261 if (subevent == 0x80) {
272 dbg("%s: generationg bus event\n", __func__); 262 pr_debug("%s: generationg bus event\n", __func__);
273 acpi_bus_generate_netlink_event(note->device->pnp.device_class, 263 acpi_bus_generate_netlink_event(note->device->pnp.device_class,
274 dev_name(&note->device->dev), 264 dev_name(&note->device->dev),
275 note->event, detail); 265 note->event, detail);
@@ -301,7 +291,7 @@ static int ibm_get_table_from_acpi(char **bufp)
301 291
302 status = acpi_evaluate_object(ibm_acpi_handle, "APCI", NULL, &buffer); 292 status = acpi_evaluate_object(ibm_acpi_handle, "APCI", NULL, &buffer);
303 if (ACPI_FAILURE(status)) { 293 if (ACPI_FAILURE(status)) {
304 err("%s: APCI evaluation failed\n", __func__); 294 pr_err("%s: APCI evaluation failed\n", __func__);
305 return -ENODEV; 295 return -ENODEV;
306 } 296 }
307 297
@@ -309,13 +299,13 @@ static int ibm_get_table_from_acpi(char **bufp)
309 if (!(package) || 299 if (!(package) ||
310 (package->type != ACPI_TYPE_PACKAGE) || 300 (package->type != ACPI_TYPE_PACKAGE) ||
311 !(package->package.elements)) { 301 !(package->package.elements)) {
312 err("%s: Invalid APCI object\n", __func__); 302 pr_err("%s: Invalid APCI object\n", __func__);
313 goto read_table_done; 303 goto read_table_done;
314 } 304 }
315 305
316 for(size = 0, i = 0; i < package->package.count; i++) { 306 for(size = 0, i = 0; i < package->package.count; i++) {
317 if (package->package.elements[i].type != ACPI_TYPE_BUFFER) { 307 if (package->package.elements[i].type != ACPI_TYPE_BUFFER) {
318 err("%s: Invalid APCI element %d\n", __func__, i); 308 pr_err("%s: Invalid APCI element %d\n", __func__, i);
319 goto read_table_done; 309 goto read_table_done;
320 } 310 }
321 size += package->package.elements[i].buffer.length; 311 size += package->package.elements[i].buffer.length;
@@ -325,7 +315,7 @@ static int ibm_get_table_from_acpi(char **bufp)
325 goto read_table_done; 315 goto read_table_done;
326 316
327 lbuf = kzalloc(size, GFP_KERNEL); 317 lbuf = kzalloc(size, GFP_KERNEL);
328 dbg("%s: element count: %i, ASL table size: %i, &table = 0x%p\n", 318 pr_debug("%s: element count: %i, ASL table size: %i, &table = 0x%p\n",
329 __func__, package->package.count, size, lbuf); 319 __func__, package->package.count, size, lbuf);
330 320
331 if (lbuf) { 321 if (lbuf) {
@@ -370,8 +360,8 @@ static ssize_t ibm_read_apci_table(struct file *filp, struct kobject *kobj,
370{ 360{
371 int bytes_read = -EINVAL; 361 int bytes_read = -EINVAL;
372 char *table = NULL; 362 char *table = NULL;
373 363
374 dbg("%s: pos = %d, size = %zd\n", __func__, (int)pos, size); 364 pr_debug("%s: pos = %d, size = %zd\n", __func__, (int)pos, size);
375 365
376 if (pos == 0) { 366 if (pos == 0) {
377 bytes_read = ibm_get_table_from_acpi(&table); 367 bytes_read = ibm_get_table_from_acpi(&table);
@@ -403,7 +393,7 @@ static acpi_status __init ibm_find_acpi_device(acpi_handle handle,
403 393
404 status = acpi_get_object_info(handle, &info); 394 status = acpi_get_object_info(handle, &info);
405 if (ACPI_FAILURE(status)) { 395 if (ACPI_FAILURE(status)) {
406 err("%s: Failed to get device information status=0x%x\n", 396 pr_err("%s: Failed to get device information status=0x%x\n",
407 __func__, status); 397 __func__, status);
408 return retval; 398 return retval;
409 } 399 }
@@ -411,7 +401,7 @@ static acpi_status __init ibm_find_acpi_device(acpi_handle handle,
411 if (info->current_status && (info->valid & ACPI_VALID_HID) && 401 if (info->current_status && (info->valid & ACPI_VALID_HID) &&
412 (!strcmp(info->hardware_id.string, IBM_HARDWARE_ID1) || 402 (!strcmp(info->hardware_id.string, IBM_HARDWARE_ID1) ||
413 !strcmp(info->hardware_id.string, IBM_HARDWARE_ID2))) { 403 !strcmp(info->hardware_id.string, IBM_HARDWARE_ID2))) {
414 dbg("found hardware: %s, handle: %p\n", 404 pr_debug("found hardware: %s, handle: %p\n",
415 info->hardware_id.string, handle); 405 info->hardware_id.string, handle);
416 *phandle = handle; 406 *phandle = handle;
417 /* returning non-zero causes the search to stop 407 /* returning non-zero causes the search to stop
@@ -432,18 +422,18 @@ static int __init ibm_acpiphp_init(void)
432 struct acpi_device *device; 422 struct acpi_device *device;
433 struct kobject *sysdir = &pci_slots_kset->kobj; 423 struct kobject *sysdir = &pci_slots_kset->kobj;
434 424
435 dbg("%s\n", __func__); 425 pr_debug("%s\n", __func__);
436 426
437 if (acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 427 if (acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
438 ACPI_UINT32_MAX, ibm_find_acpi_device, NULL, 428 ACPI_UINT32_MAX, ibm_find_acpi_device, NULL,
439 &ibm_acpi_handle, NULL) != FOUND_APCI) { 429 &ibm_acpi_handle, NULL) != FOUND_APCI) {
440 err("%s: acpi_walk_namespace failed\n", __func__); 430 pr_err("%s: acpi_walk_namespace failed\n", __func__);
441 retval = -ENODEV; 431 retval = -ENODEV;
442 goto init_return; 432 goto init_return;
443 } 433 }
444 dbg("%s: found IBM aPCI device\n", __func__); 434 pr_debug("%s: found IBM aPCI device\n", __func__);
445 if (acpi_bus_get_device(ibm_acpi_handle, &device)) { 435 if (acpi_bus_get_device(ibm_acpi_handle, &device)) {
446 err("%s: acpi_bus_get_device failed\n", __func__); 436 pr_err("%s: acpi_bus_get_device failed\n", __func__);
447 retval = -ENODEV; 437 retval = -ENODEV;
448 goto init_return; 438 goto init_return;
449 } 439 }
@@ -457,7 +447,7 @@ static int __init ibm_acpiphp_init(void)
457 ACPI_DEVICE_NOTIFY, ibm_handle_events, 447 ACPI_DEVICE_NOTIFY, ibm_handle_events,
458 &ibm_note); 448 &ibm_note);
459 if (ACPI_FAILURE(status)) { 449 if (ACPI_FAILURE(status)) {
460 err("%s: Failed to register notification handler\n", 450 pr_err("%s: Failed to register notification handler\n",
461 __func__); 451 __func__);
462 retval = -EBUSY; 452 retval = -EBUSY;
463 goto init_cleanup; 453 goto init_cleanup;
@@ -479,17 +469,17 @@ static void __exit ibm_acpiphp_exit(void)
479 acpi_status status; 469 acpi_status status;
480 struct kobject *sysdir = &pci_slots_kset->kobj; 470 struct kobject *sysdir = &pci_slots_kset->kobj;
481 471
482 dbg("%s\n", __func__); 472 pr_debug("%s\n", __func__);
483 473
484 if (acpiphp_unregister_attention(&ibm_attention_info)) 474 if (acpiphp_unregister_attention(&ibm_attention_info))
485 err("%s: attention info deregistration failed", __func__); 475 pr_err("%s: attention info deregistration failed", __func__);
486 476
487 status = acpi_remove_notify_handler( 477 status = acpi_remove_notify_handler(
488 ibm_acpi_handle, 478 ibm_acpi_handle,
489 ACPI_DEVICE_NOTIFY, 479 ACPI_DEVICE_NOTIFY,
490 ibm_handle_events); 480 ibm_handle_events);
491 if (ACPI_FAILURE(status)) 481 if (ACPI_FAILURE(status))
492 err("%s: Notification handler removal failed\n", __func__); 482 pr_err("%s: Notification handler removal failed\n", __func__);
493 /* remove the /sys entries */ 483 /* remove the /sys entries */
494 sysfs_remove_bin_file(sysdir, &ibm_apci_table_attr); 484 sysfs_remove_bin_file(sysdir, &ibm_apci_table_attr);
495} 485}