Skip to content

Instantly share code, notes, and snippets.

@sorgelig
Created August 17, 2013 23:56
Show Gist options
  • Save sorgelig/6259237 to your computer and use it in GitHub Desktop.
Save sorgelig/6259237 to your computer and use it in GitHub Desktop.
Fix for negative toggle (two -1 have been missed)
diff --git a/drivers/input/keyboard/cypress/cypress-touchkey.c b/drivers/input/keyboard/cypress/cypress-touchkey.c
index 30fb1fb..51c3a05 100644
--- a/drivers/input/keyboard/cypress/cypress-touchkey.c
+++ b/drivers/input/keyboard/cypress/cypress-touchkey.c
@@ -861,14 +861,14 @@ static inline int64_t get_time_inms(void) {
}
extern void mdnie_toggle_negative(void);
-static int key_trg_cnt = 4;
-static int key_trg_ms = 300;
+#define KEY_TRG_CNT 4
+#define KEY_TRG_MS 300
static irqreturn_t touchkey_interrupt(int irq, void *dev_id)
{
struct touchkey_i2c *tkey_i2c = dev_id;
static int64_t trigger_lasttime = 0;
- static int trigger_count = 0;
+ static int trigger_count = -1;
u8 data[3];
int ret;
int retry = 10;
@@ -900,8 +900,8 @@ static irqreturn_t touchkey_interrupt(int irq, void *dev_id)
if ((touchkey_keycode[keycode_type] == KEY_MENU) &&
pressed && mdnie_shortcut_enabled)
{
- if ((get_time_inms() - trigger_lasttime) < key_trg_ms) {
- if (++trigger_count >= key_trg_cnt) {
+ if ((get_time_inms() - trigger_lasttime) < KEY_TRG_MS) {
+ if (++trigger_count >= KEY_TRG_CNT-1) {
mdnie_toggle_negative();
trigger_count = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment