msm: qdss: initialize mutex earlier in etb_probe
Initialize mutex earlier in etb_probe to allow for it to be
used by subsequent code if required. Make corresponding changes
to mutex destroy for the error path as well as etb_remove.
Change-Id: Iac3c4fe9ddb0f31d9a0faaca3f526e928e35f6cc
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
diff --git a/arch/arm/mach-msm/qdss-etb.c b/arch/arm/mach-msm/qdss-etb.c
index 4efc2d1..9ee9265 100644
--- a/arch/arm/mach-msm/qdss-etb.c
+++ b/arch/arm/mach-msm/qdss-etb.c
@@ -274,6 +274,8 @@
etb.dev = &pdev->dev;
+ mutex_init(&etb.mutex);
+
ret = misc_register(&etb_misc);
if (ret)
goto err_misc;
@@ -284,14 +286,13 @@
goto err_alloc;
}
- mutex_init(&etb.mutex);
-
dev_info(etb.dev, "ETB initialized\n");
return 0;
err_alloc:
misc_deregister(&etb_misc);
err_misc:
+ mutex_destroy(&etb.mutex);
iounmap(etb.base);
err_ioremap:
err_res:
@@ -303,9 +304,9 @@
{
if (etb.enabled)
etb_disable();
- mutex_destroy(&etb.mutex);
kfree(etb.buf);
misc_deregister(&etb_misc);
+ mutex_destroy(&etb.mutex);
iounmap(etb.base);
return 0;