From nobody Wed Dec 17 08:19:09 2025 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 9513CCDB465 for ; Mon, 16 Oct 2023 17:05:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234697AbjJPRFv (ORCPT ); Mon, 16 Oct 2023 13:05:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232967AbjJPRFW (ORCPT ); Mon, 16 Oct 2023 13:05:22 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1964330E9; Mon, 16 Oct 2023 10:01:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697475712; x=1729011712; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cWrZJva5wG+790MFHsyIaJ0RzDiu+hSencDWcGkJyIg=; b=KDzwNO9lsyyJoPY3Q75oWjJ8J+Sdiy9sNzjK1EW0wOIZ8F++QBZZsLBn xs5GSgWvwv49npEfAr+2lxNADv4gsFYCRJkjVpoNp0Il15KQd2Q0yh01C Zm0YVCHRsyMfEJzA4OeMbuUnnA/+vFXsfV2iNO9rxFtxibF28mWHe9/Ti HtAYj1GyOMUg4GL8+IxMGGFo6tBODQQBVpKHWCpGByifhzWZvSSPhjYOh Z/xYq/zGYWczopGMMYjA/NhNhJHdn5QfHhPTY/SeOap9Xf3eooeub3gI7 TK5n1HOGR2LYQSg5ld1bzjhXd1B/5vD9fLkn63Mh9qbKg7y05dNtOLTIp A==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="385427243" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="385427243" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 10:01:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="1087133858" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1087133858" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 10:01:35 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: rafael.j.wysocki@intel.com, andriy.shevchenko@linux.intel.com, lenb@kernel.org, Michal Wilczynski Subject: [PATCH v1 1/3] ACPI: acpi_pad: Replace acpi_driver with platform_driver Date: Mon, 16 Oct 2023 20:01:23 +0300 Message-ID: <20231016170125.576159-2-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231016170125.576159-1-michal.wilczynski@intel.com> References: <20231016170125.576159-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =20 @@ -413,16 +414,16 @@ static void acpi_pad_handle_notify(acpi_handle handle) mutex_unlock(&isolated_cpus_lock); } =20 -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 =3D data; + struct device *dev =3D data; + struct acpi_device *device =3D ACPI_COMPANION(dev); =20 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); break; default: pr_warn("Unsupported event [0x%x]\n", event); @@ -430,8 +431,10 @@ static void acpi_pad_notify(acpi_handle handle, u32 ev= ent, } } =20 -static int acpi_pad_add(struct acpi_device *device) +static int acpi_pad_probe(struct platform_device *pdev) { + struct acpi_device *device =3D ACPI_COMPANION(&pdev->dev); + struct device *dev =3D &pdev->dev; acpi_status status; =20 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; =20 status =3D acpi_install_notify_handler(device->handle, - ACPI_DEVICE_NOTIFY, acpi_pad_notify, device); + ACPI_DEVICE_NOTIFY, + acpi_pad_notify, + dev); 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; } =20 -static void acpi_pad_remove(struct acpi_device *device) +static void acpi_pad_remove(struct platform_device *pdev) { + struct acpi_device *device =3D ACPI_COMPANION(&pdev->dev); + mutex_lock(&isolated_cpus_lock); acpi_pad_idle_cpus(0); mutex_unlock(&isolated_cpus_lock); =20 acpi_remove_notify_handler(device->handle, - ACPI_DEVICE_NOTIFY, acpi_pad_notify); + ACPI_DEVICE_NOTIFY, + acpi_pad_notify); acpi_pad_remove_sysfs(device); } =20 @@ -467,13 +475,12 @@ static const struct acpi_device_id pad_device_ids[] = =3D { }; MODULE_DEVICE_TABLE(acpi, pad_device_ids); =20 -static struct acpi_driver acpi_pad_driver =3D { - .name =3D "processor_aggregator", - .class =3D ACPI_PROCESSOR_AGGREGATOR_CLASS, - .ids =3D pad_device_ids, - .ops =3D { - .add =3D acpi_pad_add, - .remove =3D acpi_pad_remove, +static struct platform_driver acpi_pad_driver =3D { + .probe =3D acpi_pad_probe, + .remove_new =3D acpi_pad_remove, + .driver =3D { + .name =3D "processor_aggregator", + .acpi_match_table =3D pad_device_ids, }, }; =20 @@ -487,12 +494,12 @@ static int __init acpi_pad_init(void) if (power_saving_mwait_eax =3D=3D 0) return -EINVAL; =20 - return acpi_bus_register_driver(&acpi_pad_driver); + return platform_driver_register(&acpi_pad_driver); } =20 static void __exit acpi_pad_exit(void) { - acpi_bus_unregister_driver(&acpi_pad_driver); + platform_driver_unregister(&acpi_pad_driver); } =20 module_init(acpi_pad_init); --=20 2.41.0 From nobody Wed Dec 17 08:19:09 2025 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 8F005CDB465 for ; Mon, 16 Oct 2023 17:06:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234023AbjJPRF6 (ORCPT ); Mon, 16 Oct 2023 13:05:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234539AbjJPRFW (ORCPT ); Mon, 16 Oct 2023 13:05:22 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 190AC3254; Mon, 16 Oct 2023 10:01:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697475714; x=1729011714; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m3Z4WGrXG69PQDGxjpaL1h4E+zMeZMVLbMui312R5WQ=; b=KRnbaxOnN40z6z0rjnshn6txvvuUoOsvXmrBFc+TiWkKHuJhT34Issf3 bYSW+6uD/O79Nn3swsKM3ARdl42IiaHxPim4UBoTaQxHeULBiJs6FGIGr 6tkC5Omg2BQQqvrOUVMiPRRqRn8mo6qCB8IJs0XFcPcjssPxbxBjrCZgq eHVcpXmX2xNrAnH1yNCURX84OnBXRrJiuxblXm5soP+mQfqCdA3YFdWaN rd+ekVtdnnZ+fHhK7QKTbOQkEr2IQ13Vm6vnzGtTaCle5dhiYCT+4Mpsn mHXxbzjihOF+uaoqh+DDMg+wkfkTXKKCpeRcws0hILtD/HD+tQ+ccYP0J g==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="385427260" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="385427260" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 10:01:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="1087133904" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1087133904" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 10:01:38 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: rafael.j.wysocki@intel.com, andriy.shevchenko@linux.intel.com, lenb@kernel.org, Michal Wilczynski , Andy Shevchenko Subject: [PATCH v1 2/3] ACPI: acpi_pad: Use dev groups for sysfs Date: Mon, 16 Oct 2023 20:01:24 +0300 Message-ID: <20231016170125.576159-3-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231016170125.576159-1-michal.wilczynski@intel.com> References: <20231016170125.576159-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Change the way sysfs files are created. Use dev_groups, as it's a better approach - it allows to declare attributes, and the core code would take care of the lifecycle of those objects. Suggested-by: Andy Shevchenko Signed-off-by: Michal Wilczynski --- drivers/acpi/acpi_pad.c | 42 +++++++++-------------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c index 36e1049833a3..2513028a0299 100644 --- a/drivers/acpi/acpi_pad.c +++ b/drivers/acpi/acpi_pad.c @@ -337,33 +337,14 @@ static ssize_t idlecpus_show(struct device *dev, =20 static DEVICE_ATTR_RW(idlecpus); =20 -static int acpi_pad_add_sysfs(struct acpi_device *device) -{ - int result; - - result =3D device_create_file(&device->dev, &dev_attr_idlecpus); - if (result) - return -ENODEV; - result =3D device_create_file(&device->dev, &dev_attr_idlepct); - if (result) { - device_remove_file(&device->dev, &dev_attr_idlecpus); - return -ENODEV; - } - result =3D device_create_file(&device->dev, &dev_attr_rrtime); - if (result) { - device_remove_file(&device->dev, &dev_attr_idlecpus); - device_remove_file(&device->dev, &dev_attr_idlepct); - return -ENODEV; - } - return 0; -} +static struct attribute *acpi_pad_attrs[] =3D { + &dev_attr_idlecpus.attr, + &dev_attr_idlepct.attr, + &dev_attr_rrtime.attr, + NULL +}; =20 -static void acpi_pad_remove_sysfs(struct acpi_device *device) -{ - device_remove_file(&device->dev, &dev_attr_idlecpus); - device_remove_file(&device->dev, &dev_attr_idlepct); - device_remove_file(&device->dev, &dev_attr_rrtime); -} +ATTRIBUTE_GROUPS(acpi_pad); =20 /* * Query firmware how many CPUs should be idle @@ -440,17 +421,12 @@ static int acpi_pad_probe(struct platform_device *pde= v) strcpy(acpi_device_name(device), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME); strcpy(acpi_device_class(device), ACPI_PROCESSOR_AGGREGATOR_CLASS); =20 - if (acpi_pad_add_sysfs(device)) - return -ENODEV; - status =3D acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, acpi_pad_notify, dev); - if (ACPI_FAILURE(status)) { - acpi_pad_remove_sysfs(device); + if (ACPI_FAILURE(status)) return -ENODEV; - } =20 return 0; } @@ -466,7 +442,6 @@ static void acpi_pad_remove(struct platform_device *pde= v) acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, acpi_pad_notify); - acpi_pad_remove_sysfs(device); } =20 static const struct acpi_device_id pad_device_ids[] =3D { @@ -479,6 +454,7 @@ static struct platform_driver acpi_pad_driver =3D { .probe =3D acpi_pad_probe, .remove_new =3D acpi_pad_remove, .driver =3D { + .dev_groups =3D acpi_pad_groups, .name =3D "processor_aggregator", .acpi_match_table =3D pad_device_ids, }, --=20 2.41.0 From nobody Wed Dec 17 08:19:09 2025 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 43DE3CDB465 for ; Mon, 16 Oct 2023 17:05:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234340AbjJPRFy (ORCPT ); Mon, 16 Oct 2023 13:05:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234543AbjJPRFW (ORCPT ); Mon, 16 Oct 2023 13:05:22 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9639132; Mon, 16 Oct 2023 10:01:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697475716; x=1729011716; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9oL22kUdP5wBHGbwrW3JNkABa1U23D68tubspO8rF2s=; b=BvYa/iSXvBdRBfRh3SYEN8F0BR7Lx8SWLCLMKJxlBRgMuwST1MFITrao Mv8hR7irNbIpBSrMyrjyp/skUQfjh3Ux/kqwOvK7kyVyxaScBndWkdBJX OItxgBOAPYWJ91Pg86Qg3yA6iQK4UrzJ6EjJaoN+93PdThIzfpPlhgqHt ruYM8nVI8Uv/CKaFNEny23xbtntolG5mMMJ/qgr6MkosYyfB81vbMr4f5 CiuS7ZOIAGKvq1qt09ZLU8OlGsd7rsHuajUEVu+9rNzVwzcWwXLi2dEMm i6W1VJFfjL4XpSCj4ufQQ/ShvG3jTFiXTjb/YWUtmUYZbhxflNsJs1syd A==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="385427298" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="385427298" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 10:01:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="1087133937" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="1087133937" Received: from powerlab.fi.intel.com ([10.237.71.25]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 10:01:40 -0700 From: Michal Wilczynski To: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: rafael.j.wysocki@intel.com, andriy.shevchenko@linux.intel.com, lenb@kernel.org, Michal Wilczynski Subject: [PATCH v1 3/3] ACPI: acpi_pad: Rename ACPI device from device to adev Date: Mon, 16 Oct 2023 20:01:25 +0300 Message-ID: <20231016170125.576159-4-michal.wilczynski@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231016170125.576159-1-michal.wilczynski@intel.com> References: <20231016170125.576159-1-michal.wilczynski@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Since transformation from ACPI driver to platform driver there are two devices on which the driver operates - ACPI device and platform device. For the sake of reader this calls for the distinction in their naming, to avoid confusion. Rename device to adev, as corresponding platform device is called pdev. Signed-off-by: Michal Wilczynski --- drivers/acpi/acpi_pad.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c index 2513028a0299..87cf2234ecd2 100644 --- a/drivers/acpi/acpi_pad.c +++ b/drivers/acpi/acpi_pad.c @@ -398,12 +398,12 @@ static void acpi_pad_handle_notify(acpi_handle handle) static void acpi_pad_notify(acpi_handle handle, u32 event, void *data) { struct device *dev =3D data; - struct acpi_device *device =3D ACPI_COMPANION(dev); + struct acpi_device *adev =3D ACPI_COMPANION(dev); =20 switch (event) { case ACPI_PROCESSOR_AGGREGATOR_NOTIFY: acpi_pad_handle_notify(handle); - acpi_bus_generate_netlink_event(device->pnp.device_class, + acpi_bus_generate_netlink_event(adev->pnp.device_class, dev_name(dev), event, 0); break; default: @@ -414,14 +414,14 @@ static void acpi_pad_notify(acpi_handle handle, u32 e= vent, void *data) =20 static int acpi_pad_probe(struct platform_device *pdev) { - struct acpi_device *device =3D ACPI_COMPANION(&pdev->dev); + struct acpi_device *adev =3D ACPI_COMPANION(&pdev->dev); struct device *dev =3D &pdev->dev; acpi_status status; =20 - strcpy(acpi_device_name(device), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME); - strcpy(acpi_device_class(device), ACPI_PROCESSOR_AGGREGATOR_CLASS); + strcpy(acpi_device_name(adev), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME); + strcpy(acpi_device_class(adev), ACPI_PROCESSOR_AGGREGATOR_CLASS); =20 - status =3D acpi_install_notify_handler(device->handle, + status =3D acpi_install_notify_handler(adev->handle, ACPI_DEVICE_NOTIFY, acpi_pad_notify, dev); @@ -433,13 +433,13 @@ static int acpi_pad_probe(struct platform_device *pde= v) =20 static void acpi_pad_remove(struct platform_device *pdev) { - struct acpi_device *device =3D ACPI_COMPANION(&pdev->dev); + struct acpi_device *adev =3D ACPI_COMPANION(&pdev->dev); =20 mutex_lock(&isolated_cpus_lock); acpi_pad_idle_cpus(0); mutex_unlock(&isolated_cpus_lock); =20 - acpi_remove_notify_handler(device->handle, + acpi_remove_notify_handler(adev->handle, ACPI_DEVICE_NOTIFY, acpi_pad_notify); } --=20 2.41.0