Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp22751657rwd; Fri, 30 Jun 2023 12:05:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlGYj1uhuDdiUyrOf3SJW59LdrFvqVAkWXt9OExL+7UTLCBe+DRcntVOsAHSSzbzpqwl+dL1 X-Received: by 2002:a17:90a:f183:b0:263:3ccc:dfe4 with SMTP id bv3-20020a17090af18300b002633cccdfe4mr2754316pjb.1.1688151950977; Fri, 30 Jun 2023 12:05:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688151950; cv=none; d=google.com; s=arc-20160816; b=TNSfR4ZYAZA18+AZKGnMv+j0uqnaFudfp2CmePuLWlPvC0B1EdzTy1Hq2Bgqgppn72 KO318Bh44OEfUrt0WcjeoHklI3aD5+7DCgscOSIFJXjgRiOUJPNGZHDLrvMiZKZO6QKW JuKIaSFvBA3DkFtyqgssoK7SCaukNgPBAFJQ7H7Zn578src1PEyupNUrauDvpGl2PMFt VyTdj+0yJYC+/BBHEqLU+0MlYsdI7/JergTOqL2L45FnbtBacI8OGkNRo0o0BgqMfG8M 6vW2bxvQsGZq8Te2CRPMaOBQP67ZMTXXLHXcBk/VDJmyn4QlrXwmiYwIDTb93cKD/jcz Fnng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cPkXc5AzlSzfTGYSk+smTQY+J7PpIEgEPnsYg0vPlTw=; fh=BmoNGikZ0c0jFVvZ2YLzmoZUwDhNTkpAEx4ktuFUIgk=; b=eYW/AvsOcnpUbigAFJrSa3hC4elMb4PiUxVroHlILSxAXojyOsFm6BcGlacYhTOcQX 8RYYxdI2sU92P1IMNLSqgXEjw0TUwFNtGOCsaWW5qpZ3b1mJZzvsTVP7uyavOqgtGRvM ADD/6c5W/+JyalmwTjW91SiWjR6xxYuCI1jR+Ugqbl91/hxHkPfWXO+lRUciOS1OOM0H IAnCsWFbiouQyHTEvjDsgbe7S2vkqVIs+NyoYiiXn6kA8iKhEQDUW9KFRfNakEtkHjGu lgtLNGzPOza45Z49uFCjWs7R7j8QHzrx2/xBZReF9ZQN0MBpBffsy7xuOjTXrfreSWZU cuSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=btY7t+oi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e22-20020a63e016000000b005344b60f7ddsi13308686pgh.117.2023.06.30.12.05.33; Fri, 30 Jun 2023 12:05:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=btY7t+oi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233127AbjF3Se3 (ORCPT + 99 others); Fri, 30 Jun 2023 14:34:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233081AbjF3SeV (ORCPT ); Fri, 30 Jun 2023 14:34:21 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A877F4212; Fri, 30 Jun 2023 11:34: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=1688150057; x=1719686057; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+TtSlxKV+HOo4L7ax/yjcsU33lOHTI/V/imUAW6Fx3I=; b=btY7t+oidXlfIlxczpE1qEwEFpZk2St6iKviEeJSX4fBaU78T338H28k q6oNcq4JTOodYoMzd54bNzVUPm45cpM4IhBR9uyMFvreci6NuBAfuFw7z u33aUNpweJB4rNDvDZfsHRFDsHrk65Ff7WyKU8LdbUgtR/00sSTXs9VJ5 kZCNMa6djAtGJWfAalSJqEFgKcBsT+cOp9/8JCWGe5jAldEw40qypFgSq ZVsL8kSCvHjZRq9b8lghwGshBJ5wX7J1DQmnG5/MiJIqqzhCTxbcYdm32 JCGK3CP1KVfs3hfDSF9jr82s9ofLNTmKwMgH3RuX/ki9x6gLjHLkeLtvW Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10757"; a="365949951" X-IronPort-AV: E=Sophos;i="6.01,171,1684825200"; d="scan'208";a="365949951" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2023 11:34:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10757"; a="717896436" X-IronPort-AV: E=Sophos;i="6.01,171,1684825200"; d="scan'208";a="717896436" Received: from powerlab.fi.intel.com ([10.237.71.25]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jun 2023 11:34:13 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org Cc: rafael@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, lenb@kernel.org, dave.jiang@intel.com, ira.weiny@intel.com, rui.zhang@intel.com, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, Michal Wilczynski , "Rafael J . Wysocki" Subject: [PATCH v6 3/9] acpi/ac: Move handler installing logic to driver Date: Fri, 30 Jun 2023 21:33:38 +0300 Message-ID: <20230630183344.891077-4-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230630183344.891077-1-michal.wilczynski@intel.com> References: <20230630183344.891077-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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_dev_install_notify_handler() at the end of .add() callback. Call acpi_dev_remove_notify_handler() at the beginning of .remove() callback. Change arguments passed to the notify function to match with what's required by acpi_dev_install_notify_handler(). Remove .notify callback initialization in acpi_driver. Suggested-by: Rafael J. Wysocki Signed-off-by: Michal Wilczynski --- drivers/acpi/ac.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 1ace70b831cd..f6feff1f3118 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c @@ -34,7 +34,7 @@ MODULE_LICENSE("GPL"); static int acpi_ac_add(struct acpi_device *device); static void acpi_ac_remove(struct acpi_device *device); -static void acpi_ac_notify(struct acpi_device *device, u32 event); +static void acpi_ac_notify(acpi_handle handle, u32 event, void *data); static const struct acpi_device_id ac_device_ids[] = { {"ACPI0003", 0}, @@ -54,11 +54,9 @@ static struct acpi_driver acpi_ac_driver = { .name = "ac", .class = ACPI_AC_CLASS, .ids = ac_device_ids, - .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS, .ops = { .add = acpi_ac_add, .remove = acpi_ac_remove, - .notify = acpi_ac_notify, }, .drv.pm = &acpi_ac_pm, }; @@ -128,8 +126,9 @@ static enum power_supply_property ac_props[] = { }; /* Driver Model */ -static void acpi_ac_notify(struct acpi_device *device, u32 event) +static void acpi_ac_notify(acpi_handle handle, u32 event, void *data) { + struct acpi_device *device = data; struct acpi_ac *ac = acpi_driver_data(device); if (!ac) @@ -235,7 +234,7 @@ static int acpi_ac_add(struct acpi_device *device) result = acpi_ac_get_state(ac); if (result) - goto end; + goto err_release_ac; psy_cfg.drv_data = ac; @@ -248,7 +247,7 @@ static int acpi_ac_add(struct acpi_device *device) &ac->charger_desc, &psy_cfg); if (IS_ERR(ac->charger)) { result = PTR_ERR(ac->charger); - goto end; + goto err_release_ac; } pr_info("%s [%s] (%s)\n", acpi_device_name(device), @@ -256,9 +255,20 @@ static int acpi_ac_add(struct acpi_device *device) ac->battery_nb.notifier_call = acpi_ac_battery_notify; register_acpi_notifier(&ac->battery_nb); -end: + + result = acpi_dev_install_notify_handler(device, + ACPI_ALL_NOTIFY, + acpi_ac_notify); if (result) - kfree(ac); + goto err_unregister; + + return 0; + +err_unregister: + power_supply_unregister(ac->charger); + unregister_acpi_notifier(&ac->battery_nb); +err_release_ac: + kfree(ac); return result; } @@ -297,6 +307,9 @@ static void acpi_ac_remove(struct acpi_device *device) ac = acpi_driver_data(device); + acpi_dev_remove_notify_handler(device, + ACPI_ALL_NOTIFY, + acpi_ac_notify); power_supply_unregister(ac->charger); unregister_acpi_notifier(&ac->battery_nb); -- 2.41.0