Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp22037141rwd; Fri, 30 Jun 2023 03:05:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlFTOY51DqEiqG7Z4uvHJ59qdS3ed37HL88HRlF+MD26p2FfYfOzX9evOK+7W3EaXGzs00zY X-Received: by 2002:a05:6a00:1a0b:b0:67a:39c4:5bb5 with SMTP id g11-20020a056a001a0b00b0067a39c45bb5mr1947031pfv.6.1688119532508; Fri, 30 Jun 2023 03:05:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688119532; cv=none; d=google.com; s=arc-20160816; b=EJc3qJWWEOmax5HO9tenCcDjtUWiXHciA53heyEtJKg6UXe1fZ2AuUwjEaClcEx/MF v6nAuHSZd4mj4FpGP1jgEYrIa+NX57uaS4HTWJ6v2zrKiNttAE8ahyFp1c2wF6aE2vyX wEve7IvOvTLgwq1g4Egg0zaYRPfb3vXlo/WENG0jPP7A2di7SXHKODhRxDcEQI223cbx bype1TjKb9MUjSkxZLVIGt88OnSCqui9R03nB0uqT9EmqEQIB3GABqElDChF7kiI2NZY 9eoVMTXvD1X1dKUNxX4IN4J+CfF7wGe8NhvE3nKFUCbAk3etG9AQvzh8wVN9ydx2S0oA h5lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=U6trf1IpdWo+oFOkRZbf5EIMT1zVHf/i0IGoLpppLwA=; fh=IH5VwK8py+zARKb2mEzZVRjL3isAd365Hq1/XMOa0Oo=; b=PWCxA4k7Z70GoVaQqDQTAFraY/wOo6d5GzLSfXE9PGcYZqg8CAi0JBjs8QgjuBeRNW mNzYtlYObo9G61fdaBouGspXOcO8JuS+6kYTL5kaoELVfCroQqKC8sn8bbIZ99WUXxZC hF3stOLibsOnc9k2LQkVP2a7B4oKECgpmdp0L5QRWkvS5PmG7NZaol4w+vuOdW1uiOR3 o11xWvE1LhOWLk0tFETIc9utmn35IZMqvclIB0ry74yy1vtX9/E0YIJI5J8DhK7OP0++ DI0Y/KCTUpdFf4pghMztjMCfZ834BuX1U8CS4qYwVLjK2YyITGsrEXUCwOpzSwfpYfcv qw+Q== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cb14-20020a056a00430e00b0067d77ec0d2csi6525547pfb.123.2023.06.30.03.05.19; Fri, 30 Jun 2023 03:05:32 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232896AbjF3Jp5 convert rfc822-to-8bit (ORCPT + 99 others); Fri, 30 Jun 2023 05:45:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232600AbjF3Jpv (ORCPT ); Fri, 30 Jun 2023 05:45:51 -0400 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26885125; Fri, 30 Jun 2023 02:45:50 -0700 (PDT) Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-98273ae42d0so47340866b.0; Fri, 30 Jun 2023 02:45:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688118348; x=1690710348; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2Vw8jMWNOm82RPNOF2hjNaDBARTFH1+TBodiiRe6jac=; b=cn5MmXgIqb8oOCUucgGw6e4/r0D++GguKkhOd1nfoc7Ly4bQVfreIe4l75q58goxGQ fHX7ZtX40rNMKRtmWkaO16apKZ1fiyBh5xTxNcHmkT5V3j5UGcNFcp3+zEk1vaytosXp mk20dj793gjmN2Ddp2A0Pns5IXtelh+SvyEW4C1ntTc/xmTECnh2QwUcslft06LCkVMq pU5Sl04FIMECRODW4JDM4H5kOu736QGAnLoyFIy8ZZC7KLT6QikbsKHtGA3SBNgLIS7W akmm2LrgMvNxlLvMqmxIsQQLXaC1sTNzgb/MyAb+vvNlOEcgdEkMmTQMK3gKFMt6/bxc ucTA== X-Gm-Message-State: ABy/qLbpHai/SqIHe45vO4FeFm84AG9AgP5ExYfXSEB6mzdNqrAKUI/E c6s1sqCELF6yCIxd+j5uKm3Po1bV+eCYR5e6Mw0= X-Received: by 2002:a17:906:199b:b0:976:50a4:ac40 with SMTP id g27-20020a170906199b00b0097650a4ac40mr1491509ejd.0.1688118348393; Fri, 30 Jun 2023 02:45:48 -0700 (PDT) MIME-Version: 1.0 References: <20230616165034.3630141-1-michal.wilczynski@intel.com> <20230616165034.3630141-4-michal.wilczynski@intel.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Fri, 30 Jun 2023 11:45:37 +0200 Message-ID: Subject: Re: [PATCH v5 03/10] acpi/ac: Move handler installing logic to driver To: "Wilczynski, Michal" Cc: "Rafael J. Wysocki" , linux-acpi@vger.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, "Rafael J . Wysocki" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 On Fri, Jun 30, 2023 at 11:41 AM Rafael J. Wysocki wrote: > > On Fri, Jun 30, 2023 at 11:39 AM Wilczynski, Michal > wrote: > > > > > > > > On 6/29/2023 5:55 PM, Rafael J. Wysocki wrote: > > > On Fri, Jun 16, 2023 at 6:51 PM Michal Wilczynski > > > wrote: > > >> 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_install_notify_handler(). Remove .notify > > >> callback initialization in acpi_driver. > > >> > > >> Suggested-by: Rafael J. Wysocki > > >> Signed-off-by: Michal Wilczynski > > >> --- > > >> drivers/acpi/ac.c | 33 ++++++++++++++++++++++++--------- > > >> 1 file changed, 24 insertions(+), 9 deletions(-) > > >> > > >> diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c > > >> index 1ace70b831cd..207ee3c85bad 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,9 +126,12 @@ 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_ac *ac = acpi_driver_data(device); > > > This line doesn't need to be changed. Just add the device variable > > > definition above it. > > > > > > And the same pattern is present in the other patches in the series. > > > > I like the Reverse Christmas Tree, but sure will change that > > I do too, but in the cases when it costs 3 extra lines of code I'd > rather have something simpler. Besides, moving code around is not strictly related to the functional changes made by the patch and it kind of hides those changes. It is better to move code around in a separate patch if you really want to do that.