mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Marco Felsch <m.felsch@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 07/18] cdev: alias: add support for partition links
Date: Mon, 14 Apr 2025 12:20:34 +0200	[thread overview]
Message-ID: <af6d8b79-f081-4e39-8dba-ce487354e76d@pengutronix.de> (raw)
In-Reply-To: <20250414101715.esfc3lxmen3ez6jb@pengutronix.de>

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




  reply	other threads:[~2025-04-14 10:38 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-14  6:31 [PATCH 00/18] boot: improve cdev alias and blspec support Ahmad Fatoum
2025-04-14  6:31 ` [PATCH 01/18] cdev: make cdev_find_child_by_gpt_typeuuid external Ahmad Fatoum
2025-04-14  6:31 ` [PATCH 02/18] cdev: constify cdev_find_child_by_gpt_typeuuid's guid_t pointer argument Ahmad Fatoum
2025-04-14  6:31 ` [PATCH 03/18] partition: efi: respect DPS_TYPE_FLAG_NO_AUTO flag Ahmad Fatoum
2025-04-14 11:38   ` Sascha Hauer
2025-04-14  6:31 ` [PATCH 04/18] blspec: iterate over all XBOOTLDR partitions Ahmad Fatoum
2025-04-14  6:31 ` [PATCH 05/18] blspec: support GPT XBOOTLDR partition Ahmad Fatoum
2025-04-14  6:31 ` [PATCH 06/18] blspec: collect bootloader spec entries from ESP Ahmad Fatoum
2025-04-14 10:14   ` Marco Felsch
2025-04-14 10:19     ` Ahmad Fatoum
2025-04-14 10:41       ` Marco Felsch
2025-04-14  6:31 ` [PATCH 07/18] cdev: alias: add support for partition links Ahmad Fatoum
2025-04-14 10:17   ` Marco Felsch
2025-04-14 10:20     ` Ahmad Fatoum [this message]
2025-04-14 10:49       ` Marco Felsch
2025-04-14 13:28         ` Sascha Hauer
2025-04-14  6:31 ` [PATCH 08/18] cdev: do not dereference partname for non-partitions Ahmad Fatoum
2025-04-14  6:31 ` [PATCH 09/18] cdev: use common cdev_free helper internally Ahmad Fatoum
2025-04-14  6:31 ` [PATCH 10/18] cdev: implement devfs_create_link in terms of devfs_create Ahmad Fatoum
2025-04-14  6:31 ` [PATCH 11/18] misc: storage-by-uuid: consider only first diskuuid match Ahmad Fatoum
2025-04-14 10:24   ` Marco Felsch
2025-04-14 10:31     ` Ahmad Fatoum
2025-04-14  6:31 ` [PATCH 12/18] misc: storage-by-uuid: prepare for generalizing to different aliases Ahmad Fatoum
2025-04-14 10:31   ` Marco Felsch
2025-04-14 10:35     ` Ahmad Fatoum
2025-04-14  6:31 ` [PATCH 13/18] misc: storage-by-uuid: rename to storage-by-alias Ahmad Fatoum
2025-04-14  6:31 ` [PATCH 14/18] misc: storage-by-alias: switch over to using cdev aliases Ahmad Fatoum
2025-04-14  6:31 ` [PATCH 15/18] misc: storage-by-alias: add support barebox,bootsource Ahmad Fatoum
2025-04-14  6:31 ` [PATCH 16/18] misc: storage-by-alias: register as link to main cdev Ahmad Fatoum
2025-04-14  6:31 ` [PATCH 17/18] cdev: constify cdev_readlink argument Ahmad Fatoum
2025-04-14  6:31 ` [PATCH 18/18] cdev: follow links in cdev_find_child_by_gpt_typeuuid Ahmad Fatoum
2025-04-14 10:51 ` [PATCH 00/18] boot: improve cdev alias and blspec support Marco Felsch
2025-04-14 13:25 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=af6d8b79-f081-4e39-8dba-ce487354e76d@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.felsch@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox