From patchwork Wed May 1 12:56:16 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: 13650721 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 B80EEC25B10 for ; Wed, 1 May 2024 12:53:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Qj3VAAwgbN+maNSANNvwbAngLlRIRF7Clcl0KJLHIZQ=; b=EBCQwpxZiTa6Ty4w8sF99zy22l 7CO0EXQjeC9/TCgrbGfzXt5hWkU63VRNUJvkm8xJBkHqObPJtip64HGXswZAWS91AKe3XR6mMNBZY BwoukaQ4ZiGX+2a0uie4S6SKnatrmQpBGUgqeHDamP9pZNNr8lrJxHl3g1/EJyB4K7iIltWpBCY4f VK4QPBKE+UCrZkpOWbKcmxVg9dplYkqEoDvzAmi3pAOtHdXJRcyE9VuK+Otw1+l+N1h6Dn+czBoeg pUjVHUUHpZM1W/CzMhKptBNKbcxHNEP0Fm1ogUD/UlJtpe01j8Ad8FDYiol2qdL698R6/scj6PLEo EacTbRag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s29Sj-00000009axT-3gEq; Wed, 01 May 2024 12:53:29 +0000 Received: from mail-dbaeur03on20601.outbound.protection.outlook.com ([2a01:111:f403:260d::601] helo=EUR03-DBA-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s29SV-00000009afc-49Nh; Wed, 01 May 2024 12:53:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ljZ0boUiuNpueqEYS1sx+4W9Zsj+2UcSUMJsh4j3b2isKHr2zFReu/hFMMQ04XlujmzxtascpO/U7CSRuLvNzU9X0iM2D30Z2VC7drjMCO3HDBjmtA1XlwxmHTCfSmerCPUfDLe572/F1i/J/rcVs6YcwtyDveg8oAB6sGrDhzgdA2UOObQsT/oMe4K66fuFhSViHUttgrRG1wzt3n4Qt2/0Yn2Ob2kv4cM0fT1wPJ9XQdTQ2yBI40f2q6Lxo2h52GiMhMX3WxGNfMxmLinhVsxxVJ5IzpkJeyxy25cP23Iq5vcdZ9Pp3zrxy39I8uAw4A0MDDZLwJtsAGarpRtyMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=ZOUGS2GhtJtBkQQNXEIQ7AVz3ycnjlDuNKMdQb91LlY=; b=gLJxpZScs2tF7a2nByZLypSwz0GAItiP1G5oawi0WrggoRMRqkQocGwW5w7W/l8g0CFdHk9ghNmOzP4pdrt3tQJ60UUWqI4WU9+5nIh0Et4tVHwT/g5UGwpuMJgd8Dja9WV1VOMqmmqgtA2TXyILVSoUnHlGDHbuJ4qZSsd+vkU+oks5arx8Z4AZriPqzhHtfy44VTMjKQuaJyqQkjB3cgxtUjFdCfIhkYuvhghBw5KvztwRl3iXm1XLRHndyo2PkG9HBpOklU3x9PBWOzdxeOSQcqg2dIOYuKB74/P6pN7Q8T/hiXwg+dYkT2cgJSy1+IXZVzFCT57LBTOcWRDtgA== 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=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZOUGS2GhtJtBkQQNXEIQ7AVz3ycnjlDuNKMdQb91LlY=; b=kzyBjaKeb+AUuC7Zjd64qxo43UGsk4EmPWahLi5mkfywRXN+mOo62iMeZxfFmnxn0uQJ5B/klABzN6+DNqxRx/Isq+Nk4R9xwGwU6oLUiNSdsUB7S/D7ziGL0pVHp+ZqBqCPHe8irEOBb/23VQSPHKi5yumhx09MPN70mkmaxyY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by DBAPR04MB7432.eurprd04.prod.outlook.com (2603:10a6:10:1a9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.28; Wed, 1 May 2024 12:53:13 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d%4]) with mapi id 15.20.7519.031; Wed, 1 May 2024 12:53:13 +0000 From: "Peng Fan (OSS)" Date: Wed, 01 May 2024 20:56:16 +0800 Subject: [PATCH 18/21] pinctrl: freescale: Use scope based of_node_put() cleanups Message-Id: <20240501-pinctrl-cleanup-v1-18-797ceca46e5c@nxp.com> References: <20240501-pinctrl-cleanup-v1-0-797ceca46e5c@nxp.com> In-Reply-To: <20240501-pinctrl-cleanup-v1-0-797ceca46e5c@nxp.com> To: Linus Walleij , Thierry Reding , Jonathan Hunter , Dvorkin Dmitry , Wells Lu , Maxime Coquelin , Alexandre Torgue , Emil Renner Berthing , Jianlong Huang , Hal Feng , Orson Zhai , Baolin Wang , Chunyan Zhang , Viresh Kumar , Shiraz Hashim , soc@kernel.org, Krzysztof Kozlowski , Sylwester Nawrocki , Alim Akhtar , Geert Uytterhoeven , Patrice Chotard , Heiko Stuebner , Damien Le Moal , Ludovic Desroches , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Dong Aisheng , Fabio Estevam , Shawn Guo , Jacky Bai , Pengutronix Kernel Team , Chester Lin , Matthias Brugger , Ghennadi Procopciuc , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Sascha Hauer , Andrew Jeffery , Joel Stanley , Dan Carpenter Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-samsung-soc@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-riscv@lists.infradead.org, linux-mediatek@lists.infradead.org, imx@lists.linux.dev, linux-aspeed@lists.ozlabs.org, openbmc@lists.ozlabs.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1714568179; l=8521; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=irbmvdeFvCZAi6uMcwD/z6mbAQPBAAsA8D6exICZ4Cw=; b=s3Pfcg/yFofine3MrQ4SLUV5kyRaLbAVfgtd4OqT6ZRRIpRty68qr71SYvc+CtO+bxloRInCc NFCqy3dfezPDcwGGN6ZwYHEtnT2HOVOUi16fBq6/QSfsbgPTLk9vd26 X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR02CA0064.apcprd02.prod.outlook.com (2603:1096:4:54::28) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|DBAPR04MB7432:EE_ X-MS-Office365-Filtering-Correlation-Id: a797f85f-da26-48ff-4da8-08dc69dda962 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|52116005|7416005|376005|366007|1800799015|921011|38350700005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?lHjSlSLfGq+11kdaHWn+QHk4w/h89oI?= =?utf-8?q?WNdr9LnpmGlCtWX69zJymUMrpvunim+tiYuxdCmd7aYM73U2VV/L2osOrKlYKJ65r?= =?utf-8?q?Y1Mgjw1tdKcMd8VTZKVZKFXRViYzXmyAvapYzsIS+yGbD6SpGB7O9gBYrU8HxzdIx?= =?utf-8?q?OwQc7TZnHCm4od+r0QoClCtkQio9M+b3LIAoy3Xwox+ZQVV6dl49hvqg/hJzJW2SA?= =?utf-8?q?ckdgveGSWLOLISml/79bcfXYpCitScLvuhSAUxB9f32uzG9AZDgX558R1ZYNEWKJP?= =?utf-8?q?LpYd/+pc5TkcIErbvVVPAprqnJRkd2+c2CAxYH+EaMO63I0f7KhR8/b/vK5zJQYy0?= =?utf-8?q?f/FX4lUt4FEMFncFTLnk4L21Rpts8veFmdceFPiOzOPKGW6r6v+bO9UmIOZyrLFdJ?= =?utf-8?q?2IF4bYDuwJ1I86vDJhVwD+hGSytSeJjnYjtx3UPdOYz8AwG0Dnz8EEhDRuw7xEFOS?= =?utf-8?q?Zxf7fRyc7sfDOomNWcLUIhxmDZpJIQxr1Jr0P56Bae/Y656/iY81Cfh+6E0XMd5cB?= =?utf-8?q?BmtMBkSHQW0waantb4lys9sRZ6g0O4lYnSINxgZYEeO/hZhshNOVeyne12MSAk9DG?= =?utf-8?q?1ozHNHxm80HyZsR3oudstwd0ZkzKfi6wI9uPuhDzYM329B8ONhHhcyQxsZRSQ8bis?= =?utf-8?q?uhyPm95uEuGHd1nRJuSQS/WhDh6cotdXxgt9/B5UyhtZacPu1c6kuM1qU88JlAdWS?= =?utf-8?q?Vd5Am8yyxE8wfsovdnNSZ5aRZqRarXcJD0OytP1JJZMbOAT4DdImAHXbfbI5JDIGb?= =?utf-8?q?7qXKVQj+4G1/6f31oLh+lEwS6uU7wbaAjUCA0BwLOd3VWFsP/pGkaEqDWzCSwxu5C?= =?utf-8?q?6RNYTA4gg74gqd9Kf0nHlB3KELdU1Nzrk+bxNi9+73X19+exi+gmlmW1kdYSMhC9+?= =?utf-8?q?YU2/dh5Z+xklbGnoB5ej9qc40wrfLRHv47n6lSPOFBJ+krtXP63qm5y2+MiAbQaCU?= =?utf-8?q?hGCJKfICWE0HQuqOjQ2TDOT14hD1IYrCwJol5xtZ0/FELnfYJb/mPt0kVKnk/j7Oy?= =?utf-8?q?KE/AzDuYjZQjJjAmdyPw7Ivt+4SR31Ow4UIQer8KjG4gUUsPS4ddJrvfYLcBgA6+n?= =?utf-8?q?ckfNklYX6Rvq/X5pHsrR7uPtn0qbzZmBI0qbfmCJI9eUPdOv9YNaiQRDZrEtzPm39?= =?utf-8?q?4x7f520oYrthZ6B2TA5aAcwDgWXGEZE7VU2HgvAgX9H0DOVMWd/8pcY89mrI9V9aD?= =?utf-8?q?ipxDGAemZHAAv2PtReRsllnpGoP/s8bhDUulGe2543V7fZ9vfM/eqL14v+rSFhMFd?= =?utf-8?q?Z1r4BrAj3BzZgX25IYR3qMwRx78AfTGQq/DoSr0fSLHx05Q87IsZrGj0=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR04MB9417.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(52116005)(7416005)(376005)(366007)(1800799015)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?W3DWuDiClskqwek01EB5Wbn/BCpc?= =?utf-8?q?F1yTMShfCa6O0n1W5xLuiAfEEZEEq3u6HJBru3guG3//D8hOynIVPeilVDCmqSwKX?= =?utf-8?q?8yCzcjGDr6txtYyQgEAm0rs8TsT7XAm4WYiKI1GpieqwiblzGOl4hgc6AAW0ZmuJi?= =?utf-8?q?EtnENnyCASK5O00K7z/NW0W5nXkmuG1KltOaSfVQsGmZqz+qPTP8Yv/tMe/ipJBVH?= =?utf-8?q?b+Z8S5cYCMqjl12PA/L+s352tIpuDDQ4IezZmDuIRqXroTjQyW0j8TaZbyli5V1c9?= =?utf-8?q?O3pvsfOlgKC8OKn6l/Rf1w+ZzbMgDXLNlEuF7LKtPs8CZ4S+wacNfDhWwGIM4ZIox?= =?utf-8?q?/tRLpY9JZZ7Ka+dDq8J5Ut9z4TRXnYr65gB36IBYUP7CJWkToDXJfc8GZkNocb1rW?= =?utf-8?q?3MpNP+1wQT7TcfsLAILfXsbtwuVvbll1FgGVFcu5dbT3w2We59t9i0e7RO+Vs+NyA?= =?utf-8?q?HlZwwmG1igLDe9j2d9jpx/gZ8Ztp8nwbhKEYtc26zIbPeO5jzESeBcLuET8e2/7Pu?= =?utf-8?q?t8mIVK9a0/fZlGlAYDj4XCFxPv5tI9iZt8PrUFrUQRZ/8LbxoNXMEnYD3ShX7OnUX?= =?utf-8?q?YEe3aFWWTTYe5YWkumcI4fV6ROnfNVyq7dgxUDsBpjg2pgwsAYo5p9hoi3wfSXWCM?= =?utf-8?q?eiLqHl7bgaba4C+GTNi5b/fXvbhYUwovXUcOgGWSUVEZvw3yzL0Gz+1pw5944jEhi?= =?utf-8?q?XpTBvj6Lt5HdEA5LKjTL5z73VV4naxqFqUto1sHxDqJxnGf1bsTS+yIK6SPBlFMVR?= =?utf-8?q?Qp4eNLV/CXNvMh9MDoxnv4yBcuzaaSQPhJxGuMiY3nswIaS+YcO34Op+i8d969ZHN?= =?utf-8?q?6qESOqyDV4bzBMVU3XL06cw7ObwRJWZCXyDfI6RR1aCrUK2p9Ybto2QBMVQ7eNnxJ?= =?utf-8?q?MSPdSrT+SZGZZjtkZXmB91EQTr99MBWV+8rMPSSAfIBEQaaoZhuS7GvnGKWMjUjCS?= =?utf-8?q?e6rlTIhgTnpaoc/0XJvAX1fSP/iqrV9w31l6T2brTjqeTWUC8ba0ACwf4dragZQqZ?= =?utf-8?q?fot2cpny3HEoQz32f2sXOG6DlXEN5JhgCzEBN8bUvTtOOV449AjHqEnT5laqhRNhs?= =?utf-8?q?Eao0JG5nnGx9HakgGF4/0w/Voy/Yfr0qiyu2ad5lkWsLg3szf0s9ec0TByEnY9B3V?= =?utf-8?q?1tvYAyaCqRlZKkOUcpBhs1bctTagObXB2oFss1mWJT9SOcy1ZqY5JosE7oiMBDmRK?= =?utf-8?q?NbgLZSXWg9PtzTVHpmaOHxMeyiuzF58fVwSbH1lWq99NzTWMril1uoUxQruh2vFEJ?= =?utf-8?q?KfAdSeUR83EarH+2pPjXuEqFVKsCD1BbkK4l9dR+g61Nu6vjncVQ0v84bUkEHyENz?= =?utf-8?q?0TX/fx5QjMATxebkTNsgKWNKBhD+Y1Gr4LsPvEO5yeMY+NUUiEIZOyELPMSyKp55s?= =?utf-8?q?sN10pXLODiHy2/ePN1PN+jEqzfOJ8D8B3Ah/TlLHrv9U6lss8Iuycqa3B7k7btC8l?= =?utf-8?q?mz1ImOQKh7XTirltVF2KG/lBAVZYoT1pJelRZDhJtcUDpafb9pXpyhI7PKgEqXZFy?= =?utf-8?q?SEVzVldn9Z4T?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a797f85f-da26-48ff-4da8-08dc69dda962 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2024 12:53:13.1224 (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: Epo3rPF9ea6ewaRMkGPpJm+PckatLqvHnIGPFP0/stFX3SZcV8pEmI6V6iT2qTsH2ITL/QfniVoTBL1izJRArA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7432 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_055316_218876_41DAA20D X-CRM114-Status: GOOD ( 12.44 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Peng Fan Use scope based of_node_put() cleanup to simplify code. Signed-off-by: Peng Fan --- drivers/pinctrl/freescale/pinctrl-imx.c | 31 ++++++++------------------- drivers/pinctrl/freescale/pinctrl-imx1-core.c | 19 ++++++---------- drivers/pinctrl/freescale/pinctrl-mxs.c | 24 ++++++++------------- 3 files changed, 24 insertions(+), 50 deletions(-) diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c index 2d3d80921c0d..cb129325bf24 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx.c +++ b/drivers/pinctrl/freescale/pinctrl-imx.c @@ -63,7 +63,7 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev, const struct imx_pinctrl_soc_info *info = ipctl->info; const struct group_desc *grp; struct pinctrl_map *new_map; - struct device_node *parent; + struct device_node *parent __free(device_node) = NULL; struct imx_pin *pin; int map_num = 1; int i, j; @@ -105,7 +105,6 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev, new_map[0].type = PIN_MAP_TYPE_MUX_GROUP; new_map[0].data.mux.function = parent->name; new_map[0].data.mux.group = np->name; - of_node_put(parent); /* create config map */ new_map++; @@ -580,7 +579,6 @@ static int imx_pinctrl_parse_functions(struct device_node *np, u32 index) { struct pinctrl_dev *pctl = ipctl->pctl; - struct device_node *child; struct function_desc *func; struct group_desc *grp; const char **group_names; @@ -605,17 +603,15 @@ static int imx_pinctrl_parse_functions(struct device_node *np, if (!group_names) return -ENOMEM; i = 0; - for_each_child_of_node(np, child) + for_each_child_of_node_scoped(np, child) group_names[i++] = child->name; func->group_names = group_names; i = 0; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { grp = devm_kzalloc(ipctl->dev, sizeof(*grp), GFP_KERNEL); - if (!grp) { - of_node_put(child); + if (!grp) return -ENOMEM; - } mutex_lock(&ipctl->mutex); radix_tree_insert(&pctl->pin_group_tree, @@ -635,21 +631,13 @@ static int imx_pinctrl_parse_functions(struct device_node *np, */ static bool imx_pinctrl_dt_is_flat_functions(struct device_node *np) { - struct device_node *function_np; - struct device_node *pinctrl_np; - - for_each_child_of_node(np, function_np) { - if (of_property_read_bool(function_np, "fsl,pins")) { - of_node_put(function_np); + for_each_child_of_node_scoped(np, function_np) { + if (of_property_read_bool(function_np, "fsl,pins")) return true; - } - for_each_child_of_node(function_np, pinctrl_np) { - if (of_property_read_bool(pinctrl_np, "fsl,pins")) { - of_node_put(pinctrl_np); - of_node_put(function_np); + for_each_child_of_node_scoped(function_np, pinctrl_np) { + if (of_property_read_bool(pinctrl_np, "fsl,pins")) return false; - } } } @@ -720,7 +708,7 @@ int imx_pinctrl_probe(struct platform_device *pdev, struct regmap_config config = { .name = "gpr" }; struct device_node *dev_np = pdev->dev.of_node; struct pinctrl_desc *imx_pinctrl_desc; - struct device_node *np; + struct device_node *np __free(device_node) = NULL; struct imx_pinctrl *ipctl; struct regmap *gpr; int ret, i; @@ -765,7 +753,6 @@ int imx_pinctrl_probe(struct platform_device *pdev, } ipctl->input_sel_base = of_iomap(np, 0); - of_node_put(np); if (!ipctl->input_sel_base) { dev_err(&pdev->dev, "iomuxc input select base address not found\n"); diff --git a/drivers/pinctrl/freescale/pinctrl-imx1-core.c b/drivers/pinctrl/freescale/pinctrl-imx1-core.c index 90c696046b38..409efa1ce8f8 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx1-core.c +++ b/drivers/pinctrl/freescale/pinctrl-imx1-core.c @@ -226,7 +226,7 @@ static int imx1_dt_node_to_map(struct pinctrl_dev *pctldev, const struct imx1_pinctrl_soc_info *info = ipctl->info; const struct imx1_pin_group *grp; struct pinctrl_map *new_map; - struct device_node *parent; + struct device_node *parent __free(device_node) = NULL; int map_num = 1; int i, j; @@ -261,7 +261,6 @@ static int imx1_dt_node_to_map(struct pinctrl_dev *pctldev, new_map[0].type = PIN_MAP_TYPE_MUX_GROUP; new_map[0].data.mux.function = parent->name; new_map[0].data.mux.group = np->name; - of_node_put(parent); /* create config map */ new_map++; @@ -508,7 +507,6 @@ static int imx1_pinctrl_parse_functions(struct device_node *np, struct imx1_pinctrl_soc_info *info, u32 index) { - struct device_node *child; struct imx1_pmx_func *func; struct imx1_pin_group *grp; int ret; @@ -531,14 +529,12 @@ static int imx1_pinctrl_parse_functions(struct device_node *np, if (!func->groups) return -ENOMEM; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { func->groups[i] = child->name; grp = &info->groups[grp_index++]; ret = imx1_pinctrl_parse_groups(child, grp, info, i++); - if (ret == -ENOMEM) { - of_node_put(child); + if (ret == -ENOMEM) return ret; - } } return 0; @@ -548,7 +544,6 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev, struct imx1_pinctrl *pctl, struct imx1_pinctrl_soc_info *info) { struct device_node *np = pdev->dev.of_node; - struct device_node *child; int ret; u32 nfuncs = 0; u32 ngroups = 0; @@ -557,7 +552,7 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev, if (!np) return -ENODEV; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { ++nfuncs; ngroups += of_get_child_count(child); } @@ -579,12 +574,10 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev, if (!info->functions || !info->groups) return -ENOMEM; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { ret = imx1_pinctrl_parse_functions(child, info, ifunc++); - if (ret == -ENOMEM) { - of_node_put(child); + if (ret == -ENOMEM) return -ENOMEM; - } } return 0; diff --git a/drivers/pinctrl/freescale/pinctrl-mxs.c b/drivers/pinctrl/freescale/pinctrl-mxs.c index e77311f26262..baa1e806688d 100644 --- a/drivers/pinctrl/freescale/pinctrl-mxs.c +++ b/drivers/pinctrl/freescale/pinctrl-mxs.c @@ -406,22 +406,22 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev, { struct mxs_pinctrl_soc_data *soc = d->soc; struct device_node *np = pdev->dev.of_node; - struct device_node *child; + struct device_node *ch; struct mxs_function *f; const char *fn, *fnull = ""; int i = 0, idxf = 0, idxg = 0; int ret; u32 val; - child = of_get_next_child(np, NULL); - if (!child) { + ch = of_get_next_child(np, NULL); + if (!ch) { dev_err(&pdev->dev, "no group is defined\n"); return -ENOENT; } /* Count total functions and groups */ fn = fnull; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { if (is_mxs_gpio(child)) continue; soc->ngroups++; @@ -450,7 +450,7 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev, /* Count groups for each function */ fn = fnull; f = &soc->functions[idxf]; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { if (is_mxs_gpio(child)) continue; if (of_property_read_u32(child, "reg", &val)) @@ -490,16 +490,14 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev, /* Get groups for each function */ idxf = 0; fn = fnull; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { if (is_mxs_gpio(child)) continue; if (of_property_read_u32(child, "reg", &val)) { ret = mxs_pinctrl_parse_group(pdev, child, idxg++, NULL); - if (ret) { - of_node_put(child); + if (ret) return ret; - } continue; } @@ -509,19 +507,15 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev, f->ngroups, sizeof(*f->groups), GFP_KERNEL); - if (!f->groups) { - of_node_put(child); + if (!f->groups) return -ENOMEM; - } fn = child->name; i = 0; } ret = mxs_pinctrl_parse_group(pdev, child, idxg++, &f->groups[i++]); - if (ret) { - of_node_put(child); + if (ret) return ret; - } } return 0;