[U-Boot] [PATCH 2/3 v2] mmc: control message print in find_mmc_device

Thomas Chou
2010-05-07T00:51:05Z

An argument, verbose, is added to enable/disable the "Device not
found" message. Because we need to query mmc devices in mmc_spi
subcommand and don't want the message.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
v2: add an argument instead of add a new func, per Wolfgang.

common/cmd_mmc.c | 8 ++++----
drivers/mmc/mmc.c | 11 ++++++-----
include/mmc.h | 2 +-
3 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index c67c9cf..9736e5a 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -124,7 +124,7 @@ int do_mmcinfo (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
else
dev_num = simple_strtoul(argv[1], NULL, 0);

- mmc = find_mmc_device(dev_num);
+ mmc = find_mmc_device(dev_num, 1);

if (mmc) {
mmc_init(mmc);
@@ -148,7 +148,7 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
case 3:
if (strcmp(argv[1], "rescan") == 0) {
int dev = simple_strtoul(argv[2], NULL, 10);
- struct mmc *mmc = find_mmc_device(dev);
+ struct mmc *mmc = find_mmc_device(dev, 1);

if (!mmc)
return 1;
@@ -177,7 +177,7 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
u32 cnt = simple_strtoul(argv[5], NULL, 16);
u32 n;
u32 blk = simple_strtoul(argv[4], NULL, 16);
- struct mmc *mmc = find_mmc_device(dev);
+ struct mmc *mmc = find_mmc_device(dev, 1);

if (!mmc)
return 1;
@@ -200,7 +200,7 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
void *addr = (void *)simple_strtoul(argv[3], NULL, 16);
u32 cnt = simple_strtoul(argv[5], NULL, 16);
u32 n;
- struct mmc *mmc = find_mmc_device(dev);
+ struct mmc *mmc = find_mmc_device(dev, 1);

int blk = simple_strtoul(argv[4], NULL, 16);

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index cf4ea16..42e7937 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -60,7 +60,7 @@ int mmc_set_blocklen(struct mmc *mmc, int len)
return mmc_send_cmd(mmc, &cmd, NULL);
}

-struct mmc *find_mmc_device(int dev_num)
+struct mmc *find_mmc_device(int dev_num, int verbose)
{
struct mmc *m;
struct list_head *entry;
@@ -72,7 +72,8 @@ struct mmc *find_mmc_device(int dev_num)
return m;
}

- printf("MMC Device %d not found\n", dev_num);
+ if (verbose)
+ printf("MMC Device %d not found\n", dev_num);

return NULL;
}
@@ -84,7 +85,7 @@ mmc_bwrite(int dev_num, ulong start, lbaint_t blkcnt, const void*src)
struct mmc_data data;
int err;
int stoperr = 0;
- struct mmc *mmc = find_mmc_device(dev_num);
+ struct mmc *mmc = find_mmc_device(dev_num, 1);
int blklen;

if (!mmc)
@@ -214,7 +215,7 @@ static ulong mmc_bread(int dev_num, ulong start, lbaint_t blkcnt, void *dst)
{
int err;
int i;
- struct mmc *mmc = find_mmc_device(dev_num);
+ struct mmc *mmc = find_mmc_device(dev_num, 1);

if (!mmc)
return 0;
@@ -860,7 +861,7 @@ int mmc_register(struct mmc *mmc)

block_dev_desc_t *mmc_get_dev(int dev)
{
- struct mmc *mmc = find_mmc_device(dev);
+ struct mmc *mmc = find_mmc_device(dev, 1);

return mmc ? &mmc->block_dev : NULL;
}
diff --git a/include/mmc.h b/include/mmc.h
index 8973bc7..0903491 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -270,7 +270,7 @@ int mmc_register(struct mmc *mmc);
int mmc_initialize(bd_t *bis);
int mmc_init(struct mmc *mmc);
int mmc_read(struct mmc *mmc, u64 src, uchar *dst, int size);
-struct mmc *find_mmc_device(int dev_num);
+struct mmc *find_mmc_device(int dev_num, int verbose);
void print_mmc_devices(char separator);
int board_mmc_getcd(u8 *cd, struct mmc *mmc);

--
1.6.6.1