From patchwork Wed Jul 31 23:31:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13749313 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2052.outbound.protection.outlook.com [40.107.22.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 4FA651BC4E for ; Wed, 31 Jul 2024 23:32:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722468730; cv=fail; b=T6aQtqzmUvTXX/o/lYRHBW9XKS1uGr5wNcj1bDpnuCN890OwPGIRNt/opmdu5N7XyFgezpqbWohgCah8c/maKQ53v7eQdfhPQEmPCbn6OrnAudpyzkouWBMgSx0eJS9kmaJP8bx9v6upfnoQAX446um+PHYc6e0HH4Kq53ER7P8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722468730; c=relaxed/simple; bh=UFk+n68eg6OKseNW84t+4Btpc2eqSstFT6CR/iyammQ=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=T5F376F4NN0kN2iyE8q2NGwHflPpey5g+L0xiw9X9A2K8rhWWDHSQwXz47nU9PKRQj2zdTkxfQquW+TINKDtsSOJYbeyGlwMfIvgT8TxNEHTf/jqaV09H1ZkVY1+1/PF2ZNgt+TZLhFOQiyDwN8/Ma7lPalcTu4qu3hlILK9Ts0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=h88Wp3Jf; arc=fail smtp.client-ip=40.107.22.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="h88Wp3Jf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lEh9uuZDVVOH8GrHtLfU1eeoCN13lhzliHdZPep2Y5PVeIMeLSbrcmAcT/KfDkGl1L83hw/euxnzHdoWldefRNB+Yq/uaa1INdoW8ViJ/bvMQgjbaa3C5FIfSW+PSKDdspLH5t7dfWSRkP7+KNgmLwdrLCb4iugmUI6nFKdWfHtBlMtvBEtVxPvVJVMzzpwit/9LSZTnpYV9tl6XoshBguwupAOJLT4kl6txiRwqxYleidOtOscf932a7NZpGQQVLKd5iQFHGg2V+qL+06pOCU1MXspJiPvL+QuOMi2JtdliRLZVH/HLfLHCuVMBLrzU7LbwUImwRhpLDpgaEgTF3A== 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=WjY/IyLRX0OPpHv23KJ+cPTreh8+3AIUth6jgQTPGgQ=; b=GGevdAGtE3+qO+ixn9Oqt5qnzUbxPuCU/xEiGKS1oFp65wQqDqJcB9n02CH+6u0wBoqpA3+RUR7OyKFX05gBhBkgtzuNAotqhX5DUPkLP1Jlc7MaGUVngHlhnQGd88rLwg36R0sM0akEAMKyMacd6WxBQ8b9NYA+WxzMJCNfKr5pF8/lU+Hf9RzsRq+IhXU6M0byPj8DWlf+Bt1UJi15dpX/mqL/tMFSIci/0tg1xTIJhelfy2B/x4ga9DqnO++u/UhbALKyu1Jvtimck5ICmVTaR8exCBUt4Xrj2pGhVq5jlbAnpZ3ornJCsLDAf7LLYHrbqylm2jCiFhE/Mu/KTg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WjY/IyLRX0OPpHv23KJ+cPTreh8+3AIUth6jgQTPGgQ=; b=h88Wp3JfzHGxVBXqDY6teNEs1Q82ei06iBWOOSx3E9yn9PXQ5iHGWd6+3kzg2Wi3oXwUbZ+seIULmQVMQpKW8wY1zZyzisIYgiZ4K+AJq0rLnVOSKxKM1VwHRuGlqC7Ai94h3hLLu/R1es44bWtV7+O/dEmX24McLlNshk/Yp6mwAvRBVYXL6vCjQnzp/xt28vI1OxNA2w38JoIKFfHpO31YDHcFRMqYP8ncWymnoNIVB7fTcXxGLCH3sBTdRq2m4XM4kOY3RN9T1pgCTrDygk8RHumLvBvn36UTGFcsylcMBYVuEp+MzpVQtsqq2JDub+UQfObeAZR8A3/RDa56Sg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by AM8PR04MB7796.eurprd04.prod.outlook.com (2603:10a6:20b:243::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7807.28; Wed, 31 Jul 2024 23:32:04 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.7807.026; Wed, 31 Jul 2024 23:32:04 +0000 From: Frank Li To: Arnd Bergmann , Jason Gunthorpe , Niklas Schnelle , Andrew Morton , Alexei Starovoitov , Kent Overstreet , linux-kernel@vger.kernel.org (open list) Cc: imx@lists.linux.dev Subject: [PATCH 1/1] linux/io.h: Add cleanup defination for iounmap() and memunmap() Date: Wed, 31 Jul 2024 19:31:44 -0400 Message-Id: <20240731233145.2485874-1-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: BYAPR01CA0011.prod.exchangelabs.com (2603:10b6:a02:80::24) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM8PR04MB7796:EE_ X-MS-Office365-Filtering-Correlation-Id: 3518f1d5-a841-4404-edbe-08dcb1b8fbf7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|52116014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: yIdb+pZpXoKN7mNdztTfmX0B8O1luQZ3x3JmLHXu7wfciAM3oFWLmmr1GoXe5NQtzHHV/sp7l1ZStfIso7bgAtj+BFucVjj4CSO3nc4v86RHuUOqGIEpr+ZdYEwHUrfB1WRs0Ojf+Q+1ZjeQ5+tABsac+zbE3Ez+j+NC/QMOEwCPnxlkaQUxYXZma3Zbqu3+jp7rUpf1eWtYcDsYEW9Y0pcKXh6aM1bCilhA+atrnm5sFjbGlaBWbhnLv69UR9BAuIIGLrPSvIkwOpIBiEXCQoA4E6sbezzf0ZMoRq7pGHmMwc0642wdutrzLo3/4shO/szXh2MwLkaxluxx9Gbug/QQA/BkZL65iDIzI8ygt9BZKPrVM+LWKpsI+XIulou8EIQ1nEk+1JtDYQ1TnTScysLyZdVhT/QiDmAJ8FyYWXd7jmNmd9KipIHmqTOd+/MqRyN3Q0LKQ3OrOR300ajWqtbjjRoIj1Tr4e+qE/PYZoFrZp+DqO79uQ7XGiLqF0E9ex6SlhprxshuzBS9VmY6ftA55XtJddxweRxkTMqeLeN4uIHaYneImP2zTzY8Iqh+NIkAXwHeq7lRFimyZ03qUX2JRqtWyXkpRLBTXiWTZRQLmMqZpcZGCmnaAm/y5pZyAMIJgosvn51/kTg/R7a/U4wIfXqxxMoTHA0ACIBg8zXxCmejHBJLiV1S38DNJKf5/rsMmpaXZ4XBRrHRxmqXqAzkRLUriXa420hgGb8SsbRncLcfvO1ZFIruVADNf97JT2j6kNVR8ieR8q2NTf7XRmvAJ00zZepl4yQZXUw7s+iwCE4jCcgEVXEog3pv60xkmeMZJGBNs2S3DhiYZIZxju65HhsA+Njvc/lrq9xW4I8h2VY4cF/EL3C5vz8wCZHIt4ykzW2KMBWFQR0PFD2VwWGLOmj25doxQmph3VeeiS0O7gNnBPvOzRnqb2CbXlOvTt6v8uHFpZ1R/nqtAQOQKHwJx8xMnP1birP1CloZd9xUhF3kqcdMv9549qxT+OTLcGG3WWUzcww6jl71VnnJHlcpUXni/q1jaJgaNv2wY6znsHdGh19TZQSaysjw5rooQ+c29w3hMW8tHy9h5jmxmib560WIoh6RRfwnvwVVs19zXRuhzX8Y85+IH+3BBT7+cIwjQ9LLcq4ro0qFN1PDYawmMBHJbTib8t9bObZHbDr+MLbe8uQcJFT1xizWlJTKxzcWEkQ8//Od2NERHeK3LFiacDLaMhsUfzaT4wpRy4lsaFsfTmMYq6g5H2Yzw1mWXXusyoKX4xaxQQXjy8pvnRWgWxZNkMzYrV5Q/93DpDr8oPInOO/+xRk5PczPIQOO9XVELs+KLXVPN5v79ZOUyNm7u5+4EEfPBSjzXSIIs8ve6ibocmg4pevpvDYy0pm1CtwkgsclGV8UhXzXE1lzOA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(52116014)(1800799024)(366016)(38350700014);DIR:OUT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IXfMQvPfuFnI1h4X1d4QtLUaipsn0pgxw6DYC5po4jh/wTHdQT9p6iDwESn5B7btLdcpdhK7s4WZqRqGCm8hcafHyqUHxeQ0zOFPVi20m7PWSGRQ/CbmmOixfJPIzkzmHC0pe6/EBIgRH8ecPeUMxqF9uqYtKZAE9qLKT3sKbHdiUE/wbsRLyYLwKy9aP27ypKykfl+MfsKAcKc9tiKs+VWgI4Cnu/MiPu4/f+7/nnn0NE7cTBhbgjwccJSoU7OUrMVci7s1uW27GOWzyziTd51SpKVAgO3UbhDeGcdS049pMzCjP+JFempLw+Pg5jA5koA7Eyq/5K35gtQ7c9vbR2pwBMLCzATL/vC1ijJJFBVQFCp8taBzMMuPncTFKvDnADG4byFL/oRvgwe7LmHIbnLQA0TNwzRYDLNh4QIBgTW+XhPZTXxuFKgSyl2b7an4hpYQ6czTrXrwKaidQ9uT9cGQy42EnauxOuFozjN7tl/grL507i4cIyUjq0LQbdyVqhIf/oaqCFv27XA1kh2Y1bJ0p+BBoHdsWow0bQ4tOXFmnxgT3c5qAgGxE= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3518f1d5-a841-4404-edbe-08dcb1b8fbf7 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2024 23:32:04.1915 (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: zcQ4JomradGn0VAgxpmKiDRX90sqXYL//WjW5N4X3RpwqX15Hv9iwITwOnc46DEEj6KkBk8Gh4mO46jHS/K0PQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7796 Add DEFINE_FREE for iounmap() and memunmap() to support scope based cleanup. Signed-off-by: Frank Li --- include/linux/io.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/io.h b/include/linux/io.h index 59ec5eea696c4..7695d7973c8ff 100644 --- a/include/linux/io.h +++ b/include/linux/io.h @@ -163,6 +163,9 @@ enum { void *memremap(resource_size_t offset, size_t size, unsigned long flags); void memunmap(void *addr); +DEFINE_FREE(iounmap, void __iomem *, if (!IS_ERR_OR_NULL(_T)) iounmap(_T)) +DEFINE_FREE(memunmap, void *, if (!IS_ERR_OR_NULL(_T)) memunmap(_T)) + /* * On x86 PAT systems we have memory tracking that keeps track of * the allowed mappings on memory ranges. This tracking works for