[resent RFC 08/22] dm: blk: add UCLASS_PARTITION

Ilias Apalodimas ilias.apalodimas at linaro.org
Mon Oct 4 20:40:21 CEST 2021


Hi Akashi-san,

>  

[...]

> +int blk_create_partitions(struct udevice *parent)
> +{
> +	int part, count;
> +	struct blk_desc *desc = dev_get_uclass_plat(parent);
> +	struct disk_partition info;
> +	struct disk_part *part_data;
> +	char devname[32];
> +	struct udevice *dev;
> +	int ret;
> +
> +	if (!CONFIG_IS_ENABLED(PARTITIONS) ||
> +	    !CONFIG_IS_ENABLED(HAVE_BLOCK_DEVICE))
> +		return 0;

Would it make more sense to return an error here?

> +
> +	/* Add devices for each partition */
> +	for (count = 0, part = 1; part <= MAX_SEARCH_PARTITIONS; part++) {
> +		if (part_get_info(desc, part, &info))
> +			continue;
> +		snprintf(devname, sizeof(devname), "%s:%d", parent->name,
> +			 part);
> +
> +		ret = device_bind_driver(parent, "blk_partition",
> +					 strdup(devname), &dev);
> +		if (ret)
> +			return ret;
> +
> +		part_data = dev_get_uclass_plat(dev);
> +		part_data->partnum = part;
> +		part_data->gpt_part_info = info;
> +		count++;
> +
> +		device_probe(dev);

Probe can fail. 

> +	}
> +	debug("%s: %d partitions found in %s\n", __func__, count, parent->name);
> +
> +	return 0;
> +}
> +
>  static int blk_post_probe(struct udevice *dev)
>  {
>  	if (IS_ENABLED(CONFIG_PARTITIONS) &&
> @@ -713,3 +752,75 @@ UCLASS_DRIVER(blk) = {
>  	.post_probe	= blk_post_probe,
>  	.per_device_plat_auto	= sizeof(struct blk_desc),
>  };
[...]

Regards
/Ilias


More information about the U-Boot mailing list