Merge tag 'platform-drivers-x86-v6.8-2' into pdx/for-next
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 8 Feb 2024 11:49:31 +0000 (13:49 +0200)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Thu, 8 Feb 2024 11:49:31 +0000 (13:49 +0200)
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.

1  2 
drivers/platform/x86/intel/ifs/load.c
drivers/platform/x86/wmi.c

Simple merge
index 57026f91c396ba4f0ef907d39cb7566f29542e90,3c288e8f404beb5d4887235c85654e9ac77cd425..b83c0f0ddd5cc665e11394175a856b28b7a2c670
@@@ -199,7 -221,18 +201,18 @@@ static int wmidev_match_guid(struct dev
        return 0;
  }
  
 -static struct bus_type wmi_bus_type;
+ 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 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;
  }