diff options
author | Mike Fiore <mfiore@multitech.com> | 2014-10-13 11:54:44 -0500 |
---|---|---|
committer | Mike Fiore <mfiore@multitech.com> | 2014-10-13 11:54:44 -0500 |
commit | 580677dea4b14e359f2c0622e4340da0cee761c0 (patch) | |
tree | 286383808ecc2e94464fd1c9756d58e26b7dc30e /io-module | |
parent | 3dc67dd080a76b6d7a8ed1a60cd7bee073a23ab5 (diff) | |
download | mts-io-580677dea4b14e359f2c0622e4340da0cee761c0.tar.gz mts-io-580677dea4b14e359f2c0622e4340da0cee761c0.tar.bz2 mts-io-580677dea4b14e359f2c0622e4340da0cee761c0.zip |
mts-io: add configurable reset-monitor-intervals
add to mtr2d2 attribute list
update sysfs script to correctly show options for reset-monitor-intervals
Diffstat (limited to 'io-module')
-rw-r--r-- | io-module/mtr2d2.c | 1 | ||||
-rw-r--r-- | io-module/mts_io.c | 43 |
2 files changed, 41 insertions, 3 deletions
diff --git a/io-module/mtr2d2.c b/io-module/mtr2d2.c index 7e44881..4876c90 100644 --- a/io-module/mtr2d2.c +++ b/io-module/mtr2d2.c @@ -274,6 +274,7 @@ static struct attribute *mtr2d2_platform_attributes[] = { &dev_attr_eth_mac.attr, &dev_attr_reset.attr, &dev_attr_reset_monitor.attr, + &dev_attr_reset_monitor_intervals.attr, &dev_attr_radio_power.attr, &dev_attr_radio_reset.attr, diff --git a/io-module/mts_io.c b/io-module/mts_io.c index 12650b1..8a2de67 100644 --- a/io-module/mts_io.c +++ b/io-module/mts_io.c @@ -110,6 +110,8 @@ bool sent_extra_long = false; static int reset_short_signal = SIGUSR1; static int reset_long_signal = SIGUSR2; static int reset_extra_long_signal = SIGHUP; +static int reset_short_interval = RESET_HOLD_COUNT; +static int reset_long_interval = RESET_LONG_HOLD_COUNT; static void reset_callback(struct work_struct *ignored); @@ -137,16 +139,16 @@ static void reset_callback(struct work_struct *ignored) reset_count++; } else { //Reset button has not been pressed - if (reset_count > 0 && reset_count < RESET_HOLD_COUNT) { + if (reset_count > 0 && reset_count < reset_short_interval) { kill_pid(vpid, reset_short_signal, 1); - } else if (reset_count >= RESET_HOLD_COUNT && reset_count < RESET_LONG_HOLD_COUNT) { + } else if (reset_count >= reset_short_interval && reset_count < reset_long_interval) { kill_pid(vpid, reset_long_signal, 1); } reset_count = 0; sent_extra_long = false; } - if (reset_count >= RESET_LONG_HOLD_COUNT && ! sent_extra_long) { + if (reset_count >= reset_long_interval && ! sent_extra_long) { kill_pid(vpid, reset_extra_long_signal, 1); sent_extra_long = true; } @@ -159,6 +161,41 @@ static void reset_callback(struct work_struct *ignored) schedule_delayed_work(&reset_work, RESET_INTERVAL); } +static ssize_t mts_attr_show_reset_monitor_intervals(struct device *dev, struct device_attribute *attr, char *buf) +{ + int ret; + + mutex_lock(&mts_io_mutex); + + ret = sprintf(buf, "%d %d\n", reset_short_interval / RESET_CHECK_PER_SEC, reset_long_interval / RESET_CHECK_PER_SEC); + + mutex_unlock(&mts_io_mutex); + + return ret; +} + +static ssize_t mts_attr_store_reset_monitor_intervals(struct device *dev, struct device_attribute *attr, char *buf, size_t count) +{ + int short_int; + int long_int; + + if (sscanf(buf, "%i %i", &short_int, &long_int) != 2) { + return -EINVAL; + } + + mutex_lock(&mts_io_mutex); + + reset_short_interval = short_int * RESET_CHECK_PER_SEC; + reset_long_interval = long_int * RESET_CHECK_PER_SEC; + + mutex_unlock(&mts_io_mutex); + + return count; +} + +static DEVICE_ATTR_MTS(dev_attr_reset_monitor_intervals, "reset-monitor-intervals", + mts_attr_show_reset_monitor_intervals, mts_attr_store_reset_monitor_intervals); + static ssize_t mts_attr_show_reset_monitor(struct device *dev, struct device_attribute *attr, char *buf) |