OSDN Git Service

ACPI / button: Delay acpi_lid_initialize_state() until first user space open
authorHans de Goede <hdegoede@redhat.com>
Mon, 11 Sep 2017 14:07:06 +0000 (16:07 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 8 Nov 2017 23:30:44 +0000 (00:30 +0100)
commit84d3f6b76447896919c63b28ad71f71238cefcce
tree0ee00fa0c6532ba48342e55011e38b972774a79c
parent39dae59d66acd86d1de24294bd2f343fd5e7a625
ACPI / button: Delay acpi_lid_initialize_state() until first user space open

ACPI _LID methods may depend on OpRegions and do not always handle
handlers for those OpRegions not being present properly e.g. :

            Method (_LID, 0, NotSerialized)  // _LID: Lid Status
            {
                If ((^^I2C5.PMI1.AVBL == One) && (^^GPO2.AVBL == One))
                {
                    Return (^^GPO2.LPOL) /* \_SB_.GPO2.LPOL */
                }
            }

Note the missing Return (1) when either of the OpRegions is not available,
this causes (in this case) a report of the lid-switch being closed,
which causes userspace to do an immediate suspend at boot.

This commit delays getting the initial state and thus calling _LID for
the first time until userspace opens the /dev/input/event# node. This
ensures that all drivers will have had a chance to load and registerer
their OpRegions before the first _LID call, fixing this issue.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/button.c