lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu,  2 May 2019 22:59:46 -0500
From:   Frederick Lawler <fred@...dlawl.com>
To:     bhelgaas@...gle.com
Cc:     linux-pci@...r.kernel.org, linux-kernel@...r.kernel.org,
        mika.westerberg@...ux.intel.com, lukas@...ner.de,
        andriy.shevchenko@...ux.intel.com, keith.busch@...el.com,
        mr.nuke.me@...il.com, liudongdong3@...wei.com, thesven73@...il.com,
        Frederick Lawler <fred@...dlawl.com>
Subject: [PATCH v2 9/9] PCI: hotplug: Prefix ctrl_*() dmesg logs with pciehp slot name

Remove current uses of "Slot(%s)" and then prefix ctrl_*() dmesg
with pciehp slot name to include the slot name for all uses of ctrl_*()
wrappers.

Signed-off-by: Frederick Lawler <fred@...dlawl.com>
---
 drivers/pci/hotplug/pciehp.h      | 12 ++++---
 drivers/pci/hotplug/pciehp_core.c |  9 +++--
 drivers/pci/hotplug/pciehp_ctrl.c | 58 ++++++++++++-------------------
 drivers/pci/hotplug/pciehp_hpc.c  |  5 ++-
 4 files changed, 38 insertions(+), 46 deletions(-)

diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index 06ff9d31405e..e1cdc3565c62 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -32,13 +32,17 @@ extern int pciehp_poll_time;
 extern bool pciehp_debug;
 
 #define ctrl_dbg(ctrl, format, arg...)					\
