From patchwork Fri Dec 6 11:28:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13897091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 14996E77173 for ; Fri, 6 Dec 2024 11:31:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=6B11cyy9XOQqKXU7wxLVjDeaKeFpE/yHLm4/QVpIxuY=; b=j6r4XSVTT5bsbF01ekLJ4O9PS6 pbrFgKxtRboowa76x2Wz3dd7OgBQK2yRSEC4mVO29dR4/gB98ss6rn0FgcFDv/M1AT4Zo7TlKGrv7 /ylkav1zds2bYpexlBsurVGGs1iEUMKXLIsNdYKba4yEew9H7sL2AbiWot8VR/yDRe+n+Aoeq7LZ6 Dc6hD5Eqd0TXZp6Qmhkf2tHBRQTnGlldu+XX72ZqeHn+oCtcZHS9ah/RjvqzbzthqPNyq7j2XF1YZ ByWeDVyoY9veKk654oLNI4w+qB7S3K8HPtEQixAGTJvYet/JgR8HuiYDjsw+9jpoV9SmfJdOVpzkY 2DD9NG6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tJWYE-00000001SvM-3j7S; Fri, 06 Dec 2024 11:31:14 +0000 Received: from mail-db5eur02on2061b.outbound.protection.outlook.com ([2a01:111:f403:2608::61b] helo=EUR02-DB5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tJWWI-00000001Sb9-22QG for linux-arm-kernel@lists.infradead.org; Fri, 06 Dec 2024 11:29:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tFLjZmVr7ssxwNTNka5vp+fgKix9KY/vssot6gB8LqYZDbAREIRAyV7xHi0f+LMG2vCLKTqJ669oUHPLrtAgs0OX+E5Dt2R4fB8RjYjpk2jCQTeNATaiZbbICWQjSUlrEedsua/PaSXO20gpsQd85qVZ0E3d+WSvkYQvJfAWpm83xTLf2m6Ru5yTIhPZyhNk3WSFwNYVFjKowH1s0ooOmPr67eXjD04DF4Yg9fQ9RTbywbGNMg3PFCoCcfXdf/33yph+0U5b8naSWrQKaCWaF6Ymv1nXsbLKyvubRh5yh2t4TsZlkSZHEqhqbkgu/sKhGETZxTQiRc/j4mVpjF28Zw== 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=6B11cyy9XOQqKXU7wxLVjDeaKeFpE/yHLm4/QVpIxuY=; b=YlGN2FPPQO55bmS0k3QOyv3F3rIk7E1Itd+5+X35TA+M3eA8sr5d1Adko5GHKLUKB+6nZ/nqirWwxNLsqhluKcMY2b6sXgnqEfN6mRJKclC6T5gPn/DT7WFoG+oMxRaER6sFiL3AgzsctHCu7YEcc2xgssRqQzKIrW7jrIz9hpcMRd79ykLp7uloLP12wHXJ9m+3NocgyIUXNnBPtgIzqXhAyOGxRHBc1j1ZVXH18ejXm4E5bZ613R+XCRiVC47G90NB59ch3qcJrigXUeeXcZZ6WCwHZHAQm/9ibQLTT789lx8/5VtCJMPPpgL4HyTtyTj1qXD+n5RVxilVKT+FWA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6B11cyy9XOQqKXU7wxLVjDeaKeFpE/yHLm4/QVpIxuY=; b=eBxguAgBsJmDmYetG5SeQQh/dEatQiIRhDjNgtTLBL51ZKpdsWSaUHaJ91Dc4GoP/BPm009xLbdIInIrPIaPxVkA1V4hahZZFTEFtpYgPzISrC6oMILjKfD8aD+Vzub6JrU4OP03GxoEWW9NtzEOXlW2RFQC2EJBd7MmqId41tl35HeBUJpTCuQjZP5ULFl1hmTU0CrAkJh+3YCjFnk0IaBGBAkAsbGJsvM2M8VVNpH8KHQIwou9KLoKRRjnS9CM7yqkHEQD1RVEmR4AowucyNr5Bmx2XoVKJB+rU75kQtMEfJkTP0n5lkh7etX2kqkaCIHllPKAcz+e7gIlPvkOXQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by GV1PR04MB10273.eurprd04.prod.outlook.com (2603:10a6:150:1a5::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Fri, 6 Dec 2024 11:29:09 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%5]) with mapi id 15.20.8230.010; Fri, 6 Dec 2024 11:29:09 +0000 From: "Peng Fan (OSS)" To: shawnguo@kernel.org, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, marex@denx.de, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Peng Fan Subject: [PATCH] soc: imx8m: Add remove function Date: Fri, 6 Dec 2024 19:28:43 +0800 Message-Id: <20241206112843.98720-1-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.37.1 X-ClientProxiedBy: SG2PR01CA0153.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::33) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|GV1PR04MB10273:EE_ X-MS-Office365-Filtering-Correlation-Id: dd550ae6-99af-4fa6-0d40-08dd15e93397 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|376014|366016|38350700014; X-Microsoft-Antispam-Message-Info: 0dlx6Rs8c4BmptqcyhkYzQJoAcR84tHy7JKz1ow7ms2rZnPNHF7DM9dPnoEu+NinrLmwrf1w65MM8bIJziLmdqdzWB8h0TXtsjXFJSYrznYYY1gIggzLgA+SFo42+IDRZ9w13a2BWlilr7v5tdhuduvNUCvEwRSJm7PBUrGMRZQ/PkxfnMcNiru9I3lqyOdDKJy9k/mi0geQru+0IQ4QESayBRdeFGZBhv+68U7bfLJCnq9fqDhgedhC79UfVspcME87R+RAHc2rkbCSya/BOrjkggPgP0N2NhUT59UZYMPzdJY8haEXI0oNhjP+oED8w/LZeFsQsAglmXYtSDMrWcR3oAE5hVQIQkHLMToGcTmddomgDqPyH9jqrPrch+dd1pRMAw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;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(376014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 55jawkQEF/9NO68e4GUsisO7nY++P033h6vSu5bfv1sinbEwykitBPtMUwZBJV9VEc116cKeAug6mlPSMZaXSF8yyDzlJegDTq9PduNjBCGsWnPYEwmnQli/ZehRmafDDks5IeXmBx0WVmoxkZWqN4ayhLu6o46vOUCT9G2m7/zDsJ8xV4Q0AxbzRtl+nrVUz6pIwrVMC5BP7wfIIz8FgQ/z6LVFYF6cDQRyu9+Wrv/VrQA0SAZo1q7loqPBc2Yd2QZgmrHVBiIZR8oQYnd74bHsYA6Pj8W8SWTsmi68i5jb0VR4rhoRYxZSLd8iXmoK7z9vPVTaULc5TQ7wDaGVVAMVqgunccmFosacz2U5phpCz/rJroGXipWlVJ8vMT8cIW3BclO/+nI74TtcpTxhalMb+QnfI1C+tVs3a52FFxUl+IK+/jRZ1F8gTgHC+tIl6jbjZg42KUP+7rW+OuGnfxli/QSifXfzClLKtro/g0WCnLVqkjwcGrBotmNCO0LNuu+iBmzhIaausemKucuseaBLUoEx8kqkCsyH0+IRIRLUpwdzF7Bupwb0FNEk8iRQDiGf65ymGGK7T/okrf1O0gRIicjqoGDAe59czwsrh+v7qH3gSUtlJKq9+0ymE6xv4z5vDENxxxEnAjfcFT5WaXg9RlaE0iU9Kvm2DqOUJl26eQEW+3FPfvQs4U+u/HVTuzNAHdkVWXEaw12wsnY9ChKb4eJUqeXgt4frwm9ttsYik06+khOIklCdaestqVEPOTEDlXwbeuLd+FPwjnfCLTR8yQKOQwfwgBwl1VhB29Zsei3fw5FrcJ/fUDi1J8jzpcf2bqy9jOwci++Q0TsYZKq/x0eh5TwfzSi9egBDb1VkUJm4gZnE7pyAU5/IHVjJzX7yx5HMxt/NRRco644gh03edtdNojuW1XV+njMmdpskDgmUy59RLUaZvHSHJdycFLnRM8MOxu5zgC1AsLoZnQE9L+CW+Q5BujatNwSng9U+YqvzgQPU0BJoiWGypFgp6HbSOgYc+FR2CQ+Im9hu4tSnyrKDjUo2BxEM2Q9Qfp1avkBsq4S0qWS4pjxoNXxIWq0QiYrv2MFOpo9bOxHtDrPDeRTidNjF+3ed83MwEsHygVtlrZNRIy57R5orJApTld8UHUxAF+AhBFhyNjJrb2/cYdK+hNh9gF1zS1tQVX2GN924Tv3fru2SQ9TnFDL1evNfmBRd4V0mWTvz4OF6vI9+34qQ135kN5IBw4zin80WqSDuAzI4+Y9hUbOdSoMHIm0qfcTeWWxO9YZQYNuUsyBVonKDctA9XZm7KyG8o0dL26k7gKNBLud3wLJ4SeoHXnasLPVwMqMd4VhFMrRcHxmpy7KkQJ7kAz8Q0zlc0vYpOpIrEpnGPXsUBjGwpS1NtM2rdaGuaED2XpC1/vl7YgMChjl+a+4eUyTBmfluf1YpBoOrRL8+1LTfUcUZAXKpS/0Nz87d93YAsdK5XavPof7Z4SpbGE2vOTbKM7HVzcg/PqqQIBaVe4dXX7kYPmNfoROqXr5u1b0jbb9LCf/em3AS1KUDEwAfPkmryyUrc5zpnuo+bq0DYDLOOM0ed0z2 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd550ae6-99af-4fa6-0d40-08dd15e93397 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2024 11:29:09.6259 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YDHEUxF6ExmqwVncDBVKTv/xB17GcsCTM1vbFnnGr4i1mUs5TiqILO9e11zftBs1tae9P9nflKth4fns6j3YVw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB10273 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241206_032914_535349_988F2A04 X-CRM114-Status: GOOD ( 15.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peng Fan Unregister the cpufreq device and soc device in remove path, otherwise there will be warning when do removing test: sysfs: cannot create duplicate filename '/devices/platform/imx-cpufreq-dt' CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.13.0-rc1-next-20241204 Hardware name: NXP i.MX8MPlus EVK board (DT) Fixes: 9cc832d37799 ("soc: imx8m: Probe the SoC driver as platform driver") Signed-off-by: Peng Fan --- drivers/soc/imx/soc-imx8m.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-imx8m.c index 8ac7658e3d52..8c368947d1e5 100644 --- a/drivers/soc/imx/soc-imx8m.c +++ b/drivers/soc/imx/soc-imx8m.c @@ -33,6 +33,11 @@ struct imx8_soc_data { int (*soc_revision)(u32 *socrev, u64 *socuid); }; +struct imx8m_soc_priv { + struct soc_device *soc_dev; + struct platform_device *cpufreq_dev; +}; + #ifdef CONFIG_HAVE_ARM_SMCCC static u32 imx8mq_soc_revision_from_atf(void) { @@ -198,7 +203,7 @@ static int imx8m_soc_probe(struct platform_device *pdev) const struct imx8_soc_data *data; struct device *dev = &pdev->dev; const struct of_device_id *id; - struct soc_device *soc_dev; + struct imx8m_soc_priv *priv; u32 soc_rev = 0; u64 soc_uid = 0; int ret; @@ -207,6 +212,10 @@ static int imx8m_soc_probe(struct platform_device *pdev) if (!soc_dev_attr) return -ENOMEM; + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + soc_dev_attr->family = "Freescale i.MX"; ret = of_property_read_string(of_root, "model", &soc_dev_attr->machine); @@ -235,21 +244,34 @@ static int imx8m_soc_probe(struct platform_device *pdev) if (!soc_dev_attr->serial_number) return -ENOMEM; - soc_dev = soc_device_register(soc_dev_attr); - if (IS_ERR(soc_dev)) - return PTR_ERR(soc_dev); + priv->soc_dev = soc_device_register(soc_dev_attr); + if (IS_ERR(priv->soc_dev)) + return PTR_ERR(priv->soc_dev); pr_info("SoC: %s revision %s\n", soc_dev_attr->soc_id, soc_dev_attr->revision); if (IS_ENABLED(CONFIG_ARM_IMX_CPUFREQ_DT)) - platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0); + priv->cpufreq_dev = platform_device_register_simple("imx-cpufreq-dt", -1, NULL, 0); + + platform_set_drvdata(pdev, priv); return 0; } +static void imx8m_soc_remove(struct platform_device *pdev) +{ + struct imx8m_soc_priv *priv = platform_get_drvdata(pdev); + + if (!IS_ERR(priv->cpufreq_dev)) + platform_device_unregister(priv->cpufreq_dev); + + soc_device_unregister(priv->soc_dev); +} + static struct platform_driver imx8m_soc_driver = { .probe = imx8m_soc_probe, + .remove = imx8m_soc_remove, .driver = { .name = "imx8m-soc", },