diff options
Diffstat (limited to 'io-module')
-rw-r--r-- | io-module/mts_io.c | 36 |
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; } |