[PATCH 07/18] cdev: alias: add support for partition links

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Apr 14 03:20:34 PDT 2025


Hello Marco,

On 4/14/25 12:17, Marco Felsch wrote:
> On 25-04-14, Ahmad Fatoum wrote:
>> We currently support bootsource.2, but not bootsource.root-A.
>> Fix this and while at it, factor out the logic for general reuse.
>>
>> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
>> ---

[snip]

>> -static struct cdev *resolve_partition(struct cdev *cdev,
>> -				      const char *partname)
>> -{
>> -	struct cdev *partcdev;
>> -
>> -	if (!partname)
>> -		return cdev;
>> -
>> -	for_each_cdev_partition(partcdev, cdev) {
>> -		if (streq_ptr(partcdev->partname, partname))
>> -			return partcdev;
>> -	}
>> -
>> -	return ERR_PTR(-ENODEV);
>> -}
>> -

[snip]

>> +/**
>> + * cdev_find_partition - find a partition belonging to a physical device
>> + *
>> + * @cdev: the cdev which should be searched for partitions
>> + * @name: the partition name
>> + */
>> +struct cdev *cdev_find_partition(struct cdev *cdevm, const char *name)
>> +{
>> +	struct cdev *partcdev;
>> +
>> +	if (!name)
>> +		return cdevm;

No, I want a NULL name to expand to the parent device. This makes is a
drop-in replacement for resolve_partition() removed in this same patch.

Thanks,
Ahmad

> 
> 		return ERR_PTR(-EINVAL) ?
> 
> Regards,
>   Marco
> 
>> +
>> +	for_each_cdev_partition(partcdev, cdevm) {
>> +		struct cdev *cdevl;
>> +
>> +		if (streq_ptr(partcdev->partname, name))
>> +			return partcdev;
>> +
>> +		list_for_each_entry(cdevl, &partcdev->links, link_entry) {
>> +			if (streq_ptr(cdevl->partname, name))
>> +				return cdevl;
>> +		}
>> +	}
>> +
>> +	return NULL;
>> +}
>> +
>>  /**
>>   * device_find_partition - find a partition belonging to a physical device
>>   *
>> diff --git a/include/driver.h b/include/driver.h
>> index 3f2c681c0e80..ca002c5164c2 100644
>> --- a/include/driver.h
>> +++ b/include/driver.h
>> @@ -503,6 +503,7 @@ int devfs_create(struct cdev *);
>>  int devfs_create_link(struct cdev *, const char *name);
>>  int devfs_remove(struct cdev *);
>>  int cdev_find_free_index(const char *);
>> +struct cdev *cdev_find_partition(struct cdev *cdevm, const char *name);
>>  struct cdev *device_find_partition(struct device *dev, const char *name);
>>  struct cdev *lcdev_by_name(const char *filename);
>>  struct cdev *cdev_readlink(struct cdev *cdev);
>> -- 
>> 2.39.5
>>
>>
>>
> 

-- 
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 |




More information about the barebox mailing list