diff mbox series

[06/10] PCI: hv: Switch MSI descriptor locking to guard()

Message ID 20250309084110.521468021@linutronix.de (mailing list archive)
State Not Applicable
Headers show
Series genirq/msi: Spring cleaning | expand

Commit Message

Thomas Gleixner March 9, 2025, 8:41 a.m. UTC
Convert the code to use the new guard(msi_descs_lock).

No functional change intended.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Wei Liu <wei.liu@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: linux-hyperv@vger.kernel.org
Cc: linux-pci@vger.kernel.org
---
 drivers/pci/controller/pci-hyperv.c |   14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

Comments

Wei Liu March 10, 2025, 4:52 p.m. UTC | #1
On Sun, Mar 09, 2025 at 09:41:51AM +0100, Thomas Gleixner wrote:
> Convert the code to use the new guard(msi_descs_lock).
> 
> No functional change intended.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Wei Liu <wei.liu@kernel.org>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: linux-hyperv@vger.kernel.org
> Cc: linux-pci@vger.kernel.org

Acked-by: Wei Liu <wei.liu@kernel.org>

> ---
>  drivers/pci/controller/pci-hyperv.c |   14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)
> 
> --- a/drivers/pci/controller/pci-hyperv.c
> +++ b/drivers/pci/controller/pci-hyperv.c
> @@ -3976,24 +3976,18 @@ static int hv_pci_restore_msi_msg(struct
>  {
>  	struct irq_data *irq_data;
>  	struct msi_desc *entry;
> -	int ret = 0;
>  
>  	if (!pdev->msi_enabled && !pdev->msix_enabled)
>  		return 0;
>  
> -	msi_lock_descs(&pdev->dev);
> +	guard(msi_descs_lock)(&pdev->dev);
>  	msi_for_each_desc(entry, &pdev->dev, MSI_DESC_ASSOCIATED) {
>  		irq_data = irq_get_irq_data(entry->irq);
> -		if (WARN_ON_ONCE(!irq_data)) {
> -			ret = -EINVAL;
> -			break;
> -		}
> -
> +		if (WARN_ON_ONCE(!irq_data))
> +			return -EINVAL;
>  		hv_compose_msi_msg(irq_data, &entry->msg);
>  	}
> -	msi_unlock_descs(&pdev->dev);
> -
> -	return ret;
> +	return 0;
>  }
>  
>  /*
>
Michael Kelley March 10, 2025, 8:33 p.m. UTC | #2
From: Thomas Gleixner <tglx@linutronix.de> Sent: Sunday, March 9, 2025 12:42 AM
> 
> Convert the code to use the new guard(msi_descs_lock).
> 
> No functional change intended.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Wei Liu <wei.liu@kernel.org>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: linux-hyperv@vger.kernel.org
> Cc: linux-pci@vger.kernel.org
> ---
>  drivers/pci/controller/pci-hyperv.c |   14 ++++----------
>  1 file changed, 4 insertions(+), 10 deletions(-)
> 
> --- a/drivers/pci/controller/pci-hyperv.c
> +++ b/drivers/pci/controller/pci-hyperv.c
> @@ -3976,24 +3976,18 @@ static int hv_pci_restore_msi_msg(struct
>  {
>  	struct irq_data *irq_data;
>  	struct msi_desc *entry;
> -	int ret = 0;
> 
>  	if (!pdev->msi_enabled && !pdev->msix_enabled)
>  		return 0;
> 
> -	msi_lock_descs(&pdev->dev);
> +	guard(msi_descs_lock)(&pdev->dev);
>  	msi_for_each_desc(entry, &pdev->dev, MSI_DESC_ASSOCIATED) {
>  		irq_data = irq_get_irq_data(entry->irq);
> -		if (WARN_ON_ONCE(!irq_data)) {
> -			ret = -EINVAL;
> -			break;
> -		}
> -
> +		if (WARN_ON_ONCE(!irq_data))
> +			return -EINVAL;
>  		hv_compose_msi_msg(irq_data, &entry->msg);
>  	}
> -	msi_unlock_descs(&pdev->dev);
> -
> -	return ret;
> +	return 0;
>  }
> 

Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Jonathan Cameron March 11, 2025, 6:10 p.m. UTC | #3
On Sun,  9 Mar 2025 09:41:51 +0100 (CET)
Thomas Gleixner <tglx@linutronix.de> wrote:

> Convert the code to use the new guard(msi_descs_lock).
> 
> No functional change intended.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Wei Liu <wei.liu@kernel.org>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: linux-hyperv@vger.kernel.org
> Cc: linux-pci@vger.kernel.org
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
diff mbox series

Patch

--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -3976,24 +3976,18 @@  static int hv_pci_restore_msi_msg(struct
 {
 	struct irq_data *irq_data;
 	struct msi_desc *entry;
-	int ret = 0;
 
 	if (!pdev->msi_enabled && !pdev->msix_enabled)
 		return 0;
 
-	msi_lock_descs(&pdev->dev);
+	guard(msi_descs_lock)(&pdev->dev);
 	msi_for_each_desc(entry, &pdev->dev, MSI_DESC_ASSOCIATED) {
 		irq_data = irq_get_irq_data(entry->irq);
-		if (WARN_ON_ONCE(!irq_data)) {
-			ret = -EINVAL;
-			break;
-		}
-
+		if (WARN_ON_ONCE(!irq_data))
+			return -EINVAL;
 		hv_compose_msi_msg(irq_data, &entry->msg);
 	}
-	msi_unlock_descs(&pdev->dev);
-
-	return ret;
+	return 0;
 }
 
 /*