- char buf[CONFIG_ENV_SIZE];
- block_dev_desc_t *dev_desc = NULL;
- int dev = FAT_ENV_DEVICE;
- int part = FAT_ENV_PART;
-
-#ifdef CONFIG_MMC
- if (strcmp (FAT_ENV_INTERFACE, "mmc") == 0) {
- struct mmc *mmc = find_mmc_device(dev);
-
- if (!mmc) {
- printf("no mmc device at slot %x\n", dev);
- set_default_env(NULL);
- return;
- }
-
- mmc->has_init = 0;
- mmc_init(mmc);
- }
-#endif /* CONFIG_MMC */
-
- dev_desc = get_dev(FAT_ENV_INTERFACE, dev);
- if (dev_desc == NULL) {
- printf("Failed to find %s%d\n",
- FAT_ENV_INTERFACE, dev);
- set_default_env(NULL);
- return;
- }
- if (fat_register_device(dev_desc, part) != 0) {
- printf("Failed to register %s%d:%d\n",
- FAT_ENV_INTERFACE, dev, part);
- set_default_env(NULL);
- return;
+ ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
+ struct blk_desc *dev_desc = NULL;
+ disk_partition_t info;
+ int dev, part;
+ int err;
+
+ part = blk_get_device_part_str(FAT_ENV_INTERFACE,
+ FAT_ENV_DEVICE_AND_PART,
+ &dev_desc, &info, 1);
+ if (part < 0)
+ goto err_env_relocate;
+
+ dev = dev_desc->devnum;
+ if (fat_set_blk_dev(dev_desc, &info) != 0) {
+ printf("\n** Unable to use %s %d:%d for loading the env **\n",
+ FAT_ENV_INTERFACE, dev, part);
+ goto err_env_relocate;