Unverified Commit 5798b462 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Ilpo Järvinen
Browse files

platform/surface: surfacepro3_button: Check ACPI_COMPANION()



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(), so
platform drivers that rely on the existence of a device's ACPI companion
object need to verify its presence.

Accordingly, add a requisite ACPI_COMPANION() check against NULL to the
surfacepro3_button driver.

Fixes: d913a5a1 ("platform/surface: surfacepro3_button: Convert to a platform driver")
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarChen Yu <yu.c.chen@intel.com>
Link: https://patch.msgid.link/23119222.EfDdHjke4D@rafael.j.wysocki


Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
parent a9f305c5
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -185,12 +185,15 @@ static bool surface_button_check_MSHW0040(struct device *dev, acpi_handle handle

static int surface_button_probe(struct platform_device *pdev)
{
	struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
	struct surface_button *button;
	struct acpi_device *device;
	struct input_dev *input;
	const char *hid = acpi_device_hid(device);
	int error;

	device = ACPI_COMPANION(&pdev->dev);
	if (!device)
		return -ENODEV;

	if (strncmp(acpi_device_bid(device), SURFACE_BUTTON_OBJ_NAME,
	    strlen(SURFACE_BUTTON_OBJ_NAME)))
		return -ENODEV;
@@ -210,7 +213,8 @@ static int surface_button_probe(struct platform_device *pdev)
	}

	strscpy(acpi_device_name(device), SURFACE_BUTTON_DEVICE_NAME);
	snprintf(button->phys, sizeof(button->phys), "%s/buttons", hid);
	snprintf(button->phys, sizeof(button->phys), "%s/buttons",
		 acpi_device_hid(device));

	input->name = acpi_device_name(device);
	input->phys = button->phys;