Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp604835rdb; Fri, 6 Oct 2023 12:48:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFixdd+rZ2HQ5vrokfRd9WelQhy5YkpbtqEDeugGnDOWoBX5n+MjszCk0Ikpxb99kd0q0SD X-Received: by 2002:a05:6a00:852:b0:68f:efc2:ba3d with SMTP id q18-20020a056a00085200b0068fefc2ba3dmr10835481pfk.33.1696621702452; Fri, 06 Oct 2023 12:48:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696621702; cv=none; d=google.com; s=arc-20160816; b=F3xk71JboBe/PK7IeQNgqwcHVFkFBp0eTf60FYUsov2Vgu7fJnQRFuV0Tn9lk3JFpA nQGpnBkV873D807ECSJWy34x1vNlzHQH+ETGZJVUYACVwiZYCBzFHjtAa/8PXVRAW10H jVV58u00zj23Orxv8B6wq/Vh1RCQzb+EoSZD/yhWIBhvwNPJaUFMLU+3f/KqluY9sVck 1VjRjIMc9TlkAPKlVUb3rTIosApbBeBws2NnG3uPPDZ4VUetzinTLcHKMNWyrLnScoAY dgIalK/OiyIFJQuVWZytEWynrAQioQfUbkvwbRBiERIiQbHyZRiy39hg8lOHXccnLtiw Ynsg== 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=WAKBccjrt+nPSyt2LffrtJd6NKmFVvdOYZWdRmab8/U=; fh=iKus/dN4fxPZZ34u40/JfbXKEI51kyPup8haDVmN4q4=; b=SCRuuYc6sPhbMdj6ovBq05RnRRKO01EKH3ACXlCIwsHTHQ6plsibBgPMfrEr+U+WIS XnjFUHg8XwcsB6KcOKTMTO/nxZswdl4QblD5dqdMIWExlz0CF0sLVnhb75Q77irwYFH2 c3IKIsOudav9LBO2770ZQp/wHSrpTffes+w1nDpiXvBlpnYXYd+sSXk8AAaPyVdjBBmg bVcYAQwztky2IYkQEvJctBGAc1D+pdNSt696oqPRi2Fsjtg9lq7+wklyM46xpxRi/76G jW/lBmTesFRX86HtjKnH772nJM+NWndv80NCMmRPCP77tNjJEN2L6ZFcDDlpHPc4FxZE dsdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id u185-20020a6385c2000000b005775e17f560si4390556pgd.82.2023.10.06.12.48.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 12:48:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 064E88026553; Fri, 6 Oct 2023 12:48:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233271AbjJFTsL convert rfc822-to-8bit (ORCPT + 99 others); Fri, 6 Oct 2023 15:48:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233248AbjJFTsK (ORCPT ); Fri, 6 Oct 2023 15:48:10 -0400 Received: from mail-oo1-f50.google.com (mail-oo1-f50.google.com [209.85.161.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E17683; Fri, 6 Oct 2023 12:48:09 -0700 (PDT) Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-57be74614c0so127028eaf.1; Fri, 06 Oct 2023 12:48:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696621688; x=1697226488; 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=2qtrIYwt5+xezRUeXv6ZO7TiBtw+EXKB+lTOgWGj6zc=; b=geaaONrtbJLwZrZ7CqUjqXeVvokZ9Lb147ZzF8l33U8qYe1VKrsxhWctoWzXCHxN9m gMonZiHeVkibn47+opHE2p2+8HAdrissYXJjWSgvSXiVnyH3JuTyU8rN69N8NmeLLTqd 3fhXeWDCTRdwIvCgV+XWKKvx6mYGrmiJ+YvqgY7CipwVZP6vBuRyQc/LCtXhFvVHHLlf MFbTf6zgLXvCzmirWJCiaxyaDKQiTyPKX67cRvSKzx7e44gKfvPQ/Zt8r2gD2Ayw0mbS 8gbT5BgpWBGQ4xuD1hZnuye/8c6JSGewep5KFvqHE5C/GZwX4DFL478HDfKAlw7S9nFD PAng== X-Gm-Message-State: AOJu0YyT/8Lu3+cUXkJICvXxzYvBCegrkbOF6qYeZcj8GG4/fELNkleT gHcIJGabXMd8Vui1o7sIw5CQQApvwilrK+t1j+U= X-Received: by 2002:a4a:b807:0:b0:57b:3b64:7ea5 with SMTP id g7-20020a4ab807000000b0057b3b647ea5mr8300446oop.1.1696621688430; Fri, 06 Oct 2023 12:48:08 -0700 (PDT) MIME-Version: 1.0 References: <20231006173055.2938160-1-michal.wilczynski@intel.com> <20231006173055.2938160-4-michal.wilczynski@intel.com> In-Reply-To: <20231006173055.2938160-4-michal.wilczynski@intel.com> From: "Rafael J. Wysocki" Date: Fri, 6 Oct 2023 21:47:57 +0200 Message-ID: Subject: Re: [PATCH v2 3/6] ACPI: AC: Replace acpi_driver with platform_driver To: Michal Wilczynski Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, rafael.j.wysocki@intel.com, andriy.shevchenko@intel.com, lenb@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, ira.weiny@intel.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=2.6 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Fri, 06 Oct 2023 12:48:20 -0700 (PDT) X-Spam-Level: ** On Fri, Oct 6, 2023 at 8:33 PM Michal Wilczynski wrote: > > AC driver uses struct acpi_driver incorrectly to register itself. This > is wrong as the instances of the ACPI devices are not meant to > be literal devices, they're supposed to describe ACPI entry of a > particular device. > > Use platform_driver instead of acpi_driver. In relevant places call > platform devices instances pdev to make a distinction with ACPI > devices instances. > > Drop unnecessary casts from acpi_bus_generate_netlink_event() and > acpi_notifier_call_chain(). > > Add a blank line to distinguish pdev API vs local ACPI notify function. > > Suggested-by: Rafael J. Wysocki > Signed-off-by: Michal Wilczynski > --- > drivers/acpi/ac.c | 70 +++++++++++++++++++++++++---------------------- > 1 file changed, 37 insertions(+), 33 deletions(-) > > diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c > index f809f6889b4a..298defeb5301 100644 > --- a/drivers/acpi/ac.c > +++ b/drivers/acpi/ac.c > @@ -33,8 +33,9 @@ MODULE_AUTHOR("Paul Diefenbaugh"); > MODULE_DESCRIPTION("ACPI AC Adapter Driver"); > MODULE_LICENSE("GPL"); > > -static int acpi_ac_add(struct acpi_device *device); > -static void acpi_ac_remove(struct acpi_device *device); > +static int acpi_ac_probe(struct platform_device *pdev); > +static void acpi_ac_remove(struct platform_device *pdev); > + > static void acpi_ac_notify(acpi_handle handle, u32 event, void *data); > > static const struct acpi_device_id ac_device_ids[] = { > @@ -51,21 +52,10 @@ static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume); > static int ac_sleep_before_get_state_ms; > static int ac_only; > > -static struct acpi_driver acpi_ac_driver = { > - .name = "ac", > - .class = ACPI_AC_CLASS, > - .ids = ac_device_ids, > - .ops = { > - .add = acpi_ac_add, > - .remove = acpi_ac_remove, > - }, > - .drv.pm = &acpi_ac_pm, > -}; > - > struct acpi_ac { > struct power_supply *charger; > struct power_supply_desc charger_desc; > - struct acpi_device *device; > + struct device *dev; I'm not convinced about this change. If I'm not mistaken, you only use the dev pointer above to get the ACPI_COMPANION() of it, but the latter is already found in _probe(), so it can be stored in struct acpi_ac for later use and then the dev pointer in there will not be necessary any more. That will save you a bunch of ACPI_HANDLE() evaluations and there's nothing wrong with using ac->device->handle. The patch will then become almost trivial AFAICS and if you really need to get from ac to the underlying platform device, a pointer to it can be added to struct acpi_ac without removing the ACPI device pointer from it. > unsigned long long state; > struct notifier_block battery_nb; > };