From patchwork Sun Feb 11 19:25:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13552573 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 5050C5D73A; Sun, 11 Feb 2024 19:26:33 +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=1707679594; cv=none; b=kH9U2BukyNCx3eTs06eCEFf+QOYCr499oVHAZPyoORYBz76K7NEBKJbcwBJueiEgB/5u0OzzvI9C4bozOLmtS+w3d7/nfmZyTVBY8Hh7ec74j74F8yCAEgu4IntvqjcQMBlIqxZR0OKspC5a0aLTzqCrZksaLj8kR9zEqc9Bg/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707679594; c=relaxed/simple; bh=5BKBVxpx4qstzc7Dy13OyBJbrkG74U7h3TrTUSitCsc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F8esYrSXMDzdOVRgvt93JDDCsULhN/WEuLdooH2ak8Krq3Bda76uP61pE03ma7iasZJBoEZDvLFZXb9M7omDVe3N1ARSEqPz7FvtNB5YPUZMEGDyT/0RvJ7ivwPPKpKp/L2Ed0wl7zJv8tOfGQm8vao/zT7eWoVzg8/lLPF/1+k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZapYHsWb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZapYHsWb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3059C43390; Sun, 11 Feb 2024 19:26:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707679593; bh=5BKBVxpx4qstzc7Dy13OyBJbrkG74U7h3TrTUSitCsc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZapYHsWbFynFnItbU4COXZOxEHrq8zsYUum2h58zqy/ijFZi3ZQjeR85BziLCxCga ECFdotlGWVV3ndxAULB7exNmfwdWau2cQdKkE7Uh2jj1VIbI7voGU4tp8JArPbPTkP 7b0Rntnf+Lgb64nvDQ8G5LgSsjBTj+u3Do5pKNXNqN9Q+lQCFOy1CBQ3AZXoslcTby y5P4B1UHwDXQh2n0R6Cu2P86ed6gEIxoS66197uLR+Hf3/zF9lkNo4Rg1qKCiZYxOd irjKY8ZM9yR+TnnB2bQJdYeULuWSVQCwXiW86CHDxUGo9Mu4l4mUUznwGyAdo9wYC8 kAvt4/6o17DTA== From: Jonathan Cameron To: linux-iio@vger.kernel.org, "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org, Andy Shevchenko , Greg Kroah-Hartman , Daniel Scally , Heikki Krogerus , Sakari Ailus , Julia Lawall Cc: =?utf-8?q?Nuno_S=C3=A1?= , Cosmin Tanislav , Mihail Chindris , Rasmus Villemoes , Tomislav Denis , Marek Vasut , Olivier Moysan , Fabrice Gasnier , Lad Prabhakar , Dmitry Baryshkov , Marijn Suijten , Marius Cristea , Ibrahim Tilki , Peter Zijlstra , Jonathan Cameron Subject: [PATCH v2 01/14] device property: Add cleanup.h based fwnode_handle_put() scope based cleanup. Date: Sun, 11 Feb 2024 19:25:27 +0000 Message-ID: <20240211192540.340682-2-jic23@kernel.org> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240211192540.340682-1-jic23@kernel.org> References: <20240211192540.340682-1-jic23@kernel.org> Precedence: bulk X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron Useful where the fwnode_handle was obtained from a call such as fwnode_find_reference() as it will safely do nothing if IS_ERR() is true and will automatically release the reference on the variable leaving scope. Reviewed-by: Andy Shevchenko Signed-off-by: Jonathan Cameron --- include/linux/property.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/property.h b/include/linux/property.h index e6516d0b7d52..bcda028f1a33 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -188,6 +189,8 @@ struct fwnode_handle *device_get_named_child_node(const struct device *dev, struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode); void fwnode_handle_put(struct fwnode_handle *fwnode); +DEFINE_FREE(fwnode_handle, struct fwnode_handle *, + if (!IS_ERR_OR_NULL(_T)) fwnode_handle_put(_T)) int fwnode_irq_get(const struct fwnode_handle *fwnode, unsigned int index); int fwnode_irq_get_byname(const struct fwnode_handle *fwnode, const char *name);