From: Ilpo Järvinen Date: Thu, 8 Feb 2024 11:49:31 +0000 (+0200) Subject: Merge tag 'platform-drivers-x86-v6.8-2' into pdx/for-next X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=d16c9a3d97d1905392e4b86ac9e25fa6c2d5faa3;p=linux.git Merge tag 'platform-drivers-x86-v6.8-2' into pdx/for-next Merge tag 'platform-drivers-x86-v6.8-2' fixes into pdf86/for-next because of WMI fixes. The WMI changes done in for-next already created a minor conflict with the fixes and WMI is actively being improved currently so besides resolving the current conflict, this is also to avoid further conflicts. --- d16c9a3d97d1905392e4b86ac9e25fa6c2d5faa3 diff --cc drivers/platform/x86/wmi.c index 57026f91c396b,3c288e8f404be..b83c0f0ddd5cc --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@@ -199,7 -221,18 +201,18 @@@ static int wmidev_match_guid(struct dev return 0; } + static int wmidev_match_notify_id(struct device *dev, const void *data) + { + struct wmi_block *wblock = dev_to_wblock(dev); + const u32 *notify_id = data; + + if (wblock->gblock.flags & ACPI_WMI_EVENT && wblock->gblock.notify_id == *notify_id) + return 1; + + return 0; + } + -static struct bus_type wmi_bus_type; +static const struct bus_type wmi_bus_type; static struct wmi_device *wmi_find_device_by_guid(const char *guid_string) { @@@ -1171,30 -1233,20 +1225,19 @@@ static int wmi_notify_device(struct dev if (!(wblock->gblock.flags & ACPI_WMI_EVENT && wblock->gblock.notify_id == *event)) return 0; - /* If a driver is bound, then notify the driver. */ - if (test_bit(WMI_PROBED, &wblock->flags) && wblock->dev.dev.driver) { - struct wmi_driver *driver = drv_to_wdrv(wblock->dev.dev.driver); - struct acpi_buffer evdata = { ACPI_ALLOCATE_BUFFER, NULL }; - acpi_status status; - - if (!driver->no_notify_data) { - status = get_event_data(wblock, &evdata); - if (ACPI_FAILURE(status)) { - dev_warn(&wblock->dev.dev, "failed to get event data\n"); - return -EIO; - } - } - - if (driver->notify) - driver->notify(&wblock->dev, evdata.pointer); - - kfree(evdata.pointer); - } else if (wblock->handler) { - /* Legacy handler */ - wblock->handler(*event, wblock->handler_data); + down_read(&wblock->notify_lock); + /* The WMI driver notify handler conflicts with the legacy WMI handler. + * Because of this the WMI driver notify handler takes precedence. + */ + if (wblock->dev.dev.driver && wblock->driver_ready) { + wmi_notify_driver(wblock); + } else { + if (wblock->handler) + wblock->handler(*event, wblock->handler_data); } + up_read(&wblock->notify_lock); - acpi_bus_generate_netlink_event(wblock->acpi_device->pnp.device_class, - dev_name(&wblock->dev.dev), *event, 0); + acpi_bus_generate_netlink_event("wmi", acpi_dev_name(wblock->acpi_device), *event, 0); return -EBUSY; }