diff options
author | Anthony Olech <anthony.olech.opensource@diasemi.com> | 2014-02-17 14:23:39 -0500 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2014-03-26 16:33:09 -0400 |
commit | 415e02bd25b3c053c33db7d1228d207d81c0fb1b (patch) | |
tree | 5f424beb04b2c4a5d49ab1f3aa3276fddd61e41d | |
parent | 86234eb7f149c30b3273b47fc8f5c67066e498d0 (diff) |
Input: da9052_onkey - use correct register bit for key status
The wrong register bit of the DA9052/3 PMIC registers was
used to determine the status on the ONKEY.
Also a failure in reading the status register will no longer
result in the work queue being rescheduled as that would result
in a (potentially) endless retry.
Signed-off-by: Anthony Olech <anthony.olech.opensource@diasemi.com>
Acked-by: David Dajun Chen <david.chen@diasemi.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | drivers/input/misc/da9052_onkey.c | 29 |
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 | ||
28 | static void da9052_onkey_query(struct da9052_onkey *onkey) | 28 | static 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 | ||
55 | static void da9052_onkey_work(struct work_struct *work) | 58 | static void da9052_onkey_work(struct work_struct *work) |