[PATCH v4 06/26] usb: isp1760: Move removal cleanup code to isp1760-hcd.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The removal cleanup code is duplicated between the different bus glues.
Move it to a central location.

Signed-off-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
---

Changes since v1:

- Call release_mem_region() after iounmap()
---
 drivers/usb/host/isp1760-hcd.c | 10 ++++++++++
 drivers/usb/host/isp1760-hcd.h |  2 ++
 drivers/usb/host/isp1760-if.c  | 16 ++--------------
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index e4a9424..7498727 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -2263,6 +2263,16 @@ err_put:
 	 return ERR_PTR(ret);
 }
 
+void isp1760_unregister(struct device *dev)
+{
+	struct usb_hcd *hcd = dev_get_drvdata(dev);
+
+	usb_remove_hcd(hcd);
+	iounmap(hcd->regs);
+	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
+	usb_put_hcd(hcd);
+}
+
 MODULE_DESCRIPTION("Driver for the ISP1760 USB-controller from NXP");
 MODULE_AUTHOR("Sebastian Siewior <bigeasy@xxxxxxxxxxxxxx>");
 MODULE_LICENSE("GPL v2");
diff --git a/drivers/usb/host/isp1760-hcd.h b/drivers/usb/host/isp1760-hcd.h
index fda0f2d..ea13a58 100644
--- a/drivers/usb/host/isp1760-hcd.h
+++ b/drivers/usb/host/isp1760-hcd.h
@@ -6,6 +6,8 @@ struct usb_hcd *isp1760_register(phys_addr_t res_start, resource_size_t res_len,
 				 int irq, unsigned long irqflags,
 				 struct device *dev, const char *busname,
 				 unsigned int devflags);
+void isp1760_unregister(struct device *dev);
+
 int init_kmem_once(void);
 void deinit_kmem_cache(void);
 
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
index 3db98da..b96c62f 100644
--- a/drivers/usb/host/isp1760-if.c
+++ b/drivers/usb/host/isp1760-if.c
@@ -160,14 +160,7 @@ cleanup1:
 
 static void isp1761_pci_remove(struct pci_dev *dev)
 {
-	struct usb_hcd *hcd;
-
-	hcd = pci_get_drvdata(dev);
-
-	usb_remove_hcd(hcd);
-	iounmap(hcd->regs);
-	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
-	usb_put_hcd(hcd);
+	isp1760_unregister(&dev->dev);
 
 	pci_disable_device(dev);
 }
@@ -291,12 +284,7 @@ cleanup:
 
 static int isp1760_plat_remove(struct platform_device *pdev)
 {
-	struct usb_hcd *hcd = platform_get_drvdata(pdev);
-
-	usb_remove_hcd(hcd);
-	iounmap(hcd->regs);
-	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
-	usb_put_hcd(hcd);
+	isp1760_unregister(&pdev->dev);
 
 	return 0;
 }
-- 
2.0.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux