From patchwork Tue Dec 1 01:06:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Lutomirski X-Patchwork-Id: 7731611 Return-Path: X-Original-To: patchwork-platform-driver-x86@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 911079F54F for ; Tue, 1 Dec 2015 01:06:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B339220641 for ; Tue, 1 Dec 2015 01:06:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C655920648 for ; Tue, 1 Dec 2015 01:06:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755385AbbLABG1 (ORCPT ); Mon, 30 Nov 2015 20:06:27 -0500 Received: from mail.kernel.org ([198.145.29.136]:46897 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755373AbbLABG0 (ORCPT ); Mon, 30 Nov 2015 20:06:26 -0500 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 82A0120684; Tue, 1 Dec 2015 01:06:25 +0000 (UTC) Received: from localhost (c-71-202-137-17.hsd1.ca.comcast.net [71.202.137.17]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ABF632066B; Tue, 1 Dec 2015 01:06:24 +0000 (UTC) From: Andy Lutomirski To: Darren Hart Cc: Matthew Garrett , linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org, Mario Limonciello , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Andy Lutomirski Subject: [PATCH 12/14] wmi: Switch from acpi_driver.notify to acpi_install_notify_handler Date: Mon, 30 Nov 2015 17:06:02 -0800 Message-Id: X-Mailer: git-send-email 2.5.0 In-Reply-To: References: In-Reply-To: References: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Arguably wmi should attach to the PNP platform device, not the ACPI device. As a platform driver, acpi_driver.notify won't be available, so stop using it. Signed-off-by: Andy Lutomirski --- drivers/platform/x86/wmi.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 29448289f660..88265b28430c 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -92,7 +92,6 @@ MODULE_PARM_DESC(debug_dump_wdg, static int acpi_wmi_remove(struct acpi_device *device); static int acpi_wmi_add(struct acpi_device *device); -static void acpi_wmi_notify(struct acpi_device *device, u32 event); static const struct acpi_device_id wmi_device_ids[] = { {"PNP0C14", 0}, @@ -108,7 +107,6 @@ static struct acpi_driver acpi_wmi_driver = { .ops = { .add = acpi_wmi_add, .remove = acpi_wmi_remove, - .notify = acpi_wmi_notify, }, }; @@ -1116,7 +1114,8 @@ acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address, } } -static void acpi_wmi_notify(struct acpi_device *device, u32 event) +static void acpi_wmi_notify_handler(acpi_handle handle, u32 event, + void *context) { struct guid_block *block; struct wmi_block *wblock; @@ -1127,7 +1126,7 @@ static void acpi_wmi_notify(struct acpi_device *device, u32 event) wblock = list_entry(p, struct wmi_block, list); block = &wblock->gblock; - if (wblock->acpi_device == device && + if (wblock->acpi_device->handle == handle && (block->flags & ACPI_WMI_EVENT) && (block->notify_id == event)) { @@ -1179,13 +1178,16 @@ static void acpi_wmi_notify(struct acpi_device *device, u32 event) } acpi_bus_generate_netlink_event( - device->pnp.device_class, dev_name(&device->dev), + wblock->acpi_device->pnp.device_class, + dev_name(&wblock->dev.dev), event, 0); } static int acpi_wmi_remove(struct acpi_device *device) { + acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, + acpi_wmi_notify_handler); acpi_remove_address_space_handler(device->handle, ACPI_ADR_SPACE_EC, &acpi_wmi_ec_space_handler); wmi_free_devices(device); @@ -1210,11 +1212,20 @@ static int acpi_wmi_add(struct acpi_device *device) return -ENODEV; } + status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, + acpi_wmi_notify_handler, + NULL); + if (ACPI_FAILURE(status)) { + dev_err(&device->dev, "Error installing notify handler\n"); + error = -ENODEV; + goto err_remove_ec_handler; + } + wmi_bus_dev = device_create(&wmi_bus_class, &device->dev, MKDEV(0, 0), NULL, "wmi_bus-%s", dev_name(&device->dev)); if (IS_ERR(wmi_bus_dev)) { error = PTR_ERR(wmi_bus_dev); - goto err_remove_handler; + goto err_remove_notify_handler; } device->driver_data = wmi_bus_dev; @@ -1230,7 +1241,11 @@ err_remove_busdev: device_unregister(wmi_bus_dev); put_device(wmi_bus_dev); -err_remove_handler: +err_remove_notify_handler: + acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, + acpi_wmi_notify_handler); + +err_remove_ec_handler: acpi_remove_address_space_handler(device->handle, ACPI_ADR_SPACE_EC, &acpi_wmi_ec_space_handler);