Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3704921rdg; Wed, 18 Oct 2023 03:47:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+pv0J8IvZbF1duId+CTaJvtT+j0V7o7TLVgKib8xB9iLOPC+qQUVrK3gqyT5H9yfV93yT X-Received: by 2002:a17:902:e54f:b0:1c3:bc7b:8805 with SMTP id n15-20020a170902e54f00b001c3bc7b8805mr4510638plf.52.1697626068946; Wed, 18 Oct 2023 03:47:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697626068; cv=none; d=google.com; s=arc-20160816; b=ycthFxQtpeJ97dnlWK6dos7rFkXLWgtryfLVUyGJF6w9psPCxSj6i9BlzOwd2T0o26 t5vZAsUy3AHuzfGFwR0bSGQNzMbRKnuYD+iiffu3GXPdh+0T1GJRBeXNwR5aly4IsPBO dq1/LTRA7Fk0oF6ldPvI5wAV/02iWM20NqqdxzjoYNFD52davWgO29QpoQNNHayJIZkR 5WQkOEiGW9yfJHYUtjV44rK0fO6vmLsj2Y9mnaEBF2Nqiqr7Ita3ieI3Vp8R2ddfuv2h +v8FrEYEG4CiEdqyFy1S33V3jonLTIdca97MGOWZtMvgZiWZtX5wcokUB4843OynY+YZ +X3A== 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=V+9HQILfB2BI+E4xaexvib+xhijhpVGUAO7JH4AOMXU=; fh=UzbTbqfR96n49G2J7vG/9RdhA7gwOX4/9MYBfN5rJ30=; b=VsPMQONVubCIhZh5i6ra2KfYR/mpgWHfbhpQlzkQtMcX6t8uP+kLjPh4S8oOyvqQ3Z U3oSly8rsaiCHG/nTrZXsYnWmg3DEF6OKAmCr+9mk4ONebAsLJDqalWvGwZ+RZsRqUnV EvfWCQE0sZOjHPfLcgqEOruqDLT3ZG6FhCJ6ygYFnBDEmOiAFF6XXD/9o9CNthwgCle7 hJXALII/BoLjmA+ca4247WRMZRMjz6ilQtBZb4mwFkMRNkut4uraNjnyza9w9jru9PED L2lGw45DwkQK0Eqe1ATjJXGczkRFqsplStWeA4alqi0QTON464dCt/DThPbkBvjK8mQZ 9mkQ== 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:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id l3-20020a170903244300b001ca33bba8ecsi4273639pls.371.2023.10.18.03.47.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 03:47:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 6DE16809FA6E; Wed, 18 Oct 2023 03:47:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229702AbjJRKrj convert rfc822-to-8bit (ORCPT + 99 others); Wed, 18 Oct 2023 06:47:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229563AbjJRKrh (ORCPT ); Wed, 18 Oct 2023 06:47:37 -0400 Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A70C1B0; Wed, 18 Oct 2023 03:47:35 -0700 (PDT) Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-57bf04841ccso1372601eaf.0; Wed, 18 Oct 2023 03:47:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697626055; x=1698230855; 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=owRD6lMJDku4XSPhJxJ1EXNoQcyNAZKK4phuEs/4T2s=; b=jTt3vTlQEz8nTrOe6JfxzBF4gWWW8QkTcLwycj1aUS6mcRtLlNpOyj4qagRQFU44h+ 5GdOdPHEGkFoKDTCVtRyB4Jla1IAvscDRkclEwH1E8FdaAjcKgjjoiYTcKMfF1zm9Fb5 p09e3VXpZCrVabsQSkd2/YtE7mCLgFVOvrQkN46djJdHpkHAZGBDq+u4hBVFHInIR54Y IUQbT3GjZjs31uQ3Dtfw0ANHE3KVMhvyesL1rd/nZ/rVU+qeI40c6+UmRfekdfKDKnaM B1Tmfmb4ZLK6TZT8tL6amghhwUeISr67d0JGjnd658SufWe1/TBVPLXZNbV2pUvu6hIs AmpQ== X-Gm-Message-State: AOJu0YzX9oE1EDxaGp8zUp6MsfvSo851gkLTUgNVrWG0WbTEFPzYyFR1 rbhZnU/2L9fOitR5U7pIUInWPZB0IA4RDH6xkivAewkM X-Received: by 2002:a4a:4f15:0:b0:581:e7b8:dd77 with SMTP id c21-20020a4a4f15000000b00581e7b8dd77mr3401978oob.1.1697626054921; Wed, 18 Oct 2023 03:47:34 -0700 (PDT) MIME-Version: 1.0 References: <20231016170125.576159-1-michal.wilczynski@intel.com> <20231016170125.576159-2-michal.wilczynski@intel.com> In-Reply-To: <20231016170125.576159-2-michal.wilczynski@intel.com> From: "Rafael J. Wysocki" Date: Wed, 18 Oct 2023 12:47:24 +0200 Message-ID: Subject: Re: [PATCH v1 1/3] ACPI: acpi_pad: Replace acpi_driver with platform_driver To: Michal Wilczynski Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, rafael.j.wysocki@intel.com, andriy.shevchenko@linux.intel.com, lenb@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Wed, 18 Oct 2023 03:47:46 -0700 (PDT) On Mon, Oct 16, 2023 at 8:42 PM Michal Wilczynski wrote: > > The acpi_pad driver uses struct acpi_driver to register itself while it > would be more logically consistent to use struct platform_driver for this > purpose, because the corresponding platform device is present and the > role of struct acpi_device is to amend the other bus types. ACPI devices > are not meant to be used as proper representation of hardware entities, > but to collect information on those hardware entities provided by the > platform firmware. > > Use struct platform_driver for registering the acpi_pad driver. > > Suggested-by: Rafael J. Wysocki > Signed-off-by: Michal Wilczynski > --- > drivers/acpi/acpi_pad.c | 41 ++++++++++++++++++++++++----------------- > 1 file changed, 24 insertions(+), 17 deletions(-) > > diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c > index 7a453c5ff303..36e1049833a3 100644 > --- a/drivers/acpi/acpi_pad.c > +++ b/drivers/acpi/acpi_pad.c > @@ -18,6 +18,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -413,16 +414,16 @@ static void acpi_pad_handle_notify(acpi_handle handle) > mutex_unlock(&isolated_cpus_lock); > } > > -static void acpi_pad_notify(acpi_handle handle, u32 event, > - void *data) > +static void acpi_pad_notify(acpi_handle handle, u32 event, void *data) > { > - struct acpi_device *device = data; > + struct device *dev = data; > + struct acpi_device *device = ACPI_COMPANION(dev); > > switch (event) { > case ACPI_PROCESSOR_AGGREGATOR_NOTIFY: > acpi_pad_handle_notify(handle); > acpi_bus_generate_netlink_event(device->pnp.device_class, > - dev_name(&device->dev), event, 0); > + dev_name(dev), event, 0); This is the same mistake as in the analogous AC driver patch, as it changes the binary interface between the kernel and user space. Please leave it as is for now (at least in this patch). > break; > default: > pr_warn("Unsupported event [0x%x]\n", event); > @@ -430,8 +431,10 @@ static void acpi_pad_notify(acpi_handle handle, u32 event, > } > } > > -static int acpi_pad_add(struct acpi_device *device) > +static int acpi_pad_probe(struct platform_device *pdev) > { > + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); > + struct device *dev = &pdev->dev; > acpi_status status; > > strcpy(acpi_device_name(device), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME); > @@ -441,7 +444,9 @@ static int acpi_pad_add(struct acpi_device *device) > return -ENODEV; > > status = acpi_install_notify_handler(device->handle, > - ACPI_DEVICE_NOTIFY, acpi_pad_notify, device); > + ACPI_DEVICE_NOTIFY, > + acpi_pad_notify, > + dev); Passing the struct acpi_device pointer as the last argument here is fine, no need to change that. > if (ACPI_FAILURE(status)) { > acpi_pad_remove_sysfs(device); > return -ENODEV; > @@ -450,14 +455,17 @@ static int acpi_pad_add(struct acpi_device *device) > return 0; > } > > -static void acpi_pad_remove(struct acpi_device *device) > +static void acpi_pad_remove(struct platform_device *pdev) > { > + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); > + > mutex_lock(&isolated_cpus_lock); > acpi_pad_idle_cpus(0); > mutex_unlock(&isolated_cpus_lock); > > acpi_remove_notify_handler(device->handle, > - ACPI_DEVICE_NOTIFY, acpi_pad_notify); > + ACPI_DEVICE_NOTIFY, > + acpi_pad_notify); The white space cleanup can be done in a separate patch (here and in the other places). > acpi_pad_remove_sysfs(device); > } > > @@ -467,13 +475,12 @@ static const struct acpi_device_id pad_device_ids[] = { > }; > MODULE_DEVICE_TABLE(acpi, pad_device_ids); > > -static struct acpi_driver acpi_pad_driver = { > - .name = "processor_aggregator", > - .class = ACPI_PROCESSOR_AGGREGATOR_CLASS, > - .ids = pad_device_ids, > - .ops = { > - .add = acpi_pad_add, > - .remove = acpi_pad_remove, > +static struct platform_driver acpi_pad_driver = { > + .probe = acpi_pad_probe, > + .remove_new = acpi_pad_remove, > + .driver = { > + .name = "processor_aggregator", > + .acpi_match_table = pad_device_ids, > }, > }; > > @@ -487,12 +494,12 @@ static int __init acpi_pad_init(void) > if (power_saving_mwait_eax == 0) > return -EINVAL; > > - return acpi_bus_register_driver(&acpi_pad_driver); > + return platform_driver_register(&acpi_pad_driver); > } > > static void __exit acpi_pad_exit(void) > { > - acpi_bus_unregister_driver(&acpi_pad_driver); > + platform_driver_unregister(&acpi_pad_driver); > } > > module_init(acpi_pad_init); > --