aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/misc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/misc')
-rw-r--r--drivers/input/misc/da9052_onkey.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/drivers/input/misc/da9052_onkey.c b/drivers/input/misc/da9052_onkey.c
index 1f695f229ea8..184c8f21ab59 100644
--- a/drivers/input/misc/da9052_onkey.c
+++ b/drivers/input/misc/da9052_onkey.c
@@ -27,29 +27,32 @@ struct da9052_onkey {
27 27
28static void da9052_onkey_query(struct da9052_onkey *onkey) 28static void da9052_onkey_query(struct da9052_onkey *onkey)
29{ 29{
30 int key_stat; 30 int ret;
31 31
32 key_stat = da9052_reg_read(onkey->da9052, DA9052_EVENT_B_REG); 32 ret = da9052_reg_read(onkey->da9052, DA9052_STATUS_A_REG);
33 if (key_stat < 0) { 33 if (ret < 0) {
34 dev_err(onkey->da9052->dev, 34 dev_err(onkey->da9052->dev,
35 "Failed to read onkey event %d\n", key_stat); 35 "Failed to read onkey event err=%d\n", ret);
36 } else { 36 } else {
37 /* 37 /*
38 * Since interrupt for deassertion of ONKEY pin is not 38 * Since interrupt for deassertion of ONKEY pin is not
39 * generated, onkey event state determines the onkey 39 * generated, onkey event state determines the onkey
40 * button state. 40 * button state.
41 */ 41 */
42 key_stat &= DA9052_EVENTB_ENONKEY; 42 bool pressed = !(ret & DA9052_STATUSA_NONKEY);
43 input_report_key(onkey->input, KEY_POWER, key_stat); 43
44 input_report_key(onkey->input, KEY_POWER, pressed);
44 input_sync(onkey->input); 45 input_sync(onkey->input);
45 }
46 46
47 /* 47 /*
48 * Interrupt is generated only when the ONKEY pin is asserted. 48 * Interrupt is generated only when the ONKEY pin
49 * Hence the deassertion of the pin is simulated through work queue. 49 * is asserted. Hence the deassertion of the pin
50 */ 50 * is simulated through work queue.
51 if (key_stat) 51 */
52 schedule_delayed_work(&onkey->work, msecs_to_jiffies(50)); 52 if (pressed)
53 schedule_delayed_work(&onkey->work,
54 msecs_to_jiffies(50));
55 }
53} 56}
54 57
55static void da9052_onkey_work(struct work_struct *work) 58static void da9052_onkey_work(struct work_struct *work)