From patchwork Fri May 12 14:02:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681607 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B3BAC7EE2A for ; Fri, 12 May 2023 14:03:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241418AbjELODl (ORCPT ); Fri, 12 May 2023 10:03:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241400AbjELODS (ORCPT ); Fri, 12 May 2023 10:03:18 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 098DDB8 for ; Fri, 12 May 2023 07:03:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900196; x=1715436196; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Y4JSKytL16UQ3yiDlPjXF1qi2MF02RmJQVVc5oDWZQ0=; b=CDxumuqe8C8w96AMcWQEe4WtW6YvZ0mblxZVLIhEwb5lfiG9ysyMJlMY P0JgwL8QbZNFeTqpZDo3xgYzwBJ4OPpaVmgbJIFfPSnWUcROAUFGLwooV xMk7noG9UPCLbuIxrqhrUNC7dMaoxbFthtywh+KbyHnxU7w6l3LzN1Wqp 2FOKhc3cvSef1pT69qobt6SnDhiGpiA/SNmqYYwGpem6InSq9eHZ3NiPL mZfEspxlqymF4U+LaFQ5w0ib4XPQ4YfBbTaTZEdbpAHsIFpYGQwvPsAMQ pllvQ5AhlZ0/8xBoSqISwLaJ/VRr+dUebebPGqRJWkbU67Nc51phVUmAF Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931112" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931112" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648974" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648974" Received: from hextor.igk.intel.com ([10.123.220.6]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 07:03:15 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 17/34] platform/x86/asus-wireless: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:05 +0200 Message-Id: <20230512140222.124868-18-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230512140222.124868-1-michal.wilczynski@intel.com> References: <20230512140222.124868-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Currently logic for installing notifications from ACPI devices is implemented using notify callback in struct acpi_driver. Preparations are being made to replace acpi_driver with more generic struct platform_driver, which doesn't contain notify callback. Furthermore as of now handlers are being called indirectly through acpi_notify_device(), which decreases performance. Call acpi_device_install_event_handler() at the end of .add() callback. Call acpi_device_remove_event_handler() at the beginning of .remove() callback. Change arguments passed to the notify callback to match with what's required by acpi_device_install_event_handler(). Signed-off-by: Michal Wilczynski --- drivers/platform/x86/asus-wireless.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/asus-wireless.c b/drivers/platform/x86/asus-wireless.c index abf01e00b799..6544e3419ae4 100644 --- a/drivers/platform/x86/asus-wireless.c +++ b/drivers/platform/x86/asus-wireless.c @@ -108,19 +108,22 @@ static void led_state_set(struct led_classdev *led, enum led_brightness value) queue_work(data->wq, &data->led_work); } -static void asus_wireless_notify(struct acpi_device *adev, u32 event) +static void asus_wireless_notify(acpi_handle handle, u32 event, void *data) { - struct asus_wireless_data *data = acpi_driver_data(adev); + struct asus_wireless_data *w_data; + struct acpi_device *adev = data; + + w_data = acpi_driver_data(adev); dev_dbg(&adev->dev, "event=%#x\n", event); if (event != 0x88) { dev_notice(&adev->dev, "Unknown ASHS event: %#x\n", event); return; } - input_report_key(data->idev, KEY_RFKILL, 1); - input_sync(data->idev); - input_report_key(data->idev, KEY_RFKILL, 0); - input_sync(data->idev); + input_report_key(w_data->idev, KEY_RFKILL, 1); + input_sync(w_data->idev); + input_report_key(w_data->idev, KEY_RFKILL, 0); + input_sync(w_data->idev); } static int asus_wireless_add(struct acpi_device *adev) @@ -169,16 +172,20 @@ static int asus_wireless_add(struct acpi_device *adev) data->led.max_brightness = 1; data->led.default_trigger = "rfkill-none"; err = devm_led_classdev_register(&adev->dev, &data->led); - if (err) + if (err) { destroy_workqueue(data->wq); + return err; + } - return err; + return acpi_device_install_event_handler(adev, ACPI_DEVICE_NOTIFY, asus_wireless_notify); } static void asus_wireless_remove(struct acpi_device *adev) { struct asus_wireless_data *data = acpi_driver_data(adev); + acpi_device_remove_event_handler(adev, ACPI_DEVICE_NOTIFY, asus_wireless_notify); + if (data->wq) { devm_led_classdev_unregister(&adev->dev, &data->led); destroy_workqueue(data->wq); @@ -192,7 +199,6 @@ static struct acpi_driver asus_wireless_driver = { .ops = { .add = asus_wireless_add, .remove = asus_wireless_remove, - .notify = asus_wireless_notify, }, }; module_acpi_driver(asus_wireless_driver);