Re: [PATCH v3 02/28] driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/27/25 4:18 PM, Rob Herring wrote:
On Fri, Jun 13, 2025 at 03:47:42PM +0200, Herve Codina wrote:
get_dev_from_fwnode() calls get_device() and so it acquires a reference
on the device returned.

In order to be more obvious that this wrapper is a get_device() variant,
rename it to get_device_from_fwnode().

Suggested-by: Mark Brown <broonie@xxxxxxxxxx>
Link: https://lore.kernel.org/lkml/CAGETcx97QjnjVR8Z5g0ndLHpK96hLd4aYSV=iEkKPNbNOccYmA@xxxxxxxxxxxxxx/
Signed-off-by: Herve Codina <herve.codina@xxxxxxxxxxx>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Reviewed-by: Saravana Kannan <saravanak@xxxxxxxxxx>
Reviewed-by: Luca Ceresoli <luca.ceresoli@xxxxxxxxxxx>
---
  drivers/base/core.c | 14 +++++++-------
  1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index cbc0099d8ef2..36ccee91ba9a 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1881,7 +1881,7 @@ static void fw_devlink_unblock_consumers(struct device *dev)
  	device_links_write_unlock();
  }
-#define get_dev_from_fwnode(fwnode) get_device((fwnode)->dev)
+#define get_device_from_fwnode(fwnode)	get_device((fwnode)->dev)

In patch 3, you add the same define. Is there some reason to not move it
to a header?

AFAIK, the struct device pointer in struct fwnode_handle is not backed by a
reference count, which means that it's the callers responsibility to ensure that
it's guaranteed that the pointer in struct fwnode_handle is still valid.

Besides some driver-core internals the pointer shouldn't be used, and hence this
helper shouldn't be available through a public header.




[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux