aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLan Tianyu <tianyu.lan@intel.com>2013-09-24 20:11:48 -0400
committerBjorn Helgaas <bhelgaas@google.com>2013-09-25 19:00:51 -0400
commitbd950799d9510cac994fad2ea020767fe878b84b (patch)
treefe9f572e98acaa7894bbe779e19fe00a3a33379d
parentb8cac70afe983f0c48a0296bbb7a6177e99fbbb9 (diff)
PCI: acpiphp: Convert to dynamic debug
This patch is to use pr_debug/info/warn/err to replace acpiphp debug functions and remove module's debug param. User interface change: before this patch, boot with the "acpiphp.debug" kernel parameter to turn on debug. After this patch, set CONFIG_DYNAMIC_DEBUG=y and boot with "acpiphp.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>
-rw-r--r--drivers/pci/hotplug/acpiphp.h10
-rw-r--r--drivers/pci/hotplug/acpiphp_core.c37
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c23
3 files changed, 30 insertions, 40 deletions
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index f4e028924667..26100f510b10 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -39,16 +39,6 @@
39#include <linux/mutex.h> 39#include <linux/mutex.h>
40#include <linux/pci_hotplug.h> 40#include <linux/pci_hotplug.h>
41 41
42#define dbg(format, arg...) \
43 do { \
44 if (acpiphp_debug) \
45 printk(KERN_DEBUG "%s: " format, \
46 MY_NAME , ## arg); \
47 } while (0)
48#define err(format, arg...) printk(KERN_ERR "%s: " format, MY_NAME , ## arg)
49#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
50#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
51
52struct acpiphp_context; 42struct acpiphp_context;
53struct acpiphp_bridge; 43struct acpiphp_bridge;
54struct acpiphp_slot; 44struct acpiphp_slot;
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index bf2203ef1308..8650d39db392 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -31,6 +31,8 @@
31 * 31 *
32 */ 32 */
33 33
34#define pr_fmt(fmt) "acpiphp: " fmt
35
34#include <linux/init.h> 36#include <linux/init.h>
35#include <linux/module.h> 37#include <linux/module.h>
36#include <linux/moduleparam.h> 38#include <linux/moduleparam.h>
@@ -43,12 +45,9 @@
43#include <linux/smp.h> 45#include <linux/smp.h>
44#include "acpiphp.h" 46#include "acpiphp.h"
45 47
46#define MY_NAME "acpiphp"
47
48/* name size which is used for entries in pcihpfs */ 48/* name size which is used for entries in pcihpfs */
49#define SLOT_NAME_SIZE 21 /* {_SUN} */ 49#define SLOT_NAME_SIZE 21 /* {_SUN} */
50 50
51bool acpiphp_debug;
52bool acpiphp_disabled; 51bool acpiphp_disabled;
53 52
54/* local variables */ 53/* local variables */
@@ -61,9 +60,7 @@ static struct acpiphp_attention_info *attention_info;
61MODULE_AUTHOR(DRIVER_AUTHOR); 60MODULE_AUTHOR(DRIVER_AUTHOR);
62MODULE_DESCRIPTION(DRIVER_DESC); 61MODULE_DESCRIPTION(DRIVER_DESC);
63MODULE_LICENSE("GPL"); 62MODULE_LICENSE("GPL");
64MODULE_PARM_DESC(debug, "Debugging mode enabled or not");
65MODULE_PARM_DESC(disable, "disable acpiphp driver"); 63MODULE_PARM_DESC(disable, "disable acpiphp driver");
66module_param_named(debug, acpiphp_debug, bool, 0644);
67module_param_named(disable, acpiphp_disabled, bool, 0444); 64module_param_named(disable, acpiphp_disabled, bool, 0444);
68 65
69/* export the attention callback registration methods */ 66/* export the attention callback registration methods */
@@ -139,7 +136,7 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
139{ 136{
140 struct slot *slot = hotplug_slot->private; 137 struct slot *slot = hotplug_slot->private;
141 138
142 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); 139 pr_debug("%s - physical_slot = %s\n", __func__, slot_name(slot));
143 140
144 /* enable the specified slot */ 141 /* enable the specified slot */
145 return acpiphp_enable_slot(slot->acpi_slot); 142 return acpiphp_enable_slot(slot->acpi_slot);
@@ -156,7 +153,7 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
156{ 153{
157 struct slot *slot = hotplug_slot->private; 154 struct slot *slot = hotplug_slot->private;
158 155
159 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); 156 pr_debug("%s - physical_slot = %s\n", __func__, slot_name(slot));
160 157
161 /* disable the specified slot */ 158 /* disable the specified slot */
162 return acpiphp_disable_and_eject_slot(slot->acpi_slot); 159 return acpiphp_disable_and_eject_slot(slot->acpi_slot);
@@ -176,8 +173,9 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
176 { 173 {
177 int retval = -ENODEV; 174 int retval = -ENODEV;
178 175
179 dbg("%s - physical_slot = %s\n", __func__, hotplug_slot_name(hotplug_slot)); 176 pr_debug("%s - physical_slot = %s\n", __func__,
180 177 hotplug_slot_name(hotplug_slot));
178
181 if (attention_info && try_module_get(attention_info->owner)) { 179 if (attention_info && try_module_get(attention_info->owner)) {
182 retval = attention_info->set_attn(hotplug_slot, status); 180 retval = attention_info->set_attn(hotplug_slot, status);
183 module_put(attention_info->owner); 181 module_put(attention_info->owner);
@@ -199,7 +197,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
199{ 197{
200 struct slot *slot = hotplug_slot->private; 198 struct slot *slot = hotplug_slot->private;
201 199
202 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); 200 pr_debug("%s - physical_slot = %s\n", __func__, slot_name(slot));
203 201
204 *value = acpiphp_get_power_status(slot->acpi_slot); 202 *value = acpiphp_get_power_status(slot->acpi_slot);
205 203
@@ -221,7 +219,8 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
221{ 219{
222 int retval = -EINVAL; 220 int retval = -EINVAL;
223 221
224 dbg("%s - physical_slot = %s\n", __func__, hotplug_slot_name(hotplug_slot)); 222 pr_debug("%s - physical_slot = %s\n", __func__,
223 hotplug_slot_name(hotplug_slot));
225 224
226 if (attention_info && try_module_get(attention_info->owner)) { 225 if (attention_info && try_module_get(attention_info->owner)) {
227 retval = attention_info->get_attn(hotplug_slot, value); 226 retval = attention_info->get_attn(hotplug_slot, value);
@@ -244,7 +243,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
244{ 243{
245 struct slot *slot = hotplug_slot->private; 244 struct slot *slot = hotplug_slot->private;
246 245
247 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); 246 pr_debug("%s - physical_slot = %s\n", __func__, slot_name(slot));
248 247
249 *value = acpiphp_get_latch_status(slot->acpi_slot); 248 *value = acpiphp_get_latch_status(slot->acpi_slot);
250 249
@@ -264,7 +263,7 @@ static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
264{ 263{
265 struct slot *slot = hotplug_slot->private; 264 struct slot *slot = hotplug_slot->private;
266 265
267 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); 266 pr_debug("%s - physical_slot = %s\n", __func__, slot_name(slot));
268 267
269 *value = acpiphp_get_adapter_status(slot->acpi_slot); 268 *value = acpiphp_get_adapter_status(slot->acpi_slot);
270 269
@@ -279,7 +278,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
279{ 278{
280 struct slot *slot = hotplug_slot->private; 279 struct slot *slot = hotplug_slot->private;
281 280
282 dbg("%s - physical_slot = %s\n", __func__, slot_name(slot)); 281 pr_debug("%s - physical_slot = %s\n", __func__, slot_name(slot));
283 282
284 kfree(slot->hotplug_slot); 283 kfree(slot->hotplug_slot);
285 kfree(slot); 284 kfree(slot);
@@ -322,11 +321,11 @@ int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot,
322 if (retval == -EBUSY) 321 if (retval == -EBUSY)
323 goto error_hpslot; 322 goto error_hpslot;
324 if (retval) { 323 if (retval) {
325 err("pci_hp_register failed with error %d\n", retval); 324 pr_err("pci_hp_register failed with error %d\n", retval);
326 goto error_hpslot; 325 goto error_hpslot;
327 } 326 }
328 327
329 info("Slot [%s] registered\n", slot_name(slot)); 328 pr_info("Slot [%s] registered\n", slot_name(slot));
330 329
331 return 0; 330 return 0;
332error_hpslot: 331error_hpslot:
@@ -343,17 +342,17 @@ void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
343 struct slot *slot = acpiphp_slot->slot; 342 struct slot *slot = acpiphp_slot->slot;
344 int retval = 0; 343 int retval = 0;
345 344
346 info("Slot [%s] unregistered\n", slot_name(slot)); 345 pr_info("Slot [%s] unregistered\n", slot_name(slot));
347 346
348 retval = pci_hp_deregister(slot->hotplug_slot); 347 retval = pci_hp_deregister(slot->hotplug_slot);
349 if (retval) 348 if (retval)
350 err("pci_hp_deregister failed with error %d\n", retval); 349 pr_err("pci_hp_deregister failed with error %d\n", retval);
351} 350}
352 351
353 352
354void __init acpiphp_init(void) 353void __init acpiphp_init(void)
355{ 354{
356 info(DRIVER_DESC " version: " DRIVER_VERSION "%s\n", 355 pr_info(DRIVER_DESC " version: " DRIVER_VERSION "%s\n",
357 acpiphp_disabled ? ", disabled by user; please report a bug" 356 acpiphp_disabled ? ", disabled by user; please report a bug"
358 : ""); 357 : "");
359} 358}
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 0b7d23b4ad95..6557702a0592 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -39,6 +39,8 @@
39 * bus. It loses the refcount when the the driver unloads. 39 * bus. It loses the refcount when the the driver unloads.
40 */ 40 */
41 41
42#define pr_fmt(fmt) "acpiphp_glue: " fmt
43
42#include <linux/init.h> 44#include <linux/init.h>
43#include <linux/module.h> 45#include <linux/module.h>
44 46
@@ -58,8 +60,6 @@ static LIST_HEAD(bridge_list);
58static DEFINE_MUTEX(bridge_mutex); 60static DEFINE_MUTEX(bridge_mutex);
59static DEFINE_MUTEX(acpiphp_context_lock); 61static DEFINE_MUTEX(acpiphp_context_lock);
60 62
61#define MY_NAME "acpiphp_glue"
62
63static void handle_hotplug_event(acpi_handle handle, u32 type, void *data); 63static void handle_hotplug_event(acpi_handle handle, u32 type, void *data);
64static void acpiphp_sanitize_bus(struct pci_bus *bus); 64static void acpiphp_sanitize_bus(struct pci_bus *bus);
65static void acpiphp_set_hpp_values(struct pci_bus *bus); 65static void acpiphp_set_hpp_values(struct pci_bus *bus);
@@ -335,7 +335,7 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
335 if (ACPI_FAILURE(status)) 335 if (ACPI_FAILURE(status))
336 sun = bridge->nr_slots; 336 sun = bridge->nr_slots;
337 337
338 dbg("found ACPI PCI Hotplug slot %llu at PCI %04x:%02x:%02x\n", 338 pr_debug("found ACPI PCI Hotplug slot %llu at PCI %04x:%02x:%02x\n",
339 sun, pci_domain_nr(pbus), pbus->number, device); 339 sun, pci_domain_nr(pbus), pbus->number, device);
340 340
341 retval = acpiphp_register_hotplug_slot(slot, sun); 341 retval = acpiphp_register_hotplug_slot(slot, sun);
@@ -343,10 +343,10 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
343 slot->slot = NULL; 343 slot->slot = NULL;
344 bridge->nr_slots--; 344 bridge->nr_slots--;
345 if (retval == -EBUSY) 345 if (retval == -EBUSY)
346 warn("Slot %llu already registered by another " 346 pr_warn("Slot %llu already registered by another "
347 "hotplug driver\n", sun); 347 "hotplug driver\n", sun);
348 else 348 else
349 warn("acpiphp_register_hotplug_slot failed " 349 pr_warn("acpiphp_register_hotplug_slot failed "
350 "(err code = 0x%x)\n", retval); 350 "(err code = 0x%x)\n", retval);
351 } 351 }
352 /* Even if the slot registration fails, we can still use it. */ 352 /* Even if the slot registration fails, we can still use it. */
@@ -369,7 +369,7 @@ static acpi_status register_slot(acpi_handle handle, u32 lvl, void *data,
369 if (register_hotplug_dock_device(handle, 369 if (register_hotplug_dock_device(handle,
370 &acpiphp_dock_ops, context, 370 &acpiphp_dock_ops, context,
371 acpiphp_dock_init, acpiphp_dock_release)) 371 acpiphp_dock_init, acpiphp_dock_release))
372 dbg("failed to register dock device\n"); 372 pr_debug("failed to register dock device\n");
373 } 373 }
374 374
375 /* install notify handler */ 375 /* install notify handler */
@@ -427,7 +427,7 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
427 ACPI_SYSTEM_NOTIFY, 427 ACPI_SYSTEM_NOTIFY,
428 handle_hotplug_event); 428 handle_hotplug_event);
429 if (ACPI_FAILURE(status)) 429 if (ACPI_FAILURE(status))
430 err("failed to remove notify handler\n"); 430 pr_err("failed to remove notify handler\n");
431 } 431 }
432 } 432 }
433 if (slot->slot) 433 if (slot->slot)
@@ -830,8 +830,9 @@ static void hotplug_event(acpi_handle handle, u32 type, void *data)
830 switch (type) { 830 switch (type) {
831 case ACPI_NOTIFY_BUS_CHECK: 831 case ACPI_NOTIFY_BUS_CHECK:
832 /* bus re-enumerate */ 832 /* bus re-enumerate */
833 dbg("%s: Bus check notify on %s\n", __func__, objname); 833 pr_debug("%s: Bus check notify on %s\n", __func__, objname);
834 dbg("%s: re-enumerating slots under %s\n", __func__, objname); 834 pr_debug("%s: re-enumerating slots under %s\n",
835 __func__, objname);
835 if (bridge) { 836 if (bridge) {
836 acpiphp_check_bridge(bridge); 837 acpiphp_check_bridge(bridge);
837 } else { 838 } else {
@@ -845,7 +846,7 @@ static void hotplug_event(acpi_handle handle, u32 type, void *data)
845 846
846 case ACPI_NOTIFY_DEVICE_CHECK: 847 case ACPI_NOTIFY_DEVICE_CHECK:
847 /* device check */ 848 /* device check */
848 dbg("%s: Device check notify on %s\n", __func__, objname); 849 pr_debug("%s: Device check notify on %s\n", __func__, objname);
849 if (bridge) { 850 if (bridge) {
850 acpiphp_check_bridge(bridge); 851 acpiphp_check_bridge(bridge);
851 } else { 852 } else {
@@ -866,7 +867,7 @@ static void hotplug_event(acpi_handle handle, u32 type, void *data)
866 867
867 case ACPI_NOTIFY_EJECT_REQUEST: 868 case ACPI_NOTIFY_EJECT_REQUEST:
868 /* request device eject */ 869 /* request device eject */
869 dbg("%s: Device eject notify on %s\n", __func__, objname); 870 pr_debug("%s: Device eject notify on %s\n", __func__, objname);
870 acpiphp_disable_and_eject_slot(func->slot); 871 acpiphp_disable_and_eject_slot(func->slot);
871 break; 872 break;
872 } 873 }