Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: bbnsm_pwrkey - fix missed key press after suspend

Report input event directly on wakeup to ensure no press event is missed
when resuming from suspend.

Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
Signed-off-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20240716000721.3485597-1-Frank.Li@nxp.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Jacky Bai and committed by
Dmitry Torokhov
2f99ffd8 5d33d04e

+38
+38
drivers/input/misc/nxp-bbnsm-pwrkey.c
··· 38 38 int irq; 39 39 int keycode; 40 40 int keystate; /* 1:pressed */ 41 + bool suspended; 41 42 struct timer_list check_timer; 42 43 struct input_dev *input; 43 44 }; ··· 71 70 { 72 71 struct platform_device *pdev = dev_id; 73 72 struct bbnsm_pwrkey *bbnsm = platform_get_drvdata(pdev); 73 + struct input_dev *input = bbnsm->input; 74 74 u32 event; 75 75 76 76 regmap_read(bbnsm->regmap, BBNSM_EVENTS, &event); ··· 79 77 return IRQ_NONE; 80 78 81 79 pm_wakeup_event(bbnsm->input->dev.parent, 0); 80 + 81 + /* 82 + * Directly report key event after resume to make sure key press 83 + * event is never missed. 84 + */ 85 + if (bbnsm->suspended) { 86 + bbnsm->keystate = 1; 87 + input_event(input, EV_KEY, bbnsm->keycode, 1); 88 + input_sync(input); 89 + /* Fire at most once per suspend/resume cycle */ 90 + bbnsm->suspended = false; 91 + } 82 92 83 93 mod_timer(&bbnsm->check_timer, 84 94 jiffies + msecs_to_jiffies(DEBOUNCE_TIME)); ··· 187 173 return 0; 188 174 } 189 175 176 + static int __maybe_unused bbnsm_pwrkey_suspend(struct device *dev) 177 + { 178 + struct platform_device *pdev = to_platform_device(dev); 179 + struct bbnsm_pwrkey *bbnsm = platform_get_drvdata(pdev); 180 + 181 + bbnsm->suspended = true; 182 + 183 + return 0; 184 + } 185 + 186 + static int __maybe_unused bbnsm_pwrkey_resume(struct device *dev) 187 + { 188 + struct platform_device *pdev = to_platform_device(dev); 189 + struct bbnsm_pwrkey *bbnsm = platform_get_drvdata(pdev); 190 + 191 + bbnsm->suspended = false; 192 + 193 + return 0; 194 + } 195 + 196 + static SIMPLE_DEV_PM_OPS(bbnsm_pwrkey_pm_ops, bbnsm_pwrkey_suspend, 197 + bbnsm_pwrkey_resume); 198 + 190 199 static const struct of_device_id bbnsm_pwrkey_ids[] = { 191 200 { .compatible = "nxp,imx93-bbnsm-pwrkey" }, 192 201 { /* sentinel */ } ··· 219 182 static struct platform_driver bbnsm_pwrkey_driver = { 220 183 .driver = { 221 184 .name = "bbnsm_pwrkey", 185 + .pm = &bbnsm_pwrkey_pm_ops, 222 186 .of_match_table = bbnsm_pwrkey_ids, 223 187 }, 224 188 .probe = bbnsm_pwrkey_probe,