summaryrefslogtreecommitdiff
path: root/drivers/acpi/button.c
AgeCommit message (Collapse)Author
2026-06-02ACPI: button: Switch over to devres-based resource managementRafael J. Wysocki
Switch over the ACPI button driver to devres-based resource management by making the following changes: * Use devm_kzalloc() for allocating button object memory. * Use devm_input_allocate_device() for allocating the input class device object. * Turn acpi_lid_remove_fs() into a devm cleanup action added by devm_acpi_lid_add_fs() which is a new wrapper around acpi_lid_add_fs(). * Add devm_acpi_button_init_wakeup() for initializing the wakeup source and make it add a custom devm action that will automatically remove the wakeup source registered by it. * Turn acpi_button_remove_event_handler() into a devm cleanup action added by devm_acpi_button_add_event_handler() which is a new wrapper around acpi_button_add_event_handler(). No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/2283436.Mh6RI2rZIc@rafael.j.wysocki [ rjw: Rebased and removed unnecessary input device parent assignment ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2026-06-02ACPI: button: Reorganize installing and removing event handlersRafael J. Wysocki
To facilitate subsequent changes, move the code installing and removing button event handlers into two separate functions called acpi_button_add_event_handler() and acpi_button_remove_event_handler(), respectively, and rearrange it to reduce code duplication. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/2714170.Lt9SDvczpP@rafael.j.wysocki
2026-06-02ACPI: button: Use string literals for generating netlink messagesRafael J. Wysocki
Instead of storing strings that never change later under acpi_device_class(device) and using them for generating netlink messages, use pointers to string literals with the same content. This also allows the clearing of the acpi_device_class(device) area during driver removal and in the probe rollback path to be dropped. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/2070791.usQuhbGJ8B@rafael.j.wysocki
2026-06-02ACPI: button: Clean up adding and removing lid procfs interfaceRafael J. Wysocki
The procfs interface is only used with lid devices which only becomes clear after looking into the function bodies of acpi_button_add_fs() and acpi_button_remove_fs(). Moreover, the only error code returned by the former of these functions is -ENODEV, so the ret local variable in it is redundant, and the return type of the latter one can be changed to void. Accordingly, rename these functions to acpi_button_add_fs() and acpi_button_remove_fs(), respectively, move the button->type checks against ACPI_BUTTON_TYPE_LID from them to their callers, and make code simplifications as per the above. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/1869050.VLH7GnMWUR@rafael.j.wysocki
2026-06-02ACPI: button: Merge two switch () statements in acpi_button_probe()Rafael J. Wysocki
Two switch () statements in acpi_button_probe() operate on the same value and the statements between them can be reordered with respect to the second one, so merge them. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/3352815.5fSG56mABF@rafael.j.wysocki
2026-06-02ACPI: button: Drop redundant variable from acpi_button_probe()Rafael J. Wysocki
Local char pointer called "name" in acpi_button_probe() is redundant because its value can be assigned directly to input->name and the latter can be used in the only other place where "name" is read, so get rid of it. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/3706239.iIbC2pHGDl@rafael.j.wysocki
2026-06-02ACPI: button: Rework device verification during probeRafael J. Wysocki
Instead of manually comparing the primary ID of the device (retuned by _HID) with each of the device IDs supported by the driver, use acpi_match_acpi_device() (which includes the ACPI companion device pointer check against NULL) and store the ACPI button type as driver_data in button_device_ids[], which allows a multi-branch conditional statement to be replaced with a switch () one. However, to continue preventing successful probing of devices that only have one of the supported device IDs in their _CID lists, compare the matched device ID with the primary ID of the device and return an error if they don't match. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/7960518.EvYhyI6sBW@rafael.j.wysocki [ rjw: Fixed button memory leak on probe failure ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2026-06-01ACPI: button: Use local pointer to platform device dev field in probeRafael J. Wysocki
To avoid dereferencing pdev to get to the target platform device's dev field in multiple places in acpi_button_probe(), use a local pointer to that field. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/2049596.PYKUYFuaPT@rafael.j.wysocki
2026-06-01ACPI: button: Eliminate redundant conditional statementRafael J. Wysocki
Simplify do_update initialization in acpi_lid_notify_state() by assigning the value of the condition it depends on directly to it. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/10868292.nUPlyArG6x@rafael.j.wysocki
2026-06-01ACPI: button: Change return type of two functions to voidRafael J. Wysocki
The return value of acpi_lid_notify_state() is always 0, so change its return type to void. Moreover, the return value of the only caller of that function, acpi_lid_update_state(), is never used, so change its return type to void either. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/3429748.44csPzL39Z@rafael.j.wysocki
2026-06-01ACPI: button: Eliminate ternary operator from acpi_lid_evaluate_state()Rafael J. Wysocki
The ternary operator in acpi_lid_evaluate_state() is not actually needed because the same result can be achieved by applying the !! operator to the lid_state value, so update the code accordingly. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/3055906.e9J7NaK4W3@rafael.j.wysocki
2026-06-01ACPI: button: Use bool for representing boolean valuesRafael J. Wysocki
Change the data type of the last_state field in struct acpi_button and the data type of the acpi_lid_notify_state() second argument to bool because they both are used for storing boolean values. Update the callers of acpi_lid_notify_state() accordingly and while at it, remove the unnecessary (void) cast from the acpi_lid_update_state() call in acpi_lid_initialize_state() for consistency. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/2274778.irdbgypaU6@rafael.j.wysocki
2026-06-01ACPI: button: Improve warning message regarding lid stateRafael J. Wysocki
The warning message regarding an unexpected lid state printed by acpi_lid_notify_state() is quite cryptic and there is no information in it to indicate that it is about a platform firmware defect. In fact, it can only be understood after reading the comment below the statement printing it. For this reason, replace it with a more direct one including FW_BUG so its connection to a firmware issue is clearer. While at it, fix up a comment preceding the statement printing the message in question. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/5084775.GXAFRqVoOG@rafael.j.wysocki
2026-06-01ACPI: button: Pass ACPI handle to acpi_lid_evaluate_state()Rafael J. Wysocki
Make it clear that acpi_lid_evaluate_state() only uses the ACPI handle of the lid by changing its argument to acpi_handle and adjust its callers accordingly. Also save the ACPI handle of the lid, that later may be passed to acpi_lid_evaluate_state(), in a static variable instead of saving a pointer to the ACPI device object containing that handle. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/4747530.LvFx2qVVIh@rafael.j.wysocki
2026-06-01ACPI: button: Fix lid_device value leak past driver removalRafael J. Wysocki
Static variable lid_device is set when the ACPI button driver probes the last lid device (under the assumptions that there will be only one lid device in the system) and never cleared, but in principle it should be reset when the driver unbinds from the lid device pointed to by it. Address that and add locking that is needed to clear and set that variable safely. Fixes: 7e12715ecc47 ("ACPI button: provide lid status functions") Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/6281379.lOV4Wx5bFT@rafael.j.wysocki
2026-05-25ACPI: button: Add missing device class clearing on probe failuresRafael J. Wysocki
Commit e18947038bf4 ("ACPI: driver: Do not set acpi_device_class() unnecessarily") modified acpi_button_remove() to clear the device class field in struct acpi_device on driver removal, but it should also have updated the rollback path in acpi_button_probe(), which it didn't do, so do it now. Fixes: e18947038bf4 ("ACPI: driver: Do not set acpi_device_class() unnecessarily") Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org> Link: https://patch.msgid.link/6167713.MhkbZ0Pkbq@rafael.j.wysocki
2026-05-25ACPI: button: Enable wakeup GPEs for ACPI buttons at probe timeRafael J. Wysocki
Prior to commit 57c31e6d620f ("ACPI: scan: Use acpi_setup_gpe_for_wake() for buttons"), ACPI button wakeup GPEs having handler methods remained enabled after acpi_wakeup_gpe_init(), but currently they are not enabled because acpi_setup_gpe_for_wake() disables them. That causes function keys to stop working on some systems [1] and there may be other related issues elsewhere. To address that, make the ACPI button driver enable wakeup GPEs for ACPI buttons so long as they have handler methods. While this does not restore the old behavior exactly (the ACPI button driver needs to be bound to the button devices for the GPEs to be enabled), it should be sufficient to restore the missing functionality. For this purpose, introduce acpi_enable_gpe_cond() that enables a GPE if its dispatch type matches the supplied one and modify acpi_button_probe() to use that function for enabling the GPEs in question. Fixes: 57c31e6d620f ("ACPI: scan: Use acpi_setup_gpe_for_wake() for buttons") Reported-by: Nick <nick@kousu.ca> Closes: https://lore.kernel.org/linux-acpi/E2OXET.4X5GTP37VTNC3@kousu.ca/ [1] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Tested-by: Nick <nick@kousu.ca> Cc: 7.0+ <stable@vger.kernel.org> # 7.0+ Link: https://patch.msgid.link/9629117.CDJkKcVGEf@rafael.j.wysocki
2026-05-25ACPI: button: Fix ACPI GPE handler leak during removalRafael J. Wysocki
Commit a7e23ec17fee ("ACPI: button: Install notifier for system events as well") changed the ACPI notify handler type for ACPI buttons to ACPI_ALL_NOTIFY, but it forgot to update acpi_button_remove() to reflect that change. This leads to leaking the notify handler past driver removal, which may cause a kernel crash to occur if ACPI notify on the given device is triggered after removing the driver, and causes a subsequent probe of the given device with the same driver to fail. Address this by updating the acpi_remove_notify_handler() call in acpi_button_remove() as appropriate. Fixes: a7e23ec17fee ("ACPI: button: Install notifier for system events as well") Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org> Cc: 6.15+ <stable@vger.kernel.org> # 6.15+ Link: https://patch.msgid.link/7954431.EvYhyI6sBW@rafael.j.wysocki
2026-05-11ACPI: driver: Check ACPI_COMPANION() against NULL during probeRafael J. Wysocki
Since every platform driver can be forced to match a device that doesn't match its list of device IDs because of device_match_driver_override(), platform drivers that rely on the existence of a device's ACPI companion object should verify its presence. Accordingly, add requisite ACPI_COMPANION() or ACPI_HANDLE() checks against NULL to 13 platform drivers handling core ACPI devices. Also change the value returned by the ACPI thermal zone driver when the device's ACPI companion is not present to -ENODEV for consistency with the other drivers. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/4516068.ejJDZkT8p0@rafael.j.wysocki Cc: 7.0+ <stable@vger.kernel.org> # 7.0+
2026-03-13ACPI: driver: Do not set acpi_device_class() unnecessarilyRafael J. Wysocki
Several core ACPI device drivers set acpi_device_class() for the given struct acpi_device to whatever they like, but that value is never used unless the driver itself uses it and, sadly, they neglect to clear it on remove. Since the only one of them still using acpi_device_class() after previous changes is the button driver, update the others to stop setting it in vain. Also drop the related device class sybmols that become redundant. Since the ACPI button driver continues to use acpi_device_class(), make it clear the struct field represented by acpi_device_class() in its remove callback. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/3706295.iIbC2pHGDl@rafael.j.wysocki
2026-03-13ACPI: driver: Avoid using pnp.device_class for netlink handlingRafael J. Wysocki
Update several core ACPI device drivers that use acpi_bus_generate_netlink_event() for generating netlink messages to pass a string literal as its first argument instead of a pointer to pnp.device_class in a given struct acpi_device, which will allow them to avoid initializing the pnp.device_class field in the future. The ACPI button driver that uses different acpi_device_class() values for different button types will still pass it to acpi_bus_generate_netlink_event(), but update it to use the acpi_device_class() macro instead of open coding the pointer access path. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/7944022.EvYhyI6sBW@rafael.j.wysocki
2026-03-13ACPI: driver: Do not set acpi_device_name() unnecessarilyRafael J. Wysocki
ACPI drivers usually set acpi_device_name() for the given struct acpi_device to whatever they like, but that value is never used unless the driver itself uses it and, quite unfortunately, drivers neglect to clear it on remove. Some drivers use it for printing messages or initializing the names of subordinate devices, but it is better to use string literals for that, especially if the given one is used just once. To eliminate unnecessary overhead related to acpi_device_name() handling, rework multiple core ACPI device drivers to stop setting acpi_device_name() for struct acpi_device objects manipulated by them and use a string literal instead of it where applicable. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/10840483.nUPlyArG6x@rafael.j.wysocki
2026-02-21Convert 'alloc_obj' family to use the new default GFP_KERNEL argumentLinus Torvalds
This was done entirely with mindless brute force, using git grep -l '\<k[vmz]*alloc_objs*(.*, GFP_KERNEL)' | xargs sed -i 's/\(alloc_objs*(.*\), GFP_KERNEL)/\1)/' to convert the new alloc_obj() users that had a simple GFP_KERNEL argument to just drop that argument. Note that due to the extreme simplicity of the scripting, any slightly more complex cases spread over multiple lines would not be triggered: they definitely exist, but this covers the vast bulk of the cases, and the resulting diff is also then easier to check automatically. For the same reason the 'flex' versions will be done as a separate conversion. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2026-02-21treewide: Replace kmalloc with kmalloc_obj for non-scalar typesKees Cook
This is the result of running the Coccinelle script from scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to avoid scalar types (which need careful case-by-case checking), and instead replace kmalloc-family calls that allocate struct or union object instances: Single allocations: kmalloc(sizeof(TYPE), ...) are replaced with: kmalloc_obj(TYPE, ...) Array allocations: kmalloc_array(COUNT, sizeof(TYPE), ...) are replaced with: kmalloc_objs(TYPE, COUNT, ...) Flex array allocations: kmalloc(struct_size(PTR, FAM, COUNT), ...) are replaced with: kmalloc_flex(*PTR, FAM, COUNT, ...) (where TYPE may also be *VAR) The resulting allocations no longer return "void *", instead returning "TYPE *". Signed-off-by: Kees Cook <kees@kernel.org>
2026-02-13ACPI: button: Tweak acpi_button_remove()Rafael J. Wysocki
Modify acpi_button_remove() to get the ACPI device object pointer from button->adev instead of retrieving it with the help of the ACPI_COMPANION() macro to reduce overhead slightly. While at it, rename the struct acpi_device pointer variable in acpi_button_remove() to adev. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/13948466.uLZWGnKmhe@rafael.j.wysocki
2026-02-13ACPI: button: Tweak system wakeup handlingRafael J. Wysocki
Modify struct acpi_button to hold a struct device pointer instead of a struct platform_device one to avoid unnecessary pointer dereferences and use that pointer consistently for system wakeup initialization, handling and cleanup. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/1948258.tdWV9SEqCh@rafael.j.wysocki
2026-02-11ACPI: button: Call device_init_wakeup() earlier during probeRafael J. Wysocki
Calling device_init_wakeup() after installing a notify handler in which wakeup events are signaled may cause a wakeup event to be missed if the device is probed right before a system suspend. To avoid this, move the device_init_wakeup() call in acpi_button_probe() before the notify handler installation and add a corresponding cleanup to the error path. Also carry out wakeup cleanup for the button in acpi_button_remove() because after that point the notify handler will not run for it and wakeup events coming from it will not be signaled. Fixes: 0d51157dfaac ("ACPI: button: Eliminate the driver notify callback") Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/12854922.O9o76ZdvQC@rafael.j.wysocki
2025-12-26ACPI: button: Convert the driver to a platform oneRafael J. Wysocki
While binding drivers directly to struct acpi_device objects allows basic functionality to be provided, at least in the majority of cases, there are some problems with it, related to general consistency, sysfs layout, power management operation ordering, and code cleanliness. Overall, it is better to bind drivers to platform devices than to their ACPI companions, so convert the ACPI button driver to a platform one. While this is not expected to alter functionality, it changes sysfs layout and so it will be visible to user space. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/2461734.NG923GbCHz@rafael.j.wysocki
2025-12-26ACPI: button: Adjust event notification routinesRafael J. Wysocki
Adjust the event notification routines in the ACPI button driver to take a struct acpi_button pointer as an argument istead of a struct acpi_device one where applicable, which allows the use of acpi_driver_data() to be limited and will facilitate subsequent changes. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://patch.msgid.link/2260995.Icojqenx9y@rafael.j.wysocki
2025-10-22ACPI: button: Call input_free_device() on failing input device registrationKaushlendra Kumar
Make acpi_button_add() call input_free_device() when input_register_device() fails as required according to the documentation of the latter. Fixes: 0d51157dfaac ("ACPI: button: Eliminate the driver notify callback") Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com> Cc: 6.5+ <stable@vger.kernel.org> # 6.5+ [ rjw: Subject and changelog rewrite, Fixes: tag ] Link: https://patch.msgid.link/20251006084706.971855-1-kaushlendra.kumar@intel.com Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2025-04-07ACPI: button: Only send `KEY_POWER` for `ACPI_BUTTON_NOTIFY_STATUS`Mario Limonciello
Commit a7e23ec17feec ("ACPI: button: Install notifier for system events as well") modified the ACPI button behavior to send `ACPI_BUTTON_NOTIFY_WAKE` events. This caused a regression on Dell Optiplex 3040 sending `KEY_POWER` randomly at runtime. Adjust logic so that the `ACPI_BUTTON_NOTIFY_WAKE` event will never send `KEY_POWER`. Fixes: a7e23ec17feec ("ACPI: button: Install notifier for system events as well") Reported-by: Ian Laurie <nixuser@mail.com> Closes: https://lore.kernel.org/linux-acpi/CAJZ5v0hbA6bqxHupTh4NZR-GVSb9M5RL7JSb2yQgvYYJg+z2aQ@mail.gmail.com/T/#md8071e480212201f23e4929607386750d3b6bc13 Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2357044 Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Tested-by: Ian Laurie <nixuser@mail.com> Link: https://patch.msgid.link/20250404145034.2608574-1-superm1@kernel.org [ rjw: Changelog edits ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2025-03-11ACPI: button: Install notifier for system events as wellMario Limonciello
On some systems when the system is put to sleep pressing the ACPI power button will cause the EC SCI to try to wake the system by a Notify(DEV, 0x2) with an intention to wake the system up from suspend. This behavior matches the ACPI specification in ACPI 6.4 section 4.8.3.1.1.2 which describes that the AML handler would generate a Notify() with a code of 0x2 to indicate it was responsible for waking the system. This currently doesn't work because acpi_button_add() only configured `ACPI_DEVICE_NOTIFY` which means that device handler notifications 0x80 through 0xFF are handled. To fix the wakeups on such systems, adjust the ACPI button handler to use `ACPI_ALL_NOTIFY` which will handle all events 0x00 through 0x7F. Reported-by: Yijun Shen <Yijun.Shen@dell.com> Tested-by: Richard Gong <Richard.Gong@amd.com> Link: https://uefi.org/htmlspecs/ACPI_Spec_6_4_html/04_ACPI_Hardware_Specification/ACPI_Hardware_Specification.html?highlight=0x2#control-method-power-button Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Tested-by: Yijun Shen <Yijun_Shen@Dell.com> Link: https://patch.msgid.link/20250303212719.4153485-1-superm1@kernel.org [ rjw: Removed uneeded semicolon ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2024-10-21ACPI: button: Add DMI quirk for Samsung Galaxy Book2 to fix initial lid ↵Shubham Panwar
detection issue Add a DMI quirk for Samsung Galaxy Book2 to fix an initial lid state detection issue. The _LID device incorrectly returns the lid status as "closed" during boot, causing the system to enter a suspend loop right after booting. The quirk ensures that the correct lid state is reported initially, preventing the system from immediately suspending after startup. It only addresses the initial lid state detection and ensures proper system behavior upon boot. Signed-off-by: Shubham Panwar <shubiisp8@gmail.com> Link: https://patch.msgid.link/20241020095045.6036-2-shubiisp8@gmail.com [ rjw: Changelog edits ] Cc: All applicable <stable@vger.kernel.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2024-09-03ACPI: button: Use strscpy() instead of strcpy()Muhammad Qasim Abdul Majeed
Replace strcpy() with strscpy() in the ACPI button driver. strcpy() has been deprecated because it is generally unsafe, so help to eliminate it from the kernel source. Link: https://github.com/KSPP/linux/issues/88 Signed-off-by: Muhammad Qasim Abdul Majeed <qasim.majeed20@gmail.com> Link: https://patch.msgid.link/20240901191826.421488-1-qasim.majeed20@gmail.com [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-12-29ACPI: button: trigger wakeup key eventsKen Xue
Andorid can wakeup from various wakeup sources, but only several wakeup sources can wake up screen with right events(POWER, WAKEUP) from input device. Regarding pressing acpi power button, it can resume system and ACPI_BITMASK_WAKE_STATUS and ACPI_BITMASK_POWER_BUTTON_STATUS are set in pm1a_sts, but kernel does not report any key event to user space during resuming by default. So, send wakeup key event to user space during resume from power button. Signed-off-by: Ken Xue <Ken.Xue@amd.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> [ rjw: Subject edits ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-06-26Merge branches 'acpi-thermal' and 'acpi-button'Rafael J. Wysocki
Merge ACPI thermal driver cleanups and ACPI button drivers rework for 6.5-rc1: - Clean up the ACPI thermal driver and drop some dead or otherwise unneded code from it (Rafael Wysocki). - Rework the handling of notifications in the ACPI button drivers so as to allow the common notification handling code for devices to be simplified (Rafael Wysocki). * acpi-thermal: ACPI: thermal: Drop struct acpi_thermal_flags ACPI: thermal: Drop struct acpi_thermal_state ACPI: thermal: Eliminate struct acpi_thermal_state_flags ACPI: thermal: Move acpi_thermal_driver definition ACPI: thermal: Move symbol definitions to one place ACPI: thermal: Drop redundant ACPI_TRIPS_REFRESH_DEVICES symbol ACPI: thermal: Use BIT() macro for defining flags * acpi-button: ACPI: bus: Simplify installation and removal of notify callback ACPI: tiny-power-button: Eliminate the driver notify callback ACPI: button: Use different notify handlers for lid and buttons ACPI: button: Eliminate the driver notify callback
2023-06-16ACPI: button: Use different notify handlers for lid and buttonsRafael J. Wysocki
Since the lid handling in acpi_button_notify() is special, introduce acpi_lid_notify() specifically for handling lid notifications. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-06-16ACPI: button: Eliminate the driver notify callbackRafael J. Wysocki
Rework the ACPI button driver to install notify handlers or fixed event handlers for the devices it binds to by itself, reduce the indentation level in its notify handler routine and drop its notify callback. This will allow acpi_device_install_notify_handler() and acpi_device_remove_notify_handler() to be simplified going forward and it will allow the driver to use different notify handlers for the lid and for the power and sleep buttons. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Michal Wilczynski <michal.wilczynski@intel.com>
2023-05-17ACPI: button: Add lid disable DMI quirk for Nextbook Ares 8AHans de Goede
The LID0 device on the Nextbook Ares 8A tablet always reports lid closed causing userspace to suspend the device as soon as booting is complete. Add a DMI quirk to disable the broken lid functionality. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-11-23ACPI: make remove callback of ACPI driver voidDawei Li
For bus-based driver, device removal is implemented as: 1 device_remove()-> 2 bus->remove()-> 3 driver->remove() Driver core needs no inform from callee(bus driver) about the result of remove callback. In that case, commit fc7a6209d571 ("bus: Make remove callback return void") forces bus_type::remove be void-returned. Now we have the situation that both 1 & 2 of calling chain are void-returned, so it does not make much sense for 3(driver->remove) to return non-void to its caller. So the basic idea behind this change is making remove() callback of any bus-based driver to be void-returned. This change, for itself, is for device drivers based on acpi-bus. Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Lee Jones <lee@kernel.org> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Dawei Li <set_pte_at@outlook.com> Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com> # for drivers/platform/surface/* Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2021-08-25ACPI: button: Add DMI quirk for Lenovo Yoga 9 (14INTL5)Ulrich Huber
The Lenovo Yoga 9 (14INTL5)'s ACPI _LID is bugged: After hibernation the lid is initially reported as closed. Once closing and then reopening the lid reports the lid as open again. This leads to the conclusion that the initial notification of the lid is missing but subsequent notifications are correct. In order fo the Linux LID code to handle this device properly the lid_init_state must be set to ACPI_BUTTON_LID_INIT_OPEN. Signed-off-by: Ulrich Huber <ulrich@huberulrich.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2021-04-08ACPI: button: fix some coding style issuesXiaofei Tan
Fix some coding style issues reported by checkpatch.pl, including the following types: WARNING: Block comments use * on subsequent lines WARNING: Block comments use a trailing */ on a separate line ERROR: code indent should use tabs where possible Signed-off-by: Xiaofei Tan <tanxiaofei@huawei.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2021-02-04ACPI: button: Clean up printing messagesRafael J. Wysocki
Replace the ACPI_DEBUG_PRINT() instance in button.c with an acpi_handle_debug() call, drop the _COMPONENT and ACPI_MODULE_NAME() definitions that are not used any more, drop the no longer needed ACPI_BUTTON_COMPONENT definition from the headers and update the documentation accordingly. While at it, replace the direct printk() invocations with pr_info() (that changes the excessive log level for some of them too) and drop the unneeded PREFIX sybmbol definition from battery.c. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Hanjun Guo <guohanjun@huawei.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2020-11-09ACPI: button: Add DMI quirk for Medion Akoya E2228THans de Goede
The Medion Akoya E2228T's ACPI _LID implementation is quite broken, it has the same issues as the one from the Medion Akoya E2215T: 1. For notifications it uses an ActiveLow Edge GpioInt, rather then an ActiveBoth one, meaning that the device is only notified when the lid is closed, not when it is opened. 2. Matching with this its _LID method simply always returns 0 (closed) In order for the Linux LID code to work properly with this implementation, the lid_init_state selection needs to be set to ACPI_BUTTON_LID_INIT_OPEN, add a DMI quirk for this. While working on this I also found out that the MD60### part of the model number differs per country/batch while all of the E2215T and E2228T models have this issue, so also remove the " MD60198" part from the E2215T quirk. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2020-10-28ACPI: button: Drop no longer necessary Acer SW5-012 lid_init_state quirkHans de Goede
Commit 78a5b53e9fb4 ("Input: soc_button_array - work around DSDTs which modify the irqflags") adds a workaround for DSDTs with a _LID method which play tricks with the irqflags, assuming that the OS is using an irq-type of IRQ_TYPE_LEVEL_LOW. Now that this workaround is in place, we no longer need to disable the lid functionality on the Acer SW5-012. Fixes: 78a5b53e9fb4 ("Input: soc_button_array - work around DSDTs which modify the irqflags") Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2020-10-05ACPI: button: fix handling lid state changes when input device closeddmitry.torokhov@gmail.com
The original intent of 84d3f6b76447 was to delay evaluating lid state until all drivers have been loaded, with input device being opened from userspace serving as a signal for this condition. Let's ensure that state updates happen even if userspace closed (or in the future inhibited) input device. Note that if we go through suspend/resume cycle we assume the system has been fully initialized even if LID input device has not been opened yet. This has a side-effect of fixing access to input->users outside of input->mutex protections by the way of eliminating said accesses and using driver private flag. Fixes: 84d3f6b76447 ("ACPI / button: Delay acpi_lid_initialize_state() until first user space open") Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Cc: 4.15+ <stable@vger.kernel.org> # 4.15+ Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2020-07-09ACPI: Use fallthrough pseudo-keywordGustavo A. R. Silva
Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through # [1] Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2020-05-14ACPI: Delete unused proc filename macrosPascal Terjan
Those were used to create files in /proc/acpi long ago and were missed when that code was deleted. Signed-off-by: Pascal Terjan <pterjan@google.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2020-04-20ACPI: button: Drop no longer necessary Asus T200TA lid_init_state quirkHans de Goede
Commit 17e5888e4e18 ("x86: Select HARDIRQS_SW_RESEND on x86") fixes the edge-triggered embedded-controller (WC) IRQ not being replayed after resume when woken by opening the lid, which gets signaled by the EC. This means that the lid_init_state=ACPI_BUTTON_LID_INIT_OPEN quirk for the Asus T200TA is no longer necessary, the lid now works properly without it, so drop the quirk. Fixes: 17e5888e4e18 ("x86: Select HARDIRQS_SW_RESEND on x86") Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2020-02-13ACPI: button: move HIDs to acpi/button.hJosh Triplett
This makes it possible to use ACPI_BUTTON_HID_POWER in another driver. Signed-off-by: Josh Triplett <josh@joshtriplett.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>