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 <[email protected]>
---

Fixed nitpicks

 common/block.c         | 10 ++++++++--
 drivers/mci/mci-core.c |  4 ++--
 include/block.h        |  2 +-
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/common/block.c b/common/block.c
index ca2ed37dbd..ce998243b4 100644
--- a/common/block.c
+++ b/common/block.c
@@ -589,6 +589,7 @@ char *cdev_get_linux_rootarg(const struct cdev *partcdev)
        const struct cdev *cdevm;
        struct block_device *blk;
        char *rootarg = NULL;
+       char *root = NULL;
 
        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;
-- 
2.47.3


Reply via email to