]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
Revert "disk: Use a helper function to reduce duplication"
authorTom Rini <trini@konsulko.com>
Mon, 3 Apr 2023 14:43:37 +0000 (10:43 -0400)
committerTom Rini <trini@konsulko.com>
Mon, 3 Apr 2023 14:43:37 +0000 (10:43 -0400)
Per Takahiro Akashi this is not an equivalent rework, so revert it.

This reverts commit d87bdb82eae66512c222fd93280acaf4dd1cd4be.

Signed-off-by: Tom Rini <trini@konsulko.com>
disk/disk-uclass.c

index 7f1fd80b22487e645d3e48f0d80bb1d83302fda5..d32747e2242d5e0d38ddce3dac5ac312504f4eaa 100644 (file)
@@ -65,38 +65,26 @@ int part_create_block_devices(struct udevice *blk_dev)
        return 0;
 }
 
-static int blk_part_setup(struct udevice *dev, lbaint_t *startp,
-                         lbaint_t blkcnt)
-{
-       struct disk_part *part;
-
-       part = dev_get_uclass_plat(dev);
-       if (*startp >= part->gpt_part_info.size)
-               return -E2BIG;
-
-       if (*startp + blkcnt > part->gpt_part_info.size)
-               blkcnt = part->gpt_part_info.size - *startp;
-       *startp += part->gpt_part_info.start;
-
-       return 0;
-}
-
 static ulong part_blk_read(struct udevice *dev, lbaint_t start,
                           lbaint_t blkcnt, void *buffer)
 {
        struct udevice *parent;
+       struct disk_part *part;
        const struct blk_ops *ops;
-       int ret;
 
        parent = dev_get_parent(dev);
        ops = blk_get_ops(parent);
        if (!ops->read)
                return -ENOSYS;
 
-       ret = blk_part_setup(dev, &start, blkcnt);
-       if (ret)
+       part = dev_get_uclass_plat(dev);
+       if (start >= part->gpt_part_info.size)
                return 0;
 
+       if ((start + blkcnt) > part->gpt_part_info.size)
+               blkcnt = part->gpt_part_info.size - start;
+       start += part->gpt_part_info.start;
+
        return ops->read(parent, start, blkcnt, buffer);
 }
 
@@ -104,18 +92,22 @@ static ulong part_blk_write(struct udevice *dev, lbaint_t start,
                            lbaint_t blkcnt, const void *buffer)
 {
        struct udevice *parent;
+       struct disk_part *part;
        const struct blk_ops *ops;
-       int ret;
 
        parent = dev_get_parent(dev);
        ops = blk_get_ops(parent);
        if (!ops->write)
                return -ENOSYS;
 
-       ret = blk_part_setup(dev, &start, blkcnt);
-       if (ret)
+       part = dev_get_uclass_plat(dev);
+       if (start >= part->gpt_part_info.size)
                return 0;
 
+       if ((start + blkcnt) > part->gpt_part_info.size)
+               blkcnt = part->gpt_part_info.size - start;
+       start += part->gpt_part_info.start;
+
        return ops->write(parent, start, blkcnt, buffer);
 }
 
@@ -123,18 +115,22 @@ static ulong part_blk_erase(struct udevice *dev, lbaint_t start,
                            lbaint_t blkcnt)
 {
        struct udevice *parent;
+       struct disk_part *part;
        const struct blk_ops *ops;
-       int ret;
 
        parent = dev_get_parent(dev);
        ops = blk_get_ops(parent);
        if (!ops->erase)
                return -ENOSYS;
 
-       ret = blk_part_setup(dev, &start, blkcnt);
-       if (ret)
+       part = dev_get_uclass_plat(dev);
+       if (start >= part->gpt_part_info.size)
                return 0;
 
+       if ((start + blkcnt) > part->gpt_part_info.size)
+               blkcnt = part->gpt_part_info.size - start;
+       start += part->gpt_part_info.start;
+
        return ops->erase(parent, start, blkcnt);
 }