summaryrefslogtreecommitdiff
path: root/drivers/power
diff options
context:
space:
mode:
authorSubbaraman Narayanamurthy <subbaram@codeaurora.org>2017-02-06 16:04:32 -0800
committerSubbaraman Narayanamurthy <subbaram@codeaurora.org>2017-02-10 16:57:48 -0800
commit1f0f1184a030001389ad2e4e23f8400eb4a778fd (patch)
tree151d308a6b6ba0133771d762a4c6d5b57a455725 /drivers/power
parent580b03cf01fc09bbee0c89d9d9840d9a97152552 (diff)
qcom: storm-watch: add support to reset storm count
There are some circumstances where we have to reset the storm watch interrupt count. Add support for it. Change-Id: Iacbeb3258d53010aab8ba881d10de773fe54dd93 Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/supply/qcom/qpnp-smb2.c1
-rw-r--r--drivers/power/supply/qcom/smb138x-charger.c1
-rw-r--r--drivers/power/supply/qcom/storm-watch.c11
-rw-r--r--drivers/power/supply/qcom/storm-watch.h16
4 files changed, 22 insertions, 7 deletions
diff --git a/drivers/power/supply/qcom/qpnp-smb2.c b/drivers/power/supply/qcom/qpnp-smb2.c
index 1fb0cab6c364..4f0d85b8e1e6 100644
--- a/drivers/power/supply/qcom/qpnp-smb2.c
+++ b/drivers/power/supply/qcom/qpnp-smb2.c
@@ -1881,6 +1881,7 @@ static int smb2_request_interrupt(struct smb2 *chip,
irq_data->parent_data = chip;
irq_data->name = irq_name;
irq_data->storm_data = smb2_irqs[irq_index].storm_data;
+ mutex_init(&irq_data->storm_data.storm_lock);
rc = devm_request_threaded_irq(chg->dev, irq, NULL,
smb2_irqs[irq_index].handler,
diff --git a/drivers/power/supply/qcom/smb138x-charger.c b/drivers/power/supply/qcom/smb138x-charger.c
index 7e1f34e1ec30..8f91642db214 100644
--- a/drivers/power/supply/qcom/smb138x-charger.c
+++ b/drivers/power/supply/qcom/smb138x-charger.c
@@ -1197,6 +1197,7 @@ static int smb138x_request_interrupt(struct smb138x *chip,
irq_data->parent_data = chip;
irq_data->name = irq_name;
irq_data->storm_data = smb138x_irqs[irq_index].storm_data;
+ mutex_init(&irq_data->storm_data.storm_lock);
rc = devm_request_threaded_irq(chg->dev, irq, NULL,
smb138x_irqs[irq_index].handler,
diff --git a/drivers/power/supply/qcom/storm-watch.c b/drivers/power/supply/qcom/storm-watch.c
index 90fec12bd742..5275079c53e0 100644
--- a/drivers/power/supply/qcom/storm-watch.c
+++ b/drivers/power/supply/qcom/storm-watch.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -39,6 +39,7 @@ bool is_storming(struct storm_watch *data)
if (data->storm_period_ms <= 0)
return false;
+ mutex_lock(&data->storm_lock);
curr_kt = ktime_get_boottime();
delta_kt = ktime_sub(curr_kt, data->last_kt);
@@ -53,5 +54,13 @@ bool is_storming(struct storm_watch *data)
}
data->last_kt = curr_kt;
+ mutex_unlock(&data->storm_lock);
return is_storming;
}
+
+void reset_storm_count(struct storm_watch *data)
+{
+ mutex_lock(&data->storm_lock);
+ data->storm_count = 0;
+ mutex_unlock(&data->storm_lock);
+}
diff --git a/drivers/power/supply/qcom/storm-watch.h b/drivers/power/supply/qcom/storm-watch.h
index 44b9d64d8a87..ff05c4a661c3 100644
--- a/drivers/power/supply/qcom/storm-watch.h
+++ b/drivers/power/supply/qcom/storm-watch.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -13,6 +13,7 @@
#ifndef __STORM_WATCH_H
#define __STORM_WATCH_H
#include <linux/ktime.h>
+#include <linux/mutex.h>
/**
* Data used to track an event storm.
@@ -23,14 +24,17 @@
* @max_storm_count: The number of chained events required to trigger a storm.
* @storm_count: The current number of chained events.
* @last_kt: Kernel time of the last event seen.
+ * @storm_lock: Mutex lock to protect storm_watch data.
*/
struct storm_watch {
- bool enabled;
- int storm_period_ms;
- int max_storm_count;
- int storm_count;
- ktime_t last_kt;
+ bool enabled;
+ int storm_period_ms;
+ int max_storm_count;
+ int storm_count;
+ ktime_t last_kt;
+ struct mutex storm_lock;
};
bool is_storming(struct storm_watch *data);
+void reset_storm_count(struct storm_watch *data);
#endif