@@ -649,8 +649,11 @@ static irqreturn_t isp_isr(int irq, void *_isp)
return IRQ_HANDLED;
}
+static void isp_release(struct media_device *mdev);
+
static const struct media_device_ops isp_media_ops = {
.link_notify = v4l2_pipeline_link_notify,
+ .release = isp_release,
};
/* -----------------------------------------------------------------------------
@@ -1607,7 +1610,6 @@ static void isp_unregister_entities(struct isp_device *isp)
omap3isp_stat_unregister_entities(&isp->isp_hist);
v4l2_device_unregister(&isp->v4l2_dev);
- media_device_cleanup(&isp->media_dev);
}
static int isp_link_entity(
@@ -1955,6 +1957,19 @@ static void isp_detach_iommu(struct isp_device *isp)
#endif
}
+static void isp_release(struct media_device *mdev)
+{
+ struct isp_device *isp =
+ container_of(mdev, struct isp_device, media_dev);
+
+ isp_cleanup_modules(isp);
+
+ media_entity_enum_cleanup(&isp->crashed);
+ v4l2_async_notifier_cleanup(&isp->notifier);
+
+ kfree(isp);
+}
+
static int isp_attach_iommu(struct isp_device *isp)
{
#ifdef CONFIG_ARM_DMA_USE_IOMMU
@@ -2003,17 +2018,15 @@ static int isp_remove(struct platform_device *pdev)
v4l2_async_nf_unregister(&isp->notifier);
isp_unregister_entities(isp);
- isp_cleanup_modules(isp);
+
isp_xclk_cleanup(isp);
__omap3isp_get(isp, false);
isp_detach_iommu(isp);
__omap3isp_put(isp, false);
- media_entity_enum_cleanup(&isp->crashed);
- v4l2_async_nf_cleanup(&isp->notifier);
-
- kfree(isp);
+ /* May release isp immediately */
+ media_device_put(&isp->media_dev);
return 0;
}
Use the media device release callback to release the isp device's data structure. This approach has the benefit of not releasing memory which may still be accessed through open file handles whilst the isp driver is being unbound. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> --- drivers/media/platform/ti/omap3isp/isp.c | 25 ++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)