[10/11] pci/hotplug/pnv-php: Wrap warnings in macro
diff mbox series

Message ID 20190909154600.19917-11-fbarrat@linux.ibm.com
State New
Headers show
Series
  • opencapi: enable card reset and link retraining
Related show

Checks

Context Check Description
snowpatch_ozlabs/checkpatch warning total: 0 errors, 0 warnings, 1 checks, 147 lines checked
snowpatch_ozlabs/apply_patch success Successfully applied on branch next (c317052c95bef1f977b023158e5aa929215f443d)

Commit Message

Frederic Barrat Sept. 9, 2019, 3:45 p.m. UTC
An opencapi slot doesn't have an associated bridge device. It's not
needed for operation, but any warning is displayed through pci_warn()
which uses the pci_dev struct of the assocated bridge device. So wrap
those warning so that a different trace mechanism can be used if it's
an opencapi slot.

Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
---
 drivers/pci/hotplug/pnv_php.c | 51 +++++++++++++++++++----------------
 1 file changed, 28 insertions(+), 23 deletions(-)

Comments

Alastair D'Silva Sept. 10, 2019, 1:03 a.m. UTC | #1
On Mon, 2019-09-09 at 17:45 +0200, Frederic Barrat wrote:
> An opencapi slot doesn't have an associated bridge device. It's not
> needed for operation, but any warning is displayed through pci_warn()
> which uses the pci_dev struct of the assocated bridge device. So wrap
> those warning so that a different trace mechanism can be used if it's
> an opencapi slot.
> 
> Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
> ---
>  drivers/pci/hotplug/pnv_php.c | 51 +++++++++++++++++++------------
> ----
>  1 file changed, 28 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/pnv_php.c
> b/drivers/pci/hotplug/pnv_php.c
> index 5ca51d67db4b..d01a8595bc5c 100644
> --- a/drivers/pci/hotplug/pnv_php.c
> +++ b/drivers/pci/hotplug/pnv_php.c
> @@ -18,6 +18,9 @@
>  #define DRIVER_AUTHOR	"Gavin Shan, IBM Corporation"
>  #define DRIVER_DESC	"PowerPC PowerNV PCI Hotplug Driver"
>  
> +#define SLOT_WARN(sl, x...) \
> +	((sl)->pdev ? pci_warn((sl)->pdev, x) : dev_warn(&(sl)->bus-
> >dev, x))
> +
>  struct pnv_php_event {
>  	bool			added;
>  	struct pnv_php_slot	*php_slot;
> @@ -265,7 +268,7 @@ static int pnv_php_add_devtree(struct
> pnv_php_slot *php_slot)
>  
>  	ret = pnv_pci_get_device_tree(php_slot->dn->phandle, fdt1,
> 0x10000);
>  	if (ret) {
> -		pci_warn(php_slot->pdev, "Error %d getting FDT blob\n",
> ret);
> +		SLOT_WARN(php_slot, "Error %d getting FDT blob\n",
> ret);
>  		goto free_fdt1;
>  	}
>  
> @@ -279,7 +282,7 @@ static int pnv_php_add_devtree(struct
> pnv_php_slot *php_slot)
>  	dt = of_fdt_unflatten_tree(fdt, php_slot->dn, NULL);
>  	if (!dt) {
>  		ret = -EINVAL;
> -		pci_warn(php_slot->pdev, "Cannot unflatten FDT\n");
> +		SLOT_WARN(php_slot, "Cannot unflatten FDT\n");
>  		goto free_fdt;
>  	}
>  
> @@ -289,15 +292,15 @@ static int pnv_php_add_devtree(struct
> pnv_php_slot *php_slot)
>  	ret = pnv_php_populate_changeset(&php_slot->ocs, php_slot->dn);
>  	if (ret) {
>  		pnv_php_reverse_nodes(php_slot->dn);
> -		pci_warn(php_slot->pdev, "Error %d populating
> changeset\n",
> -			 ret);
> +		SLOT_WARN(php_slot, "Error %d populating changeset\n",
> +			  ret);
>  		goto free_dt;
>  	}
>  
>  	php_slot->dn->child = NULL;
>  	ret = of_changeset_apply(&php_slot->ocs);
>  	if (ret) {
> -		pci_warn(php_slot->pdev, "Error %d applying
> changeset\n", ret);
> +		SLOT_WARN(php_slot, "Error %d applying changeset\n",
> ret);
>  		goto destroy_changeset;
>  	}
>  
> @@ -337,10 +340,10 @@ int pnv_php_set_slot_power_state(struct
> hotplug_slot *slot,
>  	if (ret > 0) {
>  		if (be64_to_cpu(msg.params[1]) != php_slot->dn->phandle
> 	||
>  		    be64_to_cpu(msg.params[2]) != state) {
> -			pci_warn(php_slot->pdev, "Wrong msg (%lld,
> %lld, %lld)\n",
> -				 be64_to_cpu(msg.params[1]),
> -				 be64_to_cpu(msg.params[2]),
> -				 be64_to_cpu(msg.params[3]));
> +			SLOT_WARN(php_slot, "Wrong msg (%lld, %lld,
> %lld)\n",
> +				  be64_to_cpu(msg.params[1]),
> +				  be64_to_cpu(msg.params[2]),
> +				  be64_to_cpu(msg.params[3]));
>  			return -ENOMSG;
>  		}
>  		if (be64_to_cpu(msg.params[3]) != OPAL_SUCCESS) {
> @@ -359,8 +362,8 @@ int pnv_php_set_slot_power_state(struct
> hotplug_slot *slot,
>  	return ret;
>  
>  error:
> -	pci_warn(php_slot->pdev, "Error %d powering %s\n",
> -		 ret, (state == OPAL_PCI_SLOT_POWER_ON) ? "on" :
> "off");
> +	SLOT_WARN(php_slot, "Error %d powering %s\n",
> +		  ret, (state == OPAL_PCI_SLOT_POWER_ON) ? "on" :
> "off");
>  	return ret;
>  }
>  EXPORT_SYMBOL_GPL(pnv_php_set_slot_power_state);
> @@ -378,8 +381,8 @@ static int pnv_php_get_power_state(struct
> hotplug_slot *slot, u8 *state)
>  	 */
>  	ret = pnv_pci_get_power_state(php_slot->id, &power_state);
>  	if (ret) {
> -		pci_warn(php_slot->pdev, "Error %d getting power
> status\n",
> -			 ret);
> +		SLOT_WARN(php_slot, "Error %d getting power status\n",
> +			  ret);
>  	} else {
>  		*state = power_state;
>  	}
> @@ -402,7 +405,7 @@ static int pnv_php_get_adapter_state(struct
> hotplug_slot *slot, u8 *state)
>  		*state = presence;
>  		ret = 0;
>  	} else {
> -		pci_warn(php_slot->pdev, "Error %d getting presence\n",
> ret);
> +		SLOT_WARN(php_slot, "Error %d getting presence\n",
> ret);
>  	}
>  
>  	return ret;
> @@ -637,7 +640,7 @@ static int pnv_php_register_slot(struct
> pnv_php_slot *php_slot)
>  	ret = pci_hp_register(&php_slot->slot, php_slot->bus,
>  			      php_slot->slot_no, php_slot->name);
>  	if (ret) {
> -		pci_warn(php_slot->pdev, "Error %d registering slot\n",
> ret);
> +		SLOT_WARN(php_slot, "Error %d registering slot\n",
> ret);
>  		return ret;
>  	}
>  
> @@ -690,7 +693,7 @@ static int pnv_php_enable_msix(struct
> pnv_php_slot *php_slot)
>  	/* Enable MSIx */
>  	ret = pci_enable_msix_exact(pdev, &entry, 1);
>  	if (ret) {
> -		pci_warn(pdev, "Error %d enabling MSIx\n", ret);
> +		SLOT_WARN(php_slot, "Error %d enabling MSIx\n", ret);
>  		return ret;
>  	}
>  
> @@ -734,8 +737,9 @@ static irqreturn_t pnv_php_interrupt(int irq,
> void *data)
>  		   (sts & PCI_EXP_SLTSTA_PDC)) {
>  		ret = pnv_pci_get_presence_state(php_slot->id,
> &presence);
>  		if (ret) {
> -			pci_warn(pdev, "PCI slot [%s] error %d getting
> presence (0x%04x), to retry the operation.\n",
> -				 php_slot->name, ret, sts);
> +			SLOT_WARN(php_slot,
> +				  "PCI slot [%s] error %d getting
> presence (0x%04x), to retry the operation.\n",
> +				  php_slot->name, ret, sts);
>  			return IRQ_HANDLED;
>  		}
>  
> @@ -764,8 +768,9 @@ static irqreturn_t pnv_php_interrupt(int irq,
> void *data)
>  	 */
>  	event = kzalloc(sizeof(*event), GFP_ATOMIC);
>  	if (!event) {
> -		pci_warn(pdev, "PCI slot [%s] missed hotplug event
> 0x%04x\n",
> -			 php_slot->name, sts);
> +		SLOT_WARN(php_slot,
> +			  "PCI slot [%s] missed hotplug event
> 0x%04x\n",
> +			  php_slot->name, sts);
>  		return IRQ_HANDLED;
>  	}
>  
> @@ -789,7 +794,7 @@ static void pnv_php_init_irq(struct pnv_php_slot
> *php_slot, int irq)
>  	/* Allocate workqueue */
>  	php_slot->wq = alloc_workqueue("pciehp-%s", 0, 0, php_slot-
> >name);
>  	if (!php_slot->wq) {
> -		pci_warn(pdev, "Cannot alloc workqueue\n");
> +		SLOT_WARN(php_slot, "Cannot alloc workqueue\n");
>  		pnv_php_disable_irq(php_slot, true);
>  		return;
>  	}
> @@ -813,7 +818,7 @@ static void pnv_php_init_irq(struct pnv_php_slot
> *php_slot, int irq)
>  			  php_slot->name, php_slot);
>  	if (ret) {
>  		pnv_php_disable_irq(php_slot, true);
> -		pci_warn(pdev, "Error %d enabling IRQ %d\n", ret, irq);
> +		SLOT_WARN(php_slot, "Error %d enabling IRQ %d\n", ret,
> irq);
>  		return;
>  	}
>  
> @@ -849,7 +854,7 @@ static void pnv_php_enable_irq(struct
> pnv_php_slot *php_slot)
>  
>  	ret = pci_enable_device(pdev);
>  	if (ret) {
> -		pci_warn(pdev, "Error %d enabling device\n", ret);
> +		SLOT_WARN(php_slot, "Error %d enabling device\n", ret);
>  		return;
>  	}
>  

Reviewed-by: Alastair D'Silva <alastair@d-silva.org>

Patch
diff mbox series

diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c
index 5ca51d67db4b..d01a8595bc5c 100644
--- a/drivers/pci/hotplug/pnv_php.c
+++ b/drivers/pci/hotplug/pnv_php.c
@@ -18,6 +18,9 @@ 
 #define DRIVER_AUTHOR	"Gavin Shan, IBM Corporation"
 #define DRIVER_DESC	"PowerPC PowerNV PCI Hotplug Driver"
 
+#define SLOT_WARN(sl, x...) \
+	((sl)->pdev ? pci_warn((sl)->pdev, x) : dev_warn(&(sl)->bus->dev, x))
+
 struct pnv_php_event {
 	bool			added;
 	struct pnv_php_slot	*php_slot;
@@ -265,7 +268,7 @@  static int pnv_php_add_devtree(struct pnv_php_slot *php_slot)
 
 	ret = pnv_pci_get_device_tree(php_slot->dn->phandle, fdt1, 0x10000);
 	if (ret) {
-		pci_warn(php_slot->pdev, "Error %d getting FDT blob\n", ret);
+		SLOT_WARN(php_slot, "Error %d getting FDT blob\n", ret);
 		goto free_fdt1;
 	}
 
@@ -279,7 +282,7 @@  static int pnv_php_add_devtree(struct pnv_php_slot *php_slot)
 	dt = of_fdt_unflatten_tree(fdt, php_slot->dn, NULL);
 	if (!dt) {
 		ret = -EINVAL;
-		pci_warn(php_slot->pdev, "Cannot unflatten FDT\n");
+		SLOT_WARN(php_slot, "Cannot unflatten FDT\n");
 		goto free_fdt;
 	}
 
@@ -289,15 +292,15 @@  static int pnv_php_add_devtree(struct pnv_php_slot *php_slot)
 	ret = pnv_php_populate_changeset(&php_slot->ocs, php_slot->dn);
 	if (ret) {
 		pnv_php_reverse_nodes(php_slot->dn);
-		pci_warn(php_slot->pdev, "Error %d populating changeset\n",
-			 ret);
+		SLOT_WARN(php_slot, "Error %d populating changeset\n",
+			  ret);
 		goto free_dt;
 	}
 
 	php_slot->dn->child = NULL;
 	ret = of_changeset_apply(&php_slot->ocs);
 	if (ret) {
-		pci_warn(php_slot->pdev, "Error %d applying changeset\n", ret);
+		SLOT_WARN(php_slot, "Error %d applying changeset\n", ret);
 		goto destroy_changeset;
 	}
 
@@ -337,10 +340,10 @@  int pnv_php_set_slot_power_state(struct hotplug_slot *slot,
 	if (ret > 0) {
 		if (be64_to_cpu(msg.params[1]) != php_slot->dn->phandle	||
 		    be64_to_cpu(msg.params[2]) != state) {
-			pci_warn(php_slot->pdev, "Wrong msg (%lld, %lld, %lld)\n",
-				 be64_to_cpu(msg.params[1]),
-				 be64_to_cpu(msg.params[2]),
-				 be64_to_cpu(msg.params[3]));
+			SLOT_WARN(php_slot, "Wrong msg (%lld, %lld, %lld)\n",
+				  be64_to_cpu(msg.params[1]),
+				  be64_to_cpu(msg.params[2]),
+				  be64_to_cpu(msg.params[3]));
 			return -ENOMSG;
 		}
 		if (be64_to_cpu(msg.params[3]) != OPAL_SUCCESS) {
@@ -359,8 +362,8 @@  int pnv_php_set_slot_power_state(struct hotplug_slot *slot,
 	return ret;
 
 error:
-	pci_warn(php_slot->pdev, "Error %d powering %s\n",
-		 ret, (state == OPAL_PCI_SLOT_POWER_ON) ? "on" : "off");
+	SLOT_WARN(php_slot, "Error %d powering %s\n",
+		  ret, (state == OPAL_PCI_SLOT_POWER_ON) ? "on" : "off");
 	return ret;
 }
 EXPORT_SYMBOL_GPL(pnv_php_set_slot_power_state);
@@ -378,8 +381,8 @@  static int pnv_php_get_power_state(struct hotplug_slot *slot, u8 *state)
 	 */
 	ret = pnv_pci_get_power_state(php_slot->id, &power_state);
 	if (ret) {
-		pci_warn(php_slot->pdev, "Error %d getting power status\n",
-			 ret);
+		SLOT_WARN(php_slot, "Error %d getting power status\n",
+			  ret);
 	} else {
 		*state = power_state;
 	}
@@ -402,7 +405,7 @@  static int pnv_php_get_adapter_state(struct hotplug_slot *slot, u8 *state)
 		*state = presence;
 		ret = 0;
 	} else {
-		pci_warn(php_slot->pdev, "Error %d getting presence\n", ret);
+		SLOT_WARN(php_slot, "Error %d getting presence\n", ret);
 	}
 
 	return ret;
@@ -637,7 +640,7 @@  static int pnv_php_register_slot(struct pnv_php_slot *php_slot)
 	ret = pci_hp_register(&php_slot->slot, php_slot->bus,
 			      php_slot->slot_no, php_slot->name);
 	if (ret) {
-		pci_warn(php_slot->pdev, "Error %d registering slot\n", ret);
+		SLOT_WARN(php_slot, "Error %d registering slot\n", ret);
 		return ret;
 	}
 
@@ -690,7 +693,7 @@  static int pnv_php_enable_msix(struct pnv_php_slot *php_slot)
 	/* Enable MSIx */
 	ret = pci_enable_msix_exact(pdev, &entry, 1);
 	if (ret) {
-		pci_warn(pdev, "Error %d enabling MSIx\n", ret);
+		SLOT_WARN(php_slot, "Error %d enabling MSIx\n", ret);
 		return ret;
 	}
 
@@ -734,8 +737,9 @@  static irqreturn_t pnv_php_interrupt(int irq, void *data)
 		   (sts & PCI_EXP_SLTSTA_PDC)) {
 		ret = pnv_pci_get_presence_state(php_slot->id, &presence);
 		if (ret) {
-			pci_warn(pdev, "PCI slot [%s] error %d getting presence (0x%04x), to retry the operation.\n",
-				 php_slot->name, ret, sts);
+			SLOT_WARN(php_slot,
+				  "PCI slot [%s] error %d getting presence (0x%04x), to retry the operation.\n",
+				  php_slot->name, ret, sts);
 			return IRQ_HANDLED;
 		}
 
@@ -764,8 +768,9 @@  static irqreturn_t pnv_php_interrupt(int irq, void *data)
 	 */
 	event = kzalloc(sizeof(*event), GFP_ATOMIC);
 	if (!event) {
-		pci_warn(pdev, "PCI slot [%s] missed hotplug event 0x%04x\n",
-			 php_slot->name, sts);
+		SLOT_WARN(php_slot,
+			  "PCI slot [%s] missed hotplug event 0x%04x\n",
+			  php_slot->name, sts);
 		return IRQ_HANDLED;
 	}
 
@@ -789,7 +794,7 @@  static void pnv_php_init_irq(struct pnv_php_slot *php_slot, int irq)
 	/* Allocate workqueue */
 	php_slot->wq = alloc_workqueue("pciehp-%s", 0, 0, php_slot->name);
 	if (!php_slot->wq) {
-		pci_warn(pdev, "Cannot alloc workqueue\n");
+		SLOT_WARN(php_slot, "Cannot alloc workqueue\n");
 		pnv_php_disable_irq(php_slot, true);
 		return;
 	}
@@ -813,7 +818,7 @@  static void pnv_php_init_irq(struct pnv_php_slot *php_slot, int irq)
 			  php_slot->name, php_slot);
 	if (ret) {
 		pnv_php_disable_irq(php_slot, true);
-		pci_warn(pdev, "Error %d enabling IRQ %d\n", ret, irq);
+		SLOT_WARN(php_slot, "Error %d enabling IRQ %d\n", ret, irq);
 		return;
 	}
 
@@ -849,7 +854,7 @@  static void pnv_php_enable_irq(struct pnv_php_slot *php_slot)
 
 	ret = pci_enable_device(pdev);
 	if (ret) {
-		pci_warn(pdev, "Error %d enabling device\n", ret);
+		SLOT_WARN(php_slot, "Error %d enabling device\n", ret);
 		return;
 	}