PCI: endpoint: Make ->remove() callback optional
authorKishon Vijay Abraham I <kishon@ti.com>
Fri, 18 Aug 2017 14:57:55 +0000 (20:27 +0530)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 29 Aug 2017 21:00:36 +0000 (16:00 -0500)
Make ->remove() callback optional so that endpoint function drivers don't
have to populate empty ->remove() callback functions.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/endpoint/pci-epf-core.c

index f14e2be52658f7c43ea1bd8b9ead183838e7aa5f..70eccc04ee7f5c0f99f9309e056990e95967f948 100644 (file)
@@ -333,11 +333,12 @@ static int pci_epf_device_probe(struct device *dev)
 
 static int pci_epf_device_remove(struct device *dev)
 {
-       int ret;
+       int ret = 0;
        struct pci_epf *epf = to_pci_epf(dev);
        struct pci_epf_driver *driver = to_pci_epf_driver(dev->driver);
 
-       ret = driver->remove(epf);
+       if (driver->remove)
+               ret = driver->remove(epf);
        epf->driver = NULL;
 
        return ret;