From patchwork Thu Oct 31 04:09:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839894 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2072.outbound.protection.outlook.com [40.107.95.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 059EB126BF2; Thu, 31 Oct 2024 04:10:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.72 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347831; cv=fail; b=LYNFi9VkKP9iELRy6xjLzR5oHPghcVpQmpd2K7DKfmUrIyLg5wdD160cGP+YrXIvZa/Fx4uCn9YlNNjnJ6Vif3+wTtfDMAbv/B31uUXo5AOtByyGWuVTvqLE0PrxPwbzXtp5fuoHaeDTVKC/iu7wXCOQ6tcpXGgzqtYNfSKk5CM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347831; c=relaxed/simple; bh=7Y1ye+dojnd83/ekD+XzCxFvj3T3Qdw+9hKUx108gN8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HAQu89wqgvAU5HNpYiDSXqDmSgt44ohUE2Rgxc/KIUhDIjYMYNWcq8bdBcTdsH4NyxZoHTe5Zr6bjEMw873/wIQFLosI0lZZH98oGg4PULdPIetmAFx+d9hsg/LW14XcjGUGSOiLHdLBSh22UfHqxYk4oC4PMkYJFnZh87UbuvI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=2KpgXbyk; arc=fail smtp.client-ip=40.107.95.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="2KpgXbyk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dt4m3UGcNWsA9MCcZNvNmoecQwK2wvwOE+19L6WC/wi0Jl9IoZaXy7T2RzqBpSV1m+k7s1jLqSm91vjvKTcJdtxXxiNYFZ64jaMZir82A+9N1JG/4upDqERv6T+tCBtyz+8Z8NeIfi4VmJv3rlu3rZZYQT5ko0YjAU6C9f940yppRssqhlVFXtELlrO1xVKBMDNiL+iQ2k5Dic2mSbFQ4+DUkIL/ZK1XWfS2nQk8tOJZip7B+/7YZwYYrAEMesEMexVWwY2xcBDzjvbZVaBc3HieRCCqVUBiMl3uzLN9Lum5nxgbiSm6KSWmLZei8KalXga0lYfr9ekh/QHkpTs7EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1mUyzhBT4vy03YoPp8fHD/o7qorvv1zgUumIXEtGe6k=; b=IhcSaG3SUgZDjQmnZ1H/8/gVIgpoOkCHKGX013AHy9Gt3bLIrL5jMZ4MoU0UAxWw3bCk/5dsfKRWgzff7kn3zv1a1Vb4DlbRFmoIK0r0ZehSHlJPZ4sLmo8Ws1gyfDGLM2AW4ZAEBs7dYMO3wiisz5zbg+kZERqfwxc7rpc8TMusj2PvM9C5PoK9pLaKvzW/Jp5tTchHFIX47ZA21xmZH9cOr7eyfYBrTLoRACavZ8xU+x3a/3SZQUXMzYhwQcB7I1negewnINUvyhDNlcLUmMdhKK7XYtcSucNNLq7770xTn4lLiiqZAb0pHbKLnGAjWGHSDyHgdD3Z9j6N3J/sGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1mUyzhBT4vy03YoPp8fHD/o7qorvv1zgUumIXEtGe6k=; b=2KpgXbykLWalcayZD6Cz8RCvQbwm5S4/H0qrkoXHbk/q5Gorr/STgFclU2ZqpdyeyT+elbTWvYKqJfLUJc9jDUOoKgVPN5Ct372I55zBzSmzpN42v5qO3TnTNRXI3a42/hLt5YS+cRPxts9j67Eypl7HdG8MpgyMWBIKU11t7p4= Received: from PH7P222CA0020.NAMP222.PROD.OUTLOOK.COM (2603:10b6:510:33a::8) by BY5PR12MB4066.namprd12.prod.outlook.com (2603:10b6:a03:207::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.22; Thu, 31 Oct 2024 04:10:25 +0000 Received: from CY4PEPF0000FCC5.namprd03.prod.outlook.com (2603:10b6:510:33a:cafe::e) by PH7P222CA0020.outlook.office365.com (2603:10b6:510:33a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Thu, 31 Oct 2024 04:10:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC5.mail.protection.outlook.com (10.167.242.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:24 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:22 -0500 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 02/22] platform/x86/dell: dell-pc: Create platform device Date: Wed, 30 Oct 2024 23:09:32 -0500 Message-ID: <20241031040952.109057-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC5:EE_|BY5PR12MB4066:EE_ X-MS-Office365-Filtering-Correlation-Id: df2096cc-1754-445b-ccbf-08dcf961f21d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|82310400026|376014|7416014; X-Microsoft-Antispam-Message-Info: zjd8H5bjiA8ZaMseRZvunorrLZd/UuAHQaf0FxsNdNfx9IuhqdgKNn4sj7P5bTTlpaDFNKQfbA2kf1Ruchy8NgDlWbOX26NkYHkYq9s/YtWHCvc7ji09AG2LX6ccK73oJz9g4Iw+E/NatdMb+Y62840YRSwvQBe6C5NMP9rhOJOd7ip24zycRcn9PS3Kxn0Fg6SsQp48ZEptJ5jTepKUb540XlRhPV/AA5t/+j7CzKFQvteYMIImOS3eZ9U0oFA89E7LHs2ybnWXDdQXZj1o+AKGPR7j7MHs3QE/k9LZsrqbKUQXgqdQ+7FeGK+PfgC/7f2kL9RdEjnGpUfY2epjqvyahEKF5+p0Vf5U6Jy8oBZNajBrvYAgapf/P+1V4FlufMv6YrUG7QX42VF3XuEpZp3CYv5Dmp2Sgl+U9jnIq0JHnrhukw4300lrgoOvT6jpm4SW8MViBcCUqw+ug5HgliGwYFk7oJfuR6vVvA7PvKJYrfm49JnBEl2cz+PQEfn1dRlS/17kh6ocfdbQQIZmRpyXnqLGKsjaSdOfhVthGcPcda0LzOGpB7D4GCpUeAFsCCxaZEKKO60rzNQbXn/s842hk/WrArJbORp9nKTsB6yAbO1CcXCaplB4iKvarmR8yQgh0mNpyWg8GjEl16ZCCFUkDkBh/wd1p2aZZjd680XXwc/6l1zQv7r4C2P0G3NEyzSS8rb4KiTgJ/kazLGoEbOyJ7PErXIOUjyzjPvRxzoFg+wcZMXrfHyatVQksige05ntCR5zKezRSfi40EoRxH8g1dD5AqktATjDHnyEAMJ3lkJteUqrg2h0njld7RQCWYUKuvnGSWorj19Z9izriR4ds6GDiFLsOKMqYoesbChFi0HnbBGZdzg6WrQc20hr9Fu1UQrAM692VXCjjh3nkONSn82VGmP0FfLI/Rb6CHluhFKnglXDR1ipWZG2y6gd4sI2OiSNgvbNXAiGYLrlN9paQ04jjKmavoxcBRWTCkhVjxok3e40KEPcUYItXLBWc4B02FYoT3gYLX5OTWUNkBsBaqPeusOS5QPrkWnIgdIhRLmba8J0opMRkdH9OkxJW+0tNBudMKYfUROp9xwKRbDCGzkN3tu3j05mHJiMO1s84GPe05XEj2a2UIeT3P6/bgpSy3jzOZTwberDsUQRcyPSaXlTHxdnzwLrxJbRJgK1aarS27pLJRalWfcplsIRC2T4K2xd0OSk7QtA0EmBZWiQe4aLC5OvLMOvGn5ATA/B1kR+SHO8VzN40mZd7M8K4L6BwaD7gyX5Jmw7fdLK7j6aEQGI5HZAQZkIvI9iC+Nmtqwiz8C+p5NhEIW+iE6D0QL/PjLDhwYzorzyaFoXmGYgqYmz3zX+LpgjaI9RKMjI6ZrjXJYKQBg5Z0l7BUNgxh6WB452mM1QxA7wqnuIYQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014)(7416014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:24.7232 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: df2096cc-1754-445b-ccbf-08dcf961f21d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4066 In order to have a device for the platform profile core to reference create a platform device for dell-pc. While doing this change the memory allocation for the thermal handler to be device managed to follow the lifecycle of that device. Signed-off-by: Mario Limonciello --- drivers/platform/x86/dell/dell-pc.c | 35 +++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 3cf79e55e3129..b145fedb6b710 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -18,10 +18,13 @@ #include #include #include +#include #include #include "dell-smbios.h" +static struct platform_device *platform_device; + static const struct dmi_system_id dell_device_table[] __initconst = { { .ident = "Dell Inc.", @@ -244,9 +247,18 @@ static int thermal_init(void) if (!supported_modes) return 0; - thermal_handler = kzalloc(sizeof(*thermal_handler), GFP_KERNEL); - if (!thermal_handler) + platform_device = platform_device_alloc("dell-pc", PLATFORM_DEVID_NONE); + if (!platform_device) return -ENOMEM; + ret = platform_device_add(platform_device); + if (ret) + goto cleanup_platform_device; + + thermal_handler = devm_kzalloc(&platform_device->dev, sizeof(*thermal_handler), GFP_KERNEL); + if (!thermal_handler) { + ret = -ENOMEM; + goto cleanup_platform_device; + } thermal_handler->name = "dell-pc"; thermal_handler->profile_get = thermal_platform_profile_get; thermal_handler->profile_set = thermal_platform_profile_set; @@ -262,20 +274,25 @@ static int thermal_init(void) /* Clean up if failed */ ret = platform_profile_register(thermal_handler); - if (ret) { - kfree(thermal_handler); - thermal_handler = NULL; - } + if (ret) + goto cleanup_thermal_handler; + + return 0; + +cleanup_thermal_handler: + thermal_handler = NULL; + +cleanup_platform_device: + platform_device_del(platform_device); return ret; } static void thermal_cleanup(void) { - if (thermal_handler) { + if (thermal_handler) platform_profile_remove(); - kfree(thermal_handler); - } + platform_device_unregister(platform_device); } static int __init dell_init(void) From patchwork Thu Oct 31 04:09:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839893 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2056.outbound.protection.outlook.com [40.107.95.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC54D13D502; Thu, 31 Oct 2024 04:10:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.56 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347835; cv=fail; b=m820QSpFtvYCSrKNMMHLY6ylDkBtAt4OvT0AxfTBi3LKtMqpBki/OugZpuIHIH85KGwTK66bt30pynT9n7tNAMeuoP5oK3NNJ+YoiDdhQf5GHjOcCPy7zdy90qRCjHEZDVSICs51hcskKVl7jf+7/Nj8/2AXC4Xam4Y8j5WAYa8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347835; c=relaxed/simple; bh=Pi8a/vJuw+WnaI/I+TEEffa4Bpy42bLAbqsc9USwYpM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Xkslp7+acPP/HPyX2ulp+DOLKrH3uYVoC+p7/8k2jLLOzkLeJ5mjddEjUAiTUGLaXOrecMdmUd4Wl1DZ7ZNR/NDQiChxYvrxFh5P0lZ6X4N074sLIk3tiltC/hK5K2EJdzlFt2w9MS+KZk3EsnpL90kWYGqtTmGwWTKC7sOB4sg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=LyEc4zuN; arc=fail smtp.client-ip=40.107.95.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="LyEc4zuN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YjA5xnGCkBg5Aegp1EmcgyHnk8qTorhXGMAhtxmimaornVk/67huZMi//44N27376qImjehd1YXsXiYz9mQnMYzcn4MK971Ea9WG2o4q2YNhqhAmr9K1kM1CoVG2TpFPZLxy9jCF7i8OinKpGySKGlETS1p4BwdrCS+yydc67q3KfAFyOZX4jHawfpHZhzck4mNTNPTtNhV60SXLYUWwBx6BdjN7BhNBa7Ad+3POuXlGxdzQh5I9U7z0pCWIyZAHjcdIP0qyrkqAlqeSutY25ihTkUP+ZBvYHJpL5Y9t4YzSAKboFm9bumGOlhb1J268hRMMcsIYeXqUYM0vs2folw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OhvVpL5s8sr72BvRS6yZGodBn0fZHl5FV/9LqwVd0aE=; b=TMaDn27h66jtrBcGSrJZ203XbzChT/DGC7xxILB7Toya9ZdIWZFjVrTw5nDqMcaB+qe9L7LFRqJ2CEaIZ9FEhFhvZ3xjTSO/0rjX9gNJeIDCbu8R+BkhWhGwg28aTRmSLcg+O8qfWO8xQX2+PiMk/Pleuyx1Zc40HOBsezATUn1HhpjfKoDBjQrfk/f02m/bYB+KAbynQcWZ5ArCQEcHvSpsklwQIRfLs3urdHcxnNl4jzAe5s00RcrcFhT/sYBPvO3F4N3iKFzjWHqneaREGLx2HO+H+5FugqFd1aPubHcghclmtF9wdXySnA39m45KvQQKi3ROsYRhvy5ucCugSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OhvVpL5s8sr72BvRS6yZGodBn0fZHl5FV/9LqwVd0aE=; b=LyEc4zuN1CBUjIgu0efoOOMJApxvFcp3nbmJTE4j8Hs5AJnG0L+VuGkIGCRHxmLRu5+nyATEuxMCRQk1nffvVk9w/jCcllzVeodrspcFVgwLeLG9mU3FvMqhvwhqPNiki0CBr/p5rzdqwRMWWi7D79y6hZ7wY0/4BYEDYGdT+bk= Received: from PH7P220CA0083.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32c::19) by DM4PR12MB7765.namprd12.prod.outlook.com (2603:10b6:8:113::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Thu, 31 Oct 2024 04:10:27 +0000 Received: from CY4PEPF0000FCBF.namprd03.prod.outlook.com (2603:10b6:510:32c:cafe::e4) by PH7P220CA0083.outlook.office365.com (2603:10b6:510:32c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.22 via Frontend Transport; Thu, 31 Oct 2024 04:10:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBF.mail.protection.outlook.com (10.167.242.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:26 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:24 -0500 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 03/22] ACPI: platform_profile: Add device pointer into platform profile handler Date: Wed, 30 Oct 2024 23:09:33 -0500 Message-ID: <20241031040952.109057-4-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBF:EE_|DM4PR12MB7765:EE_ X-MS-Office365-Filtering-Correlation-Id: 06dc93f0-af49-4773-8fce-08dcf961f395 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|7416014|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: DkCMAQL/9VT6TMqvWCpjL4QFYFcch7YJ/4o2s1du+cs3R8U11UonKaJsCphwevIuS9njMjRJJ/BgXPVRFhM25ya+eq79sz+pMwptsDwYI+TPhpqRCYSnVQoDa6afGE9ocQ2143G1XmlXe9OFtuVgUGUXbzDR8bcH+aRhDUQwKJFbxqyv4KG+/N4ujO7Wb6bgA/A/z4zRFDOahOc4PFLF+ug4kSo6WQhixi20k6jEIFsr1v1e0429lBI1196/X4bkgjBMXqN6uWtFbuz6qIV1iFyjzS/Y20T8QD6qsr2Yx6Fnq+RAOnWvqvCMGW5fArgR9SX4XzqvOFawbpw9wtTy1wk+KJNcbkS3CkceV7a2pDcRP0LG8AnT/7sg4vIPcjzFUEE2DXzBMczLeyKvOEjQNjqDChfLwa1rudpODbFNi0Chfd4hlV8XTP7xtc0D2FBv0jrQZoFKutB90FqgXXzeGY6HsZ35+0BnDRRowiQYzL+tW0w2QXkXSPjQ8yziu4alP7yaPiGDYlFG7l6/Q0fcyihqP8HfCjsa43wmVxD67AgFJi3HkOgw9kPsRb/AXWOhIZFRtrHZf5D/dbNfRgHppZMlYEfxw/g2t/qTQcrqsyQ5Fs/HzHlpSh9wEWQKXg/RBgokDb+4KIi2FIvqlQSWTI35f3XYda/6E/3njWTmut7jwqkxuqckqDiQnjufDVucVEkwbXbB3aomq6DEaKFvFozPIerkux3YW1QWe+DgAnOJ64ekyHaXIYKCt4h/CBEee0KPDv2vQfT8qaiV+mxySbLOv/VbHkfIkEhs0v/kALgRr2YXU+7knF/K0brZM0vKRFCTprsYINh11Sxm4wajoNTFxQV6RbvrekF2vmLkTblpItOkoL1GHaxFMQr5MOvIdxhJCzvepeOh/dakiuCoJYHanQBrLub/Aw4BUoLwREa8G20POQN6SoWi0t0rLBbuA3ibeD3pmc8tHhE7MfNbAzQZlcNy+dJL8EMabNf306YJ3sDP0SMnTXLZRFprZJYkDvfZGNhJDDyWPYTpIKGiJqeOGt7v/vZJ3iYj7QcYQAxZV9zU/mlzmPRYX1XVr1+413xaJwzbdoY0safS8tplL5R3hFy/+pulvxj7VcS84lARR6fiVNfUTUxoScW8Sq9HoxdJQorFq/XJelZ1k/+FdhsPkBnGqmqwLG8RaUJ8aU8fpOk6fW1Uic1sznFTYaHIIgEJI0T+AqArqLaZlN8foAOot7da7cTuDqpl9Gd3D9ZBl2GAysK2T1bHi2+orLRa8ruZwjD15yn9rfb0AJmDBVyqJDx6qUfkQ1g/6JW9cGmAaEaqgPLXLXKHW4w4KKqx9Y7HVSOdpqpI6BsZdQ3cGWJLOGQHyruy7tWTcdAiKeS56SJezhhfA1brEOtppIHmammRV3jEMC8w1yRv3Lj5VA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(82310400026)(7416014)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:26.6545 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 06dc93f0-af49-4773-8fce-08dcf961f395 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7765 In order to let platform profile handlers manage platform profile for their driver the core code will need a pointer to the device. Add this to the structure and use it in the trivial driver cases. Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 5 +++++ drivers/platform/surface/surface_platform_profile.c | 1 + drivers/platform/x86/acer-wmi.c | 5 +++-- drivers/platform/x86/amd/pmf/sps.c | 1 + drivers/platform/x86/asus-wmi.c | 1 + drivers/platform/x86/dell/dell-pc.c | 1 + drivers/platform/x86/hp/hp-wmi.c | 5 +++-- drivers/platform/x86/ideapad-laptop.c | 1 + drivers/platform/x86/inspur_platform_profile.c | 1 + drivers/platform/x86/thinkpad_acpi.c | 1 + include/linux/platform_profile.h | 1 + 11 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index d2f7fd7743a13..5d9f3f7ba71c5 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -179,6 +179,11 @@ int platform_profile_register(struct platform_profile_handler *pprof) { int err; + if (!pprof->dev) { + pr_err("platform_profile: handler device is not set\n"); + return -EINVAL; + } + mutex_lock(&profile_lock); /* We can only have one active profile */ if (cur_profile) { diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c index 9d3e3f9458186..b73cfdd920c66 100644 --- a/drivers/platform/surface/surface_platform_profile.c +++ b/drivers/platform/surface/surface_platform_profile.c @@ -212,6 +212,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev) tpd->sdev = sdev; tpd->handler.name = "Surface Platform Profile"; + tpd->handler.dev = &sdev->dev; tpd->handler.profile_get = ssam_platform_profile_get; tpd->handler.profile_set = ssam_platform_profile_set; diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 13a97afe0112d..a5caa529351ea 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -1878,12 +1878,13 @@ acer_predator_v4_platform_profile_set(struct platform_profile_handler *pprof, return 0; } -static int acer_platform_profile_setup(void) +static int acer_platform_profile_setup(struct platform_device *device) { if (quirks->predator_v4) { int err; platform_profile_handler.name = "acer-wmi"; + platform_profile_handler.dev = &device->dev; platform_profile_handler.profile_get = acer_predator_v4_platform_profile_get; platform_profile_handler.profile_set = @@ -2536,7 +2537,7 @@ static int acer_platform_probe(struct platform_device *device) goto error_rfkill; if (has_cap(ACER_CAP_PLATFORM_PROFILE)) { - err = acer_platform_profile_setup(); + err = acer_platform_profile_setup(device); if (err) goto error_platform_profile; } diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index e2d0cc92c4396..1b94af7c0e0c4 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -406,6 +406,7 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) } dev->pprof.name = "amd-pmf"; + dev->pprof.dev = dev->dev; dev->pprof.profile_get = amd_pmf_profile_get; dev->pprof.profile_set = amd_pmf_profile_set; diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 6177fbee60573..1a8c29aafe892 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -3921,6 +3921,7 @@ static int platform_profile_setup(struct asus_wmi *asus) dev_info(dev, "Using throttle_thermal_policy for platform_profile support\n"); asus->platform_profile_handler.name = "asus-wmi"; + asus->platform_profile_handler.dev = dev; asus->platform_profile_handler.profile_get = asus_wmi_platform_profile_get; asus->platform_profile_handler.profile_set = asus_wmi_platform_profile_set; diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index b145fedb6b710..730f97aab70cd 100644 --- a/drivers/platform/x86/dell/dell-pc.c +++ b/drivers/platform/x86/dell/dell-pc.c @@ -260,6 +260,7 @@ static int thermal_init(void) goto cleanup_platform_device; } thermal_handler->name = "dell-pc"; + thermal_handler->dev = &platform_device->dev; thermal_handler->profile_get = thermal_platform_profile_get; thermal_handler->profile_set = thermal_platform_profile_set; diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 10a853b6b0514..1b6677e176769 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -1565,7 +1565,7 @@ static inline void omen_unregister_powersource_event_handler(void) unregister_acpi_notifier(&platform_power_source_nb); } -static int thermal_profile_setup(void) +static int thermal_profile_setup(struct platform_device *device) { int err, tp; @@ -1625,6 +1625,7 @@ static int thermal_profile_setup(void) } platform_profile_handler.name = "hp-wmi"; + platform_profile_handler.dev = &device->dev; set_bit(PLATFORM_PROFILE_BALANCED, platform_profile_handler.choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, platform_profile_handler.choices); @@ -1664,7 +1665,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) if (err < 0) return err; - thermal_profile_setup(); + thermal_profile_setup(device); return 0; } diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 6c72d1b6a2aff..feaf98819dc82 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -1103,6 +1103,7 @@ static int ideapad_dytc_profile_init(struct ideapad_private *priv) mutex_init(&priv->dytc->mutex); priv->dytc->pprof.name = "ideapad-laptop"; + priv->dytc->pprof.dev = &priv->platform_device->dev; priv->dytc->priv = priv; priv->dytc->pprof.profile_get = dytc_profile_get; priv->dytc->pprof.profile_set = dytc_profile_set; diff --git a/drivers/platform/x86/inspur_platform_profile.c b/drivers/platform/x86/inspur_platform_profile.c index 03da2c8cf6789..5a53949bbbf5f 100644 --- a/drivers/platform/x86/inspur_platform_profile.c +++ b/drivers/platform/x86/inspur_platform_profile.c @@ -178,6 +178,7 @@ static int inspur_wmi_probe(struct wmi_device *wdev, const void *context) dev_set_drvdata(&wdev->dev, priv); priv->handler.name = "inspur-wmi"; + priv->handler.dev = &wdev->dev; priv->handler.profile_get = inspur_platform_profile_get; priv->handler.profile_set = inspur_platform_profile_set; diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index c8c316b8507a5..222fba97d79a7 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10616,6 +10616,7 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) dbg_printk(TPACPI_DBG_INIT, "DYTC version %d: thermal mode available\n", dytc_version); + dytc_profile.dev = &tpacpi_pdev->dev; /* Create platform_profile structure and register */ err = platform_profile_register(&dytc_profile); /* diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index 6fa988e417428..daec6b9bad81f 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -28,6 +28,7 @@ enum platform_profile_option { struct platform_profile_handler { const char *name; + struct device *dev; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); From patchwork Thu Oct 31 04:09:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839892 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2083.outbound.protection.outlook.com [40.107.92.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E9081448E4; Thu, 31 Oct 2024 04:10:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.83 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347837; cv=fail; b=IMsuWruGYmpsus9uYgnPAenzNJ1ALGvcQAXIk0rO2QVag4UF/Ef76ndoYIaMDOpNYD/7gffU9c13/PCOg8URy0F4xtJtTGD8f7gpWwzyvxbz/k4D7pBogjSL/K1Kce9vzVnIeRZs5+eHxxM2uDLOhuSsZ8WWbB0EZEsgfhsalUY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347837; c=relaxed/simple; bh=3+yolz3CqVaVknInHwF6eh5BNFawW6KdLcAksK32EyM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MB+wFJOGoeNgDCvhiNLiUus97mtr4R1YSg4yWZezBsSsIFD5OYCW77kd224hF1YYJBH27ZvIZ3PtnPAHduRwfavWINkvqiAO9uzKtgldv9ukULFX7zBNPZG5tbEYZAB1ta/1Nh0jaQRheuOE0Bwg3LyFyvFu25+JnEBlYBTcV30= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=pJZF0HYK; arc=fail smtp.client-ip=40.107.92.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="pJZF0HYK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=B/yIbt3uN4O9Sq6UyrwEvLH+OBoN7w66Qj7coOfPGrmO6x2cvz/85cnx1ftqgA5h48kTd7n1tH6/wkByZFmWjC4iiXULTt+3mbPFjvx/UYxvu23pPcS9w+SJKBfZ9x5RfhsRy09hw8+mnpx5d2nscUv8Itxu6GzREeu5939l0Q7tUe0w8ikrpBOPY9Un+C82aM10ch7mR+sWhC7Jau00PCxF4NABWfqvn1ei8E/V7x8DzVsUtYeKmmDwPMSeWn17d2xMvL9QXRemR9HBPX4hXnwpoWyfI7WFV0b7UKDK/M8pnNlwvJvaRnk/KCvp4DvZbyiLchjfxMe9bz74X9N+Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YEt3L4xHA0kK5K+bkOWuGumS5UXZV2HyiCh2P6m2MgM=; b=XSaTwDUeOjCk5qQzKLvQijCRI0nELpenAxi4uHLkgAOpwKB5g8T6hFy6wrxguhNaHBNnHkXXaken3kF4FUK2rvXPwPu57C52TGSYWjqxYNj3uNIfpbX9oL4CVObiAozLvMGmH0OX5B8hW7t1P0e+nBAItWXfs1UNDKRFzbD866nnO3hlQlZUnITu4o6SEHZc8d2duasfBs+x1zLgmui/eYPlPHdzSzEqOU4PcYJEhhjZzeLwfySEJ+nC7bQD7Vd9yWqzPNBwViSOgiGCpr53BsbIJFt7RGjKo+EEMd4rZDolrv8WF4HvAB14+w78imlC0PAUBJt1cJtycn0RlYj1wQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YEt3L4xHA0kK5K+bkOWuGumS5UXZV2HyiCh2P6m2MgM=; b=pJZF0HYKQs4C+HdJYoZSTIqrY5aDClZjTcJtUcsEhEyxvsfAxM0ARkjBoas0GKciwa5lmFcMHEOnXhRgLhhaKmA08NTtAQibWWY/u1UVylPzhVJT0asF/v7+fiapituddz/ekoFzx1Q2e05Tcn2lmd8gG2s1hLL9T356iA6S2z8= Received: from PH7P220CA0072.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32c::31) by CH3PR12MB8851.namprd12.prod.outlook.com (2603:10b6:610:180::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Thu, 31 Oct 2024 04:10:31 +0000 Received: from CY4PEPF0000FCBF.namprd03.prod.outlook.com (2603:10b6:510:32c:cafe::1f) by PH7P220CA0072.outlook.office365.com (2603:10b6:510:32c::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Thu, 31 Oct 2024 04:10:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBF.mail.protection.outlook.com (10.167.242.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:30 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:27 -0500 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 05/22] ACPI: platform_profile: Add a list to platform profile handler Date: Wed, 30 Oct 2024 23:09:35 -0500 Message-ID: <20241031040952.109057-6-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBF:EE_|CH3PR12MB8851:EE_ X-MS-Office365-Filtering-Correlation-Id: 698754d6-39ac-4433-4d0e-08dcf961f5db X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|7416014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: hrkKcBUMQRtT6outp0szF9AL2iETAW7gYE2eN66HOzrbjym3qMr5flKVYLLTLd5U7h73LjWGH7PLb1caLTYVlAuib3mMIk2hc+XU21jJ4WgpcVoFqfep7sCshgMniL2SEBXEZHGXgTTXgAj+Er+dDX5H2YW0QcbvBMF7PK1C0MdqRO1Fv8iyAhwbJkiyelFk32iC6nJrVSj8GwqZc12a/R0VqVlrqtGEomidUihMNBHIe3vpYvjTWduBp+JQ9zLvLTAb24991NTBLN8zp74E1ZOUOcri0oIjwHnvOQlMkKW00rqjJnGhTLPl8z3nddO6NCzyViESYF6njmxqdGOlH92ZnxoZ9CvwHnkffqOwvdc6ILZfnF5JXOtKGVcukbaPrKqh8SF0fVp6QSFQbbIE/3+IjEs4UtJvVsNOS+9zX8TUitOvCamrzsARpDuCWQjKifd792nDUA9l5yo23EflOvJZWcUQdC3ZWGFH9ys/l490+oVibwX+sWtwgQ5P/zsWqSDpoivN9c2z9BgdQNZEcMRV0x9Tgw2PaDgO/1cSEUBRiSPRbpk7VISekoMAhEAIG3By5izVKhr/2GXzGzEPbTogRNN3z34GeOJgcsXedV10IX35rZxWJ92S1UyVPJNExFjIL4JnWhqUjy/GalNHcF7MTSV7JF925EHrgoHMMEDcoR9QexSxUk7GnVHnIYsaAQJrDZdNcOs19dCO4HnlkxNSZZnKDAYfxI+ydibYd0Duz5kJMWhmFeUKR8nUt4HV0wr31PBxW0NtZBsQ8uznDmr72Qm8/BdcmiYfhISci2RXqn2R2PjD49E0HP4JMAcW0+Im+n3c7QSMs1YNMVIVRaVPf6PGMIZkEaxPYCWRSkBIXf+RwwXPERRiEhmfTvnAWQpXk44DRmiA9kgkR62QYtoTaKp9rlePuwo2A2slXOQMZ7kTXXf+vSJaOw1hzxODb2+jIKOCfFa735nDVhAHiepVMP/9B9cuY0upQll8vsYIo7gZeOADpj/7w0t17D2jtXq34WIngIlZLXH0pvqu+5c4Hg2RN0tmtkjGtMtUtZiiv59aXti4mAbj/bv3hYsDb75CUQeuTpIrXlvwhceiLzOU2IO2GoWCW5FTgFK19z0gm2Q5iAUkEDoblrpKzGBbjqn/nee0cUFMRvmxdYr8a4TIaTUUAoCVDnBxXjSs6vGXMV7ozN3IZvADj9qFeUH7G2yJbVXwIfp1fRw+m/z8HejGgdtjMlEAG9MX3x6cgoR+WNvsdRmN1MbznDDR9NkbiZwFl0mHss/6GhGOCkXLdcdSaVmDJJeydnKnn6Za9uMnsCxqeIUNDAgABABEBBldCF3bqrwuXvBOCU+jqfgw9JWtYVV7LKas/BN6BPt6hxs2qsxXmz37k5c91kw8kfttUggXJxbu4Jewc38L4bDcgQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(376014)(7416014)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:30.9983 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 698754d6-39ac-4433-4d0e-08dcf961f5db X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8851 In order to prepare for having support for multiple platform handlers a list will be needed to iterate over them for various platform profile handler calls. Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 5 ++++- include/linux/platform_profile.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index c76b8e3fdcde6..d0198d2ccb551 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -10,6 +10,7 @@ #include static struct platform_profile_handler *cur_profile; +static LIST_HEAD(platform_profile_handler_list); static DEFINE_MUTEX(profile_lock); static const char * const profile_names[] = { @@ -203,6 +204,7 @@ int platform_profile_register(struct platform_profile_handler *pprof) mutex_unlock(&profile_lock); return err; } + list_add_tail(&pprof->list, &platform_profile_handler_list); cur_profile = pprof; mutex_unlock(&profile_lock); @@ -212,8 +214,9 @@ EXPORT_SYMBOL_GPL(platform_profile_register); int platform_profile_remove(struct platform_profile_handler *pprof) { - sysfs_remove_group(acpi_kobj, &platform_profile_group); + list_del(&pprof->list); + sysfs_remove_group(acpi_kobj, &platform_profile_group); mutex_lock(&profile_lock); cur_profile = NULL; mutex_unlock(&profile_lock); diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index bcaf3aa39160f..6aad98f4abaf4 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -30,6 +30,7 @@ struct platform_profile_handler { const char *name; struct device *dev; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; + struct list_head list; int (*profile_get)(struct platform_profile_handler *pprof, enum platform_profile_option *profile); int (*profile_set)(struct platform_profile_handler *pprof, From patchwork Thu Oct 31 04:09:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839891 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2040.outbound.protection.outlook.com [40.107.237.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBA821474A9; Thu, 31 Oct 2024 04:10:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.40 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347840; cv=fail; b=PVzxD2/AfyQRpWrcoKNHfJ033RQu/fvI/MQeHKKsabrVg3I1lCgLBy5pC6RUfljqqnTeGJvNTRg0woypnarHhGip2xY8TRpKFhxL4VovFPZX98bQXLrCmE9PEij0SpGuWFtFRc6k29luZuZkV8S0kFXCAhJnBFIzuSupQbWCmDU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347840; c=relaxed/simple; bh=kHSWXmoYwTA7lWKf20voObXAqnC26/Pqba/tidTV9C4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dDXQs1DTz5qDLjkPY7jt0k89ykdgoU/jdd9geaLYwn64CvVtJJnr2z8k/EkG3/Yfff0iVN+jzc/Gy+jBMJRDmwU7vy/nPMvKqtEcUSSmMfNX/8oh8a3li6A1/A3+to0UMfD77xoI/KGZnLKs5lcynl/KT9B/vYDlwvSBXtWClgA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=00HJhEU8; arc=fail smtp.client-ip=40.107.237.40 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="00HJhEU8" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KmIrnJuG0HYA8slndJMHB18BE4SBDvBK0VDPtiXf6ru2QdDdQu7kVSPJZ7+N5+5qglcb0ut7vkRzVDbOyqOY4/Fc1eOI7BUDD6OgrMHGxxRkWL0mlesjpBymgDlwxptgof19o9BxsBZUGz9QeY2B/cIT7kQKeu2ElF9NIWcPP21/Vi9HaFiA8wfvIhOZRWdvVh0697Spk0El45fnMwhWgGXwJ9TlmpnKXizusBA7vGlVvLjxdYO4OBni1Tc8iN14WpRhunLPra9K2sb4JLMyv9AO7caFITph00nTsX+XSQw9JDZS7o0P3FznI9kuxnG4OPri8lcQ1gGq3Asb6iwesg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=i9RBHR3gyJfqRzIdQq8UYU5tcO1bw9e9KrBG5YRN3FU=; b=SHnFKv6E4X5gOXXLGooC1YaSPwNsiGFYDvIs5RMI4x/AcnVJU8OAnYk6JrV6MfESWrlaf3cscjQPlzND1GN+g6CEDMkqYTiC6SMvm6AWlggBlYsau9G3VLRDFs5Rt2/8m8ATcMsTvvf8teeO87RWLQ9zGAxmrZido5AbM5Dx3FW2zu5dt4PvkFoc/XTSgc4Pak2s0Py4SerNLyWpbVucwVJ9VratD8B9a3LcJK4Fr9bHnUWk9PdG5gb9lYp7qOj9naF6W/Nb1508jqTS0ojDFySYbVK8EyStHdrINB+WEo2MqfK2OLQIxSDcX1CbkwgfVtS825NeXkEs8udwHdwFeA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=i9RBHR3gyJfqRzIdQq8UYU5tcO1bw9e9KrBG5YRN3FU=; b=00HJhEU8KrklNo54gQ14vGxKNYa4eKppr42J1I6YRjy1GFCHhP1aaW2299vBf5T4FDsYLn8/mq0PPdkPbdJEOxKMT8CKQ7cLzSRhQYvbjd+gowBtVmHpfdsF76dzKE90l8gLYBjT3NxSuUTny6rBoZbmg0bAemms1wLZEN/IsbI= Received: from PH7P220CA0089.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32c::14) by CYXPR12MB9337.namprd12.prod.outlook.com (2603:10b6:930:d8::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Thu, 31 Oct 2024 04:10:35 +0000 Received: from CY4PEPF0000FCBF.namprd03.prod.outlook.com (2603:10b6:510:32c:cafe::10) by PH7P220CA0089.outlook.office365.com (2603:10b6:510:32c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Thu, 31 Oct 2024 04:10:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBF.mail.protection.outlook.com (10.167.242.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:34 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:32 -0500 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 08/22] ACPI: platform_profile: Use `scoped_cond_guard` for platform_profile_choices_show() Date: Wed, 30 Oct 2024 23:09:38 -0500 Message-ID: <20241031040952.109057-9-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBF:EE_|CYXPR12MB9337:EE_ X-MS-Office365-Filtering-Correlation-Id: c15bb5b4-4b8f-4709-34b2-08dcf961f7ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|7416014|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: ummZYh2LH5vJN3GrknABRToIXN67YQVin4AivSSbPTKuVx+rwVB3EiceRyonpZWCW0kJZnroRTYAF2fcJXPQRwWOBHrIdNSN1hdNSGGZsrz94tQWC4puPANOSBoWyvo3otR/FumO/4XETZikZ199JAsR/8PM6U4pMp3NM29LVfV9Hx4gu3RmI5ZBtPXZKIkZBdcKAmxA/HpeEpTTgg1jmycho26dEaZH06ZVZUQV91ym8N4Jp7kQCe1rYx16Iwa/X+ubrPDM3ncfkqUoC6LPrKd+7hAClUl5VF9edbMIVRTigvZNv52s6YTME5cQii9Ph4O54dxndVUeecUMW0qxoYNowPxxonYKpboRadBN66WFoZVySr5CsLNyO88YJnjXXDBnvG/AGt6UW31rq7lQW7MR3HQSsbWz0918iGAFUiZgoD2axmoD6mDWXm9o5LMWcn9A5goZf2hGUKt64WbYh6mMvAkhfh/FaT6WeZyrVGjL9jW2GFx1wi51juFIgbgEgbt3ACItGhWEgk4QPUpuOkWU8Pab/ry47nxQfrMvJzL5FxenA2viW5njN6kfH3t55rrCtRUQkw0CTteAN3OpO8nWMazPi5n8tKAO8XnqQ+zGTs+QPSWq80XOoiQi7GJZ2f9m7vDNKV1FbxlMzBon2+mXHQQFT56I7GjFmJavMivVg1E88GiY5XvAHTAoJyyIkgAnazn3DbQVkCqSApWkN2lBRkEcxtsvcDeC8Iy8wrTOVUrIzdFoMQA2k+lm39p4nUnk7/ILwQpW9XcVpsCR7D5XwzQrs+65TbLYYIUcdsJBIXLBQGZ1TCRNKVHo+5oiJyUojLo+8SgEUlLLLrSSOHVfA5CEnMgEeV8scge4BQDdnJcIeeRhR6gEcb/na+J7cktQdW1eFFdU80ktGs3vg002ms8y8k1yheFxzYi+LvTa7wzYTv/SyOa1frQ9klcuq38Kl5ZIKAMXMZFewcNdayQVWk7mGgfIntW9LAxAD340IF3h5ys3kOGQGP9hbOcNlyz9S4Iedq+HGceON0svx00sUye5xocoGsW0vG08qdvgAjZbZ1ni785sTCp7/yktEeq9DwB4zx6quXbNNLii+yhmNudN46nQx9UHWKZ/jelah0rIBMzRu57LtnmIqPBHsSeeBqGG/jCHoWt8ecXUx1W7/TNyBnvANqiAJX1ijkZV8XpxAHyKT+brF49rccF+zzEHzWAYaujgVZ8Tf5pg6igqrLAnf1zYBxipNzo3qEp7IbpYsvoL1GhqIOmc51fblIQhEmNd0XFTu6G0xyjaiB4//Gm0yr/zDwBhz9iG7E3VziBvusEN5FWbdoGbH3XxObSaDK+toLBW+k/STtdQPRZthnqoe45Hwa/eZWnxyuZe4vVbBqGUmIV+TqFAl89FzlFiUXZA8wlMNBOdcopD5w== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(7416014)(376014)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:34.4514 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c15bb5b4-4b8f-4709-34b2-08dcf961f7ea X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR12MB9337 Migrate away from using an interruptible mutex to scoped_cond_guard. Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index cc2037147c0fd..79feb273c1def 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -28,25 +28,21 @@ static ssize_t platform_profile_choices_show(struct device *dev, char *buf) { int len = 0; - int err, i; - - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; - - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } - - for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) { - if (len == 0) - len += sysfs_emit_at(buf, len, "%s", profile_names[i]); - else - len += sysfs_emit_at(buf, len, " %s", profile_names[i]); + int i; + + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; + + for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) { + if (len == 0) + len += sysfs_emit_at(buf, len, "%s", profile_names[i]); + else + len += sysfs_emit_at(buf, len, " %s", profile_names[i]); + } } len += sysfs_emit_at(buf, len, "\n"); - mutex_unlock(&profile_lock); + return len; } From patchwork Thu Oct 31 04:09:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839890 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2055.outbound.protection.outlook.com [40.107.95.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECF941487C0; Thu, 31 Oct 2024 04:10:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.55 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347841; cv=fail; b=BmfIP0v3SFeMPrvpaH5wCGplyIqYBoe8s5QtjQhA8vE5TJehlHUc0Gg+EYD+S6lySC5HBRSXCnJoil9hcAbc8pEligHyAlPbw+9wDpN4y5/KMz98ij4qRPgmG1doH64vx2p7jvV3ylii4B+ejWK7jIqqgVsbQOTomtwBKTgmlTA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347841; c=relaxed/simple; bh=kZbx+5plx1y9L5bCopHfGpx/A+YaI2ZaYuLZ1EpbbYc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oYqk8npnMmB8+iUr7Y4+MYvs1hN0eedJZMyatScxvXJEgO5HQ8ScEZOEAfxqnp/JHdB69OzwfTtq+2wOUQWTgGy+PAInA39IivIHHuL51K9ocfuMdTDrwSR7BF8sQ30hQ5IjCmYBa4S3gflc2LXwELAvI2UE1sTnqTIslt7+qdI= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=hX63oKhE; arc=fail smtp.client-ip=40.107.95.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="hX63oKhE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jEpfcGklEbmCl0hZT52wTOUPlOpjVkYbebwQ/PwBDuL3I/A++IPmRCFElNxGKuSunv0N9GNbKJdG55PX+2ZvEqjaK1C1vmiAbIMejraLVfKF4gzu5G86GB++rRoAwFyCNYjTc6REbkY4UO7fk76dbnbKfJQ1J7avKetvucEGr1jK3owNZBnvTnzghf/CzYP6CtP90iGpo+QtZZ5OmqYtWjyldCvMAoBSEQn4JUR2aLUdOIAbFpb3Xz4mqDH8PUp3uQ2w5r7MNA0O4NWRAfUiowsnvS5EgzMjuP7bx3nkPNf5rlSobG6lNISZCNxelmJZc/uA3iWwrzECyqZxGpYvBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZsZ5aFimorcU3PbFA/8AHd8NCIp4H4npWyPb1dAAxI0=; b=GZZBBysaeoXbdb6yqHzqXvfM9l/C6JT9q9mqBC0TFDKUnYj2tFS2p3+U2wHkO7LfmSpy5WwqL9A4zNqMCXXpAXUtwxiD+5sKGfxEkOi2h8FBzftVdnZWCpYzL35bOXkkKDhDgFLtZllYHbUplDZstGDF/ooszsuMFQ82iTMfkjn1/TPU3SQcJnpfhC1wdzQs29K0RppYhN1HkQWott9+ljS2WlE3gb9IOXC6ifB34y8MH+sYojv0f1CXYTqLZlje4+TwUP+SwL9cL9uAyfW9xE8+xBVF2rnx1leYcJyyffimjYP6DUHbZO8pDcXBaeh7H4VqfHqLErMx2nRhLPeVpw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZsZ5aFimorcU3PbFA/8AHd8NCIp4H4npWyPb1dAAxI0=; b=hX63oKhEeCGkzTCAXJZb3CYMxw6S350DtUIMR3cgDhT3mSJeZohM9JjP33OkQTRSiEM1XV4ZDMadNeGLo4fBccqLQrx+pvnzMWWUOdnV+V0Ar6+By0AyFYQXhAV475l2aLgrIbeCeyRR7Cpwjt3j1m9ojggzHC/rdpOYkt0MANg= Received: from PH7P220CA0080.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32c::23) by MW4PR12MB6778.namprd12.prod.outlook.com (2603:10b6:303:1e8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Thu, 31 Oct 2024 04:10:37 +0000 Received: from CY4PEPF0000FCBF.namprd03.prod.outlook.com (2603:10b6:510:32c:cafe::7a) by PH7P220CA0080.outlook.office365.com (2603:10b6:510:32c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Thu, 31 Oct 2024 04:10:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBF.mail.protection.outlook.com (10.167.242.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:36 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:33 -0500 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 09/22] ACPI: platform_profile: Use `scoped_cond_guard` for platform_profile_show() Date: Wed, 30 Oct 2024 23:09:39 -0500 Message-ID: <20241031040952.109057-10-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBF:EE_|MW4PR12MB6778:EE_ X-MS-Office365-Filtering-Correlation-Id: ffaf378b-a87c-452e-4bdc-08dcf961f946 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: hSiAMMF/HABaf6wLDcC3SI6gjdH37W61RhFmk8U76xTmc8prJLEDOBD9UD983APkkm+C2ix7weHmj/jDB8qrICX/TL8KKxu1NPQVau6z/X1SsRCOFP/7sszwrht91ug2NE8Ist/39hBhtMfpWatIe5I76ZH7ffsCaezWoNKIu1M8CQpNzdh6LkUKdDU24t+ieTrSOkk9sCEJXyyJjY4PUK79yhZR6ADaCyS1OltgzbVJ5SR0LH6/9/qBd0Kq+lX4OQBF/i0vy0nONlGI1ATwJxJ2LZsOL6XKL+DQnznJaZ2aw+TCB8TlRE0Y8/TVF/md01kyiCWSogmY12RvXDLp6kNTWdfG/aVHsvY1oJqGeMfv8vLdL+sywS8t02DfqXOPYZK0OEWOEt3MF/nHgbTgnz0OvQSAzvkbqQgMDJfrZO2s5dY9cG5Ygmh0ZWkx+dGFbsUdPacBvJbCDvr60C1XpWGpx3giocYylgxvDzgNiSdoGrtNgvKnkQ1vYKyzcAhoBzMQ7hsg5Ku1buP9kjBgK381oZnEhOBmrPNwidi1fOHpHCjK3hQhhXqtsHVQigCEPBRr/0V5e5wdeyjN/Fju3SEI+LRPngvSUWl9mEb7UKtEDiyOz1KTEQzGiG0SGRImXJ1r5JqWEA7HqSX5TO4eJtgv9GtESOQuaqyFHgYsxcGhxm+9hW/Q6a0ZLpCPp47+ziVfFwhDzQiCECqiTpXU+ust7QHx1Garh78kFhlSC7nB1OMd3rneXnjFRyJ9nGE5jiy+hjFDcnpdDMIRoGlpSZrGFjL3Qqe5TPPEzEVpWH1NAjMreR0+uKgIzbq2YozttB+nPt1LCv9gVwgxWfN79yVJ7quDqCEP3PSxYhIZq8EwodXYH+naBd7mUg7N/s/YTq5ZvzWBUdSkQoIEXZOHXvuuU168niGLL19PHod8BFhtK/1zJN70vRWStzP6sI8CbLix0fZea3LQbT+/RQVkoY2Fl9/1FztAMf9DToJJyYhzbknsQIv/ILh8s/Pc1vBLg5eplnpf6618sHb3urkTb1xD4jrCLftATk5Y0Bn7dzamYuxWvVNgRS73xYz4jzU8JBJUcJWx3HNk9rfkwRRcFLNj6ZcQ7oBa1rgHdS2sDMm4csqrm9ql05Ugpm3f+i4KW+mXYiTCuCOO/pVkUBZK5h85Ktn9BkFgycEMrFIH4Y3/cWg6c7PxWEcFt79MIP7Iwt+VpHvGrC+hE0hbro1MJ1NAzPtHIHZxTYL/m/w41KhLQgF4D8ZMXAV9TLmOEZ6ylFTC4AobF/uU38q2XSiuGlkVhSbOOf7jOezA+3brEN+Cpc8AxDNz2spK3YilhBwh/JKENYPMQ3+IEwLQb9FoLGM3AhtQRSbi9fItls0gjx9FnRb0oJ4Uq5YtIwDtyeDvaN3WM/RKecL0PAwzCYgZyg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(7416014)(82310400026)(36860700013)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:36.7326 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ffaf378b-a87c-452e-4bdc-08dcf961f946 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6778 Use scoped_cond_guard for the interruptible mutex in platform_profile_show(). Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 79feb273c1def..b48dd34301f13 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -53,20 +53,15 @@ static ssize_t platform_profile_show(struct device *dev, enum platform_profile_option profile = PLATFORM_PROFILE_BALANCED; int err; - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; + err = cur_profile->profile_get(cur_profile, &profile); + if (err) + return err; } - err = cur_profile->profile_get(cur_profile, &profile); - mutex_unlock(&profile_lock); - if (err) - return err; - /* Check that profile is valid index */ if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names)))) return -EIO; From patchwork Thu Oct 31 04:09:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839889 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2066.outbound.protection.outlook.com [40.107.94.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF5EF14EC46; Thu, 31 Oct 2024 04:10:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.94.66 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347845; cv=fail; b=DGUUrb/v/Ei1PhIXuSu38mGKTaIPQOrCIRZTvzcOMJiCasVqpjpsaRr4Jub5u/1l3Rex/5TOz4vpRzaYRgAyjM/xG0dLzAdxEEsorwM1UKqQEQsujiH0Otd9WOmgaByhtKDLig1cPMc4OozKKgKatk4d4u9hpHwMgvvU2YESXO8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347845; c=relaxed/simple; bh=NA85YAzU5HGhnAyOn7Slgl06+COemEDtnALxY7uCu9E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kvSs545s75YOUAKIeJ/l/JTmwsiYYHT4r8tXRuPA24TaUIblkuQPUY2MycZU8Ilwrjfxg6Iqyq1a43G3fEgYIC6Kkh9lh0sAF06+S4nzMrRebd9C3Y4nHpU8MY+R1JsotkYb9nqT7RiyhO+cNqjEuEzShs7ouKOGproT+F0vFA4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=h04SUTy+; arc=fail smtp.client-ip=40.107.94.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="h04SUTy+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TXbbxQGsiFbf37vWu09V0+GYjZzRfr+5DvfTough3JXEVdogudM3dXjDE/HZwKVGz9Dyz29kqMZ1faYs3PY4lKQxYzU0IC3WkFzCk/acJmUHcft4d0BTLlaAfUuZx8dOHJJNXXvQeJGJPdyoboXjsZ7wkwHkaDYJlZeC011FNX5UKDhbdZDUBoL2X6R0k/S3TWB4GV2pY97HtTwB6cpI2weVoCt5ao+++zQipcCM+Ey0yi51U8oDtFJMBub6jkf7QyRFODeZXo2E+HRu1hYOcsr398edJvkJGkBIPelLHV6BratRq0XNgD9WowOB+RTDKmJ0rc4WnYOdQAyVHUyvkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3XyZCGQydisWB0aecSxy6A4iPT3N6k+B+VWHygPISz0=; b=fOf1O5sSaRHoPQ4nCqgVzwC+SgIPrhjuYDaCp/YKO42uKl0Pt9HhSaClC+74SqKWREXxwk+BozD4629iX/Oct0jdItOLlvAgtfw9Txk+z92GyMk1Lmp9ZcQvJ5kRpFldJmS/rWXWOoAnUcneoNgxQxfuHCqhmDshR/oY2U62SBgacZjovwmNcj5t3/jDImK+BirIcdu33fgF8bjyrJIsmbq6V2DuwPM8xNnArXScshZghvi+C+d5EqHg3+X5V/O92PihK0giwWrBQtgkPo2d11J0vMTrAXOWTnMJgJMN5latqa2ype5IUF1hbIVt6oNquJaJoFYGjnFc2qpSwivpVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3XyZCGQydisWB0aecSxy6A4iPT3N6k+B+VWHygPISz0=; b=h04SUTy+VT/blGEvKhtD/cF5tBCBesHMuI4UHd0i0lOgKky8vROuvYm/N12Qec6OklKVLy+VK1C6Uz+FdmY+l6HsZio1uP6Cg3tchbFNI/3RmafE/qkUy6uP628kcipuifFW4PAzYNKEV2BwT3tty9Q4I+pLe22atv4Sv9tt3ik= Received: from PH7P220CA0065.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32c::22) by LV2PR12MB5728.namprd12.prod.outlook.com (2603:10b6:408:17c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Thu, 31 Oct 2024 04:10:39 +0000 Received: from CY4PEPF0000FCBF.namprd03.prod.outlook.com (2603:10b6:510:32c:cafe::d0) by PH7P220CA0065.outlook.office365.com (2603:10b6:510:32c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.23 via Frontend Transport; Thu, 31 Oct 2024 04:10:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBF.mail.protection.outlook.com (10.167.242.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:38 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:36 -0500 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 11/22] ACPI: platform_profile: Use `scoped_cond_guard` for platform_profile_cycle() Date: Wed, 30 Oct 2024 23:09:41 -0500 Message-ID: <20241031040952.109057-12-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBF:EE_|LV2PR12MB5728:EE_ X-MS-Office365-Filtering-Correlation-Id: 5c031ac0-a45d-4e1c-03c1-08dcf961fa62 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|82310400026|7416014|1800799024; X-Microsoft-Antispam-Message-Info: a3u0qQ6d5K0TEI5xulIlGRPm7Lpl7h15YvVYAALDjygJXDnP5Q7bW6zEIGM6zt9I9qMB3uUhjrp43PKQHuG6mturH7yNHLW05oKHLX0d0xySMAD6qKSEPZrdoVZI64rT2ELKhXwP50DwqAVgj63N9XBFlt1h5QZ1UUtkkEi8Z/kmA82vzmJW+AVC7RKAqggRAusmXsct9NdoZku+e99Ssq/nda+dGw58Gn77/2VI5pfhWb5wlQaPLmGDe8DFHhcwQkmjXpaxs1VAi2FutlTt6x2Z07x3CxdqMUF8KgQRsYSmjFCI5vYiAWUjeiAxF+kAv5sMc9rStU6oC6JyrWyb4bd3xeaPL8fcQghsUv1bCOFVufl4VJKVuyoqO7TzpZpFBToGJn6CzUoZ2cYY5oNPI/PvbV7oCPHU24VCyFjvn1Rcz0GPNCRzXIWfxIJH/Oqa6wVhwFH75mB+WMRyViDHR+i6i0O/Az+rX4fZCMry8RlgFyKeyNTQ90Qj+STxRfWMWPeo3TmWdo2QqcDO7QWFC/UXxhHm7lDu63Ykm3ULR1KbNl8Zo8s8z4xY5Yj1lMAQloHpSCdiibLvyGMWYuvcK1Mz1xMlu9uGhfdynm1qqSUU6dWYzwO6f7iJRDcvu9bJAkzXnv3SGjv7ng0tx8xvXalN6cBPyOri41f1rGn/cqthdkmdSdTKqTmrtMAFCyS8rJ3Xgy2aF6p2ydpiLROAo3ITAa25qF54SNmYUPM4QfboWb9ADCvy+4uuafph3hGozAPsFjD0C07r3mj2cAuzE5RnrxlIdG61NDvulOGS0ZpEHcoX9Ow9VbDBhNYB/4qATXGkVy3JyICrX0z0N3IspSpTvNQfIOtSFzg+FpxKT618Lf58yop7IL3EYxi2DvA5H63X0wdrT4LsktOsnAoreMO3dOs9VlJhT1dzDUq5QZivuxEF79V7gyxhqH9ogKb6ziS7zHNBD1j1qpf0kEofcbcc+QLaEY1JpiRImH5snK+tVHE+BtrFFHj3Fb2H/lGBWX+1QFQEoDBBTzlyTPUtLWW/p4jZr/qmkLZbxqFJMCoecp5sAp7nFzZR0351u3AUMpZZiMhymo80pk5RoT0eYcrTGgiY8bx8Tl8L7UF8YItuzg+rZIXk9pOHe9+zxw2ylSIL9qQEcJkBNuOYAKDn/YDWAHlr0Ri9xMix6BLQMP/mSjFKHagStAN1UzTad1TJJUoYa3B+XvwhnPsV5CPffj1mIJILKMb9BlSQbIDqywDquMsirfwCIP8lVplG9o0MuYGIXeg2bti0hEU0eZtLFLU1JpT6/ObGbpiMrXz0RYnGeILhHbtuIhhYoAONgH4qWMz3yaIRH3r+S6f+/27CPbdfMFywNDsGW+n5qb8Cb+5Yzy8XTb9I3S7AlUrAUvMQd51/AeLZSYRQGu0fPuonXw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(376014)(82310400026)(7416014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:38.5920 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5c031ac0-a45d-4e1c-03c1-08dcf961fa62 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5728 Migrate away from using an interruptible mutex to scoped_cond_guard. Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 39 +++++++++++++-------------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 63a5f5ac33898..2d971dba2d917 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -124,36 +124,27 @@ int platform_profile_cycle(void) enum platform_profile_option next; int err; - err = mutex_lock_interruptible(&profile_lock); - if (err) - return err; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { + if (!cur_profile) + return -ENODEV; - if (!cur_profile) { - mutex_unlock(&profile_lock); - return -ENODEV; - } + err = cur_profile->profile_get(cur_profile, &profile); + if (err) + return err; - err = cur_profile->profile_get(cur_profile, &profile); - if (err) { - mutex_unlock(&profile_lock); - return err; - } + next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, + profile + 1); - next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, - profile + 1); + if (WARN_ON(next == PLATFORM_PROFILE_LAST)) + return -EINVAL; - if (WARN_ON(next == PLATFORM_PROFILE_LAST)) { - mutex_unlock(&profile_lock); - return -EINVAL; + err = cur_profile->profile_set(cur_profile, next); + if (err) + return err; } - err = cur_profile->profile_set(cur_profile, next); - mutex_unlock(&profile_lock); - - if (!err) - sysfs_notify(acpi_kobj, NULL, "platform_profile"); - - return err; + sysfs_notify(acpi_kobj, NULL, "platform_profile"); + return 0; } EXPORT_SYMBOL_GPL(platform_profile_cycle); From patchwork Thu Oct 31 04:09:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839888 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2074.outbound.protection.outlook.com [40.107.100.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D528155A53; Thu, 31 Oct 2024 04:10:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.100.74 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347850; cv=fail; b=tbbHbqc9jyActBBRdxfXHtGa0gRxeX69dMEITNcVghxnb3Sz1hNELuvp7p+ndKehsImFnrcNzlcVUl5gbn4McyTP1q8l/XGLJUhrzoWTVE97v2Y+pYA/K8q0J/aSZckn7vELH2WfM+1QkCiDM2PB4p8aTWip7C99UOnCQQASzdw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347850; c=relaxed/simple; bh=mWOy5GM5UEJggDyZTxNZzpYHTp+vSago3fuXq6E9D30=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HttnirmKDozYR6HIoOgnc1tvwp+Y6gqo9+8CjLcKPwGzPXxKY+irWlVO6phKPtQ0W1jqXkgVr1ALSJDNauwrm8yIzuiCzbtO/d68p3qeQ2oST9qlchhsHcETEByxigssZwcrGC5wWwem21mUer7A+Yv9qnUgWGe1RN1yDOEF9zU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=MzIuSfe5; arc=fail smtp.client-ip=40.107.100.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="MzIuSfe5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d6X0UqIj8h7mGae1pK0C79dIxGYt/gyLyFiWDjN8KxjeTkGil2j/UTPgB5aPMUwqZSl+x0FufkwlFeLfpZpWNFmGDnz062gwbvDV6Gw2KwXv3Mk8pqbsjaSjIKMqbk57qftyis2vUvvudj7cFEpWsHpvGwCu8UInbdds/mZCLlQlI/PLEV2KdyyKUtG3a38091UeFVYRrPLv+/rbv10KDFTFmABz+Vt/ON6SDwI1yXMzlVYixLsAHB4YijqQdGaeQsQSaU7SNBMtTgeDUej3qIR4oEFSlQ7BI9myo9jPAbyWvjcHBP+HBH/fyn6SPOPsF8Dxzxtc/FQGbSlyvq997Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kJzYNeaKYSJpkQy8diwOKNYtzHPdojNbidqIUCme8uI=; b=qcj7DGmwTNHB5mmEsihFShcdIaTyIzhz2D8sQ7xxgST7SOcqwiZqJ1LEAVFNOBYHRTzXmf3xBJZBz7UHO7jhs/vekP9ZA8ysmPNOoemj/9DWpdmIZCxB3wImYpFTvPAIgxzLAb09L79rcr3EYIOfjiChnvGDP/ivNXOOHl3hVvHtejDOvNx37WQM1/m8HNYHE5MQPqX/HyH5NyFL4s0XbvT7k/xwI65E/HvtdwjHtOJcKp+7Z9+p2S36K3rl7JG2Qlxj/T3olk5Yn4ffslBtS753FTHTuKmEsnX9MmMaiuB0vzlPc/YBB8B26slR4QnMu7e+1ycBEgVDOPoFwF+S4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kJzYNeaKYSJpkQy8diwOKNYtzHPdojNbidqIUCme8uI=; b=MzIuSfe5+l+6GY3pdpdQE5iPxX4a8ABjm7H0Bs3iEOPN8MHl44izFtB2k1Erw6XmLmGTLLsQdd7sCVzwGL/k2agHfGwEZpuVQ03bbbrkTTrlmYsotT8ShzW1pNc5ki+w2bkoyV2IlyXl5CIO4t8zj3bI//ceeGJXUoFlxIXN45c= Received: from DS7PR03CA0345.namprd03.prod.outlook.com (2603:10b6:8:55::29) by MN2PR12MB4047.namprd12.prod.outlook.com (2603:10b6:208:1de::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Thu, 31 Oct 2024 04:10:42 +0000 Received: from CY4PEPF0000FCC4.namprd03.prod.outlook.com (2603:10b6:8:55:cafe::c5) by DS7PR03CA0345.outlook.office365.com (2603:10b6:8:55::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25 via Frontend Transport; Thu, 31 Oct 2024 04:10:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC4.mail.protection.outlook.com (10.167.242.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:10:41 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:10:38 -0500 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 12/22] ACPI: platform_profile: Only remove group when no more handler registered Date: Wed, 30 Oct 2024 23:09:42 -0500 Message-ID: <20241031040952.109057-13-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC4:EE_|MN2PR12MB4047:EE_ X-MS-Office365-Filtering-Correlation-Id: de47a983-6d2e-42da-ec9b-08dcf961fc22 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|7416014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: WzsDlELE6f7TinTUQ7C+SHBpAAs8EPw8dwACqIadmSgWoWhKpuKKi4bpyuiCPzl/8x7UA2HeM7fSRbQdCMfoog8H5B2m/aHe7HrOGPO6o+a9SJadNT3HNsxoDEjMyo/drKvZM4RQkZtNDDInGD+WGnYQxUbMVXvP053eW9J5zlEi6XDH/JqknaGGtmxtvsL95D9vr0beSWhcZ4RVFyqhmoqlUxOMmbqs+oouB7xp6J08npcmoAlnQeqEvmJW/wyYHv4SPaT23K3lIXCud7TYTsUz9I4V1O8oRwKIjI0xMC21X1V7TooPZ61BArpo2CGkSd0Dtvtpm6hV23N47PNYcQg1Dc6crrWjBgsVbOcqc+XqlaRLt3SjJd3KwiVboxvPxC2RZBWyjQNseMUdzs6H5CKLeL5Ht4oy81G9rF+kLt20nReHKjUiS6A5n6vHxqur9T7Tnt0NaPxvWUKWbla1vBS6lZJ9eeBXh1OJmH1tfRAJCrk1Cl9MxIbmKYb4Eqlhim3EaUcTXIZ5xpsQaY8Egt+kILAWM+pSopcqkenCFCbx+sKa2dziYGLZXSwxV7qIX/TNKERNlqSjsRqUe4IygyIxl6mQWrNzJVbyneD9lS76C5LWcsCNeYlBdwMOiefGQWmzzpDU6dl1xdQofvvBRSdYM548A537kaMq7ADoNXudfa6QXj93mLDRNoPpSPPUoHjB9mt1oOPa2qUT+W9F6gzGt6Js3S3W5WfdfwkR/r9gTcBwyv9LZJhuEvkC2oxK/VFcuHH+EwkxI8O5gs3tndndxNCYY+rtS7/r7TsAlFYgNPsrG4SACOlPhyN+z2IghbWnoobdZEeFsbhS7ckiaDZUoB7RyoZpxGNpQ8Hx+lP5N8i4MYXCcB1NGy56VbKac2WMAE0O8zOcrFw9Dz+KhIzQj3fC4s6dW4/WPh+OiL8R4TuQLIiYWXiMALG4cilZ6ybCzm1ey5ZvD3pCLyyXR4XW1ObuQ6c6osxnbcLF+ay8S+0Q9pGqLv7DhjxjG/VM/8HqnZlGAVkfyJXEPtvwSyUPU6+O4gg/HP+078vZvrGt8qoBCw5g+LtFLgeB82OpltgXFEYb7IeH9z34mOIx9U8VXbzzJssFMR13r+Tq288tJy/DjeqwlvKHtYfPDWu4Bi/VSZrJDD4qw7H+tG+pTux2w8ILanUExTcwL7+TFfZ2qM22EfwXTXgV61DbeqiQDk1awYcI9wq9IieFkRdApYTxf0TywBQudZUutQWSX8JASL4ttaswy/a7pwFLzC/uVkOUt3NQLDyH/HKsZIT1gn2kX660JguMo+bpt9FdJp9SOqZvxSwO4ED/32nzgEJcq1DeKOw7o/qhFWiwG7W8OoO3FuGRvrJ7ubw9UZ8kwtYhJj+C/W8yS4ig+Mb2/WdN8Fr1UfuMVNO8u5XiDQmyAw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(36860700013)(7416014)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:10:41.5340 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: de47a983-6d2e-42da-ec9b-08dcf961fc22 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4047 As multiple handlers may register for ACPI platform profile handler, only remove the sysfs group when the last one unregisters. Tested-by: Matthew Schwartz Reviewed-by: Hans de Goede Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 2d971dba2d917..b70ceb11947d0 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -23,6 +23,12 @@ static const char * const profile_names[] = { }; static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); +static bool platform_profile_is_registered(void) +{ + lockdep_assert_held(&profile_lock); + return !list_empty(&platform_profile_handler_list); +} + static ssize_t platform_profile_choices_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -184,8 +190,10 @@ int platform_profile_remove(struct platform_profile_handler *pprof) list_del(&pprof->list); - sysfs_remove_group(acpi_kobj, &platform_profile_group); cur_profile = NULL; + if (!platform_profile_is_registered()) + sysfs_remove_group(acpi_kobj, &platform_profile_group); + return 0; } EXPORT_SYMBOL_GPL(platform_profile_remove); From patchwork Thu Oct 31 04:09:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839887 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2052.outbound.protection.outlook.com [40.107.92.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4626126BF2; Thu, 31 Oct 2024 04:11:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.92.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347880; cv=fail; b=Lj5C4NUy7WHItLsBfoMmztxZ2NXke5Kz81wUJPNPG1R2jAFNms1w2HVwKoPKGZvIDDsds57B/3Ump+ahF1jvAOeb1Y8uU8hNayk8xsPT8AIu9SDvDacCmI8uZ4Uej3jayBBhOFQchTZg8jQuZ/Gmd1eGSg8NXSvaJntfeJGr4Pg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347880; c=relaxed/simple; bh=OtCtHlpL5bk4vLAegdwWm3/Ky92bzSLwgrPBZOPM1rA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=E/o0Yh62SB7uZfzZHYOGPOM40pPDzNDRYjEXOvPjBwpxx+g08Kl56+QIdGFiAnY58N8rWnhrM2qySmVNskhHaHtAF64uk5bFy0bfohoaP51ZxrClsbxmvLOa8yaFqEfqzAeMPSBXRaf4OqWEqYuDILIQi0wcI4vGXIpAEGWjC4I= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=5KLz9Udy; arc=fail smtp.client-ip=40.107.92.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="5KLz9Udy" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xrN0/Oz5XSxP0sR21Bp8KQAf6vKol6rXibbowHQ/mjHg+2M7dqCdR6Py0denpYSuYQQB5pz6yEG9YUm5D7/YSl7VUY1/pwQo6bJJ7Eju5VvQfDC26KVVZ5cAvgCSdRQZJgK0xUiSZx7AyMGzaQ3rHBTiMY5X6DSG5jleknxih3Aq1HlKToJuxsz9VtW3Ken6UGCuVFSv0AOhXuTR3u7mbEXzeeyBtFi7pn3BX7g41dEiWSx+zZ31WbRwlsZ9Wqit834aiYzGzIodg6R59/0kWfOP5tiXEBTIohH0UiEQjDFzHCkuCKqkk+YGr/+CjW2mz3Ez58Nf+fHuNdAsvrDGKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GTMgLG4xbIsY9gFb29ycOBwD5iLmIPptvlydkm4UJuM=; b=KWiAQGtVj2s1lxGN/r2e6w8Ch9o01W8ZHV23kLGFcXpe3YWGE69D08XuiIULSfV1TL0ZVMxD/nNXALqOKUBF2pUSficjSH2KNTS5NogfTD6EPl709AEaIShTa7SOj77Bu6x5ZN8QSaBbOiHLvrt5iiCBnTM64KAJbGys/D23PaRV+mwtOLXOcz7srTVIa+yZqB3R1LSy8hiPpQD/xXtB8D2kl33Wt2QQXnXMK7xg2Ri+n5C544oDlRtIdoXGjgHwSYKkf+i9miFuzI434JohfPG6IAp5ya1IxfaFcEIuL84kywXSVbWwxN/ZwaFbJ32EsRrfe+opg82kY7/Qf6t1zw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GTMgLG4xbIsY9gFb29ycOBwD5iLmIPptvlydkm4UJuM=; b=5KLz9UdyVZH8KcqD4FMIea1rR1advafVoeDMWD5V5CsFKJmCXN4InDiYgHrGBQ6+/9BR4QF731jejIJJ7iBs+dhsy71p9pnFhBoRV2w16HcHELirkZzWMLqFTfyYpD3dQfSJNEMos4/4X27J5iHfBbFoHPriNIiH3xy32wZJW48= Received: from PH7PR10CA0007.namprd10.prod.outlook.com (2603:10b6:510:23d::7) by SN7PR12MB7854.namprd12.prod.outlook.com (2603:10b6:806:32b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.23; Thu, 31 Oct 2024 04:11:15 +0000 Received: from CY4PEPF0000FCC5.namprd03.prod.outlook.com (2603:10b6:510:23d:cafe::ff) by PH7PR10CA0007.outlook.office365.com (2603:10b6:510:23d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Thu, 31 Oct 2024 04:11:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC5.mail.protection.outlook.com (10.167.242.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:11:14 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:11:13 -0500 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 15/22] ACPI: platform_profile: Only show profiles common for all handlers Date: Wed, 30 Oct 2024 23:09:45 -0500 Message-ID: <20241031040952.109057-16-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC5:EE_|SN7PR12MB7854:EE_ X-MS-Office365-Filtering-Correlation-Id: bad308c9-efbb-4e67-c297-08dcf9621007 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|376014|36860700013|7416014; X-Microsoft-Antispam-Message-Info: 0htAXIwqA//U5U8PKOmOfACotYNVuT/ckP7MsWqy/e3f3fkCCmApYlFpqtHPvvjfTEa2GIhafbp1Oq7mA5aRJj7br+hqtPJZKT9ZIomFDKWNnEugDOPWEbENKzJjt9+D03rQyhNzZ1JzfxvYxbtcX4bP6aVrm0dU50TaJQNnZAbOA5SD9SNnNJWmMqja/yp1sItJyHghqa+a73ytXy39ZMIcobB9/EF9v0Z3s1uh1KeMHR23jliEGmUKcYfLyycvVR+UBsJGR1qy2ptciY3+sDNa44g2MQOchkYRNtXOjHPrTj8cpoNB2vgrUxxlfqhw2QneMy29SM3sBzLAqHuYxhA/2ldJQBZxZHr5tflsY/AdHmI9IFQ9RC79OqOd6IEDr9ewOLPFx9yvApL8PAZUvH4pm8ADpxrNL9MoYbu7FCzfrHq1bdVU/Gjg3k9aKUuHZu8RQLyqUpM228hWQJRArwEHPQaoMUw7gSG18pGBZZ9ZNWU/iM2aFHiH3KxUnbw2danbMSba+wahMTd0AZNawmtqQw3yNDUVxIPfbvDaesB4CyhtNy1IFtiAotBjVxV91ohLW83xsZERXIO02fZSdnvs5NesWf2aQrHj9XoC9z3QiJXVrKAm+r7wg8BAZIl8NZlk2KFscS+3gseeh1ezzNLTx1QVw1lVDTEOkFbpf6KEPxGApwE9g3zvAKcKeil6U71EVru/G1SgLD4eyP25J1nZnCBSnEjogCudNgSImbgTprHlJBFW/ceNA+IDYqjM2H7F7K1Tpj3m+l3zRQP/5JLNRtHhmDOO7LcEldESk7McCU4Q7mznvAeI/j//fLwx17auEAT3VJx3vMnTduRuBiQ53PLNaSgPoEPol7UJU28NUyOGBrbQuMlIM7pIDThRmSNoV15rgehSNUM8iiO4VMq2vr3HFqarmlNCDB43KSQ5sE9ovYj6Q8xAqodngN9QCu2PT0PA8/mWbGMbeMZg0ktjo1Ztq8i3aUy/s0+wzeZsmqR6G2VNEf8CewBpJ/n72TpHL4Uh/xmnnvfwRu70ouqG1dIXs6FCo+h4Ar8EdAABV4QmrmdAbtra2AbKfKHZVuSovDg0cNYt9rJcSFxM3NYAUEYapERmLs+bM7Zx2u8ElxpSW8vo3zeag06qaehqW3F/dOAyXRSMBCTzo6Hee9kLGo7s4ioiwtPtHsP/quEg+xikl15JoYLdg6OqC+R3Dam38u3EFpWcwncIBlh+paL5ak73BiSG+oC8Auj+F8unK8IJCtEi39k8zT+PePowUuzP6r1YT+uCsr5jt/uZbJ9v82Rzp4szH6AiO5V0gRBbzxi7on8guQdxcYA/huSum3Vhd4mc4oWJh7yoN4PO+dIor820az3mWX5+0m1V6LehwYOh4lzKk5hycRoCLVrR+hIWw7sEOZjBh8n2qs7VBQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(82310400026)(1800799024)(376014)(36860700013)(7416014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:11:14.9104 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bad308c9-efbb-4e67-c297-08dcf9621007 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC5.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7854 If multiple platform profile handlers have been registered, don't allow switching to profiles unique to only one handler. Tested-by: Matthew Schwartz Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 38 +++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 7bd32f1e8d834..90cbc0de4d5bc 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -29,23 +29,43 @@ static bool platform_profile_is_registered(void) return !list_empty(&platform_profile_handler_list); } +static unsigned long platform_profile_get_choices(void) +{ + struct platform_profile_handler *handler; + unsigned long aggregate = 0; + int i; + + lockdep_assert_held(&profile_lock); + list_for_each_entry(handler, &platform_profile_handler_list, list) { + unsigned long individual = 0; + + for_each_set_bit(i, handler->choices, PLATFORM_PROFILE_LAST) + individual |= BIT(i); + if (!aggregate) + aggregate = individual; + else + aggregate &= individual; + } + + return aggregate; +} + static ssize_t platform_profile_choices_show(struct device *dev, struct device_attribute *attr, char *buf) { + unsigned long choices; int len = 0; int i; - scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; + scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) + choices = platform_profile_get_choices(); - for_each_set_bit(i, cur_profile->choices, PLATFORM_PROFILE_LAST) { - if (len == 0) - len += sysfs_emit_at(buf, len, "%s", profile_names[i]); - else - len += sysfs_emit_at(buf, len, " %s", profile_names[i]); - } + for_each_set_bit(i, &choices, PLATFORM_PROFILE_LAST) { + if (len == 0) + len += sysfs_emit_at(buf, len, "%s", profile_names[i]); + else + len += sysfs_emit_at(buf, len, " %s", profile_names[i]); } len += sysfs_emit_at(buf, len, "\n"); From patchwork Thu Oct 31 04:09:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839886 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2048.outbound.protection.outlook.com [40.107.96.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DD191428E3; Thu, 31 Oct 2024 04:11:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.96.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347883; cv=fail; b=CAIPn84+oBa1qgXU3J5R7o8cDEmtjF7RxdnvOJezbzsyIEy/BJXlGdJ0yrH5C5qFIZcyp0sHVzx5Nsx4mQaMNF13r33Fhy5lX25DukkC4tFeVfzXu6g6rvO9dV4Ni6IHlx6xXpN5jMf/XxQ7ammD8I8feYf6Y0Jr7LQr6WYycTU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347883; c=relaxed/simple; bh=qrb4y8DNgSCrDBbHhO0W2f8rcPdti6swkaWXkEoVYR8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VwNVIQr9MyVd2/+YYY5x8RUuVQHx6imDVJbwogS6DFyaitM7GydHs8gJfpn5T6SG+AoG+roURJzbKnz9CL406pr9jrX6w9x2x64tl/UTNTvZHnxnZTJ5EfNRgcLzBvsqDjLHZLx9XxSbUga78k8GScQO6okyMK4F1d81dlbZ/A0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=Wt4Hl+5S; arc=fail smtp.client-ip=40.107.96.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="Wt4Hl+5S" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xfQUiQcrQwbEFddmke7tX/PYCu4uSo7pQq0YTqJmY6MqKWDeFLIhSLa5oWirBzz2htB5nrnXoeK9JVkFQyGcQX4beJG0d/Yru2H0HnIYvJ12Ydisy9I72koXeDylQ8paJwZywOiyyhik6KJxz2nXxFsAS0UCJisFCzzfc+R7fxfyPU5NfzXG8pGSGGO+23fYqvHsRzdoAzBNl2I0r4UIcbIpMvgrbadQ/q6ARsBnHkZXpQvCj68jpWgR6Dh8bUOdndSPhnE5dSQ4A3vwZ+YG0IDjZCIhbUsUBz9CAMq7wC1H4lryB7i/XjKGXD2uzjLn1gD8Tqc+V7Zi3xIt3RVYrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xZRw0PnuGSquX6w1fAZagDnZwh1ox+3Ian7/NRON/FU=; b=BQZzFcKIwo9fU0jgbKL/yHtPkAtop+lBbf5wi8OPPU7UlKqh3JPtape0yjZV0T8Ul+y/qb7f3W/QlRYQO+GrlvGEWtn1PZV0QT6xSuCHJQArwg/+FeyBhWG/SaPlON49Uhalg2uX7fDDJnVPS5uQRqWSFvKlTJh8iNy3QcvlAt3UthV//or5sD77dxsv7xN+mMqM4EZZJSU6/1b1370Y+FVTQ8PZ11nlYGa9I4spckruNfrs4fWeMn+WpZhio+94xWPEdKknYJaZp1HAidalcD/YeNznumSvTqHLpMZMeTt+J1o+M2JwZw/7JvTcKxvjRLpwmKjRnYRWuYw2TMczpw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xZRw0PnuGSquX6w1fAZagDnZwh1ox+3Ian7/NRON/FU=; b=Wt4Hl+5SEQUqrz2fQb4kj7usagNfB9AdefWIInI4w017FuX3p2//ZVgf2IaJSqc1Xr2i/B+9l0Wz6k+k0sRQAC5XSYoW3HfWpGNbb25BRbBDV6JCqZXTP9ugl/3sCnfnCNYWKMlsVS7sypVzUP+0JFWY4BcuaPjf8w/INd8lLQg= Received: from DS7PR03CA0354.namprd03.prod.outlook.com (2603:10b6:8:55::12) by SJ1PR12MB6147.namprd12.prod.outlook.com (2603:10b6:a03:45a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20; Thu, 31 Oct 2024 04:11:17 +0000 Received: from CY4PEPF0000FCC4.namprd03.prod.outlook.com (2603:10b6:8:55:cafe::c9) by DS7PR03CA0354.outlook.office365.com (2603:10b6:8:55::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.25 via Frontend Transport; Thu, 31 Oct 2024 04:11:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC4.mail.protection.outlook.com (10.167.242.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:11:17 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:11:14 -0500 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 16/22] ACPI: platform_profile: Set profile for all registered handlers Date: Wed, 30 Oct 2024 23:09:46 -0500 Message-ID: <20241031040952.109057-17-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC4:EE_|SJ1PR12MB6147:EE_ X-MS-Office365-Filtering-Correlation-Id: 057f5614-3275-4f45-3ce5-08dcf962114e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|7416014|36860700013; X-Microsoft-Antispam-Message-Info: 5liTDJdmhzzYsbqhI+MUeBuYt2ZVHrk3wB2+yGRmZNJ7SdQ3bsvDRBzodW9i0oC+1UuKH9+Vr6QIIHXK3xlat+2HDzHHmALi9lRT/d8zzpHaBqvXETI6ZIzfS64alTDHr5yd0oLftcgaZWb0ETksorSWtinvoj2F5mJmfaUSFQC//BPRGhlZYAdrgdONnXxkjCnAfuEH3jCSfjxy24YRdpqPky7tBA7WRVhliJRL8z1y7nTPRjBbKf03rn4+UJXdT5UIt+fnqY9k2RALvzIAzxaF0cbn8xQgaPcTcQZ4pa3yfoIL4jf9eu45v3oQYjPiRgCUdw4cLbxJJSArmWvX9cjxvJjzImQXBEc27FSdXyX9tugFYUppEwd5p8KMBdYuUDIVuFwNP1yteMUvbeCiu/FmD5E3kZXiL/wkk0zNvTq3ES752kEGwXI4QrOzup7vzBlUO1o9iTVxUFmf+YReh2ZKT8QCHQEX0DRq9wdIOXBLdtqmcpOSpEGlj9wU7MrpRTevTkSxH5bfAgQFZrS7NzZcm+dOprr/sNAgq0SIHdTouKYWt2k/GAGe4BBSsFq4/s6StGNCeze5ecLmeYodcLw7OTipKmRSnBdCA2NcvVLUWELMIqm8JQC4fmEk8wrhVJLS1jq7mjjN+WcCUM1Bj5kslP/0r/EoeILYnOnRg1nj4uAyzNjbkl14VF/miXN/TyC42aAXFFSXcHrZZPIBK3xGJa5Yv91n/wyOwMOX7G7Z/elC/B1Z+LkqxpWsFcOORvonckJH8Fl9djfaR+NQBsrxejE3nWClxHbA3UjPb4sGM+BlfEWNqbRde+edKgDapVe+4A8dcqe6kYY2J1d4lHlRrA4W/45molS8Hot9VLFp3UxuyAgyE+VbwltbSdK4iRe8oL+/XvOPDp7Q64zm6jnZDsTPHV5PP+ZJKo1uib1jz4Z+QXJsH/mi64mfBtnUCxnFIdliP7wr7xBf0UoyVIGir1dW6QklydEq0vur8sVfHGWODQXkPm9TiEEWIWGJy1OMC/JLaifhODtaa83yCK2jaQdmaZgAvv75qu9oYp9S2C55Is30YmV1D+Nfa3uS8s/jNYCS7wIr5pRJbr5XKN2jw4m3XorZe5v9DvB+uKXiVf207RlvgNwzBl3tiqEAXWOjC4C65NEI+B9oNmOl+mNjWLq3KpG+PdtY3IiXvtJ74zKOkGmxf49gj9Gj5ysLB9w7jUDlCML+oYl4W63UaMCJf4nSn7xSTlrUxvzZchOoaiNn3j1CvHf1L+x2LjGRerszrQkVl63/HmCBQuhWrcfzM3IQo3zOvdO0tEX79gze/FbyEp3j4fUvbkApQ8LotwmcroWk6YLSdazAX5eWCJNX/fDoSrs1cvgkkEGCz49LJb0CK7ZRb8vUXOI3m7IY1HXzeA5EO/yF33lOIGHK8A== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(82310400026)(1800799024)(7416014)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:11:17.0656 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 057f5614-3275-4f45-3ce5-08dcf962114e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6147 If multiple platform profile handlers have been registered then when setting a profile verify that all profile handlers support the requested profile and set it to each handler. If this fails for any given handler, revert all profile handlers back to balanced and log an error into the kernel ring buffer. Tested-by: Matthew Schwartz Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 90cbc0de4d5bc..c2bb325ba531c 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -99,6 +99,8 @@ static ssize_t platform_profile_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { + struct platform_profile_handler *handler; + unsigned long choices; int err, i; /* Scan for a matching profile */ @@ -107,16 +109,29 @@ static ssize_t platform_profile_store(struct device *dev, return -EINVAL; scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) + if (!platform_profile_is_registered()) return -ENODEV; - /* Check that platform supports this profile choice */ - if (!test_bit(i, cur_profile->choices)) + /* Check that all handlers support this profile choice */ + choices = platform_profile_get_choices(); + if (!test_bit(i, &choices)) return -EOPNOTSUPP; - err = cur_profile->profile_set(cur_profile, i); - if (err) + list_for_each_entry(handler, &platform_profile_handler_list, list) { + err = handler->profile_set(handler, i); + if (err) { + pr_err("Failed to set profile for handler %s\n", handler->name); + break; + } + } + if (err) { + list_for_each_entry_continue_reverse(handler, &platform_profile_handler_list, list) { + if (handler->profile_set(handler, PLATFORM_PROFILE_BALANCED)) + pr_err("Failed to revert profile for handler %s\n", + handler->name); + } return err; + } } sysfs_notify(acpi_kobj, NULL, "platform_profile"); From patchwork Thu Oct 31 04:09:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839885 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2059.outbound.protection.outlook.com [40.107.212.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C223513B2B4; Thu, 31 Oct 2024 04:11:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347891; cv=fail; b=ffjS2nycfOg4wwmeZ/zG4ifmJT19KGM+q+3lvsn/rkBMAab0RFS5li2UTa2DflWmcDGj0g/gJ5XQ7EE1ANGKO0YsLPsAj6b+W/LCGYs5Fr0bILh71Qr7eYWiWJfKDcBo2If1zQjJbdNW2k0OIXnVMS3P+jSvsKG9ylMopHz1W7A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347891; c=relaxed/simple; bh=OYjck0t5lChXtVOi739FYh2KJY2cGMLR7AjODyNcx9U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QnvWLrpdqH/DtUUulIKvOGugftTt8bG9J04Pu+/zOAzMZGTGwwBkA76qg8Rc+alxYnj6+6YkOXVHhuF1RHPUHz4quZcWEje6FGfnTpQcKuG2fhrfVaDrGljI6UMt0g65I/ikcboGwfXLChy9cTqZQc+jCf9e7mhQGEqBB0WXH1E= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=fXNUWLTG; arc=fail smtp.client-ip=40.107.212.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="fXNUWLTG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x4TJ7N+H5Db0SZQnQ7Un9YMq1rARJtv299QC3+sbN6oQWI7hovboKbqXjaGKM6g/eKMFDr2qMx+X/BBVI37W5tNf+nMgrYa+/5k6KzsWXgikrCRAJs57QO2m4j/2N4SCKDxrIl4McY9g2r0uQDJ4NLbhqxkjXNtEn2vvb3WkMGbe2KpX9GJlhSI7p1kV2Opso2Gp2verXtjP8MtT3PMbFsSq201ef3OQjrewS5uaqyZ66pGONGBT7/IgJbyx1njlEnkX5ERzgCY0jYrEu6FZKkIaHExumycrXjjjoTRxi56n9vp8hqfJywXPGZfCRtYim8d6cI2pkloCfaouhslYrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1BHOmBpCMLd2UWhz8UzPz+xuXGm5140wW5a7FSkKKrk=; b=QMvCMgnxxsSPZ/51IUsp+xWtJjrgbaVXKIZ/StQJvVva2hHn7tcsRHK7BUFNWC73JGqVbZvmn4QqZiLKWf8UHyOm2EuS+jFcp+vz1bRvpUIVii8iw2Hc1nGQM00NoNFAscM9NlcPvEYeuYI+zI/02+hbiFYCwTzvKyiH+EsSHM4a8m793GSHCY/VDKtFhg1peiqbB3H/vhjDmTNE4nlN/ucGhM/yYR9y1iEMNNpYn5hIX8Lgxrqn7psZl0qUsyga/eZiq/iPzEC83dFhRePQ0Vcs6b/j4HiwpF1HzY6xB8STs41glbwxedKPUrNnXKgSw7ftrTRonlf7d4igR74eqw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1BHOmBpCMLd2UWhz8UzPz+xuXGm5140wW5a7FSkKKrk=; b=fXNUWLTGYpHTXAz1bs6gnYa3h+OBwuuUUiNTwewmoxPOBspDXvfeaEGcMcG7CeOY7j8yIpagWXegnRJxWhGrj5dYIKgWBZeakDvimTyYqdrNp8LNkNVAjT855J3Y465ZLdCXAzbDLzWWa0Zz95trpixuTwj7+rknhaid6slxOx0= Received: from PH0PR07CA0058.namprd07.prod.outlook.com (2603:10b6:510:e::33) by DS7PR12MB6069.namprd12.prod.outlook.com (2603:10b6:8:9f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Thu, 31 Oct 2024 04:11:25 +0000 Received: from CY4PEPF0000FCBE.namprd03.prod.outlook.com (2603:10b6:510:e:cafe::fd) by PH0PR07CA0058.outlook.office365.com (2603:10b6:510:e::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.31 via Frontend Transport; Thu, 31 Oct 2024 04:11:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBE.mail.protection.outlook.com (10.167.242.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:11:24 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:11:19 -0500 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 19/22] ACPI: platform_profile: Check all profile handler to calculate next Date: Wed, 30 Oct 2024 23:09:49 -0500 Message-ID: <20241031040952.109057-20-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBE:EE_|DS7PR12MB6069:EE_ X-MS-Office365-Filtering-Correlation-Id: 692e7e49-a65d-4145-83ed-08dcf9621644 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|82310400026|7416014|1800799024; X-Microsoft-Antispam-Message-Info: anXxWTWYt72qvS/TR24MBR1AC+R5j/ILRfuCty15EAXxU3wUBrJfkaW7osTkGJAU85bNMp6zIfheS8hI1IFm5FWbd/4pYsmYLlUX30QyLCHCWHVVLPNVRgZ5BlCqQPTTxWd919+PgQFElSRuDK2U3nuGeuJq01jsqMdmedLrFjPXsJoqdh8XMU4s+UHxpqxjfWmPViR6UfRMfpRPaDvnEwk3cPtgKteS5Du2F0bIpNoLobXvfdpj0VAQMBZgPB/7IZwGdDcH2U336Gr3u/mOItPeeV9rPai1HwdasjEXVs23v+rt+YSO2vne7Zf16Dnd6fNq62a8gmDGr6Oe1Mhc4f/AGhHVJs0Oh62kOl7kNkRYaNvpKYRtAWHmUCCyc4+XYWASLbei+KDhzeDw+14ObB/q58FXxZvEwolXmE7iat67fhnRomRnJjraLExDnDMXOzevFd2ntYyz+yGtMUqK9RXJ7L//WvJDOJSB+EEstGUwbTW3LK8VEq7jDqfWgFiBaNJMqCO2T43jjmF1nQLzBfkOMlyXpSzh3PnJxkBtzdLugkX4sCjOWQkYOsRkWBCyKf6GGDJG0yrSn8Laqo/wj+O6tvegIK1hZug/fvusQQ37bLFFHNSpNNuFMzzHJds8SGIiK/2OSeRypqH3vEBp8yBJsTyrw4uaM9RnCss6H56c/pE7u62hhV4hBqjvn9LYUlCkiWc3UA3dJGbJ3z7GYeUrPPx2nyNHgl6fn1IjDXyCV8ZEO1jVkAUdNXEDBq2/9ODLMLldA2Qigk0hrFtQfSkf/Nqv3dJpO8wdlsnzJeUCDvIBlQ2IMWABCbA98f8nPaDJrYXtRWnEr6ksn0c6YuPDhyGpVPONyMev7Ja+QcKFC5F2EsEvP6W6iNly/sWaY9P3XoQ+Wz9WGepCxjTgCYyg12/UYeJr1ZI6RD3i9gWvZtEFrR9lIBdBlBtbGfMkg8O8EKYGTM2QBdB1vqLciecPdOlBD8p2NjJZrj0OtQr4/iL9W1hK4QaSP5OCy4QrDzveFdpXxlFyguVtVX4rDyD+FGw5QNjLI9fiGtEn9vWmyoedrtoZTUF6WDEolyjNxnKbGztpiLi2gecfBUTp2NmJNFP4FJ/271m+raJhi7BwsAm5zqWOc7BALKANdENJCWSSww2Xi7eurzG4y8C1a48jWIptYDkSSPoTY8gJtgCBU9uOTWhpYPfrOYCep87fUvf642+XfkEB+8Scnce+Yj54jbQQIo2E8urtemkv9TxlNmABJ472fBzThmp0scOIBlOTGU/6TOOtgLI8/i8PKs+r8WhUmlvHxk8el+0IOusu6EuIEy7RR09wJAiL7VL0QkCfK7hc+jXs4hhgsMELRf8JUK3zZgIrzmNmjfphkU7zgx4zZ/PVz+mRv+GcUq465HyfpsOUF24KG81a8JMUsA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(376014)(82310400026)(7416014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:11:24.8592 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 692e7e49-a65d-4145-83ed-08dcf9621644 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6069 As multiple platform profile handlers might not all support the same profile, cycling to the next profile could have a different result depending on what handler are registered. Check what is active and supported by all handlers to decide what to do. Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 35 ++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 5baac1f9a9c0e..9b681884ae324 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -187,30 +187,41 @@ EXPORT_SYMBOL_GPL(platform_profile_notify); int platform_profile_cycle(void) { + enum platform_profile_option next = PLATFORM_PROFILE_LAST; + struct platform_profile_handler *handler; enum platform_profile_option profile; - enum platform_profile_option next; + unsigned long choices; int err; scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - if (!cur_profile) - return -ENODEV; - - err = cur_profile->profile_get(cur_profile, &profile); + err = platform_profile_get_active(&profile); if (err) return err; - next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST, - profile + 1); + choices = platform_profile_get_choices(); - if (WARN_ON(next == PLATFORM_PROFILE_LAST)) - return -EINVAL; + next = find_next_bit_wrap(&choices, + PLATFORM_PROFILE_LAST, + profile + 1); - err = cur_profile->profile_set(cur_profile, next); - if (err) - return err; + list_for_each_entry(handler, &platform_profile_handler_list, list) { + err = handler->profile_set(handler, next); + if (err) { + pr_err("Failed to set profile for handler %s\n", handler->name); + break; + } + } + if (err) { + list_for_each_entry_continue_reverse(handler, &platform_profile_handler_list, list) { + err = handler->profile_set(handler, PLATFORM_PROFILE_BALANCED); + if (err) + pr_err("Failed to revert profile for handler %s\n", handler->name); + } + } } sysfs_notify(acpi_kobj, NULL, "platform_profile"); + return 0; } EXPORT_SYMBOL_GPL(platform_profile_cycle); From patchwork Thu Oct 31 04:09:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 839884 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2080.outbound.protection.outlook.com [40.107.236.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33278146A6C; Thu, 31 Oct 2024 04:11:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.80 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347892; cv=fail; b=uwKHwpKi8ZtOb9yRBZlZe02ru+fqdsWdPdMiENsKUvyegfTaRg4gs9zzcc1lnbXpxI8WS7VramgOqpopeYxHd5wmAokLWli1jcXgDtBkZCPlIbk9lP7Na4qUOA5LZl04yDiGaUWlyq0nB5imD748e2OGXqwQg6K+l5ouVgHF4M8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730347892; c=relaxed/simple; bh=ASgI2mf+wn+56shboFohC1GXeGNgqkK7PrRqtaLk6a8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kO4UT5TdM9By14SW2oyy3ZYqumARW5X05OcrZHCtpXPGAjJPDvuhAFfn77dMQ58cbduQILP+lyTL9fNNMWlC0ldF4nlUEZbmaOXNr0tpPjOEtHy6T030p+ZHaGIrgl/tSyAlr4FsS84UJaRch3w7Mlp7FeNCWds/UANXrtGTNUo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=spXwOoiJ; arc=fail smtp.client-ip=40.107.236.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="spXwOoiJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nUkwvJUVqtRbuGKookuuab3C5xfW0Ouefnp4/GnDQy0gNMLEEJDBfqcxekhJpVNlygYuulSUu6tErUPFQX2RT2g34Ps4XP5kGyjvaneWg6S5tWnq33NOVq4qN7lR5uEKCodfClgBM6D/eQ265KD86DNBUnn9YFOpguW7Hx1lWMNVEZxj9/yQZ2iKEtkSC1tKZLgjmXVC7HmvN6nzD+XgQmnLW1e/L0orEOFimKF7NWOAYIs9cO0taAqdro8n5HlCbiATy8cZ/pjP5cTvOm/pd1+9tSYIdDkwdSrJYJB3Uds1NDdMrz5SFj2ihtLtczZ3EhbUrz8WkEb+7O0rAnMSrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hQFE8Inguc1AFWBccMNoWw32J5ynjV70yDTo8C2otig=; b=TDcJuzWWzixnbVcxGkSmIz/BZfJ/hS/2tBLbU4JT4EQFWtuJsklUXBU+ZLd9LSOO0JsMbGRMoaokUusekl/B53siJI3wQUXQ3Rf+NcIdNCpGcAmdWChnfx7ufX4c2rUvmNQtD67zQjXh6sIuQKSE7TWYRzWx0YctE/4DVfWd42e1aKfiKtUDPF3mDQG3U0gTpnjVtHgYqbxrN6TvLR+gmHCtb6tlqx84HwOKl/8eZuCO41Nc1JZBa3EVGhefaCE7wlB4AZUG973iQVOjchCfaYiQf3P6aDtB3xvZMbAFVl03p68wXrukoqvEBbJJ42gUmxT4Y/jB2v9wll7YefeHPQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hQFE8Inguc1AFWBccMNoWw32J5ynjV70yDTo8C2otig=; b=spXwOoiJ2OHl/khhlODrsK82E+NhhFkce8Fp+qqv9Pl3lix2OFjZmU0gMwmh6XTEQCHQ46z9tpWQD4o5w49YQYWqegnc7yPDZXza+e4+tM1PVbfY+SqxYtcjO3Mn7ZK3afAQPAIVFdhyk3UzlNcAltz9zZRJUv1X3Tp30ipYozQ= Received: from PH0PR07CA0039.namprd07.prod.outlook.com (2603:10b6:510:e::14) by IA0PR12MB9012.namprd12.prod.outlook.com (2603:10b6:208:485::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.18; Thu, 31 Oct 2024 04:11:26 +0000 Received: from CY4PEPF0000FCBE.namprd03.prod.outlook.com (2603:10b6:510:e:cafe::b3) by PH0PR07CA0039.outlook.office365.com (2603:10b6:510:e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.20 via Frontend Transport; Thu, 31 Oct 2024 04:11:26 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBE.mail.protection.outlook.com (10.167.242.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8114.16 via Frontend Transport; Thu, 31 Oct 2024 04:11:26 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Wed, 30 Oct 2024 23:11:21 -0500 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello Subject: [PATCH v3 20/22] ACPI: platform_profile: Register class device for platform profile handlers Date: Wed, 30 Oct 2024 23:09:50 -0500 Message-ID: <20241031040952.109057-21-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241031040952.109057-1-mario.limonciello@amd.com> References: <20241031040952.109057-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBE:EE_|IA0PR12MB9012:EE_ X-MS-Office365-Filtering-Correlation-Id: bd320fb9-b846-4778-4169-08dcf96216e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|7416014|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: eo+Xlb0PN1ZjhfnJCPPiWgGFJ4GdfzX5oBOPMROEBnONYP7um9vTZ85BHUDch6cSuDJdVnAETjFuRVFDLo7Nh0krErYKzf8RILTM+DmHxaYjOn0d0Z1wXxgXxiAtPG7tdKM2xpmD2/isBrTp+iP9923ZImIG0jvQIooSkLs5AfSfjBLQc4IdnfY/dikKLpdSV191qjPaW5yWbhMSAu/PFOviUMbidZV0DpD1BZ3Fb8gMd+HyPzzxp8fEm0CiAJL4VhMVhZfLPudCkXxXAQUKV9XZGoQQHx0p+iS2T1LT0+8jjqdXy64rDoAIxYS6mOHsi/e/Tqn6JrAXsTmqfeL5AFTQX0fVffkCnEUp34zG/YMjegXQqZ37RjmfD/gt2FH/lXxIbPijwzMtgl9uPs/lsWm7uJrQXiTgSxDWhfFdk4htcnSoRLrKq0jtJtL3BkE7tYgk/95mNdUBmQtH2mUWf1hVS0FyuNnfGrb/n7fSKjiqOQ81pw6j0J72nlS1FUUJA8C0K7DLDUiZYZ8eRDBc0Ks5VHD5EyaLP+HB4W2xJSDqVDfmM2E9UhG7GrAr6OCM5nxPTneefAhe6ZJprIZXzbxIAhOkxepSsKW6/Wd/gX2qqvCAER7WfA3NyUZT9RTyctqgLc5iD1GYEAF6gQcAmZZCUzyn177ikfKfld7rCpNAcf9V5dvKlh5ZKv+jTUNRrUgBFeY2mN3sGmXoUP8AW3j7dkxxY5eBglJPQRmLhptxTfO+nqGzcbZyHmBSR1eWvYRM4J8mI1CH9La35XWXASCuYEUwi59/xWnvKXnox8f+dcUqBNZ90sm+viFyWVcx9pTa4B2GaWY3KigW+DBQRzJyGA/eaJNIZTu+CxBksuRBvBkHgQt4hEVts1e/dctVvpwKGjOAtgwqFecACS/MSZWyRNumVDu7toLMWkzbuslV8VrsJ4KajTJM1iHpZc0xxAd6F9Gsj/UqDZlOMh0L2QON25PUP9lYwKGnZyB9FlAoQx+wsci18ocEehpVljxb2oeKpvuJd/Xzo4yt+D/eF6pP8blmTqJQ4Y97Iwp1K56gGpm9q05k9LICpO0xlvcfU7hUK5eSIlvG7LfkitcXXq4T/AnOqV5U2Hao6gYutc9OyThgqyTOdl9CMFqie6jpeAvRaTnCGd51MhxTCaCQWdDLFa9k4HZkchvosNWJcZFxrtXk4T2ZI9zJTim5ehYxslOl0nx5UsyuY4nxKXITMScQKRPm0jRuMSbMqcpxe/dqW7Kh3aNJzDJFJjsAgGZDVhzeBdnQUPNhSBsNHfWdcqt9YiWlGQIDdUWhjn2+939Whb1LBry1GrtzYJM/gNaqWXdwhtpAmmPHf1qu+K7qamI6PEt9gkLAAdLR/hLSzhmSTNCKSUJEifAf9UgGFacU5faEotejGuAvWzgpcz9NGw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(7416014)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Oct 2024 04:11:26.2655 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bd320fb9-b846-4778-4169-08dcf96216e4 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCBE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB9012 The "platform_profile" class device has the exact same semantics as the platform profile files in /sys/firmware/acpi/ but it reflects values only present for a single platform profile handler. The expectation is that legacy userspace can change the profile for all handlers in /sys/firmware/acpi/platform_profile and can change it for individual handlers by /sys/class/platform_profile/*. Signed-off-by: Mario Limonciello --- drivers/acpi/platform_profile.c | 93 ++++++++++++++++++++++++++++---- include/linux/platform_profile.h | 2 + 2 files changed, 85 insertions(+), 10 deletions(-) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index 9b681884ae324..1cc8182930dde 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -24,13 +24,24 @@ static const char * const profile_names[] = { }; static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); +static DEFINE_IDR(platform_profile_minor_idr); + +static const struct class platform_profile_class = { + .name = "platform-profile", +}; + static bool platform_profile_is_registered(void) { lockdep_assert_held(&profile_lock); return !list_empty(&platform_profile_handler_list); } -static unsigned long platform_profile_get_choices(void) +static bool platform_profile_is_class_device(struct device *dev) +{ + return dev && dev->class == &platform_profile_class; +} + +static unsigned long platform_profile_get_choices(struct device *dev) { struct platform_profile_handler *handler; unsigned long aggregate = 0; @@ -40,6 +51,9 @@ static unsigned long platform_profile_get_choices(void) list_for_each_entry(handler, &platform_profile_handler_list, list) { unsigned long individual = 0; + /* if called from a class attribute then only match that one */ + if (platform_profile_is_class_device(dev) && handler->dev != dev->parent) + continue; for_each_set_bit(i, handler->choices, PLATFORM_PROFILE_LAST) individual |= BIT(i); if (!aggregate) @@ -51,7 +65,7 @@ static unsigned long platform_profile_get_choices(void) return aggregate; } -static int platform_profile_get_active(enum platform_profile_option *profile) +static int platform_profile_get_active(struct device *dev, enum platform_profile_option *profile) { struct platform_profile_handler *handler; enum platform_profile_option active = PLATFORM_PROFILE_LAST; @@ -60,6 +74,8 @@ static int platform_profile_get_active(enum platform_profile_option *profile) lockdep_assert_held(&profile_lock); list_for_each_entry(handler, &platform_profile_handler_list, list) { + if (platform_profile_is_class_device(dev) && handler->dev != dev->parent) + continue; err = handler->profile_get(handler, &val); if (err) { pr_err("Failed to get profile for handler %s\n", handler->name); @@ -69,6 +85,10 @@ static int platform_profile_get_active(enum platform_profile_option *profile) if (WARN_ON(val >= PLATFORM_PROFILE_LAST)) return -EINVAL; + /* + * If the profiles are different for class devices then this must + * show "custom" to legacy sysfs interface + */ if (active != val && active != PLATFORM_PROFILE_LAST) { *profile = PLATFORM_PROFILE_CUSTOM; return 0; @@ -90,7 +110,7 @@ static ssize_t platform_profile_choices_show(struct device *dev, int i; scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) - choices = platform_profile_get_choices(); + choices = platform_profile_get_choices(dev); for_each_set_bit(i, &choices, PLATFORM_PROFILE_LAST) { if (len == 0) @@ -113,7 +133,7 @@ static ssize_t platform_profile_show(struct device *dev, scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { if (!platform_profile_is_registered()) return -ENODEV; - err = platform_profile_get_active(&profile); + err = platform_profile_get_active(dev, &profile); if (err) return err; } @@ -138,12 +158,22 @@ static ssize_t platform_profile_store(struct device *dev, if (!platform_profile_is_registered()) return -ENODEV; - /* Check that all handlers support this profile choice */ - choices = platform_profile_get_choices(); + /* don't allow setting custom to legacy sysfs interface */ + if (!platform_profile_is_class_device(dev) && + i == PLATFORM_PROFILE_CUSTOM) { + pr_warn("Custom profile not supported for legacy sysfs interface\n"); + return -EINVAL; + } + + /* Check that applicable handlers support this profile choice */ + choices = platform_profile_get_choices(dev); if (!test_bit(i, &choices)) return -EOPNOTSUPP; list_for_each_entry(handler, &platform_profile_handler_list, list) { + if (platform_profile_is_class_device(dev) && + handler->dev != dev->parent) + continue; err = handler->profile_set(handler, i); if (err) { pr_err("Failed to set profile for handler %s\n", handler->name); @@ -152,6 +182,9 @@ static ssize_t platform_profile_store(struct device *dev, } if (err) { list_for_each_entry_continue_reverse(handler, &platform_profile_handler_list, list) { + if (platform_profile_is_class_device(dev) && + handler->dev != dev->parent) + continue; if (handler->profile_set(handler, PLATFORM_PROFILE_BALANCED)) pr_err("Failed to revert profile for handler %s\n", handler->name); @@ -194,11 +227,11 @@ int platform_profile_cycle(void) int err; scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &profile_lock) { - err = platform_profile_get_active(&profile); + err = platform_profile_get_active(NULL, &profile); if (err) return err; - choices = platform_profile_get_choices(); + choices = platform_profile_get_choices(NULL); next = find_next_bit_wrap(&choices, PLATFORM_PROFILE_LAST, @@ -228,6 +261,7 @@ EXPORT_SYMBOL_GPL(platform_profile_cycle); int platform_profile_register(struct platform_profile_handler *pprof) { + bool registered; int err; /* Sanity check the profile handler */ @@ -250,14 +284,49 @@ int platform_profile_register(struct platform_profile_handler *pprof) if (cur_profile) return -EEXIST; - err = sysfs_create_group(acpi_kobj, &platform_profile_group); + registered = platform_profile_is_registered(); + if (!registered) { + /* class for individual handlers */ + err = class_register(&platform_profile_class); + if (err) + return err; + /* legacy sysfs files */ + err = sysfs_create_group(acpi_kobj, &platform_profile_group); + if (err) + goto cleanup_class; + + } + + /* create class interface for individual handler */ + pprof->minor = idr_alloc(&platform_profile_minor_idr, pprof, 0, 0, GFP_KERNEL); + pprof->class_dev = device_create(&platform_profile_class, pprof->dev, + MKDEV(0, pprof->minor), NULL, "platform-profile-%s", + pprof->name); + if (IS_ERR(pprof->class_dev)) { + err = PTR_ERR(pprof->class_dev); + goto cleanup_legacy; + } + err = sysfs_create_group(&pprof->class_dev->kobj, &platform_profile_group); if (err) - return err; + goto cleanup_device; + list_add_tail(&pprof->list, &platform_profile_handler_list); sysfs_notify(acpi_kobj, NULL, "platform_profile"); cur_profile = pprof; return 0; + +cleanup_device: + device_destroy(&platform_profile_class, MKDEV(0, pprof->minor)); + +cleanup_legacy: + if (!registered) + sysfs_remove_group(acpi_kobj, &platform_profile_group); +cleanup_class: + if (!registered) + class_unregister(&platform_profile_class); + + return err; } EXPORT_SYMBOL_GPL(platform_profile_register); @@ -270,6 +339,10 @@ int platform_profile_remove(struct platform_profile_handler *pprof) cur_profile = NULL; sysfs_notify(acpi_kobj, NULL, "platform_profile"); + + sysfs_remove_group(&pprof->class_dev->kobj, &platform_profile_group); + device_destroy(&platform_profile_class, MKDEV(0, pprof->minor)); + if (!platform_profile_is_registered()) sysfs_remove_group(acpi_kobj, &platform_profile_group); diff --git a/include/linux/platform_profile.h b/include/linux/platform_profile.h index da009c8a402c9..764c4812ef759 100644 --- a/include/linux/platform_profile.h +++ b/include/linux/platform_profile.h @@ -30,6 +30,8 @@ enum platform_profile_option { struct platform_profile_handler { const char *name; struct device *dev; + struct device *class_dev; + int minor; unsigned long choices[BITS_TO_LONGS(PLATFORM_PROFILE_LAST)]; struct list_head list; int (*profile_get)(struct platform_profile_handler *pprof,