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>

authored by Anthony Olech and committed by Dmitry Torokhov 70b00524 910a9f56

+17 -14
+17 -14
drivers/input/misc/da9052_onkey.c
··· 27 28 static void da9052_onkey_query(struct da9052_onkey *onkey) 29 { 30 - int key_stat; 31 32 - key_stat = da9052_reg_read(onkey->da9052, DA9052_EVENT_B_REG); 33 - if (key_stat < 0) { 34 dev_err(onkey->da9052->dev, 35 - "Failed to read onkey event %d\n", key_stat); 36 } else { 37 /* 38 * Since interrupt for deassertion of ONKEY pin is not 39 * generated, onkey event state determines the onkey 40 * button state. 41 */ 42 - key_stat &= DA9052_EVENTB_ENONKEY; 43 - input_report_key(onkey->input, KEY_POWER, key_stat); 44 - input_sync(onkey->input); 45 - } 46 47 - /* 48 - * Interrupt is generated only when the ONKEY pin is asserted. 49 - * Hence the deassertion of the pin is simulated through work queue. 50 - */ 51 - if (key_stat) 52 - schedule_delayed_work(&onkey->work, msecs_to_jiffies(50)); 53 } 54 55 static void da9052_onkey_work(struct work_struct *work)
··· 27 28 static void da9052_onkey_query(struct da9052_onkey *onkey) 29 { 30 + int ret; 31 32 + ret = da9052_reg_read(onkey->da9052, DA9052_STATUS_A_REG); 33 + if (ret < 0) { 34 dev_err(onkey->da9052->dev, 35 + "Failed to read onkey event err=%d\n", ret); 36 } else { 37 /* 38 * Since interrupt for deassertion of ONKEY pin is not 39 * generated, onkey event state determines the onkey 40 * button state. 41 */ 42 + bool pressed = !(ret & DA9052_STATUSA_NONKEY); 43 44 + input_report_key(onkey->input, KEY_POWER, pressed); 45 + input_sync(onkey->input); 46 + 47 + /* 48 + * Interrupt is generated only when the ONKEY pin 49 + * is asserted. Hence the deassertion of the pin 50 + * is simulated through work queue. 51 + */ 52 + if (pressed) 53 + schedule_delayed_work(&onkey->work, 54 + msecs_to_jiffies(50)); 55 + } 56 } 57 58 static void da9052_onkey_work(struct work_struct *work)