Re: [PATCH 04/18] of: partition: support of_partition_ensure_probed on parent device

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

 



Hello Marco,

On 31.05.23 18:30, Marco Felsch wrote:
> Hi Ahmad,
> 
> On 23-05-31, Ahmad Fatoum wrote:
>> barebox-state code uses of_partition_ensure_probed to resolve the
>> backend property. We want to allow backend to point directly at a
>> storage device instead of a partition. We can't determine whether a DT
>> device is a storage device though before it's probed, so let's have
>> of_partition_ensure_probed support either case.
>>
>> Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
>> ---
>>  drivers/of/partition.c | 26 ++++++++++++++++++++++----
>>  drivers/of/platform.c  |  2 +-
>>  2 files changed, 23 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/of/partition.c b/drivers/of/partition.c
>> index 40c47f554ad2..a70e503cec9e 100644
>> --- a/drivers/of/partition.c
>> +++ b/drivers/of/partition.c
>> @@ -110,14 +110,32 @@ int of_parse_partitions(struct cdev *cdev, struct device_node *node)
>>  	return 0;
>>  }
>>  
>> +/**
>> + * of_partition_ensure_probed - ensure a parition is probed
>> + * @np: pointer to a partition or to a partitionable device
>> + *      Unfortunately, there is no completely reliable way
>> + *      to differentiate partitions from devices prior to
>> + *      probing, because partitions may also have compatibles.
>> + *      We only handle nvmem-cells, so anything besides that
>> + *      is assumed to be a device that should be probed directly.
>> + *
>> + * Returns zero on success or a negative error code otherwise
>> + */
>>  int of_partition_ensure_probed(struct device_node *np)
>>  {
>> -	np = of_get_parent(np);
>> +	struct device_node *parent = of_get_parent(np);
>>  
>> -	if (of_device_is_compatible(np, "fixed-partitions"))
>> -		np = of_get_parent(np);
>> +	if (parent && of_device_is_compatible(parent, "fixed-partitions"))
> 
> When is the parent not present? This should only be the case when 'np'
> points to the root_node. So in case of !parent I would return -EINVAL
> early.

will do.

> 
>> +		return of_device_ensure_probed(of_get_parent(np));
> 							     ^
> 							   parent?

Yes, You're right.

> Not related to this patch but the logic would become easier if would
> have devices for each mtd-part, like the kernel does. In such case we
> could avoid these special handlings and just use
> of_device_ensure_probed() at least for the mtd-parts, nvmem-cells still
> need a special handling.

How you mean? of_partition_ensure_probed can be called before there can
be any devices at all.

> 
> Regards,
>   Marco
> 
>> -	return np ? of_device_ensure_probed(np) : -EINVAL;
>> +	if (of_get_compatible_child(np, "fixed-partitions"))
>> +		return of_device_ensure_probed(np);

I think this can be dropped, so the case falls through to the final
of_device_ensure_probed.

>> +
>> +	if (!of_property_present(np, "compatible") ||
>> +	    of_device_is_compatible(np, "nvmem-cells"))
>> +		return of_device_ensure_probed(parent);
>> +
>> +	return of_device_ensure_probed(np);
>>  }
>>  EXPORT_SYMBOL_GPL(of_partition_ensure_probed);

Thanks,
Ahmad

>>  
>> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
>> index ab737629325a..78b8a31331db 100644
>> --- a/drivers/of/platform.c
>> +++ b/drivers/of/platform.c
>> @@ -484,7 +484,7 @@ int of_device_ensure_probed(struct device_node *np)
>>  {
>>  	struct device *dev;
>>  
>> -	if (!deep_probe_is_supported())
>> +	if (!np || !deep_probe_is_supported())
>>  		return 0;
>>  
>>  	dev = of_device_create_on_demand(np);
>> -- 
>> 2.39.2
>>
>>
>>
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux