From patchwork Fri Feb 16 17:52:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13560407 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 8B8A812F38D; Fri, 16 Feb 2024 17:52: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=1708105970; cv=none; b=XvVeohppBkpgDBkK3akUskH8n12eHF6ZJ+HiKFGNLjrFlKB4HkFN4t2JpKKZuIfvhxq70STTPDzW9lGI2RWLddMBoQDP6vPmsTePRIXUTSNT8o77oiS/nJFX/jamOuq/iYsh7IsJm/teZiqXSnEmO68zEIomoyGL352lD/aJjCA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708105970; c=relaxed/simple; bh=ooH3tVQ8RhEdYrJS+Vd+dsFlhzvCEObmeWM2dC5oN6E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h4OHXJlkVbQvzvWUJzmRWRi6XEhcFWEQckDzRo0T9JxO1onye6OJOLUuyQLfvdHdoJ7f6R+XAcNh4MfE+Xq6fhfGJA/vMiEjT8Ca8xs95eTKZF5S292uTF6fvFU3GutTyghEc+aQFZsWDsvJM/96y0vTf+QSe3aY37d1wxqsYk4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RQMr2kNI; 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="RQMr2kNI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04299C433F1; Fri, 16 Feb 2024 17:52:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708105970; bh=ooH3tVQ8RhEdYrJS+Vd+dsFlhzvCEObmeWM2dC5oN6E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RQMr2kNIKv9JO+vemAAOG8JYySOol6MLWIkaHRKyVby2H7S6SMaynLsGdo7yu+uVJ 899WJBVOTgy/a05jzF0BRU4WsC/ojl5DnyvBi9sBjY76ibULtb7W1RJuOS6thfcqyo y3FivUtfZNmVnNC8a7iLuvneheBCicG9DQmaeLGv1Kh4+cQAfTIsPHtN3cPmL03Xpj waRZn3KjkJf4fwbunwVdiCUUHr8tksy5aT2v2SAsioyi4b8klRjRigJ+nRnXYOcV3M BQTp753NzLtYvLXyGQC76KhGFAKsLt8PYdU9X4e2OsEV5vsufj64jgwJ89wkdY00Du NZWCgIMHxtE5Q== 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 v3 02/15] device property: Add cleanup.h based fwnode_handle_put() scope based cleanup. Date: Fri, 16 Feb 2024 17:52:08 +0000 Message-ID: <20240216175221.900565-3-jic23@kernel.org> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240216175221.900565-1-jic23@kernel.org> References: <20240216175221.900565-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 151bcab4f92a..9e67c3c4df6e 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -201,6 +202,8 @@ static inline void fwnode_handle_put(struct fwnode_handle *fwnode) fwnode_call_void_op(fwnode, put); } +DEFINE_FREE(fwnode_handle, struct fwnode_handle *, 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);