dfu: mmc: support to get partition information by name accepted/tizen/common/20140807.102412 submit/tizen/20140807.020216
authorJoonyoung Shim <jy0922.shim@samsung.com>
Wed, 6 Aug 2014 02:48:30 +0000 (11:48 +0900)
committerChanho Park <chanho61.park@samsung.com>
Thu, 7 Aug 2014 01:48:41 +0000 (10:48 +0900)
The partitions can have partition name like label. If partition name is
exist, first get partition information by name than by partition number,
so we can ignore hardcoding dependency of partition number.

Change-Id: Ibfb2521438ce366959814c2a87085e9f384de588
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
drivers/dfu/dfu_mmc.c

index 63cc876612c9aa44df4539e5e6c1a3b1d0af0b14..41d67eb7295469336bcb1bb5a058383f4290d89e 100644 (file)
@@ -217,6 +217,24 @@ int dfu_read_medium_mmc(struct dfu_entity *dfu, u64 offset, void *buf,
        return ret;
 }
 
+static int dfu_get_partition_info_by_name(block_dev_desc_t *dev_desc,
+                                         const char *name,
+                                         disk_partition_t *info)
+{
+       switch (dev_desc->part_type) {
+#ifdef CONFIG_EFI_PARTITION
+       case PART_TYPE_EFI:
+               if (get_partition_info_efi_by_name(dev_desc, name, info) == 0)
+                       return 0;
+               break;
+#endif
+       default:
+               break;
+       }
+
+       return -EPERM;
+}
+
 /*
  * @param s Parameter string containing space-separated arguments:
  *     1st:
@@ -290,12 +308,17 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *s)
                int mmcdev = second_arg;
                int mmcpart = third_arg;
 
+               if (dfu_get_partition_info_by_name(blk_dev, dfu->name,
+                                       &partinfo) == 0)
+                       goto skip;
+
                if (get_partition_info(blk_dev, mmcpart, &partinfo) != 0) {
                        error("Couldn't find part #%d on mmc device #%d\n",
                              mmcpart, mmcdev);
                        return -ENODEV;
                }
 
+skip:
                dfu->layout                     = DFU_RAW_ADDR;
                dfu->data.mmc.lba_start         = partinfo.start;
                dfu->data.mmc.lba_size          = partinfo.size;