From patchwork Mon Dec 2 05:50:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13890016 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2051.outbound.protection.outlook.com [40.107.237.51]) (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 47BA01F8AEA; Mon, 2 Dec 2024 05:51:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.237.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118697; cv=fail; b=CJp8P/BIvKQZJJVAIbZdQ9DXEzo5Fcu/L9IaW39ak8Ry/vwrafu48MkHU84we1PilJlcyRQ10qtIqLL7jLGlqoJzR/I52WpQm8vdkHmaLPTB7ZA3y9pRFIoby02/jHJM5aHJPMb11iZq//QLkohL20NaSE+SxJCGyYVIHCQ/VR0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733118697; c=relaxed/simple; bh=7FR0mS053av9fSakTvKuY8cLkqdOo6I54zrt7+qryVw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZDS9M4sOfNxDITexWFd61uNsWB/9V0zzkQkEAwT30xBU970cCMEQXyfh1lhfAf2nhJ7I+4sr0bqwIP2fEkuHc6UzjmQ25AwxD+USeVndyPeseeq19zOJCzR+u7s7BngI+oTv0qEiC7txkOFrU89IiaL/bef4AzLrDu4EbLoroZs= 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=OYe77kvQ; arc=fail smtp.client-ip=40.107.237.51 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="OYe77kvQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UVZtTWwmSVd/KWP3e9OFfSds5CT3Nlyfo080P20t181k8e6mVwzhz5O7V94v+HS7CX/CtLnmYfAWy7k9ek4r24wraDyxq5IAc1K5y2upS42rstc0KJecS4XmaCwqMgjjfYNNnKbhpSbpvobOshRsFQuJDdwVW1I2Z+FUZwZfB6zMiAyDUMnQ5ahMGl0hClWMh2U6h6QjDCHsbFWzAAWxL1mXGzt/CFnPEdPXVjI0MnmiNcSedgC2feF9h21QXLhxwuNe8fS9VpWqA4qBLAl4KKUB9V/p3wQLRCV88AVs5BYgTcdphCcGYfot7GK+ZikgG29wJT40OdJkyMkWylTkMw== 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=HO5D+drA4qa07bYVA6TrUgo8LFJF1qHTIg2teKV8f8U=; b=G1R0UOwTAfWI7xukgS5jYInJymQlzco/5HbffCPy4Gtg9bDhKrdFNQWdbmmqpH3qt/4k107G0saqzP9JPnTAro9m003d5Rl/gwSpzhpXgsX4TlVigXfdtrBGjFpAvW0Aqe1Utm95QolAwH7e6OFC1ho/7M2xv6J7O3rdwBykbmB7oEpMoJiIh+/7IBWSuOJulOKsC3tbpvaKrf8+tX/XHotMlaKfO2QnYXOFpe42topN+hUseTEfkykf78qPKZrC5qcam4xSrfqb/Ss/x1Yjhicz9bfzeKECtnsIUGDvhI8i30pyyqOFLo9JgPgRh76/Kls8zYQ+PTNoUIVsn3GtuQ== 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=HO5D+drA4qa07bYVA6TrUgo8LFJF1qHTIg2teKV8f8U=; b=OYe77kvQiE9Ne+ds0SsPTilxy3d7sqNsRsO8DgsOlfVxx+MIgt/DKaHr29LTOuE7cJJ7ajWpijJ6w0WTQToFeBXoVGjCc1PEBX4AMWNRLZTokzERqTPBub2QXGEDm3nkrKdF8oZn6aublfqjtiGRkENIrrnvnLs4t3MaBUohTEw= Received: from CH2PR16CA0006.namprd16.prod.outlook.com (2603:10b6:610:50::16) by SA3PR12MB8811.namprd12.prod.outlook.com (2603:10b6:806:312::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.19; Mon, 2 Dec 2024 05:51:30 +0000 Received: from CH1PEPF0000AD78.namprd04.prod.outlook.com (2603:10b6:610:50:cafe::53) by CH2PR16CA0006.outlook.office365.com (2603:10b6:610:50::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.17 via Frontend Transport; Mon, 2 Dec 2024 05:51:30 +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 CH1PEPF0000AD78.mail.protection.outlook.com (10.167.244.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Mon, 2 Dec 2024 05:51: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; Sun, 1 Dec 2024 23:51:28 -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 v9 02/22] platform/x86/dell: dell-pc: Create platform device Date: Sun, 1 Dec 2024 23:50:11 -0600 Message-ID: <20241202055031.8038-3-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241202055031.8038-1-mario.limonciello@amd.com> References: <20241202055031.8038-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: platform-driver-x86@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: CH1PEPF0000AD78:EE_|SA3PR12MB8811:EE_ X-MS-Office365-Filtering-Correlation-Id: e4bf76ba-b86b-422a-2eb0-08dd12955eb2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|7416014|82310400026|376014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?/GKDvrtx97V98DjgUuh8l1PRG96EjH9?= =?utf-8?q?aAQJc6c3Nm4eCVy8WTmKbYrXp1U07CGqOchLOuRJX8g0UHSLxa3FIbpZc+w/PBwdg?= =?utf-8?q?WyQ+DIRc8x4S4PfmPdfjU+J7JLP4I0dSxa2OXoaiSW4FN1JAID25zcj0EcFwEeHX4?= =?utf-8?q?ThHvn7dfYZFi6QJcDiD1cHXT18lT4ZKWCALSzTrNE3LtFWThFxCjF12lSvZxcWxD5?= =?utf-8?q?idoNZHSqKLovwOh3Z8ZOWnHymNO5drHrh6uBi0UB+WUGTF4+kLPHkdgvYHa53hm+c?= =?utf-8?q?+8vvgaQi8hVmveolFRRRBWUmt+irMJ08+wG+KzcJnJA0PzFigfBAuU20W5NSolDqV?= =?utf-8?q?zYDeulEmw40CZEjXaNI/2bvceb6O1i+kOMLQOVG4n1ZzCHkpa5pjcq2Rdt+4WsAlP?= =?utf-8?q?8lN/epEnI9VtTj6KA3aAhfEqMbBfaJvAal7xxSafGZr9f/BtmiuIq90ow27eA6V6k?= =?utf-8?q?tiNnPVBt2YJ6WHvsLx1DRtmBdsKcdTEQtnsUWGwpt44d8t03evF1FnZ/zVttxmt6k?= =?utf-8?q?bhZJ7YlpXV7gbzPzob913pPaij3riFmqSgrsuW3KJFVSEEbJJaT6v4nkOdAxzk6tO?= =?utf-8?q?erqVl3cqgaTs432tcDdxctzAvDdtnTXvYMKle6bsaY4Q9OBYqOQ2QZxUywHD8wC5l?= =?utf-8?q?uJuw6DGtMoWhQGDF8kxCURvobTF6ITs15cA2kC4mTZrqThFF9eKrEB0ITMU0KzXE9?= =?utf-8?q?xyLPWfkNnLAyPB7UFxUbsFrb8gMjETJr++uu9PrOcsD/kIVFoFOCJ8OSKNGT96j7B?= =?utf-8?q?joKpK7EYYWLxOrvH0Tv9GZen1/Ebcfg+Ns4yaXNbWH3GQRnEidBbLku2pzs4QjwfQ?= =?utf-8?q?W6GhVs+AEKRRyO5vrjnA8T9Co5qp60zFG+AEWcr8oY8JO01+OBEnhlY0gyVUYiZ/3?= =?utf-8?q?jANGXFUdiUvGr8xUbqoZk0pJRt9jwTpf6ynIr+3VnUc+ZUY/P9E8+JANJQmfMv2mz?= =?utf-8?q?uS1anUENrs5Q/O4QINhrNElF62kzFGUGcJVzyW6fs8iJ3CMay21FcPuu8Jr52sgFk?= =?utf-8?q?0ZmrFEMDWDMXXZmxKUwMBlZVkKqj9CNOUOpsbAhE7pyrA555Aue+TGvENr0SFAbBy?= =?utf-8?q?bh4kQuGkkirbFUHzOwyI9j+wI3FowWLBwdFknG4eu5w3BGG5CSG4jEeabBz6ZG4w9?= =?utf-8?q?5auTGDaBk0hrXBqi8qV2dzk0lNGwEb2lyIbFuW/Y3gsMN047qAmWNEYQn6vQq/DuO?= =?utf-8?q?4jL3/88oXEnWTzi+iyCSstLpEZONfTpCdpL0ugx00MZCZZeJHB+CRtwPAfYWnSpg6?= =?utf-8?q?jfrm9O5/2HqDm3UbkUvm2dBoMnBz8zA7thBtXmVLWP69vc3mBlVvhVYPNTWk8yfL6?= =?utf-8?q?YVkp/xc4oH3Nrs9/5rWqQpC/BoBMep2kp6hn2zocBygMVxmKB9wb37tJmiFemDw77?= =?utf-8?q?QNaQtlZnfIL?= 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)(7416014)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2024 05:51:30.3859 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e4bf76ba-b86b-422a-2eb0-08dd12955eb2 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: CH1PEPF0000AD78.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB8811 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 --- v9: * ERR_PTR() -> PTR_ERR() 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..c0dbbd3b23065 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 PTR_ERR(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)