[COMMON] media: smfc: add the shutdown callback
authorWon Jung <w00.jung@samsung.com>
Thu, 22 Sep 2016 07:48:03 +0000 (16:48 +0900)
committerCosmin Tanislav <demonsingur@gmail.com>
Mon, 22 Apr 2024 17:22:19 +0000 (20:22 +0300)
if shutdown, smfc driver should wait to finish the H/W
operation to avoid the access the power domain/ clk
after the detach of pm_domain

Change-Id: I7328be4c4c4ef15ba578c5c44e3ba5396592fcce
Signed-off-by: Won Jung <w00.jung@samsung.com>
drivers/media/platform/exynos/smfc/smfc.c

index 39d2f7bab80b2dae925343a3473f4fd85d1ed740..628953027d9d51ffd7ad8f960aea8994197e6fbc 100644 (file)
@@ -993,6 +993,19 @@ static int smfc_runtime_suspend(struct device *dev)
 }
 #endif
 
+static void exynos_smfc_shutdown(struct platform_device *pdev)
+{
+       DECLARE_WAIT_QUEUE_HEAD_ONSTACK(smfc_suspend_wq);
+       struct smfc_dev *smfc = platform_get_drvdata(pdev);
+       unsigned long flags;
+
+       spin_lock_irqsave(&smfc->flag_lock, flags);
+       if (!!(smfc->flags & SMFC_DEV_RUNNING))
+               smfc->flags |= SMFC_DEV_SUSPENDING;
+       spin_unlock_irqrestore(&smfc->flag_lock, flags);
+       wait_event(smfc_suspend_wq, !(smfc->flags & SMFC_DEV_SUSPENDING));
+}
+
 static const struct dev_pm_ops exynos_smfc_pm_ops = {
        SET_SYSTEM_SLEEP_PM_OPS(smfc_suspend, smfc_resume)
        SET_RUNTIME_PM_OPS(NULL, smfc_runtime_resume, smfc_runtime_suspend)
@@ -1001,6 +1014,7 @@ static const struct dev_pm_ops exynos_smfc_pm_ops = {
 static struct platform_driver exynos_smfc_driver = {
        .probe          = exynos_smfc_probe,
        .remove         = exynos_smfc_remove,
+       .shutdown       = exynos_smfc_shutdown,
        .driver = {
                .name   = MODULE_NAME,
                .owner  = THIS_MODULE,