* [U-Boot] [PATCH] cmd_mmc: add support device command for selecting mmc device
@ 2009-03-28 5:04 Minkyu Kang
2009-03-28 7:14 ` Dirk Behme
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Minkyu Kang @ 2009-03-28 5:04 UTC (permalink / raw)
To: u-boot
This patch improves device command for selecting mmc device
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
---
common/cmd_mmc.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 64 insertions(+), 5 deletions(-)
diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 16c919b..2557892 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -26,20 +26,79 @@
#include <mmc.h>
#ifndef CONFIG_GENERIC_MMC
+int curr_device = -1;
+
int do_mmc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
- if (mmc_legacy_init (1) != 0) {
- printf ("No MMC card found\n");
+ switch (argc) {
+ case 0:
+ case 1:
+ cmd_usage(cmdtp);
+ return 1;
+ case 2:
+ if (strncmp(argv[1], "init", 4) == 0) {
+ if (curr_device < 0)
+ curr_device = 1;
+
+ if (mmc_legacy_init(curr_device) != 0) {
+ printf("No MMC card found\n");
+ return 1;
+ }
+
+ printf("mmc%d is available\n", curr_device);
+ return 0;
+ } else if (strncmp(argv[1], "dev", 3) == 0) {
+ if (curr_device < 0) {
+ printf("no MMC devices available\n");
+ return 1;
+ }
+
+ printf("mmc%d is current device\n", curr_device);
+ return 0;
+ }
+
+ cmd_usage(cmdtp);
+ return 1;
+ case 3:
+ if (strncmp(argv[1], "init", 4) == 0) {
+ int dev = (int)simple_strtoul(argv[2], NULL, 10);
+
+ if (mmc_legacy_init(dev) != 0) {
+ printf("No MMC card found\n");
+ return 1;
+ }
+
+ curr_device = dev;
+
+ printf("mmc%d is available\n", curr_device);
+ return 0;
+ } else if (strncmp(argv[1], "dev", 3) == 0) {
+ int dev = (int)simple_strtoul(argv[2], NULL, 10);
+
+#ifdef CONFIG_SYS_MMC_SET_DEV
+ if (mmc_set_dev(dev) != 0)
+ return 1;
+#endif
+
+ curr_device = dev;
+
+ printf("mmc%d is now current device\n", curr_device);
+ return 0;
+ }
+
+ cmd_usage(cmdtp);
return 1;
}
return 0;
}
U_BOOT_CMD(
- mmcinit, 1, 0, do_mmc,
- "init mmc card",
- NULL
+ mmc, 3, 1, do_mmc,
+ "MMC sub-system",
+ "mmc init [dev] - init MMC sub system\n"
+ "mmc device [dev] - show or set current device\n"
);
+
#else /* !CONFIG_GENERIC_MMC */
^ permalink raw reply related [flat|nested] 4+ messages in thread* [U-Boot] [PATCH] cmd_mmc: add support device command for selecting mmc device
2009-03-28 5:04 [U-Boot] [PATCH] cmd_mmc: add support device command for selecting mmc device Minkyu Kang
@ 2009-03-28 7:14 ` Dirk Behme
2009-03-28 10:15 ` Mike Frysinger
2009-04-16 23:18 ` Andy Fleming
2 siblings, 0 replies; 4+ messages in thread
From: Dirk Behme @ 2009-03-28 7:14 UTC (permalink / raw)
To: u-boot
Minkyu Kang wrote:
> This patch improves device command for selecting mmc device
We should add Andy to CC, as it seems that he is the new MMC maintainer :)
Andy: Would be quite nice if you could comment on Minkyu's changes.
See [1], [2] and [3] for the history, too.
Dirk
[1] http://lists.denx.de/pipermail/u-boot/2009-March/049660.html
[2] http://lists.denx.de/pipermail/u-boot/2009-March/049694.html
[3] http://lists.denx.de/pipermail/u-boot/2009-March/049707.html
> Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
> ---
> common/cmd_mmc.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++----
> 1 files changed, 64 insertions(+), 5 deletions(-)
>
> diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
> index 16c919b..2557892 100644
> --- a/common/cmd_mmc.c
> +++ b/common/cmd_mmc.c
> @@ -26,20 +26,79 @@
> #include <mmc.h>
>
> #ifndef CONFIG_GENERIC_MMC
> +int curr_device = -1;
> +
> int do_mmc (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
> {
> - if (mmc_legacy_init (1) != 0) {
> - printf ("No MMC card found\n");
> + switch (argc) {
> + case 0:
> + case 1:
> + cmd_usage(cmdtp);
> + return 1;
> + case 2:
> + if (strncmp(argv[1], "init", 4) == 0) {
> + if (curr_device < 0)
> + curr_device = 1;
> +
> + if (mmc_legacy_init(curr_device) != 0) {
> + printf("No MMC card found\n");
> + return 1;
> + }
> +
> + printf("mmc%d is available\n", curr_device);
> + return 0;
> + } else if (strncmp(argv[1], "dev", 3) == 0) {
> + if (curr_device < 0) {
> + printf("no MMC devices available\n");
> + return 1;
> + }
> +
> + printf("mmc%d is current device\n", curr_device);
> + return 0;
> + }
> +
> + cmd_usage(cmdtp);
> + return 1;
> + case 3:
> + if (strncmp(argv[1], "init", 4) == 0) {
> + int dev = (int)simple_strtoul(argv[2], NULL, 10);
> +
> + if (mmc_legacy_init(dev) != 0) {
> + printf("No MMC card found\n");
> + return 1;
> + }
> +
> + curr_device = dev;
> +
> + printf("mmc%d is available\n", curr_device);
> + return 0;
> + } else if (strncmp(argv[1], "dev", 3) == 0) {
> + int dev = (int)simple_strtoul(argv[2], NULL, 10);
> +
> +#ifdef CONFIG_SYS_MMC_SET_DEV
> + if (mmc_set_dev(dev) != 0)
> + return 1;
> +#endif
> +
> + curr_device = dev;
> +
> + printf("mmc%d is now current device\n", curr_device);
> + return 0;
> + }
> +
> + cmd_usage(cmdtp);
> return 1;
> }
> return 0;
> }
>
> U_BOOT_CMD(
> - mmcinit, 1, 0, do_mmc,
> - "init mmc card",
> - NULL
> + mmc, 3, 1, do_mmc,
> + "MMC sub-system",
> + "mmc init [dev] - init MMC sub system\n"
> + "mmc device [dev] - show or set current device\n"
> );
> +
> #else /* !CONFIG_GENERIC_MMC */
>
^ permalink raw reply [flat|nested] 4+ messages in thread* [U-Boot] [PATCH] cmd_mmc: add support device command for selecting mmc device
2009-03-28 5:04 [U-Boot] [PATCH] cmd_mmc: add support device command for selecting mmc device Minkyu Kang
2009-03-28 7:14 ` Dirk Behme
@ 2009-03-28 10:15 ` Mike Frysinger
2009-04-16 23:18 ` Andy Fleming
2 siblings, 0 replies; 4+ messages in thread
From: Mike Frysinger @ 2009-03-28 10:15 UTC (permalink / raw)
To: u-boot
On Saturday 28 March 2009 01:04:10 Minkyu Kang wrote:
> + case 2:
> + if (strncmp(argv[1], "init", 4) == 0) {
> + } else if (strncmp(argv[1], "dev", 3) == 0) {
why strncmp ? i dont think it makes sense to support "init", "init.moo"
"initaksldfjaksldfjasdf" ...
> + printf("No MMC card found\n");
no format modifiers -> use puts()
> + if (curr_device < 0) {
> + printf("no MMC devices available\n");
puts("No MMC card selected\n");
> + case 3:
considering how much code is duplicated with "case 2", seems like it would
make sense to unify them and have each piece check the argc
> U_BOOT_CMD(
> - mmcinit, 1, 0, do_mmc,
> - "init mmc card",
> - NULL
> + mmc, 3, 1, do_mmc,
> + "MMC sub-system",
> + "mmc init [dev] - init MMC sub system\n"
first usage string should omit the command. run 'help mmc' on the board to
see why ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090328/1504de03/attachment.pgp
^ permalink raw reply [flat|nested] 4+ messages in thread* [U-Boot] [PATCH] cmd_mmc: add support device command for selecting mmc device
2009-03-28 5:04 [U-Boot] [PATCH] cmd_mmc: add support device command for selecting mmc device Minkyu Kang
2009-03-28 7:14 ` Dirk Behme
2009-03-28 10:15 ` Mike Frysinger
@ 2009-04-16 23:18 ` Andy Fleming
2 siblings, 0 replies; 4+ messages in thread
From: Andy Fleming @ 2009-04-16 23:18 UTC (permalink / raw)
To: u-boot
On Sat, Mar 28, 2009 at 12:04 AM, Minkyu Kang <mk7.kang@samsung.com> wrote:
> This patch improves device command for selecting mmc device
>
> Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
Rather than porting features from the generic mmc framework into the
legacy system, I'd really prefer if the omap driver were ported to the
generic mmc framework. The framework already has support for multiple
devices. We can then discuss how to deal with selecting which device
is the default device as a side issue.
Andy
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-04-16 23:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-28 5:04 [U-Boot] [PATCH] cmd_mmc: add support device command for selecting mmc device Minkyu Kang
2009-03-28 7:14 ` Dirk Behme
2009-03-28 10:15 ` Mike Frysinger
2009-04-16 23:18 ` Andy Fleming
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.