[PATCH 10/18] cdev: have devfs_add_partition return existing identical partition, not NULL
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed Jun 7 01:06:02 PDT 2023
On 01.06.23 09:36, Sascha Hauer wrote:
> On Wed, May 31, 2023 at 04:59:19PM +0200, Ahmad Fatoum wrote:
>> Starting with commit 7f9f45b9bfef ("devfs: Do not create overlapping
>> partitions"), any overlapping is disallowed. Overlapping can be useful
>> though to bridge the gap between partition described in DT and via
>> on-disk partition tables. Let's handle the case of identical partitions
>> specially and have it neither be an error or a duplicate partition, but
>> instead just return the existing partition. This existing partition will
>> be given a device tree node and thus enabling schemes like:
>>
>> &{/state} {
>> backend = <&state_part>;
>> };
>>
>> &mmc1 {
>> partitions {
>> compatible = "fixed-partitions";
>> #address-cells = <2>;
>> #size-cells = <2>;
>>
>> state_part: partition at 5300000 {
>> label = "barebox-state";
>> /* will be folded with overlapping GPT partition if found */
>> reg = <0x0 0x5300000 0x0 0x100000>;
>> };
>> };
>> };
>
> You introduced the DEVFS_PARTITION_FROM_OF earlier this series.
> Depending on the order the code runs you end up with either the
> partition from the partition table or the one created from OF with
> DEVFS_PARTITION_FROM_OF. I am not sure about the implications of
> this inconsistency. Can it lead to problems later?
Order is always the same: parse_partition_table is called before
of_parse_partitions. The latter is called on the cdev populated
by blockdevice_register at all call site.
Nevertheless, I have tested that you can reorder parse_partition_table
and of_parse_partitions, but there's a slight change in behavior: The first
partition that's registered is the namesake. I have adapted the code
to call devfs_create_link(overlap, partinfo->name); in that case. That way
we will always have all partitions in /dev regardless of order. The only
thing that will change, is which is a real cdev and which is a link.
Thanks,
Ahmad
>
> 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