1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016 Socionext Inc.
4 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
11 #include <linux/errno.h>
13 static int find_first_mmc_device(bool is_sd)
18 for (i = 0; (mmc = find_mmc_device(i)); i++) {
20 ((is_sd && IS_SD(mmc)) || (!is_sd && IS_MMC(mmc))))
27 int mmc_get_env_dev(void)
29 return find_first_mmc_device(false);
32 static int do_mmcsetn(struct cmd_tbl *cmdtp, int flag, int argc,
37 dev = find_first_mmc_device(false);
39 return CMD_RET_FAILURE;
41 env_set_ulong("mmc_first_dev", dev);
42 return CMD_RET_SUCCESS;
46 mmcsetn, 1, 1, do_mmcsetn,
47 "Set the first MMC (not SD) dev number to \"mmc_first_dev\" environment",
51 static int do_sdsetn(struct cmd_tbl *cmdtp, int flag, int argc,
56 dev = find_first_mmc_device(true);
58 return CMD_RET_FAILURE;
60 env_set_ulong("sd_first_dev", dev);
61 return CMD_RET_SUCCESS;
65 sdsetn, 1, 1, do_sdsetn,
66 "Set the first SD dev number to \"sd_first_dev\" environment",