Skip to content

Commit 0ba5cd9

Browse files
andy-shevbjorn-helgaas
authored andcommitted
PCI/MSI: Make error path handling follow the standard pattern
Make error path handling follow the standard pattern, i.e. checking for errors first. This makes code much easier to read and understand despite being a bit longer. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 4cece76 commit 0ba5cd9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

drivers/pci/msi/msi.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ static int pcim_setup_msi_release(struct pci_dev *dev)
8686
return 0;
8787

8888
ret = devm_add_action(&dev->dev, pcim_msi_release, dev);
89-
if (!ret)
90-
dev->is_msi_managed = true;
91-
return ret;
89+
if (ret)
90+
return ret;
91+
92+
dev->is_msi_managed = true;
93+
return 0;
9294
}
9395

9496
/*
@@ -99,9 +101,10 @@ static int pci_setup_msi_context(struct pci_dev *dev)
99101
{
100102
int ret = msi_setup_device_data(&dev->dev);
101103

102-
if (!ret)
103-
ret = pcim_setup_msi_release(dev);
104-
return ret;
104+
if (ret)
105+
return ret;
106+
107+
return pcim_setup_msi_release(dev);
105108
}
106109

107110
/*

0 commit comments

Comments
 (0)