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

Input: don't call input_dev_release_keys() in resume

When waking up the platform by pressing a specific key, sending a
release on that key makes it impossible to react on the event in
user-space. This is fixed by moving the input_reset_device() call to
resume instead.

[dmitry.torokhov@gmail.com: make sure we still restore LED/sound state
after resume, handle hibernation properly]

Signed-off-by: Aleksej Makarov <aleksej.makarov@sonymobile.com>
Signed-off-by: Oskar Andero <oskar.andero@sonymobile.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Aleksej Makarov and committed by
Dmitry Torokhov
768d9aa5 c2729850

+57 -19
+57 -19
drivers/input/input.c
··· 1653 1653 */ 1654 1654 void input_reset_device(struct input_dev *dev) 1655 1655 { 1656 + unsigned long flags; 1657 + 1656 1658 mutex_lock(&dev->mutex); 1659 + spin_lock_irqsave(&dev->event_lock, flags); 1657 1660 1658 - if (dev->users) { 1659 - input_dev_toggle(dev, true); 1661 + input_dev_toggle(dev, true); 1662 + input_dev_release_keys(dev); 1660 1663 1661 - /* 1662 - * Keys that have been pressed at suspend time are unlikely 1663 - * to be still pressed when we resume. 1664 - */ 1665 - spin_lock_irq(&dev->event_lock); 1666 - input_dev_release_keys(dev); 1667 - spin_unlock_irq(&dev->event_lock); 1668 - } 1669 - 1664 + spin_unlock_irqrestore(&dev->event_lock, flags); 1670 1665 mutex_unlock(&dev->mutex); 1671 1666 } 1672 1667 EXPORT_SYMBOL(input_reset_device); 1673 1668 1674 - #ifdef CONFIG_PM 1669 + #ifdef CONFIG_PM_SLEEP 1675 1670 static int input_dev_suspend(struct device *dev) 1676 1671 { 1677 1672 struct input_dev *input_dev = to_input_dev(dev); 1678 1673 1679 - mutex_lock(&input_dev->mutex); 1674 + spin_lock_irq(&input_dev->event_lock); 1680 1675 1681 - if (input_dev->users) 1682 - input_dev_toggle(input_dev, false); 1676 + /* 1677 + * Keys that are pressed now are unlikely to be 1678 + * still pressed when we resume. 1679 + */ 1680 + input_dev_release_keys(input_dev); 1683 1681 1684 - mutex_unlock(&input_dev->mutex); 1682 + /* Turn off LEDs and sounds, if any are active. */ 1683 + input_dev_toggle(input_dev, false); 1684 + 1685 + spin_unlock_irq(&input_dev->event_lock); 1685 1686 1686 1687 return 0; 1687 1688 } ··· 1691 1690 { 1692 1691 struct input_dev *input_dev = to_input_dev(dev); 1693 1692 1694 - input_reset_device(input_dev); 1693 + spin_lock_irq(&input_dev->event_lock); 1694 + 1695 + /* Restore state of LEDs and sounds, if any were active. */ 1696 + input_dev_toggle(input_dev, true); 1697 + 1698 + spin_unlock_irq(&input_dev->event_lock); 1699 + 1700 + return 0; 1701 + } 1702 + 1703 + static int input_dev_freeze(struct device *dev) 1704 + { 1705 + struct input_dev *input_dev = to_input_dev(dev); 1706 + 1707 + spin_lock_irq(&input_dev->event_lock); 1708 + 1709 + /* 1710 + * Keys that are pressed now are unlikely to be 1711 + * still pressed when we resume. 1712 + */ 1713 + input_dev_release_keys(input_dev); 1714 + 1715 + spin_unlock_irq(&input_dev->event_lock); 1716 + 1717 + return 0; 1718 + } 1719 + 1720 + static int input_dev_poweroff(struct device *dev) 1721 + { 1722 + struct input_dev *input_dev = to_input_dev(dev); 1723 + 1724 + spin_lock_irq(&input_dev->event_lock); 1725 + 1726 + /* Turn off LEDs and sounds, if any are active. */ 1727 + input_dev_toggle(input_dev, false); 1728 + 1729 + spin_unlock_irq(&input_dev->event_lock); 1695 1730 1696 1731 return 0; 1697 1732 } ··· 1735 1698 static const struct dev_pm_ops input_dev_pm_ops = { 1736 1699 .suspend = input_dev_suspend, 1737 1700 .resume = input_dev_resume, 1738 - .poweroff = input_dev_suspend, 1701 + .freeze = input_dev_freeze, 1702 + .poweroff = input_dev_poweroff, 1739 1703 .restore = input_dev_resume, 1740 1704 }; 1741 1705 #endif /* CONFIG_PM */ ··· 1745 1707 .groups = input_dev_attr_groups, 1746 1708 .release = input_dev_release, 1747 1709 .uevent = input_dev_uevent, 1748 - #ifdef CONFIG_PM 1710 + #ifdef CONFIG_PM_SLEEP 1749 1711 .pm = &input_dev_pm_ops, 1750 1712 #endif 1751 1713 };