[PATCH v2 1/4] block.h: renamed get_rootargs to get_root

Ahmad Fatoum a.fatoum at pengutronix.de
Thu Nov 27 03:08:23 PST 2025


Hi,

On 11/27/25 11:57 AM, Fabian Pflug wrote:
> Don't return the full commandline-parameter, but instead just return the
> root block/fs/etc. The functions downstream can add root= before.
> 
> This is the first commit in a series to make root= dynamic.
> 
> Signed-off-by: Fabian Pflug <f.pflug at pengutronix.de>

Reviewed-by: Ahmad Fatoum <a.fatoum at pengutronix.de>

> +	char *root = NULL;

Scope could be reduced, but you don't need to resend just for that.

Thanks,
Ahmad


>  
>  	if (!partcdev)
>  		return NULL;
> @@ -598,8 +599,13 @@ char *cdev_get_linux_rootarg(const struct cdev *partcdev)
>  	if (!blk)
>  		return NULL;
>  
> -	if (blk->ops->get_rootarg)
> -		rootarg = blk->ops->get_rootarg(blk, partcdev);
> +	if (blk->ops->get_root) {
> +		root = blk->ops->get_root(blk, partcdev);
> +		if (root) {
> +			rootarg = basprintf("root=%s", root);
> +			free(root);
> +		}
> +	}
>  	if (!rootarg && partcdev->partuuid[0] != 0)
>  		rootarg = basprintf("root=PARTUUID=%s", partcdev->partuuid);
>  
> diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
> index 57825bc849..206147cb93 100644
> --- a/drivers/mci/mci-core.c
> +++ b/drivers/mci/mci-core.c
> @@ -2691,7 +2691,7 @@ static char *mci_get_linux_mmcblkdev(struct block_device *blk,
>  		 * skipping it.
>  		 */
>  		if (cdev_partname_equal(partcdev, cdev))
> -			return basprintf("root=/dev/mmcblk%dp%d", id, partnum);
> +			return basprintf("/dev/mmcblk%dp%d", id, partnum);
>  		if (cdev->flags & DEVFS_PARTITION_FROM_TABLE)
>  			partnum++;
>  	}
> @@ -2703,7 +2703,7 @@ static struct block_device_ops mci_ops = {
>  	.read = mci_sd_read,
>  	.write = IS_ENABLED(CONFIG_MCI_WRITE) ? mci_sd_write : NULL,
>  	.erase = IS_ENABLED(CONFIG_MCI_ERASE) ? mci_sd_erase : NULL,
> -	.get_rootarg = IS_ENABLED(CONFIG_MMCBLKDEV_ROOTARG) ?
> +	.get_root = IS_ENABLED(CONFIG_MMCBLKDEV_ROOTARG) ?
>  		mci_get_linux_mmcblkdev : NULL,
>  };
>  
> diff --git a/include/block.h b/include/block.h
> index fc7a0a32fb..b277f590e4 100644
> --- a/include/block.h
> +++ b/include/block.h
> @@ -14,7 +14,7 @@ struct block_device_ops {
>  	int (*write)(struct block_device *, const void *buf, sector_t block, blkcnt_t num_blocks);
>  	int (*erase)(struct block_device *blk, sector_t block, blkcnt_t num_blocks);
>  	int (*flush)(struct block_device *);
> -	char *(*get_rootarg)(struct block_device *blk, const struct cdev *partcdev);
> +	char *(*get_root)(struct block_device *blk, const struct cdev *partcdev);
>  };
>  
>  struct chunk;

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