From patchwork Fri Feb 16 17:52:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13560417 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 1346612F38D; Fri, 16 Feb 2024 17:52:43 +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=1708105964; cv=none; b=WhRa6cTIqoFRbvooPBnbOtqqbsrvkcRF4GA/Ay+pXF9RKWfOlsPLnVhdl1g5MYTFf1wiJaVWXtpR4IPkh0UE2QqbT5c0EO8FHQ6QNIYEoee+Tn0wsRTGSfWR5UnmQgFcVakM2RdePnE9BjeESi0GJB2pDQjwgCiRzJTuRh2D6Es= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708105964; c=relaxed/simple; bh=gZcNKYyfXotLlrZugPfjZu+r2vzoJfxqVIW/Zvhx97Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FMTbpkgjHjB3sohuYaO7K1Jr6hb4bexEI0A0PVAwdMtJdPoeRUKHcIutsdpryMyGVEXSUYR2n3WIZzkaZ12zPNprLTL/cRadaVUHv9lkFW5ToM+cbIiJhifNt5mfa6K7CSPm/C1k6w/gWPAvEFYKUPMSHTAnjy7SFkZ9lUQPzn4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qF6oc5ct; 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="qF6oc5ct" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24AA1C43394; Fri, 16 Feb 2024 17:52:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708105963; bh=gZcNKYyfXotLlrZugPfjZu+r2vzoJfxqVIW/Zvhx97Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qF6oc5ctgliN//gOGRPP/Pmos7Z0LvcwsRNTds/TniRVMqS5t5jtHurxxQa0gZ3zV Wv2pJx9U1brdKepTOZ07JzjShn+Panido7fHLAJFiO6zitjEMGdIjrTDnvqXAL5aUx 41oQnNCx/v8jrXY8xuPiIpoAaVpCSqcE6JZTc947hU0i9PlgiDOu2ws0chs6d1APCa 2niY0FQLPCNHQ4u+N6H7ObPt8T8Ctlc7i0dFSW7TKsc0Qfw0Hbyq/TnnbLEgNIxZzc pHkVfulPayTtGnkOwwIrOHAuRTVHs3WwEkRA2ojWPbxyBBRdKK1+WtSiiZMdztCjfB i2oSkd3mhiA2Q== 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 01/15] device property: Move fwnode_handle_put() into property.h Date: Fri, 16 Feb 2024 17:52:07 +0000 Message-ID: <20240216175221.900565-2-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-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Cameron By having this function as static inline in the header, the compiler is able to see if can optimize the call out if (IS_ERR_OR_NULL(fwnode)) This will allow a simpler DEFINE_FREE() call in the following patch. Suggested-by: Sakari Ailus Signed-off-by: Jonathan Cameron --- drivers/base/property.c | 14 -------------- include/linux/property.h | 14 +++++++++++++- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/base/property.c b/drivers/base/property.c index a1b01ab42052..53e42031c646 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -923,20 +923,6 @@ struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode) } EXPORT_SYMBOL_GPL(fwnode_handle_get); -/** - * fwnode_handle_put - Drop reference to a device node - * @fwnode: Pointer to the device node to drop the reference to. - * - * This has to be used when terminating device_for_each_child_node() iteration - * with break or return to prevent stale device node references from being left - * behind. - */ -void fwnode_handle_put(struct fwnode_handle *fwnode) -{ - fwnode_call_void_op(fwnode, put); -} -EXPORT_SYMBOL_GPL(fwnode_handle_put); - /** * fwnode_device_is_available - check if a device is available for use * @fwnode: Pointer to the fwnode of the device. diff --git a/include/linux/property.h b/include/linux/property.h index e6516d0b7d52..151bcab4f92a 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -187,7 +187,19 @@ struct fwnode_handle *device_get_named_child_node(const struct device *dev, const char *childname); struct fwnode_handle *fwnode_handle_get(struct fwnode_handle *fwnode); -void fwnode_handle_put(struct fwnode_handle *fwnode); + +/** + * fwnode_handle_put - Drop reference to a device node + * @fwnode: Pointer to the device node to drop the reference to. + * + * This has to be used when terminating device_for_each_child_node() iteration + * with break or return to prevent stale device node references from being left + * behind. + */ +static inline void fwnode_handle_put(struct fwnode_handle *fwnode) +{ + fwnode_call_void_op(fwnode, put); +} 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);