* [PATCH v1 1/1] PCI/MSI: Make error path handling follow the standard pattern
@ 2024-04-26 14:40 Andy Shevchenko
2024-04-26 22:05 ` Bjorn Helgaas
0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2024-04-26 14:40 UTC (permalink / raw)
To: linux-pci, linux-kernel; +Cc: Bjorn Helgaas, Andy Shevchenko
Make error path handling follow the standard pattern, i.e.
checking for errors first. This makes code much more easier
to read and understand despite being a bit longer.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/pci/msi/msi.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
index 682fa877478f..c5625dd9bf49 100644
--- a/drivers/pci/msi/msi.c
+++ b/drivers/pci/msi/msi.c
@@ -86,9 +86,11 @@ static int pcim_setup_msi_release(struct pci_dev *dev)
return 0;
ret = devm_add_action(&dev->dev, pcim_msi_release, dev);
- if (!ret)
- dev->is_msi_managed = true;
- return ret;
+ if (ret)
+ return ret;
+
+ dev->is_msi_managed = true;
+ return 0;
}
/*
@@ -99,9 +101,10 @@ static int pci_setup_msi_context(struct pci_dev *dev)
{
int ret = msi_setup_device_data(&dev->dev);
- if (!ret)
- ret = pcim_setup_msi_release(dev);
- return ret;
+ if (ret)
+ return ret;
+
+ return pcim_setup_msi_release(dev);
}
/*
--
2.43.0.rc1.1336.g36b5255a03ac
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1 1/1] PCI/MSI: Make error path handling follow the standard pattern
2024-04-26 14:40 [PATCH v1 1/1] PCI/MSI: Make error path handling follow the standard pattern Andy Shevchenko
@ 2024-04-26 22:05 ` Bjorn Helgaas
0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2024-04-26 22:05 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-pci, linux-kernel, Bjorn Helgaas
On Fri, Apr 26, 2024 at 05:40:39PM +0300, Andy Shevchenko wrote:
> Make error path handling follow the standard pattern, i.e.
> checking for errors first. This makes code much more easier
> to read and understand despite being a bit longer.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Applied to pci/msi for v6.10, thanks!
I like this style much better too.
> ---
> drivers/pci/msi/msi.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
> index 682fa877478f..c5625dd9bf49 100644
> --- a/drivers/pci/msi/msi.c
> +++ b/drivers/pci/msi/msi.c
> @@ -86,9 +86,11 @@ static int pcim_setup_msi_release(struct pci_dev *dev)
> return 0;
>
> ret = devm_add_action(&dev->dev, pcim_msi_release, dev);
> - if (!ret)
> - dev->is_msi_managed = true;
> - return ret;
> + if (ret)
> + return ret;
> +
> + dev->is_msi_managed = true;
> + return 0;
> }
>
> /*
> @@ -99,9 +101,10 @@ static int pci_setup_msi_context(struct pci_dev *dev)
> {
> int ret = msi_setup_device_data(&dev->dev);
>
> - if (!ret)
> - ret = pcim_setup_msi_release(dev);
> - return ret;
> + if (ret)
> + return ret;
> +
> + return pcim_setup_msi_release(dev);
> }
>
> /*
> --
> 2.43.0.rc1.1336.g36b5255a03ac
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-26 22:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-26 14:40 [PATCH v1 1/1] PCI/MSI: Make error path handling follow the standard pattern Andy Shevchenko
2024-04-26 22:05 ` Bjorn Helgaas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox