/* Test that we can get a block from its parent */ static int dm_test_blk_get_from_parent(struct unit_test_state *uts) { struct udevice *dev, *blk; ut_assertok(uclass_get_device(UCLASS_MMC, 0, &dev)); ut_assertok(blk_get_from_parent(dev, &blk)); ut_assertok(uclass_get_device(UCLASS_I2C, 0, &dev)); ut_asserteq(-ENOTBLK, blk_get_from_parent(dev, &blk)); ut_assertok(uclass_get_device(UCLASS_GPIO, 0, &dev)); ut_asserteq(-ENODEV, blk_get_from_parent(dev, &blk)); return 0; }
static const char *init_mmc_for_env(struct mmc *mmc) { if (!mmc) return "!No MMC card found"; #ifdef CONFIG_BLK struct udevice *dev; if (blk_get_from_parent(mmc->dev, &dev)) return "!No block device"; #else if (mmc_init(mmc)) return "!MMC init failed"; #endif if (mmc_set_env_part(mmc)) return "!MMC partition switch failed"; return NULL; }