1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016 Socionext Inc.
4 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
10 #include <linux/errno.h>
12 static int find_first_mmc_device(bool is_sd)
17 for (i = 0; (mmc = find_mmc_device(i)); i++) {
19 ((is_sd && IS_SD(mmc)) || (!is_sd && IS_MMC(mmc))))
26 int mmc_get_env_dev(void)
28 return find_first_mmc_device(false);
31 static int do_mmcsetn(struct cmd_tbl *cmdtp, int flag, int argc,
36 dev = find_first_mmc_device(false);
38 return CMD_RET_FAILURE;
40 env_set_ulong("mmc_first_dev", dev);
41 return CMD_RET_SUCCESS;
45 mmcsetn, 1, 1, do_mmcsetn,
46 "Set the first MMC (not SD) dev number to \"mmc_first_dev\" environment",
50 static int do_sdsetn(struct cmd_tbl *cmdtp, int flag, int argc,
55 dev = find_first_mmc_device(true);
57 return CMD_RET_FAILURE;
59 env_set_ulong("sd_first_dev", dev);
60 return CMD_RET_SUCCESS;
64 sdsetn, 1, 1, do_sdsetn,
65 "Set the first SD dev number to \"sd_first_dev\" environment",