-	pci_dbg(ctrl->pcie->port, format, ## arg)
+	pci_dbg(ctrl->pcie->port, "Slot(%s): " format,			\
+		slot_name(ctrl), ## arg)
 #define ctrl_err(ctrl, format, arg...)					\
-	pci_err(ctrl->pcie->port, format, ## arg)
+	pci_err(ctrl->pcie->port, "Slot(%s): " format,			\
+		slot_name(ctrl), ## arg)
 #define ctrl_info(ctrl, format, arg...)					\
-	pci_info(ctrl->pcie->port, format, ## arg)
+	pci_info(ctrl->pcie->port, "Slot(%s): " format,			\
+		 slot_name(ctrl), ## arg)
 #define ctrl_warn(ctrl, format, arg...)					\
-	pci_warn(ctrl->pcie->port, format, ## arg)
+	pci_warn(ctrl->pcie->port, "Slot(%s): " format,			\
+		 slot_name(ctrl), ## arg)
 
 #define SLOT_NAME_SIZE 10
 
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 67d024b7f476..ddaa45475572 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -85,7 +85,8 @@ static int init_slot(struct controller *ctrl)
 	retval = pci_hp_initialize(&ctrl->hotplug_slot,
 				   ctrl->pcie->port->subordinate, 0, name);
 	if (retval) {
-		ctrl_err(ctrl, "pci_hp_initialize failed: error %d\n", retval);
+		pci_err(ctrl->pcie->port,
+			"pci_hp_initialize failed: error %d\n", retval);
 		kfree(ops);
 	}
 	return retval;
@@ -201,9 +202,11 @@ static int pciehp_probe(struct pcie_device *dev)
 	rc = init_slot(ctrl);
 	if (rc) {
 		if (rc == -EBUSY)
-			ctrl_warn(ctrl, "Slot already registered by another hotplug driver\n");
+			pci_warn(ctrl->pcie->port,
+				 "Slot already registered by another hotplug driver\n");
 		else
-			ctrl_err(ctrl, "Slot initialization failed (%d)\n", rc);
+			pci_err(ctrl->pcie->port,
+				"Slot initialization failed (%d)\n", rc);
 		goto err_out_release_ctlr;
 	}
 
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index bf81f977a751..046ec4d52159 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -76,7 +76,7 @@ static int board_added(struct controller *ctrl)
 
 	/* Check for a power fault */
 	if (ctrl->power_fault_detected || pciehp_query_power_fault(ctrl)) {
-		ctrl_err(ctrl, "Slot(%s): Power fault\n", slot_name(ctrl));
+		ctrl_err(ctrl, "Power fault\n");
 		retval = -EIO;
 		goto err_exit;
 	}
@@ -160,12 +160,10 @@ void pciehp_handle_button_press(struct controller *ctrl)
 	case ON_STATE:
 		if (ctrl->state == ON_STATE) {
 			ctrl->state = BLINKINGOFF_STATE;
-			ctrl_info(ctrl, "Slot(%s): Powering off due to button press\n",
-				  slot_name(ctrl));
+			ctrl_info(ctrl, "Powering off due to button press\n");
 		} else {
 			ctrl->state = BLINKINGON_STATE;
-			ctrl_info(ctrl, "Slot(%s) Powering on due to button press\n",
-				  slot_name(ctrl));
+			ctrl_info(ctrl, "Powering on due to button press\n");
 		}
 		/* blink green LED and turn off amber */
 		pciehp_green_led_blink(ctrl);
@@ -179,7 +177,7 @@ void pciehp_handle_button_press(struct controller *ctrl)
 		 * press the attention again before the 5 sec. limit
 		 * expires to cancel hot-add or hot-remove
 		 */
-		ctrl_info(ctrl, "Slot(%s): Button cancel\n", slot_name(ctrl));
+		ctrl_info(ctrl, "Button cancel\n");
 		cancel_delayed_work(&ctrl->button_work);
 		if (ctrl->state == BLINKINGOFF_STATE) {
 			ctrl->state = ON_STATE;
@@ -189,12 +187,11 @@ void pciehp_handle_button_press(struct controller *ctrl)
 			pciehp_green_led_off(ctrl);
 		}
 		pciehp_set_attention_status(ctrl, 0);
-		ctrl_info(ctrl, "Slot(%s): Action canceled due to button press\n",
-			  slot_name(ctrl));
+		ctrl_info(ctrl, "Action canceled due to button press\n");
 		break;
 	default:
-		ctrl_err(ctrl, "Slot(%s): Ignoring invalid state %#x\n",
-			 slot_name(ctrl), ctrl->state);
+		ctrl_err(ctrl, "Ignoring invalid state %#x\n",
+			 ctrl->state);
 		break;
 	}
 	mutex_unlock(&ctrl->state_lock);
@@ -232,11 +229,9 @@ void pciehp_handle_presence_or_link_change(struct controller *ctrl, u32 events)
 		ctrl->state = POWEROFF_STATE;
 		mutex_unlock(&ctrl->state_lock);
 		if (events & PCI_EXP_SLTSTA_DLLSC)
-			ctrl_info(ctrl, "Slot(%s): Link Down\n",
-				  slot_name(ctrl));
+			ctrl_info(ctrl, "Link Down\n");
 		if (events & PCI_EXP_SLTSTA_PDC)
-			ctrl_info(ctrl, "Slot(%s): Card not present\n",
-				  slot_name(ctrl));
+			ctrl_info(ctrl, "Card not present\n");
 		pciehp_disable_slot(ctrl, SURPRISE_REMOVAL);
 		break;
 	default:
@@ -261,11 +256,9 @@ void pciehp_handle_presence_or_link_change(struct controller *ctrl, u32 events)
 		ctrl->state = POWERON_STATE;
 		mutex_unlock(&ctrl->state_lock);
 		if (present)
-			ctrl_info(ctrl, "Slot(%s): Card present\n",
-				  slot_name(ctrl));
+			ctrl_info(ctrl, "Card present\n");
 		if (link_active)
-			ctrl_info(ctrl, "Slot(%s): Link Up\n",
-				  slot_name(ctrl));
+			ctrl_info(ctrl, "Link Up\n");
 		ctrl->request_result = pciehp_enable_slot(ctrl);
 		break;
 	default:
@@ -281,8 +274,7 @@ static int __pciehp_enable_slot(struct controller *ctrl)
 	if (MRL_SENS(ctrl)) {
 		pciehp_get_latch_status(ctrl, &getstatus);
 		if (getstatus) {
-			ctrl_info(ctrl, "Slot(%s): Latch open\n",
-				  slot_name(ctrl));
+			ctrl_info(ctrl, "Latch open\n");
 			return -ENODEV;
 		}
 	}
@@ -290,8 +282,7 @@ static int __pciehp_enable_slot(struct controller *ctrl)
 	if (POWER_CTRL(ctrl)) {
 		pciehp_get_power_status(ctrl, &getstatus);
 		if (getstatus) {
-			ctrl_info(ctrl, "Slot(%s): Already enabled\n",
-				  slot_name(ctrl));
+			ctrl_info(ctrl, "Already enabled\n");
 			return 0;
 		}
 	}
@@ -323,8 +314,7 @@ static int __pciehp_disable_slot(struct controller *ctrl, bool safe_removal)
 	if (POWER_CTRL(ctrl)) {
 		pciehp_get_power_status(ctrl, &getstatus);
 		if (!getstatus) {
-			ctrl_info(ctrl, "Slot(%s): Already disabled\n",
-				  slot_name(ctrl));
+			ctrl_info(ctrl, "Already disabled\n");
 			return -EINVAL;
 		}
 	}
@@ -367,18 +357,16 @@ int pciehp_sysfs_enable_slot(struct hotplug_slot *hotplug_slot)
 			   !atomic_read(&ctrl->pending_events));
 		return ctrl->request_result;
 	case POWERON_STATE:
-		ctrl_info(ctrl, "Slot(%s): Already in powering on state\n",
-			  slot_name(ctrl));
+		ctrl_info(ctrl, "Already in powering on state\n");
 		break;
 	case BLINKINGOFF_STATE:
 	case ON_STATE:
 	case POWEROFF_STATE:
-		ctrl_info(ctrl, "Slot(%s): Already enabled\n",
-			  slot_name(ctrl));
+		ctrl_info(ctrl, "Already enabled\n");
 		break;
 	default:
-		ctrl_err(ctrl, "Slot(%s): Invalid state %#x\n",
-			 slot_name(ctrl), ctrl->state);
+		ctrl_err(ctrl, "Invalid state %#x\n",
+			 ctrl->state);
 		break;
 	}
 	mutex_unlock(&ctrl->state_lock);
@@ -400,18 +388,16 @@ int pciehp_sysfs_disable_slot(struct hotplug_slot *hotplug_slot)
 			   !atomic_read(&ctrl->pending_events));
 		return ctrl->request_result;
 	case POWEROFF_STATE:
-		ctrl_info(ctrl, "Slot(%s): Already in powering off state\n",
-			  slot_name(ctrl));
+		ctrl_info(ctrl, "Already in powering off state\n");
 		break;
 	case BLINKINGON_STATE:
 	case OFF_STATE:
 	case POWERON_STATE:
-		ctrl_info(ctrl, "Slot(%s): Already disabled\n",
-			  slot_name(ctrl));
+		ctrl_info(ctrl, "Already disabled\n");
 		break;
 	default:
-		ctrl_err(ctrl, "Slot(%s): Invalid state %#x\n",
-			 slot_name(ctrl), ctrl->state);
+		ctrl_err(ctrl, "Invalid state %#x\n",
+			 ctrl->state);
 		break;
 	}
 	mutex_unlock(&ctrl->state_lock);
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 1713b0b08a5e..2cb85433736d 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -629,15 +629,14 @@ static irqreturn_t pciehp_ist(int irq, void *dev_id)
 
 	/* Check Attention Button Pressed */
 	if (events & PCI_EXP_SLTSTA_ABP) {
-		ctrl_info(ctrl, "Slot(%s): Attention button pressed\n",
-			  slot_name(ctrl));
+		ctrl_info(ctrl, "Attention button pressed\n");
 		pciehp_handle_button_press(ctrl);
 	}
 
 	/* Check Power Fault Detected */
 	if ((events & PCI_EXP_SLTSTA_PFD) && !ctrl->power_fault_detected) {
 		ctrl->power_fault_detected = 1;
-		ctrl_err(ctrl, "Slot(%s): Power fault\n", slot_name(ctrl));
+		ctrl_err(ctrl, "Power fault\n");
 		pciehp_set_attention_status(ctrl, 1);
 		pciehp_green_led_off(ctrl);
 	}
-- 
2.17.1

Powered by blists - more mailing lists