[PATCH v3 17/24] driver core: Export get_dev_from_fwnode()
Danilo Krummrich
dakr at kernel.org
Wed Jul 2 12:26:18 PDT 2025
On Wed, Jul 02, 2025 at 09:34:12AM +0200, Greg Kroah-Hartman wrote:
> On Tue, Jul 01, 2025 at 01:47:19PM +0200, Ulf Hansson wrote:
> > It has turned out get_dev_from_fwnode() is useful at a few other places
> > outside of the driver core, as in gpiolib.c for example. Therefore let's
> > make it available as a common helper function.
> >
> > Suggested-by: Saravana Kannan <saravanak at google.com>
> > Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
> > Tested-by: Hiago De Franco <hiago.franco at toradex.com> # Colibri iMX8X
> > Tested-by: Tomi Valkeinen <tomi.valkeinen at ideasonboard.com> # TI AM62A,Xilinx ZynqMP ZCU106
> > Signed-off-by: Ulf Hansson <ulf.hansson at linaro.org>
> > ---
> > drivers/base/core.c | 8 ++++++--
> > include/linux/device.h | 1 +
> > 2 files changed, 7 insertions(+), 2 deletions(-)
> >
>
> Acked-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
I'm a bit concerned about exporting get_dev_from_fwnode() -- at least without a
clear note on that this helper should be used with caution.
AFAIK, a struct fwnode_handle instance does not have a reference count for its
struct device pointer.
Hence, calling get_dev_from_fwnode() with a valid fwnode handle is not enough.
The caller also needs to ensure that the device the fwnode has a pointer to has
not been released yet.
If this really needs to be exported, can we please add documentation covering
this properly?
- Danilo
More information about the linux-arm-kernel
mailing list