From patchwork Fri May 12 14:02:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 681245 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 DCBAEC77B7C for ; Fri, 12 May 2023 14:03:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241448AbjELODe (ORCPT ); Fri, 12 May 2023 10:03:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241398AbjELODQ (ORCPT ); Fri, 12 May 2023 10:03:16 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B45F10DD for ; Fri, 12 May 2023 07:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683900194; x=1715436194; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZUbSep0pdTiKrpeVtzP63h/qO8K83Xh8tZa8dvUFxTw=; b=NKIE0sB/yI5mvfJ+5twBJMjyNIjZKwKZO9duqqD1YrIq3obG5U181PHj mX58RJib9A1E/3hwR3mePyqUbxTm0sx+X7DKUn4isUiktrNp27eEpW5dO 6t54LAMwmby2wTQaMdfytKVd+wyvgfaNNq7O2FIVBuiSQN6JOFb4cGK7n 8EBVGt5mV/8AWQTQSMoUrQzNpjbCv7gNPFznbnG9EhjhFi5u9UyBdflnc tyCCIk7kOLRzAa/yBt6avM3OTzfV4LXVvgL0rOZtYThtOmeKl7yJYoiHL lR54Fc9f5kLed+hkwPTWiPVzvya00ZjnQgfVt1cYfp3I3bsWj+xR9SA/t g==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="378931104" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="378931104" 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:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="650648966" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="650648966" 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:13 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, Michal Wilczynski Subject: [PATCH v1 15/34] platform/x86/acer-wireless: Move handler installing logic to driver Date: Fri, 12 May 2023 16:02:03 +0200 Message-Id: <20230512140222.124868-16-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/acer-wireless.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/acer-wireless.c b/drivers/platform/x86/acer-wireless.c index 1b5d935d085a..275215fd18c2 100644 --- a/drivers/platform/x86/acer-wireless.c +++ b/drivers/platform/x86/acer-wireless.c @@ -18,9 +18,12 @@ static const struct acpi_device_id acer_wireless_acpi_ids[] = { }; MODULE_DEVICE_TABLE(acpi, acer_wireless_acpi_ids); -static void acer_wireless_notify(struct acpi_device *adev, u32 event) +static void acer_wireless_notify(acpi_handle handle, u32 event, void *data) { - struct input_dev *idev = acpi_driver_data(adev); + struct acpi_device *adev = data; + struct input_dev *idev; + + idev = acpi_driver_data(adev); dev_dbg(&adev->dev, "event=%#x\n", event); if (event != 0x80) { @@ -36,6 +39,7 @@ static void acer_wireless_notify(struct acpi_device *adev, u32 event) static int acer_wireless_add(struct acpi_device *adev) { struct input_dev *idev; + int ret; idev = devm_input_allocate_device(&adev->dev); if (!idev) @@ -50,7 +54,17 @@ static int acer_wireless_add(struct acpi_device *adev) set_bit(EV_KEY, idev->evbit); set_bit(KEY_RFKILL, idev->keybit); - return input_register_device(idev); + ret = input_register_device(idev); + + if (ret) + return ret; + + return acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY, acer_wireless_notify); +} + +static void acer_wireless_remove(struct acpi_device *adev) +{ + acpi_device_remove_event_handler(device, ACPI_DEVICE_NOTIFY, acer_wireless_notify); } static struct acpi_driver acer_wireless_driver = { @@ -59,7 +73,7 @@ static struct acpi_driver acer_wireless_driver = { .ids = acer_wireless_acpi_ids, .ops = { .add = acer_wireless_add, - .notify = acer_wireless_notify, + .remove = acer_wireless_remove, }, }; module_acpi_driver(acer_wireless_driver);