diff options
| author | Ondrej Hlavac <hlavaco@gmail.com> | 2017-03-25 11:53:24 +0100 |
|---|---|---|
| committer | Davide Garberi <dade.garberi@gmail.com> | 2022-07-27 18:59:04 +0200 |
| commit | 3ac6332f857a3bdb116274450f4fcf22736bb3ac (patch) | |
| tree | 3101906ad5fd3e7a6cce6fb55c12e7f0771e048a | |
| parent | 03b88a9e3e49c5058ed4866bc127e203ab185362 (diff) | |
fpc1020: add sysfs for disabling key emulation
- needed for KeyDisabler
Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
Change-Id: Ia6a3a12d4aede9d19cfc2dcc7b2831673ce73480
| -rw-r--r-- | drivers/fingerprint/fpc1020_ree.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/drivers/fingerprint/fpc1020_ree.c b/drivers/fingerprint/fpc1020_ree.c index 06b34540ad00..60a78378b5fc 100644 --- a/drivers/fingerprint/fpc1020_ree.c +++ b/drivers/fingerprint/fpc1020_ree.c @@ -80,6 +80,8 @@ extern void reset_home_button(void); bool reset; +static bool utouch_disable; + static int fb_notifier_callback(struct notifier_block *self, unsigned long event, void *data); @@ -131,7 +133,7 @@ static ssize_t set_key(struct device *device, bool home_pressed; retval = kstrtou64(buffer, 0, &val); - if (!retval) { + if (!retval && !utouch_disable) { if (val == KEY_HOME) /* Convert to U-touch long press keyValue */ val = KEY_NAVI_LONG; @@ -149,13 +151,41 @@ static ssize_t set_key(struct device *device, pr_info("calling home key reset"); reset_home_button(); } - } else + } else if (retval) return -ENOENT; return strnlen(buffer, count); } static DEVICE_ATTR(key, S_IRUSR | S_IWUSR, get_key, set_key); +static ssize_t utouch_store_disable(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + int value; + if (1 != sscanf(buf, "%d", &value)) { + dev_err(dev, "Failed to parse integer: <%s>\n", buf); + return -EINVAL; + } + if (value == 1) { + utouch_disable = true; + pr_info("utouch disabled\n"); + } else { + utouch_disable = false; + pr_info("utouch enabled\n"); + } + return count; +} + +static ssize_t utouch_show_disable(struct device *dev, + struct device_attribute *attr, char *buf) +{ + if (utouch_disable) + return sprintf(buf, "1\n"); + else + return sprintf(buf, "0\n"); +} +static DEVICE_ATTR(utouch_disable, S_IRUGO|S_IWUSR, utouch_show_disable, utouch_store_disable); + static ssize_t proximity_state_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -183,6 +213,7 @@ static struct attribute *attributes[] = { &dev_attr_irq.attr, &dev_attr_key.attr, &dev_attr_proximity_state.attr, + &dev_attr_utouch_disable.attr, NULL }; |
