summaryrefslogtreecommitdiff
path: root/io-module
diff options
context:
space:
mode:
Diffstat (limited to 'io-module')
-rw-r--r--io-module/mts-io.c6
-rw-r--r--io-module/mts_supercap.c7
-rw-r--r--io-module/mts_supercap.h2
3 files changed, 13 insertions, 2 deletions
diff --git a/io-module/mts-io.c b/io-module/mts-io.c
index 83c3ddf..6c14a74 100644
--- a/io-module/mts-io.c
+++ b/io-module/mts-io.c
@@ -1255,6 +1255,12 @@ static void __exit mts_io_exit(void)
gpio_free(pin->pin.gpio);
cleanup_buttons();
+
+ //cleanup supercap monitor worker if SUPERCAP CAPA is true
+ if(DEVICE_CAPA(id_eeprom.capa, CAPA_SUPERCAP)) {
+ cleanup_supercap_worker();
+ }
+
cleanup();
if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA) && attr_group_lora) {
mts_teardown_lora_port();
diff --git a/io-module/mts_supercap.c b/io-module/mts_supercap.c
index e028408..6cd9841 100644
--- a/io-module/mts_supercap.c
+++ b/io-module/mts_supercap.c
@@ -74,6 +74,8 @@ static void supercap_worker(struct work_struct *ignored)
struct pid *vpid;
int running_on_cap = 0;
+ mutex_lock(&mts_io_mutex);
+
pin = gpio_pin_by_attr_name("power-fail");
if (pin) {
@@ -83,6 +85,7 @@ static void supercap_worker(struct work_struct *ignored)
if (supercap.pid > 0) {
vpid = find_vpid(supercap.pid);
}
+
if (vpid) {
if (running_on_cap == 0 && supercap.pwf_count == 0) {
schedule_delayed_work(&supercap_work, SUPERCAP_CHECK_INTERVAL);
@@ -109,6 +112,8 @@ static void supercap_worker(struct work_struct *ignored)
}
} /* vpid */
+ mutex_unlock(&mts_io_mutex);
+
schedule_delayed_work(&supercap_work, SUPERCAP_CHECK_INTERVAL);
}
@@ -117,7 +122,7 @@ void init_supercap_worker(void) {
supercap_worker(NULL);
}
-void cleanup_sepercap_worker(void) {
+void cleanup_supercap_worker(void) {
cancel_delayed_work_sync(&supercap_work);
}
diff --git a/io-module/mts_supercap.h b/io-module/mts_supercap.h
index 79ea7df..871346d 100644
--- a/io-module/mts_supercap.h
+++ b/io-module/mts_supercap.h
@@ -28,7 +28,7 @@ typedef struct supercap_info {
} supercap_info_t, *supercap_info_pt;
extern void init_supercap_worker(void);
-extern void cleanup_sepercap_worker(void);
+extern void cleanup_supercap_worker(void);
extern ssize_t mts_attr_show_supercap_monitor(struct device *dev,
struct device_attribute *attr,