From patchwork Sat Nov 30 14:04:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 846308 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2054.outbound.protection.outlook.com [40.107.93.54]) (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 01E3519EED7; Sat, 30 Nov 2024 14:05:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.54 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975535; cv=fail; b=hWGhQmY0W9AYgUB7gl1qy6W989cFU/k80fQNCXwrqbFWlPX9VgpINF7BlQqswie7eEQ4GHKJZH7jrkXcPBDCoqnUISse8SD99nmXAjSGOSsmTms0f1zTIty8rqSaVMLn067S+xnvr6XRs3xRWrghn5rujHEiYzJvo0iiLPVoi6U= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975535; c=relaxed/simple; bh=DJ7yecRfFdjZ6h4DsR/Q0ETjDidYjDcuSCiQNrFW6tk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fYbE9hlDMRCY0OKxKJEI4izNW5uBqucji03f70zjDBJ/ySsqzP8FsT0cMxqaWHc9yJt3ShRf+2AMsdkF9OWlnj3Wyy0zWX76pKSoXNisweSLNHd5yPruPBcLo5x/T6J/qyUOKZ1A8dJlPzzTDtPdF2xAA5rJRlyQGakCHTDP5NE= 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=bw68iHDI; arc=fail smtp.client-ip=40.107.93.54 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="bw68iHDI" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Js26h+H2TNLULl3QV1yA5ukZ/xRwNTEEedbATM1R8JUL4auWqx5QBzPwCGu+7Kf+YXlwYd6VEbT4PaZYW8Z+/0+V0RlnpqrJGyMNqlqn7V0R0A3LYxuUU1iHGcyGsvSljy3uPob4oZqhi9QxLFTkuXNBTYqGdVELcClfZ57a78ZSS8n/v8KxE0Rbxyo6F/c0aeVUynAGIwApRhfpxBkykFYDYlNwQEciDDDbYyojsSo9SGHtaG6rSrt85HiN1tbhWZfZYAcHGfW58XtGWs3CpEefDplCL386Bpu49lKn0WGjli2FlyIE++Ckb8mUzgRbTEHjhUSfc8vNONtlTSEYEA== 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=ARvH4Vt/K8c944FfThFOJb4Ly2SmZHct8fdk8/8lZ4U=; b=aeoT8zyvBee6BjA5gyKbC5ZS4rfPMQrX5h7zhXdqAsTd6sp49XpZpCxxejcQjiGGf1O/km+jJn9KSKkPf5UEQo2An6maNPASS5hxvKXOFl4H+xGJHJdZz44MIrnyg/FkxtODjEr3DHrbBXBwwJdQrHcHybio7uki9TbrOV3NQOewiEfUzv7iGOSFpl/QrtyAArKW5ckPXTD4PXSHlq5tw5du5XHYeEwxyVSEhigX7CMdwlkGjidITaHtsVBOkXQf0Cym5QmL+EwwHInurTHiIXnm4g5ZBLjK0itSS1axSaKtBbpKx4wYJpS+wMjlJHvMC4rYyH9nzaRyAtV1yAxvHg== 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=ARvH4Vt/K8c944FfThFOJb4Ly2SmZHct8fdk8/8lZ4U=; b=bw68iHDI28AnqCIedAJOYE8M+0NsROoHXJ24eg+yKWlG02kFrr33jRH8koP0QRIiNvxEQLcmGyFHKbmXmLUTO5b1Q1EvK3eBjpZ7eGndCJIDPl1EHU6DyRZz+pzML056viUMKPGbbiXeVINF+iQMD9LvX+lDjpX2lLO2UgDQZbw= Received: from PH7PR10CA0004.namprd10.prod.outlook.com (2603:10b6:510:23d::22) by CH3PR12MB8711.namprd12.prod.outlook.com (2603:10b6:610:176::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.14; Sat, 30 Nov 2024 14:05:24 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:23d:cafe::51) by PH7PR10CA0004.outlook.office365.com (2603:10b6:510:23d::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.16 via Frontend Transport; Sat, 30 Nov 2024 14:05:24 +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 CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05:23 +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; Sat, 30 Nov 2024 08:05:20 -0600 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 , Armin Wolf Subject: [PATCH v8 02/22] platform/x86/dell: dell-pc: Create platform device Date: Sat, 30 Nov 2024 08:04:34 -0600 Message-ID: <20241130140454.455-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-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: CY4PEPF0000EDD6:EE_|CH3PR12MB8711:EE_ X-MS-Office365-Filtering-Correlation-Id: d8dc0dd3-393c-440c-c280-08dd11480867 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?6Nhr7U5n4j+kntJDAz3sVLSRkU+UtXW?= =?utf-8?q?ykBde8Ya5PUFaaxjztLZpdWsNQQMWba8zkARcZLC3sBrK8xFrLpbVZV9bBLtYTt5p?= =?utf-8?q?TASqz32phpkZvDq9v5dACD2+Hs9ok/KUfR3lruFakG7BMJ6UjpAJnhTgLRA+onO/Z?= =?utf-8?q?oZscioH31OWfA1EXX9EPgTzVfH7+1Fsd1GYRB+2p29JK0Pu7TYYz/+YmyhyINbOdO?= =?utf-8?q?mJLNWwowM/mS5PkUzlShEQ10SvjKCMpcekaSrqcAKxp97WYHkeM6T+Gkqlsarm+ZQ?= =?utf-8?q?5m4LFSG0rhBWvWw8jlM+MckcrIvOKq+mEMMtOatdZGx10AOprBSjLWofckKuCI4Lw?= =?utf-8?q?dyA/bZGTuuYhIaKmeUQxWHsyH4OtDf1kK12mQSLuCI3AwQavf0P9e+P+8maSdra62?= =?utf-8?q?6P9V8L1aX1MJJX5LaPnv1lURCe1WAngRgzMzOtu4h8BHoIkJRXT+AGff47DiMjitT?= =?utf-8?q?bRrj371tYUNMDlNjBIXT3l5l+P/DJmVUSifI0iUmXJFJP1jLDseFrBzLiVJgeTibW?= =?utf-8?q?q7fiixPeZvNmQYsPXJmHXOJkUpePvSjjRX6FJsoCqYoGTlNLnfsn4Ef/XkK3OC5g3?= =?utf-8?q?lSydnEjBTuEayhsjXMB6k28vG3vLjVwSHpdlQ/gzGiQQOgyucrI9f8I1mJAiJddtJ?= =?utf-8?q?dIRvw7ryrfbJOleZcdccCmOhy4foCD0raGG+5/Hxkhi4Zbh8Fu+dqQwZf3/1b0ZAA?= =?utf-8?q?muL70R67D/iBhOshtkscZ5RG5idlR0pMD134doQec08ZdqnBOygGaREt8ge/T3E6r?= =?utf-8?q?OPJZWna4iA+NBNqJ+gDkFozJWHZOqbyj0H9lVxj8N3cQXtkK6CvSc2z/kOy5P1Tyx?= =?utf-8?q?S4+LFpHX42cUFRTMtH3u7qJS0SSdTKvEx/H6r3QzvqAI/5+GZp2QqG79mNShNRqYs?= =?utf-8?q?toqeqF09NJbbVm7MHEApJNnIKuVBEB6XZCTOYFaoSjtQStc1lspijhQzq2q6OPlFB?= =?utf-8?q?z3CRv7hCvU6D5wtcpkPU9QktVN9IhZjepMGmPE4XegmKZj/mbsJDMab7RVCBE0Ulv?= =?utf-8?q?nQDA0UImsnHqKYnKWo3sHI5bwRXJ2MtW/gC/52gwjccaksS/xPErrpaGYjlxEmP1i?= =?utf-8?q?Glf8D1abYBilqg19pjP2quFyZCu5pphOv6RKWFkvNMeUUBEFWXB1f2LoRsRoa/6ZH?= =?utf-8?q?JAnoCaBcQVV5q31fvRyAPGhpm1Clcb3RBs+2msLlbffHPMpUIADQ5MsiTcu1xjQKE?= =?utf-8?q?CBQDZk83++tq7zYBKGW6mRrv/OembV1MbbN6kzhzxvEMoAI9B5iap1JcQKH6sMgCJ?= =?utf-8?q?QZzgnAIfrrvRmX3hftFCGoekoC1YgkREc25hmsv8VVDtcRMVfzlBQat7TPtMjo6xD?= =?utf-8?q?LkjPHni9qrTDgGhPBf9JbMmBRhlECcksOfFphVQ3b34AZpOIFBH+vL9Zsi+TQ+EVE?= =?utf-8?q?7UqaKN2cpP5?= 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)(376014)(36860700013)(7416014)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:05:23.1094 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d8dc0dd3-393c-440c-c280-08dd11480867 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: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8711 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. Reviewed-by: Armin Wolf Tested-by: Mark Pearson Reviewed-by: Ilpo Järvinen Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello Reviewed-by: Armin Wolf --- v8: * Use IS_ERR()/ERR_PTR() --- drivers/platform/x86/dell/dell-pc.c | 34 ++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/drivers/platform/x86/dell/dell-pc.c b/drivers/platform/x86/dell/dell-pc.c index 3cf79e55e3129..8bacbde0f0506 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,15 @@ static int thermal_init(void) if (!supported_modes) return 0; - thermal_handler = kzalloc(sizeof(*thermal_handler), GFP_KERNEL); - if (!thermal_handler) - return -ENOMEM; + platform_device = platform_device_register_simple("dell-pc", PLATFORM_DEVID_NONE, NULL, 0); + if (IS_ERR(platform_device)) + return ERR_PTR(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 +271,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_unregister(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)