diff options
| author | Álvaro Brey <alvaro.brv@gmail.com> | 2017-03-16 13:19:54 +0100 |
|---|---|---|
| committer | Davide Garberi <dade.garberi@gmail.com> | 2022-07-27 18:59:03 +0200 |
| commit | 6b401a46c8b30241ed29ce4d5cb437779dd0368d (patch) | |
| tree | cde994a340aa2e00fe0c5fe42729aef60403d50a | |
| parent | 9c94cc153eb85eaec8d13888343529fe6ca5385c (diff) | |
drivers: fpc/gpio cleanup
* General improvements to code style
* Remove unused functions
* Remove redundant param for reset_home_button
* Reuse function calls as variables to improve performance
* Simplify boolean checks
* Document extern functions and relevant variables
Change-Id: I597c5d4f35b80b797d6ab51dc0030d48d665bad1
Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
| -rw-r--r-- | drivers/fingerprint/fpc1020_ree.c | 29 | ||||
| -rw-r--r-- | drivers/input/keyboard/gpio_keys.c | 36 |
2 files changed, 43 insertions, 22 deletions
diff --git a/drivers/fingerprint/fpc1020_ree.c b/drivers/fingerprint/fpc1020_ree.c index 7c31100c923f..91960cc64fc4 100644 --- a/drivers/fingerprint/fpc1020_ree.c +++ b/drivers/fingerprint/fpc1020_ree.c @@ -57,8 +57,14 @@ struct fpc1020_data { int screen_on; }; +/* + * From drivers/input/keyboard/gpio_keys.c + */ extern bool home_button_pressed(void); -extern void reset_home_button(bool); +/* + * From drivers/input/keyboard/gpio_keys.c + */ +extern void reset_home_button(void); bool reset; @@ -86,7 +92,7 @@ static ssize_t irq_set(struct device* device, else if (val == 0) disable_irq(fpc1020->irq); else - return -ENOENT; + return -ENOENT; return strnlen(buffer, count); } @@ -156,7 +162,7 @@ static DEVICE_ATTR(wakeup, S_IRUSR | S_IWUSR, get_wakeup_status, set_wakeup_stat static ssize_t get_key(struct device* device, struct device_attribute* attribute, char* buffer) { struct fpc1020_data* fpc1020 = dev_get_drvdata(device); - return scnprintf(buffer, PAGE_SIZE, "%i\n", fpc1020->report_key); + return scnprintf(buffer, PAGE_SIZE, "%i\n", fpc1020->report_key); } static ssize_t set_key(struct device* device, @@ -166,31 +172,30 @@ static ssize_t set_key(struct device* device, int retval = 0; u64 val; struct fpc1020_data* fpc1020 = dev_get_drvdata(device); + bool home_pressed; retval = kstrtou64(buffer, 0, &val); if (!retval) { if (val == KEY_HOME) val = KEY_NAVI_LONG; //Convert to U-touch long press keyValue - if (val != 0 && home_button_pressed()) val = 0; - pr_info("home key pressed = %d\n", (int)home_button_pressed()); + home_pressed = home_button_pressed(); + + if (val && home_pressed) val = 0; + + pr_info("home key pressed = %d\n", (int)home_pressed); fpc1020->report_key = (int)val; queue_work(fpc1020->fpc1020_wq, &fpc1020->input_report_work); - if (val == 0) { + if (!val) { pr_info("calling home key reset"); - reset_home_button(0); + reset_home_button(); } } else return -ENOENT; return strnlen(buffer, count); } -bool reset_gpio(void) -{ - return reset; -} - static DEVICE_ATTR(key, S_IRUSR | S_IWUSR, get_key, set_key); static ssize_t get_screen_stat(struct device* device, struct device_attribute* attribute, char* buffer) diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index eeaaf1071a42..3db6805be316 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -59,8 +59,6 @@ struct gpio_keys_drvdata { struct gpio_button_data data[0]; }; -extern bool reset_gpio(void); - static struct device *global_dev; static struct syscore_ops gpio_keys_syscore_pm_ops; @@ -68,6 +66,11 @@ static struct syscore_ops gpio_keys_syscore_pm_ops; static void gpio_keys_syscore_resume(void); /* + * From drivers/misc/fpc1020_ree.c + */ +extern bool reset_gpio(void); + +/* * SYSFS interface for enabling/disabling keys and switches: * * There are 4 attributes under /sys/devices/platform/gpio-keys/ @@ -365,6 +368,11 @@ static struct attribute_group gpio_keys_attr_group = { .attrs = gpio_keys_attrs, }; +/* + * Status of home button. + * true: pressed + * false: not pressed + */ bool home_button_status; static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata) @@ -394,10 +402,23 @@ static void gpio_keys_gpio_report_event(struct gpio_button_data *bdata) input_sync(input); } -void reset_home_button(int i) +/* + * Used by drivers/misc/fpc1020_ree.c + * Resets home button status. + */ +void reset_home_button(void) +{ + home_button_status = false; + pr_info("key home button reset ok, home_button_status=%d", home_button_status); +} + +/* + * Used by drivers/misc/fpc1020_ree.c + * Returns a bool specifying whether home button is pressed. + */ +bool home_button_pressed(void) { - home_button_status = i; - pr_info("key home button reset ok, home_button_status=%d",i); + return home_button_status; } @@ -1057,11 +1078,6 @@ static void __exit gpio_keys_exit(void) platform_driver_unregister(&gpio_keys_device_driver); } -bool home_button_pressed(void) -{ - return home_button_status; -} - late_initcall(gpio_keys_init); module_exit(gpio_keys_exit); |
