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

Sascha Hauer s.hauer at pengutronix.de
Mon Apr 14 06:28:27 PDT 2025


On Mon, Apr 14, 2025 at 12:49:14PM +0200, Marco Felsch wrote:
> On 25-04-14, Ahmad Fatoum wrote:
> > 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.
> 
> I have seen that :-) but in the end it was a local function so changes
> shouldn't be hard to adapt.
> 
> With making the function public avaiable I don't see why
> cdev_find_partition() should return the parent device if NULL is
> provided. IMHO this is wrong input from the user. What use-case do you
> see with returning the parent device?

I can follow this argument and changed the caller to:

	if (partname) {
		cdev = cdev_find_partition(cdev, partname);
		if (!cdev)
			return -ENODEV;
	}

Sascha

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