summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Godinez <sgodinez@multitech.com>2013-11-22 10:23:06 -0600
committerSean Godinez <sgodinez@multitech.com>2013-11-22 10:23:06 -0600
commite0e72edb4da3ac44f8db1d144729ea87e50b24f1 (patch)
tree96a83a2b37d386d4c4a5877d5b54fd51a6f5831a
parent5b405021260a35757d594bddc313b75d2c15a994 (diff)
downloadcdp-io-controller-e0e72edb4da3ac44f8db1d144729ea87e50b24f1.tar.gz
cdp-io-controller-e0e72edb4da3ac44f8db1d144729ea87e50b24f1.tar.bz2
cdp-io-controller-e0e72edb4da3ac44f8db1d144729ea87e50b24f1.zip
added optional extra long reset hold signal
-rw-r--r--io-module/mts_io.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/io-module/mts_io.c b/io-module/mts_io.c
index 211dbc4..bdbc43d 100644
--- a/io-module/mts_io.c
+++ b/io-module/mts_io.c
@@ -1179,11 +1179,13 @@ struct clk *adc_clk;
#define BLINK_PER_SEC 8
#define BLINK_INTERVAL (HZ / BLINK_PER_SEC)
#define RESET_HOLD_COUNT (BLINK_PER_SEC * 3)
+#define RESET_LONG_HOLD_COUNT (BLINK_PER_SEC * 30)
static pid_t reset_pid = -1;
static pid_t reset_count = 0;
static int reset_short_signal = SIGUSR1;
static int reset_long_signal = SIGUSR2;
+static int reset_extra_long_signal = SIGHUP;
static DEFINE_MUTEX(mts_io_mutex);
static void blink_callback(struct work_struct *ignored);
@@ -1213,11 +1215,14 @@ static void blink_callback(struct work_struct *ignored)
} else if (reset_count > 0 && reset_count < RESET_HOLD_COUNT) {
kill_pid(vpid, reset_short_signal, 1);
reset_count = 0;
+ } else if (reset_count >= RESET_HOLD_COUNT && reset_count < RESET_LONG_HOLD_COUNT) {
+ reset_count = 0;
+ kill_pid(vpid, reset_long_signal, 1);
}
- if (reset_count >= RESET_HOLD_COUNT) {
+ if (reset_count >= RESET_LONG_HOLD_COUNT) {
reset_count = 0;
- kill_pid(vpid, reset_long_signal, 1);
+ kill_pid(vpid, reset_extra_long_signal, 1);
}
} else {
reset_count = 0;
@@ -2083,7 +2088,7 @@ static ssize_t mts_attr_show_reset_monitor(struct device *dev,
mutex_lock(&mts_io_mutex);
- ret = sprintf(buf, "%d %d %d\n", reset_pid, reset_short_signal, reset_long_signal);
+ ret = sprintf(buf, "%d %d %d %d\n", reset_pid, reset_short_signal, reset_long_signal, reset_extra_long_signal);
mutex_unlock(&mts_io_mutex);
@@ -2096,18 +2101,31 @@ static ssize_t mts_attr_store_reset_monitor(struct device *dev,
pid_t pid;
int short_signal;
int long_signal;
+ int extra_long_signal;
+ int result = sscanf(buf, "%i %i %i %i", &pid, &short_signal, &long_signal, &extra_long_signal);
- if (sscanf(buf, "%i %i %i", &pid, &short_signal, &long_signal) != 3) {
+ if (result < 3 || result > 4) {
return -EINVAL;
}
- mutex_lock(&mts_io_mutex);
+ if(result == 3) {
+ mutex_lock(&mts_io_mutex);
- reset_pid = pid;
- reset_short_signal = short_signal;
- reset_long_signal = long_signal;
+ reset_pid = pid;
+ reset_short_signal = short_signal;
+ reset_long_signal = long_signal;
- mutex_unlock(&mts_io_mutex);
+ mutex_unlock(&mts_io_mutex);
+ } else {
+ mutex_lock(&mts_io_mutex);
+
+ reset_pid = pid;
+ reset_short_signal = short_signal;
+ reset_long_signal = long_signal;
+ reset_extra_long_signal = long_signal;
+
+ mutex_unlock(&mts_io_mutex);
+ }
return count;
}