Subject: linux-next: manual merge of the drivers-x86 tree with Linus' tree

From: Stephen Rothwell <[email-masked]>
Date: Thu, 8 Feb 2024 12:57:44 +1100

Hi all,

Today's linux-next merge of the drivers-x86 tree got a conflict in:

  drivers/platform/x86/wmi.c

between commit:

  3ea7f59af8ff ("platform/x86: wmi: Decouple legacy WMI notify handlers from wmi_block_list")

from Linus' tree and commit:

  10fdfd13a359 ("platform: x86: wmi: make wmi_bus_type const")

from the drivers-x86 tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/platform/x86/wmi.c
index 3c288e8f404b,5682c7de0394..000000000000
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@@ -221,18 -219,7 +221,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)
  {
@@@ -1233,20 -1179,30 +1233,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;
  }