From patchwork Sun Feb 25 14:27:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 206023 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1599694dyb; Sun, 25 Feb 2024 06:28:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX0VUilsmGvqS1L112HeaK+amWxUJYITnK07bi8nAVFcVOS8YsDuC31jt7w9qI25nxa4ZaLZJQ4kWX9yK9bUjDWmKEd3A== X-Google-Smtp-Source: AGHT+IHh0OHLzTSulshAljG5hi9gcw5owIzkbjLk4yVAevj833oIUliuUS/gf/p1X8xPLeublhGg X-Received: by 2002:a05:620a:570c:b0:787:7cf8:dcfa with SMTP id wi12-20020a05620a570c00b007877cf8dcfamr6096808qkn.76.1708871288415; Sun, 25 Feb 2024 06:28:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708871288; cv=pass; d=google.com; s=arc-20160816; b=HiXqbeApZfW31/x2/wJUnonLNvvpn0ZMdbkwzCZZceRUYFIdDgkUBuPl/7OAEt/Nnk WEDBzSUPIgzR5PdZl3CZ2bCjZujv1r/SGKy1HLF2Ed4nRAdidiHL5H4b+YDxXcy7SscH CFtMCjLWda6KwRbQR8jzqTvDXsbOBPqM05g7kEt182jJQSj8AufnwMMM5+9SdNRSYMMm m4IuTDVyLTU6L/AagEuMGGst9fNCtSwEuhFB+r+im9RUNQB6zE7ATRZcx4aYmqSZSa88 BU7jYf7jYaAkwa+R8dov0Cl8Qj6ZL/Zud52AUEa221xOq9ZCxUSGd6l3oZKQkctDOkyE 0H5g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=F73PukQcjePdt0NFnjd8avHPgvRLhun90mCfXwZ4nKo=; fh=PiZ5V/4sGLDov5cF6A5wY5iqIfZAXRefEy8l5uZe2FU=; b=IejqXyLNfaZVVBrjcwuqOmmpdRqmFGjDjTItOYXQDRlsS+aEiDyi2S9agNM+sPZJUQ xT10X5pV8JjVjeFt96mjrgO7rW8NGt33Ucv6+dT0QekcCjQmZUPYtnmR667uulkgmxsX A45xJMwAaJH02JNlw2pXjl6jTr3KmYxX82HeDoyXQ+PVWT9TrjEnKLtB8rW/YWhE268J ievj7OxbF7N5+rW9nN0VbX/B3vejcYFmdlilVy5BbgVsh6M0pc2l/FGTCeikwGFFOFOJ gugYn+pbOR1d1glZTE9bilJUZKivhv7LTc5sSZIJUM/gCtOL1z2fKOmPDCUtTjb2boob W5xw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EIbuUKf4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80098-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80098-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d17-20020a05620a137100b00787a0bed972si3027790qkl.145.2024.02.25.06.28.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 06:28:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80098-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EIbuUKf4; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80098-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80098-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 182071C20BD5 for ; Sun, 25 Feb 2024 14:28:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DDE6314AB7; Sun, 25 Feb 2024 14:27:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EIbuUKf4" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3576214280; Sun, 25 Feb 2024 14:27:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708871258; cv=none; b=lozC34kN4ME3mu4ouBayGd626KnOKvMHV4Fa0TO6pt9J9KSiQpMF6LUK/6CZa+6usaDdbrE58kHngL04QJ5Lfc4YpSfW+YAVSQTE8Z54VXhMkbb5VuBoi46WRX99s3cJp1Mvyipi86e0FF7jOEqwcULPV19wdBcqjTG1RfgAu4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708871258; c=relaxed/simple; bh=HAT98xnSwLDAnpvodaMTdqxT64M67j1g0X6shQNezLg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZF7olYEI7dZiRzbO+QRdpI38BN+HZAemE+yOgfgHpxXcLaC2P05xst2MD8ed4VTYC5sNuJSBoxF3bCv6A9V3ZpUxVsSk4AQdrjQYFUfSpDlLS6eNRkvmyuOZmIDsrG66wc61hubUO2vng1l0FcZZyuO9wmB3ewV7/7oiGjXQsuY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EIbuUKf4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53840C43390; Sun, 25 Feb 2024 14:27:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708871257; bh=HAT98xnSwLDAnpvodaMTdqxT64M67j1g0X6shQNezLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EIbuUKf4y/pyYsjG9hm5YQtRuJ+jRGEDKz0LyJSGSgCYl7GMGtEKsNgSvlyhPE7VT gjg1AGMvcM9tkJTDSjtJAaRWLUDHJe7+eRIYtGe1/Ba3DzDztt0FUjxFuEnGDzHBRo ckofUhmRYZQY9angGKOPvspLMtrocVDHCl4KRa9sojUOn/oYbzZYRp4JoIvPzmhTR8 E2Z5Rwfu+oQi26eKAo2/Iw1g/jI/MBDZfnWpFBJ3nt1LExcck6xa3oTZGSBPuAgfgb UQsCsHrT1UysEFxyvUxOIZUtZo5t/vcli98lJY22HTRLk8CPVt2cv3++RInceSR4S2 jFYjQ75vN5zsQ== From: Jonathan Cameron To: devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Rob Herring , Frank Rowand , linux-kernel@vger.kernel.org, Julia Lawall Cc: Peter Zijlstra , Andy Shevchenko , Greg Kroah-Hartman , marek.vasut@gmail.com, Jonathan Cameron Subject: [RESEND PATCH v2 1/4] of: Add cleanup.h based auto release via __free(device_node) markings. Date: Sun, 25 Feb 2024 14:27:11 +0000 Message-ID: <20240225142714.286440-2-jic23@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240225142714.286440-1-jic23@kernel.org> References: <20240225142714.286440-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791881420240933517 X-GMAIL-MSGID: 1791881420240933517 From: Jonathan Cameron The recent addition of scope based cleanup support to the kernel provides a convenient tool to reduce the chances of leaking reference counts where of_node_put() should have been called in an error path. This enables struct device_node *child __free(device_node) = NULL; for_each_child_of_node(np, child) { if (test) return test; } with no need for a manual call of of_node_put(). A following patch will reduce the scope of the child variable to the for loop, to avoid an issues with ordering of autocleanup, and make it obvious when this assigned a non NULL value. In this simple example the gains are small but there are some very complex error handling cases buried in these loops that will be greatly simplified by enabling early returns with out the need for this manual of_node_put() call. Note that there are coccinelle checks in scripts/coccinelle/iterators/for_each_child.cocci to detect a failure to call of_node_put(). This new approach does not cause false positives. Longer term we may want to add scripting to check this new approach is done correctly with no double of_node_put() calls being introduced due to the auto cleanup. It may also be useful to script finding places this new approach is useful. Signed-off-by: Jonathan Cameron --- include/linux/of.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/of.h b/include/linux/of.h index 6a9ddf20e79a..50e882ee91da 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -13,6 +13,7 @@ */ #include #include +#include #include #include #include @@ -134,6 +135,7 @@ static inline struct device_node *of_node_get(struct device_node *node) } static inline void of_node_put(struct device_node *node) { } #endif /* !CONFIG_OF_DYNAMIC */ +DEFINE_FREE(device_node, struct device_node *, if (_T) of_node_put(_T)) /* Pointer for first entry in chain of all nodes. */ extern struct device_node *of_root; From patchwork Sun Feb 25 14:27:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 206024 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1599851dyb; Sun, 25 Feb 2024 06:28:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUN9dT2BH63VQiK8mSz+yv1IqwH4IKGMHuk9I8yEUg5xptEQAZZ5vKd0aSWmT1JJ5LAvnYhE/g8AGrtjp+tUMqLYTwc1A== X-Google-Smtp-Source: AGHT+IFjJf1sTRAqFSODte96/7TwWRgz+uLttWIcgPUyXrM72x511E1eFPOV20BBRMPY65jRCVqw X-Received: by 2002:a05:6a20:c896:b0:19f:f059:c190 with SMTP id hb22-20020a056a20c89600b0019ff059c190mr4153209pzb.24.1708871321114; Sun, 25 Feb 2024 06:28:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708871321; cv=pass; d=google.com; s=arc-20160816; b=RX1LErwDGqxdi4R1VKbkb+OUCdW0OP06a22Q+teSmp3JT7toB2oTeFcnlgaHFrJUe6 hht4IHB+6aDbaWVq8YPV551VX56m44vnLLK4aIUkE8ACbT2YBbWxostQhkk5zpK4RP1o GF0LvCOWK4h34blPGaZDsen9cmnK6cbzICtLBox6xzwnJ33gOrEKJ93VyvRp0dyQOLgX orv+4zo5hQRhO+a/E8nqSYGO5IcfDlI0HGZf65l1vXtK/UtYOdGRA76od7dezAbHkoQv dMu+znf8d7tqWUU1cyadw2U9hbjUwg+9bJ0QLCdzMQKabh6R+KhxP0opqmIsYP/pOTn7 M7Rw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ZxnQYunt9dHV1HqD7hX+sXznv05Wmnd0Z4hkMgi8/7A=; fh=PiZ5V/4sGLDov5cF6A5wY5iqIfZAXRefEy8l5uZe2FU=; b=wr+wVzy7qfEV+dpFE25YUZS3l1SmGni91p6QSfhNMbc/tHvEBqcgo8hIHrOa9RvST0 Ddt2mCEkG0j3AbM4B2uj7l5X2+3WE5zZYlnmbNxHYWZ51WrqYJfRSprs/GrXEd4vsLrC KHUGuwMSX7PoCbyuZlqmzFUH9tc89At0TnrGZawFUrXE3QEImX/Xu8mzdS/CL6NwjJUt qZ+MyO2MzKhD3nPG6IgEMJntsMMktT8q9+UzuVoMx1qTIqXX3Go8rWdnMtDwpewX0JOH Lq0hISaiM5QgTnPtjeODoP5eZlFBCKidVHxHR678NeRj64yhXbvrz2WYAdCCkm5FDcwb HTBw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ICAhHYMD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80099-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80099-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id qj14-20020a17090b28ce00b0029abb848362si489623pjb.169.2024.02.25.06.28.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 06:28:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80099-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ICAhHYMD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80099-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80099-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A225AB2103D for ; Sun, 25 Feb 2024 14:28:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 83192171B6; Sun, 25 Feb 2024 14:27:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ICAhHYMD" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D925014F62; Sun, 25 Feb 2024 14:27:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708871263; cv=none; b=NLbmsoUOrIEZo/QR1aKKc76EmC0AQm6OYzgYukF9iohH/EoYejEp+KO+Ha9E6g5piCUb1n8GMA4rXDkl5724x2dHhe+0/v0+oJQ9yYDlEQxWVETYSTMwyVkslq24GZaBNVX+37qBvkzOOGxFBOinlLJDrZkHLgaiNfcyNfcDHj4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708871263; c=relaxed/simple; bh=JrxvOnnekqmZH3ajB2UIPWqOc4Gn4lKhT3b0ty+A5S8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qvYh1AIEtKpQ2M96CL9WsWhrkAc2Odn5l+luXWzwbTjWr4Q5dCxT0QI06qc4QLBR5UHluotnyw03v8578vrv0amNY8z8yTKfFL632Poztj7KR96dMeXQFQ/3fdQNyfLme9mA/SNH2tlKqKe/XDA+XI3HHL7Oy2YWs8BfU0JZycI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ICAhHYMD; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5430CC43394; Sun, 25 Feb 2024 14:27:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708871262; bh=JrxvOnnekqmZH3ajB2UIPWqOc4Gn4lKhT3b0ty+A5S8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ICAhHYMDXJlaFwdl0M9SxF2WSfiL+8mnR/YOiI670MrkWnJY7o5CdDZ8EyAfWy8Yw zJ7Qyvnvsiiw6YrMRN9e5rVbq9TFAmAWcOCH84LPhQtqHrC3IOgg5F5AAFcnTcNvQB WvXiIC1wkr/40zKn8zihJf3wEhhwxje2gjXvAogBPkSCuhcTDSyEA/M5xkrcw4SrDO sNAhlIrAaD5ItV5GP34OJQD1Hg3dP4d/NVw0HDi0DMM/RD/iY8DIMHmGjSyPhuobX4 iuyEu9+QMvwIxDKdjLtK42XAsISWGfn60HEI8Jn9N5Y+nZ/f1fwwurTEfALt1JwOSM G7lvr6gZ51kyQ== From: Jonathan Cameron To: devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Rob Herring , Frank Rowand , linux-kernel@vger.kernel.org, Julia Lawall Cc: Peter Zijlstra , Andy Shevchenko , Greg Kroah-Hartman , marek.vasut@gmail.com, Jonathan Cameron Subject: [RESEND PATCH v2 2/4] of: Introduce for_each_*_child_of_node_scoped() to automate of_node_put() handling Date: Sun, 25 Feb 2024 14:27:12 +0000 Message-ID: <20240225142714.286440-3-jic23@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240225142714.286440-1-jic23@kernel.org> References: <20240225142714.286440-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791881454903720549 X-GMAIL-MSGID: 1791881454903720549 From: Jonathan Cameron To avoid issues with out of order cleanup, or ambiguity about when the auto freed data is first instantiated, do it within the for loop definition. The disadvantage is that the struct device_node *child variable creation is not immediately obvious where this is used. However, in many cases, if there is another definition of struct device_node *child; the compiler / static analysers will notify us that it is unused, or uninitialized. Note that, in the vast majority of cases, the _available_ form should be used and as code is converted to these scoped handers, we should confirm that any cases that do not check for available have a good reason not to. Signed-off-by: Jonathan Cameron --- include/linux/of.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/of.h b/include/linux/of.h index 50e882ee91da..024dda54b9c7 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -1430,10 +1430,23 @@ static inline int of_property_read_s32(const struct device_node *np, #define for_each_child_of_node(parent, child) \ for (child = of_get_next_child(parent, NULL); child != NULL; \ child = of_get_next_child(parent, child)) + +#define for_each_child_of_node_scoped(parent, child) \ + for (struct device_node *child __free(device_node) = \ + of_get_next_child(parent, NULL); \ + child != NULL; \ + child = of_get_next_child(parent, child)) + #define for_each_available_child_of_node(parent, child) \ for (child = of_get_next_available_child(parent, NULL); child != NULL; \ child = of_get_next_available_child(parent, child)) +#define for_each_available_child_of_node_scoped(parent, child) \ + for (struct device_node *child __free(device_node) = \ + of_get_next_available_child(parent, NULL); \ + child != NULL; \ + child = of_get_next_available_child(parent, child)) + #define for_each_of_cpu_node(cpu) \ for (cpu = of_get_next_cpu_node(NULL); cpu != NULL; \ cpu = of_get_next_cpu_node(cpu)) From patchwork Sun Feb 25 14:27:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 206025 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1599856dyb; Sun, 25 Feb 2024 06:28:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVsHIO0f4dLYyh8gTUK54ivakK71HLTXZnLTaxawOE1vuigeM4qRYv2J5PCV6jAg1vfcXS/TjKARWUkJi+BBSCsFgYC4w== X-Google-Smtp-Source: AGHT+IHPG9RTEbtm4YRmKdhE17JcoVWhqUkq3upBccvJEcq4u+KpZTFU7FbEK84px9bXtLbl/PkJ X-Received: by 2002:aa7:c999:0:b0:565:eda7:c12b with SMTP id c25-20020aa7c999000000b00565eda7c12bmr248525edt.0.1708871322486; Sun, 25 Feb 2024 06:28:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708871322; cv=pass; d=google.com; s=arc-20160816; b=f+wUyyzmRnRb9GW9yNow/VoFHKUD70gQD71n6lATsR2DECtiVSrVoMyIxUA96KSqg+ nXLnoZNERbfnjtBbto0BocvT3m7+pazRpDKn/yi6k+R77SaEzXPCA0/UX/05ojkpy/e3 7mkENb/DuC8eRkibC6eXTKvvAHDKJMxXSBiAPtcNdhjjgJ4cF5Y9AIwJF51gIgMA9kl+ e9Me4H6budNywI4xeoEJuSe1Mc/lMZXIRaGx83ZcerG0FEeeX8nfI0tefqat50NWpY4O GELwv6g/UQhTgdyghrRwyf7AscccwwSa7ED76cEG9DmoYEr11O063+Du5uax+mfNMCzn 4Z3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=qiON56UoXU0/uGWTYEp8exutI6n25nxHKy9cdV6V1e8=; fh=PiZ5V/4sGLDov5cF6A5wY5iqIfZAXRefEy8l5uZe2FU=; b=uko/3aroNTdEt2nba59rLH2WK4puTKiabtQN+dkaU4G5F1QgVgQFMXwwni8k0OBO5N Z9HFXs/+ty0VJ/QvUTEEdFrUZpsW+kjIyJO0yLjA59RPLvBSz/iH5JIN9xRhaj8rrw/W eyZK1hMiwJouuce9aXbG18UYKYhNgPapPYRpW2/6XZzEJ0V89+OupBsvxJ9BXKQnX8dZ l57ATswAbs0iBJ6E5Y66r3GsfjsR5C3tTOi3uPqaYjOY0Yvgejz2PbvV8O4PRQ/kkKQ5 fV+JnvOPfQNilS36eUWDZ0ARGzzKXWq04pkXOPX7zos/LSPEBtetWL/lGhDKDajjQtSs 2KiA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DihQqm1c; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80100-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80100-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cz7-20020a0564021ca700b00564c1ac8428si1317961edb.273.2024.02.25.06.28.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 06:28:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80100-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DihQqm1c; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80100-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80100-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1C22D1F21343 for ; Sun, 25 Feb 2024 14:28:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94577175AD; Sun, 25 Feb 2024 14:27:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DihQqm1c" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E923317579; Sun, 25 Feb 2024 14:27:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708871267; cv=none; b=i/FW5lnaTLVaea9twjxeIvTOFFHpz9d2ZRc6PPewC+pAG5hp3Ps4TNoJf5z8H9CU+c8m/a9tgzwjmXUnINCI5ejPscxKSLgI/cqDTa2fcMDwk4vWrA1wAIKDoFI5WbN/0L60mLumH+U88W1JuFf/zt6ZTIOFP++HeqH2OxLZTsU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708871267; c=relaxed/simple; bh=cy3xgv+zOTeCfTawrekO50j/BQnaTUqEu6LMlwDPXkg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sthZvdpeyNhFLDh8vQdyv/tuAg31UxW2A+ZMDg7qBiOvxX9KtjHG8Zr48viSz9lKbcgjzPBuK2CT1gO9Lr1RPQZzr6gC8rZNTFZ5JcNn9gXmscFzlpvWTalOyThqwhxdewIJAmhNBxA1nkBl3lo99I0S4EfcVh4mbPkx6w9mbKI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DihQqm1c; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4E28C433F1; Sun, 25 Feb 2024 14:27:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708871266; bh=cy3xgv+zOTeCfTawrekO50j/BQnaTUqEu6LMlwDPXkg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DihQqm1cO4S4hEX3mO7srDwzf8AMPmNm9EXTEwCUb5Ft61bHiQ/1Ti6VC3WR4TSt0 C2VD+yTN7u2+bDQISJ+ctCCUE/NkwCiU0/44ISX3U/OQjEK9Oy0LczGoor0eHlMCf+ lU8DVnp61JzDLpAIiUV6x51vVmXtjtRVKMxci84kwkJ4f9vYDLyiuiPzMeRjaXH/9O BGmTIx5qtzD9+05iKnUJKA/fCGOcYlo3JMAc5hjfITNSRzZnZGz3dr649kKpmSKkeB kwSNQp00qkqbm8g+kaVgvvk5KInutdjD7x67aAoUKdFq/qY1pz9FYHXqOyCNH7A2im 907Ychz4iLJIw== From: Jonathan Cameron To: devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Rob Herring , Frank Rowand , linux-kernel@vger.kernel.org, Julia Lawall Cc: Peter Zijlstra , Andy Shevchenko , Greg Kroah-Hartman , marek.vasut@gmail.com, Jonathan Cameron Subject: [RESEND PATCH v2 3/4] of: unittest: Use for_each_child_of_node_scoped() Date: Sun, 25 Feb 2024 14:27:13 +0000 Message-ID: <20240225142714.286440-4-jic23@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240225142714.286440-1-jic23@kernel.org> References: <20240225142714.286440-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791881455840810848 X-GMAIL-MSGID: 1791881455840810848 From: Jonathan Cameron A simple example of the utility of this autocleanup approach to handling of_node_put(). In this particular case some of the nodes needed for the test are not available and the _available_ version would cause them to be skipped resulting in a test failure. Signed-off-by: Jonathan Cameron --- drivers/of/unittest.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index cfd60e35a899..d353327767b3 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -233,27 +233,22 @@ static void __init of_unittest_dynamic(void) static int __init of_unittest_check_node_linkage(struct device_node *np) { - struct device_node *child; int count = 0, rc; - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { if (child->parent != np) { pr_err("Child node %pOFn links to wrong parent %pOFn\n", child, np); - rc = -EINVAL; - goto put_child; + return -EINVAL; } rc = of_unittest_check_node_linkage(child); if (rc < 0) - goto put_child; + return rc; count += rc; } return count + 1; -put_child: - of_node_put(child); - return rc; } static void __init of_unittest_check_tree_linkage(void) From patchwork Sun Feb 25 14:27:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 206026 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1599943dyb; Sun, 25 Feb 2024 06:28:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUzNuzUGkwimpsO7YMotBlBzaZzn/5qttDM2wtsE6gi74dy3qXpi0dEQ7NITcZSf/vEfpEjP8fJon0qo/qmIS1IgWNqXw== X-Google-Smtp-Source: AGHT+IENrR3imq5+rrFICce8r93pshkZtkNn5rnIZz7F680NHi8vNa1GgefAQKSPdtyG/dk0h/fk X-Received: by 2002:a05:620a:1091:b0:787:c623:9ccd with SMTP id g17-20020a05620a109100b00787c6239ccdmr3318896qkk.58.1708871339102; Sun, 25 Feb 2024 06:28:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708871339; cv=pass; d=google.com; s=arc-20160816; b=Xqe9vqHdoomdFCKuxYl1u8qxrJ6HCBhdH/kz7kuNGd/dPi19hAeRuKX9Fhv13Y76L2 p4dhTZf6NrMyImWBb/idKk8Aorjj5iUZYCcKc8QkimrkpaUoTeJUa5Zx3JVZGZwOqlbA hva56wOl6HeCIvAUkruo1cnWMBpkr3HT3LJBTb6KaniRsjI7/vMu6h9YeY3ZVVJ3/qPq 3Gqbwh+r74q8eHwV9lQY3ZyG57p4A+VdbrxCBUfN/8q9Ng/SriHRIct92Bhs6V6oASwP NdTNzgRNvvNlulzHC3bOgnKlAFFTb87LMh8e0oHlTGQwasn3VQk4f9Yq8MhiVxc8nPLa PHGQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=yrG5adLrW+jnciAACbwy0oBs7XJnJ9GbNUbU8vn5lD8=; fh=PiZ5V/4sGLDov5cF6A5wY5iqIfZAXRefEy8l5uZe2FU=; b=h9aJs0s5CHmCc+tyc0e2ZSwm+LRDoh5AHyhbBpwkJdRuBq6lBVIZoBXxyZQFKTwgJf wDiqGzL7XAKbEoLnvcybuOZzX1AGguHJjdGxQxDtZ7bipA7PLszkPwxjtZJaecHIbR0v U1i6WRUNzeckJiBNV6i6cGycqTrIokHPIeMAQAe2PifqG4B713U9Ie+xXRhB9qvtm9h/ rnmz1VeuiUhua7Q8G96CXVB17pTV0llOk9MtEy5zpwM/xxnqEyp0oqGnbyBTI0Y/mo1/ iTvVPLFbilC+rVUjvMO1xlF2ZZrk9yQxDvPvNTjxPusy5fBAqfLSzUGNVdQugEF6DoOj mvFg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=re8r5oJN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80101-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80101-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id p18-20020a05620a113200b00787c953a7b0si2052683qkk.701.2024.02.25.06.28.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 06:28:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80101-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=re8r5oJN; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80101-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80101-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DF0A31C20B21 for ; Sun, 25 Feb 2024 14:28:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 86153179AF; Sun, 25 Feb 2024 14:27:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="re8r5oJN" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D3F28175BC; Sun, 25 Feb 2024 14:27:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708871270; cv=none; b=V/wvoRqQFmDx5AObb9c4qyzNQRqfO8R21AgaOr/u47+sYOtoZuX0Ab6cz8uhU++7nLImGzVMzUVC9LXEhOh1TQ6Whv3nRIbriyw4nG2OXdyaU9vJNRTy+wZVSukzQNm/8P9jtg0651Xj2BxIPUNFrlzbbeJM5f78ty9QVteWhWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708871270; c=relaxed/simple; bh=FqXiRDMNp8tTGWD6g9YkejKEc8q+OEjl8zHNs3d6IoU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t+Znc4WrOrXb+TpUt4VmTXVoPwRTivwW5hJo9iFzd2QeaPn7QEFgGVnLvu9PCXqHEyyYHtP3fGXtzQ9+Bwzjki8J69v+XJ1zI9WQZn7Mt64+/SdRHKKL7XtOY2yUoUHHyA6kCgDlZFs58VJ0cxkn4BUBmTCIA5meTSCYf5hTTwU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=re8r5oJN; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6FF42C433F1; Sun, 25 Feb 2024 14:27:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708871270; bh=FqXiRDMNp8tTGWD6g9YkejKEc8q+OEjl8zHNs3d6IoU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=re8r5oJNr4bsZl9Uw7G61ebplfEtdtt99hYivWytcHnU04kO99xj0WMHxrr6reaFv nmDN0hWSpVR3FW+1A3imLl4aL7lI9OdFIWZPtsPVQnqcZj7eELmv7RbgONjjUeKeW8 oHNIA7iaFJErWJHuRbNk36FTkOw2KSA3ROxaY9dpMXjtfzs1v6HkU9BCdMt/cCLIXH vcr2/C3NipA+0mWwJDzi83LhQl6qrR5e8vZ5Yh5fuJkbnOILEAdiqAY3ZdfTgeJveu Bxgz2JkCa10NJrvF+vbUUh7WMNj+5n5mSBvLe4OBmWMmdTuDefB8qyQT9MOYpY57mv eRdrY2HvYL8cw== From: Jonathan Cameron To: devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Rob Herring , Frank Rowand , linux-kernel@vger.kernel.org, Julia Lawall Cc: Peter Zijlstra , Andy Shevchenko , Greg Kroah-Hartman , marek.vasut@gmail.com, Jonathan Cameron Subject: [RESEND PATCH v2 4/4] iio: adc: rcar-gyroadc: use for_each_available_child_node_scoped() Date: Sun, 25 Feb 2024 14:27:14 +0000 Message-ID: <20240225142714.286440-5-jic23@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240225142714.286440-1-jic23@kernel.org> References: <20240225142714.286440-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791881473223045414 X-GMAIL-MSGID: 1791881473223045414 From: Jonathan Cameron Using automated cleanup to replace of_node_put() handling allows for a simplfied flow by enabling direct returns on errors. Non available child nodes should never have been considered; that is ones where status != okay and was defined. Signed-off-by: Jonathan Cameron --- drivers/iio/adc/rcar-gyroadc.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c index d524f2e8e927..15a21d2860e7 100644 --- a/drivers/iio/adc/rcar-gyroadc.c +++ b/drivers/iio/adc/rcar-gyroadc.c @@ -318,7 +318,6 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) struct rcar_gyroadc *priv = iio_priv(indio_dev); struct device *dev = priv->dev; struct device_node *np = dev->of_node; - struct device_node *child; struct regulator *vref; unsigned int reg; unsigned int adcmode = -1, childmode; @@ -326,7 +325,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) unsigned int num_channels; int ret, first = 1; - for_each_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { of_id = of_match_node(rcar_gyroadc_child_match, child); if (!of_id) { dev_err(dev, "Ignoring unsupported ADC \"%pOFn\".", @@ -352,7 +351,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) num_channels = ARRAY_SIZE(rcar_gyroadc_iio_channels_3); break; default: - goto err_e_inval; + return -EINVAL; } /* @@ -369,7 +368,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) dev_err(dev, "Failed to get child reg property of ADC \"%pOFn\".\n", child); - goto err_of_node_put; + return ret; } /* Channel number is too high. */ @@ -377,7 +376,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) dev_err(dev, "Only %i channels supported with %pOFn, but reg = <%i>.\n", num_channels, child, reg); - goto err_e_inval; + return -EINVAL; } } @@ -386,7 +385,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) dev_err(dev, "Channel %i uses different ADC mode than the rest.\n", reg); - goto err_e_inval; + return -EINVAL; } /* Channel is valid, grab the regulator. */ @@ -396,8 +395,7 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) if (IS_ERR(vref)) { dev_dbg(dev, "Channel %i 'vref' supply not connected.\n", reg); - ret = PTR_ERR(vref); - goto err_of_node_put; + return PTR_ERR(vref); } priv->vref[reg] = vref; @@ -422,7 +420,6 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) * we can stop parsing here. */ if (childmode == RCAR_GYROADC_MODE_SELECT_1_MB88101A) { - of_node_put(child); break; } } @@ -433,12 +430,6 @@ static int rcar_gyroadc_parse_subdevs(struct iio_dev *indio_dev) } return 0; - -err_e_inval: - ret = -EINVAL; -err_of_node_put: - of_node_put(child); - return ret; } static void rcar_gyroadc_deinit_supplies(struct iio_dev *indio_dev)