mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
910a9f5636
commit
70b0052425
|
@ -27,29 +27,32 @@ struct da9052_onkey {
|
|||
|
||||
static void da9052_onkey_query(struct da9052_onkey *onkey)
|
||||
{
|
||||
int key_stat;
|
||||
int ret;
|
||||
|
||||
key_stat = da9052_reg_read(onkey->da9052, DA9052_EVENT_B_REG);
|
||||
if (key_stat < 0) {
|
||||
ret = da9052_reg_read(onkey->da9052, DA9052_STATUS_A_REG);
|
||||
if (ret < 0) {
|
||||
dev_err(onkey->da9052->dev,
|
||||
"Failed to read onkey event %d\n", key_stat);
|
||||
"Failed to read onkey event err=%d\n", ret);
|
||||
} else {
|
||||
/*
|
||||
* Since interrupt for deassertion of ONKEY pin is not
|
||||
* generated, onkey event state determines the onkey
|
||||
* button state.
|
||||
*/
|
||||
key_stat &= DA9052_EVENTB_ENONKEY;
|
||||
input_report_key(onkey->input, KEY_POWER, key_stat);
|
||||
input_sync(onkey->input);
|
||||
}
|
||||
bool pressed = !(ret & DA9052_STATUSA_NONKEY);
|
||||
|
||||
/*
|
||||
* Interrupt is generated only when the ONKEY pin is asserted.
|
||||
* Hence the deassertion of the pin is simulated through work queue.
|
||||
*/
|
||||
if (key_stat)
|
||||
schedule_delayed_work(&onkey->work, msecs_to_jiffies(50));
|
||||
input_report_key(onkey->input, KEY_POWER, pressed);
|
||||
input_sync(onkey->input);
|
||||
|
||||
/*
|
||||
* Interrupt is generated only when the ONKEY pin
|
||||
* is asserted. Hence the deassertion of the pin
|
||||
* is simulated through work queue.
|
||||
*/
|
||||
if (pressed)
|
||||
schedule_delayed_work(&onkey->work,
|
||||
msecs_to_jiffies(50));
|
||||
}
|
||||
}
|
||||
|
||||
static void da9052_onkey_work(struct work_struct *work)
|
||||
|
|
Loading…
Reference in New Issue