From patchwork Sat May 27 05:31:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Darren Hart X-Patchwork-Id: 9751547 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6EDEF60393 for ; Sat, 27 May 2017 05:35:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 602D2283C5 for ; Sat, 27 May 2017 05:35:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 553592846A; Sat, 27 May 2017 05:35:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C377A28408 for ; Sat, 27 May 2017 05:35:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752247AbdE0FcO (ORCPT ); Sat, 27 May 2017 01:32:14 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:59575 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752126AbdE0Fb4 (ORCPT ); Sat, 27 May 2017 01:31:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=l0cvBujPSKeh4FQPZ5sSMfXsJoJ6E+0MxVlblvzKtw4=; b=ltqTlnsnU0mihRvdcPqMBP7b0 BvgeLCs71VenB/wuYrz4MEbeR4RbJsA8yzbAxKZYNI6jwjwb4g3VLZrxWOcko45/UheyUMfSdl2HW 6375c3qKfeJxpXzWcBfFPRXHxQ86frulzZVDC1yENpMRZgKAoAi+tWJSKXwqR/Ja7huXX5YNVt5lF MfZR0HsaVHxOfPdymBz857RGPI+dXMB/KBT+M+cX2/sAQAKH/o/kwSNZtO5Lticbz5UXVOsf0yahV k0v/tkcauM6scd8EHn8Zs5VCsd9oNaOJnUP6Sjvs4DvVSMq8ahD8zxwZjFVN6QVbZDXRYeLnFWYVV 7u20dMXLQ==; Received: from dvhart by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1dEUKS-0000js-0e; Sat, 27 May 2017 05:31:56 +0000 From: Darren Hart To: platform-driver-x86@vger.kernel.org Cc: Andy Shevchenko , Andy Lutomirski , Andy Lutomirski , Mario Limonciello , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Rafael Wysocki , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Darren Hart Subject: [PATCH 12/16] platform/x86: wmi: Bind the platform device, not the ACPI node Date: Fri, 26 May 2017 22:31:26 -0700 Message-Id: X-Mailer: git-send-email 2.9.4 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andy Lutomirski We already have the PNP glue to instantiate platform devices for the ACPI devices that WMI drives. WMI should therefore attach to the platform device, not the ACPI node. Signed-off-by: Andy Lutomirski Cc: Andy Lutomirski Cc: Mario Limonciello Cc: Pali Rohár Cc: Rafael Wysocki Cc: linux-kernel@vger.kernel.org Cc: platform-driver-x86@vger.kernel.org Cc: linux-acpi@vger.kernel.org Signed-off-by: Darren Hart (VMware) --- drivers/platform/x86/wmi.c | 57 +++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 483e4a6..f1c9464 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -91,8 +92,8 @@ module_param(debug_dump_wdg, bool, 0444); MODULE_PARM_DESC(debug_dump_wdg, "Dump available WMI interfaces [0/1]"); -static int acpi_wmi_remove(struct acpi_device *device); -static int acpi_wmi_add(struct acpi_device *device); +static int acpi_wmi_remove(struct platform_device *device); +static int acpi_wmi_probe(struct platform_device *device); static const struct acpi_device_id wmi_device_ids[] = { {"PNP0C14", 0}, @@ -101,14 +102,13 @@ static const struct acpi_device_id wmi_device_ids[] = { }; MODULE_DEVICE_TABLE(acpi, wmi_device_ids); -static struct acpi_driver acpi_wmi_driver = { - .name = "acpi-wmi", - .owner = THIS_MODULE, - .ids = wmi_device_ids, - .ops = { - .add = acpi_wmi_add, - .remove = acpi_wmi_remove, +static struct platform_driver acpi_wmi_driver = { + .driver = { + .name = "acpi-wmi", + .acpi_match_table = wmi_device_ids, }, + .probe = acpi_wmi_probe, + .remove = acpi_wmi_remove, }; /* @@ -1113,26 +1113,34 @@ static void acpi_wmi_notify_handler(acpi_handle handle, u32 event, } -static int acpi_wmi_remove(struct acpi_device *device) +static int acpi_wmi_remove(struct platform_device *device) { - acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, + struct acpi_device *acpi_device = ACPI_COMPANION(&device->dev); + + acpi_remove_notify_handler(acpi_device->handle, ACPI_DEVICE_NOTIFY, acpi_wmi_notify_handler); - acpi_remove_address_space_handler(device->handle, + acpi_remove_address_space_handler(acpi_device->handle, ACPI_ADR_SPACE_EC, &acpi_wmi_ec_space_handler); - wmi_free_devices(device); - device_unregister((struct device *)acpi_driver_data(device)); - device->driver_data = NULL; + wmi_free_devices(acpi_device); + device_unregister((struct device *)dev_get_drvdata(&device->dev)); return 0; } -static int acpi_wmi_add(struct acpi_device *device) +static int acpi_wmi_probe(struct platform_device *device) { + struct acpi_device *acpi_device; struct device *wmi_bus_dev; acpi_status status; int error; - status = acpi_install_address_space_handler(device->handle, + acpi_device = ACPI_COMPANION(&device->dev); + if (!acpi_device) { + dev_err(&device->dev, "ACPI companion is missing\n"); + return -ENODEV; + } + + status = acpi_install_address_space_handler(acpi_device->handle, ACPI_ADR_SPACE_EC, &acpi_wmi_ec_space_handler, NULL, NULL); @@ -1141,7 +1149,8 @@ static int acpi_wmi_add(struct acpi_device *device) return -ENODEV; } - status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, + status = acpi_install_notify_handler(acpi_device->handle, + ACPI_DEVICE_NOTIFY, acpi_wmi_notify_handler, NULL); if (ACPI_FAILURE(status)) { @@ -1156,9 +1165,9 @@ static int acpi_wmi_add(struct acpi_device *device) error = PTR_ERR(wmi_bus_dev); goto err_remove_notify_handler; } - device->driver_data = wmi_bus_dev; + dev_set_drvdata(&device->dev, wmi_bus_dev); - error = parse_wdg(wmi_bus_dev, device); + error = parse_wdg(wmi_bus_dev, acpi_device); if (error) { pr_err("Failed to parse WDG method\n"); goto err_remove_busdev; @@ -1170,11 +1179,11 @@ static int acpi_wmi_add(struct acpi_device *device) device_unregister(wmi_bus_dev); err_remove_notify_handler: - acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, + acpi_remove_notify_handler(acpi_device->handle, ACPI_DEVICE_NOTIFY, acpi_wmi_notify_handler); err_remove_ec_handler: - acpi_remove_address_space_handler(device->handle, + acpi_remove_address_space_handler(acpi_device->handle, ACPI_ADR_SPACE_EC, &acpi_wmi_ec_space_handler); @@ -1212,7 +1221,7 @@ static int __init acpi_wmi_init(void) if (error) goto err_unreg_class; - error = acpi_bus_register_driver(&acpi_wmi_driver); + error = platform_driver_register(&acpi_wmi_driver); if (error) { pr_err("Error loading mapper\n"); goto err_unreg_bus; @@ -1231,7 +1240,7 @@ static int __init acpi_wmi_init(void) static void __exit acpi_wmi_exit(void) { - acpi_bus_unregister_driver(&acpi_wmi_driver); + platform_driver_unregister(&acpi_wmi_driver); class_unregister(&wmi_bus_class); bus_unregister(&wmi_bus_type); }