[PATCH v6 1/2] part: Export part_driver_lookup_type for external use
Javier Tia
javier.tia at linaro.org
Fri Sep 26 00:49:46 CEST 2025
Hi Ilias,
On Thu, Sep 25, 2025, at 12:20 AM, Ilias Apalodimas wrote:
> Hi Javier,
>
> On Thu, 25 Sept 2025 at 02:31, Javier Tia <javier.tia at linaro.org> wrote:
>>
>> Make part_driver_lookup_type non-static so it can be used outside
>> part.c. This allows external callers to determine the appropriate
>> partition driver for a block device, enabling more flexible handling of
>> partition types.
>>
>> Add a prototype and kernel-doc comment in part.h to document the
>> function contract. Provide a stub inline implementation returning NULL
>> when partition support is disabled, ensuring build consistency across
>> configurations.
>>
>> Signed-off-by: Javier Tia <javier.tia at linaro.org>
>> ---
>> disk/part.c | 2 +-
>> include/part.h | 21 +++++++++++++++++++++
>> 2 files changed, 22 insertions(+), 1 deletion(-)
>>
>> diff --git a/disk/part.c b/disk/part.c
>> index 66e2b3a7219..f0c6866e210 100644
>> --- a/disk/part.c
>> +++ b/disk/part.c
>> @@ -63,7 +63,7 @@ static struct part_driver *part_driver_get_type(int part_type)
>> * @dev_desc: Device descriptor
>> * Return: Driver found, or NULL if none
>> */
>> -static struct part_driver *part_driver_lookup_type(struct blk_desc *desc)
>> +struct part_driver *part_driver_lookup_type(struct blk_desc *desc)
>> {
>> struct part_driver *drv =
>> ll_entry_start(struct part_driver, part_driver);
>> diff --git a/include/part.h b/include/part.h
>> index b772fb34c8a..52fd3d534e0 100644
>> --- a/include/part.h
>> +++ b/include/part.h
>> @@ -471,6 +471,9 @@ ulong disk_blk_erase(struct udevice *dev, lbaint_t start, lbaint_t blkcnt);
>> #define part_get_info_ptr(x) x
>> #endif
>>
>> +static inline struct part_driver *part_driver_lookup_type(struct blk_desc *desc)
>> +{ return NULL; }
>
> This won't compile. You need to define it in the #else of #if
> CONFIG_IS_ENABLED(PARTITIONS)
Thanks. I have fixed it and tested it in the CI: https://github.com/u-boot/u-boot/pull/816.
> Cheers
> /Ilias
>> +
>> /**
>> * struct part_driver - partition driver
>> */
>> @@ -727,6 +730,24 @@ int part_get_type_by_name(const char *name);
>> */
>> int part_get_bootable(struct blk_desc *desc);
>>
>> +/**
>> + * part_driver_lookup_type() - Look up the partition driver for a blk device
>> + *
>> + * If @desc->part_type is PART_TYPE_UNKNOWN, this checks each partition driver
>> + * against the blk device to see if there is a valid partition table acceptable
>> + * to that driver.
>> + *
>> + * If @desc->part_type is already set, it just returns the driver for that
>> + * type, without testing if the driver can find a valid partition on the
>> + * descriptor.
>> + *
>> + * On success it updates @desc->part_type if set to PART_TYPE_UNKNOWN on entry
>> + *
>> + * @desc: Device descriptor
>> + * Return: Driver found, or NULL if none
>> + */
>> +struct part_driver *part_driver_lookup_type(struct blk_desc *desc);
>> +
>> #else
>> static inline int part_driver_get_count(void)
>> { return 0; }
>> --
>> 2.51.0
>>
--
» Javier Tia ✍
More information about the U-Boot
mailing list