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(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
35 dev = find_first_mmc_device(false);
37 return CMD_RET_FAILURE;
39 env_set_ulong("mmc_first_dev", dev);
40 return CMD_RET_SUCCESS;
44 mmcsetn, 1, 1, do_mmcsetn,
45 "Set the first MMC (not SD) dev number to \"mmc_first_dev\" environment",
49 static int do_sdsetn(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
53 dev = find_first_mmc_device(true);
55 return CMD_RET_FAILURE;
57 env_set_ulong("sd_first_dev", dev);
58 return CMD_RET_SUCCESS;
62 sdsetn, 1, 1, do_sdsetn,
63 "Set the first SD dev number to \"sd_first_dev\" environment",