]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
disk: Move part_create_block_devices() to blk uclass
authorMarek Vasut <marek.vasut+renesas@mailbox.org>
Sun, 13 Aug 2023 23:46:47 +0000 (01:46 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 22 Aug 2023 19:17:52 +0000 (15:17 -0400)
Move part_create_block_devices() to blk uclass and unexpose
the function. This can now be internal to the block uclass.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
disk/disk-uclass.c
drivers/block/blk-uclass.c
include/part.h

index 90a7c6f0f8abb7cd258a172c1104b60dbb0f32e7..efe4bf1f9490ba8e972569a7ac8aa61b25c21de5 100644 (file)
@@ -55,54 +55,6 @@ static lbaint_t disk_blk_part_offset(struct udevice *dev, lbaint_t start)
        return start + part->gpt_part_info.start;
 }
 
-int part_create_block_devices(struct udevice *blk_dev)
-{
-       int part, count;
-       struct blk_desc *desc = dev_get_uclass_plat(blk_dev);
-       struct disk_partition info;
-       struct disk_part *part_data;
-       char devname[32];
-       struct udevice *dev;
-       int ret;
-
-       if (!CONFIG_IS_ENABLED(PARTITIONS) || !blk_enabled())
-               return 0;
-
-       if (device_get_uclass_id(blk_dev) != UCLASS_BLK)
-               return 0;
-
-       /* 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", blk_dev->name,
-                        part);
-
-               ret = device_bind_driver(blk_dev, "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++;
-
-               ret = device_probe(dev);
-               if (ret) {
-                       debug("Can't probe\n");
-                       count--;
-                       device_unbind(dev);
-
-                       continue;
-               }
-       }
-       debug("%s: %d partitions found in %s\n", __func__, count,
-             blk_dev->name);
-
-       return 0;
-}
-
 /*
  * BLOCK IO APIs
  */
index 614b975e25c2b78d9c2198ebfd39f2c4ecf39e76..9521b3eb8788d8637806fd8de1788040a392bb1d 100644 (file)
@@ -766,6 +766,54 @@ int blk_unbind_all(int uclass_id)
        return 0;
 }
 
+static int part_create_block_devices(struct udevice *blk_dev)
+{
+       int part, count;
+       struct blk_desc *desc = dev_get_uclass_plat(blk_dev);
+       struct disk_partition info;
+       struct disk_part *part_data;
+       char devname[32];
+       struct udevice *dev;
+       int ret;
+
+       if (!CONFIG_IS_ENABLED(PARTITIONS) || !blk_enabled())
+               return 0;
+
+       if (device_get_uclass_id(blk_dev) != UCLASS_BLK)
+               return 0;
+
+       /* 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", blk_dev->name,
+                        part);
+
+               ret = device_bind_driver(blk_dev, "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++;
+
+               ret = device_probe(dev);
+               if (ret) {
+                       debug("Can't probe\n");
+                       count--;
+                       device_unbind(dev);
+
+                       continue;
+               }
+       }
+       debug("%s: %d partitions found in %s\n", __func__, count,
+             blk_dev->name);
+
+       return 0;
+}
+
 static int blk_post_probe(struct udevice *dev)
 {
        if (CONFIG_IS_ENABLED(PARTITIONS) && blk_enabled()) {
index 8e451bbdff9462dfe2d2b7e7c30d0e0ddaff315f..be1447687777736c7148184f6bdff985061fe87d 100644 (file)
@@ -315,15 +315,6 @@ part_get_info_by_dev_and_name_or_num(const char *dev_iface,
 int part_get_bootable(struct blk_desc *desc);
 
 struct udevice;
-/**
- * part_create_block_devices - Create block devices for disk partitions
- *
- * Create UCLASS_PARTITION udevices for each of disk partitions in @parent
- *
- * @blk_dev:   Whole disk device
- */
-int part_create_block_devices(struct udevice *blk_dev);
-
 /**
  * disk_blk_read() - read blocks from a disk partition
  *