]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
PCI: Use devm_add_action_or_reset()
authorFuqian Huang <huangfq.daxian@gmail.com>
Mon, 8 Jul 2019 12:33:54 +0000 (20:33 +0800)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 24 Jul 2019 19:20:31 +0000 (14:20 -0500)
devm_add_action_or_reset() is a helper function which internally calls
devm_add_action().  If the devm_add_action() fails, it will execute the
action mentioned and return the error code.

Use devm_add_action_or_reset() to reduce source code size (avoid writing
the action twice) and reduce the likelihood of bugs.

Link: https://lore.kernel.org/r/20190708123354.12127-1-huangfq.daxian@gmail.com
Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/controller/pci-host-common.c

index c742881b5061a7be0cdae6b485c10b9d3816fa84..c8cb9c5188a415aaa9f03495c169e660404060fc 100644 (file)
@@ -43,9 +43,8 @@ static struct pci_config_window *gen_pci_init(struct device *dev,
                goto err_out;
        }
 
-       err = devm_add_action(dev, gen_pci_unmap_cfg, cfg);
+       err = devm_add_action_or_reset(dev, gen_pci_unmap_cfg, cfg);
        if (err) {
-               gen_pci_unmap_cfg(cfg);
                goto err_out;
        }
        return cfg;