msm: qdss: introduce mutex locking for funnel_enable/disable
In preparation for other qdss source drivers to use the qdss APIs
ensure that funnel_enable and funnel_disable are properly protected
by locks.
Also default the funnel priority for all ports to zero so that all
sources get equal priority.
This is required since going forward there will be more than one
user of the qdss driver.
Change-Id: I8fec21f88e5a206c019d66a50570e5fc91ba6044
Signed-off-by: Pratik Patel <pratikp@codeaurora.org>
diff --git a/arch/arm/mach-msm/qdss-funnel.c b/arch/arm/mach-msm/qdss-funnel.c
index b42c4f6..990295b 100644
--- a/arch/arm/mach-msm/qdss-funnel.c
+++ b/arch/arm/mach-msm/qdss-funnel.c
@@ -52,14 +52,13 @@
struct funnel_ctx {
void __iomem *base;
bool enabled;
+ struct mutex mutex;
struct device *dev;
struct kobject *kobj;
uint32_t priority;
};
-static struct funnel_ctx funnel = {
- .priority = 0xFAC680,
-};
+static struct funnel_ctx funnel;
static void __funnel_enable(uint8_t id, uint32_t port_mask)
{
@@ -79,10 +78,12 @@
void funnel_enable(uint8_t id, uint32_t port_mask)
{
+ mutex_lock(&funnel.mutex);
__funnel_enable(id, port_mask);
funnel.enabled = true;
dev_info(funnel.dev, "FUNNEL port mask 0x%lx enabled\n",
(unsigned long) port_mask);
+ mutex_unlock(&funnel.mutex);
}
static void __funnel_disable(uint8_t id, uint32_t port_mask)
@@ -100,10 +101,12 @@
void funnel_disable(uint8_t id, uint32_t port_mask)
{
+ mutex_lock(&funnel.mutex);
__funnel_disable(id, port_mask);
funnel.enabled = false;
dev_info(funnel.dev, "FUNNEL port mask 0x%lx disabled\n",
(unsigned long) port_mask);
+ mutex_unlock(&funnel.mutex);
}
#define FUNNEL_ATTR(__name) \
@@ -181,6 +184,8 @@
funnel.dev = &pdev->dev;
+ mutex_init(&funnel.mutex);
+
funnel_sysfs_init();
dev_info(funnel.dev, "FUNNEL initialized\n");
@@ -197,6 +202,7 @@
if (funnel.enabled)
funnel_disable(0x0, 0xFF);
funnel_sysfs_exit();
+ mutex_destroy(&funnel.mutex);
iounmap(funnel.base);
return 0;