[PATCH v3 02/28] driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode()
Danilo Krummrich
dakr at kernel.org
Wed Jul 2 11:51:33 PDT 2025
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 at kernel.org>
>> Link: https://lore.kernel.org/lkml/CAGETcx97QjnjVR8Z5g0ndLHpK96hLd4aYSV=iEkKPNbNOccYmA@mail.gmail.com/
>> Signed-off-by: Herve Codina <herve.codina at bootlin.com>
>> Reviewed-by: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
>> Reviewed-by: Saravana Kannan <saravanak at google.com>
>> Reviewed-by: Luca Ceresoli <luca.ceresoli at bootlin.com>
>> ---
>> 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.
More information about the linux-arm-kernel
mailing list