From 16c0ace22b10bf076341d18349cde1af6447755f Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Mon, 13 Dec 2010 19:26:03 -0800 Subject: [PATCH] Fix write_raw_image on mtd devices. Change-Id: I0fa64d4f4deaf8f067be3bd0b0bb963cf5af3f3f --- commands.c | 11 ++++++----- flashutils/flashutils.c | 8 -------- flashutils/flashutils.h | 13 +++++++++++++ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/commands.c b/commands.c index c7e4fd7..d233877 100644 --- a/commands.c +++ b/commands.c @@ -40,6 +40,7 @@ #include "roots.h" #include "extendedcommands.h" +#include "flashutils/flashutils.h" static int gDidShowProgress = 0; @@ -653,7 +654,11 @@ static int cmd_write_raw_image(const char *name, void *cookie, int argc, const char *argv[], PermissionRequestList *permissions) { -#ifdef BOARD_USES_MTDUTILS + if (device_flash_type() != MTD) { + LOGE("Board does not support mtd utils."); + return -1; + } + UNUSED(cookie); CHECK_WORDS(); //xxx permissions @@ -739,10 +744,6 @@ cmd_write_raw_image(const char *name, void *cookie, return -1; } return 0; -#else - LOGE("Board does not support mtd utils."); - return -1; -#endif } /* mark dirty|clean diff --git a/flashutils/flashutils.c b/flashutils/flashutils.c index 5c57756..b71d4fa 100644 --- a/flashutils/flashutils.c +++ b/flashutils/flashutils.c @@ -5,14 +5,6 @@ #include "flashutils/flashutils.h" -enum flash_type { - UNSUPPORTED = -1, - UNKNOWN = 0, - MTD = 1, - MMC = 2, - BML = 3 -}; - int the_flash_type = UNKNOWN; int device_flash_type() diff --git a/flashutils/flashutils.h b/flashutils/flashutils.h index 953dd00..d5dadcb 100644 --- a/flashutils/flashutils.h +++ b/flashutils/flashutils.h @@ -1,3 +1,6 @@ +#ifndef FLASHUTILS_H +#define FLASHUTILS_H + int restore_raw_partition(const char *partition, const char *filename); int backup_raw_partition(const char *partition, const char *filename); int erase_raw_partition(const char *partition); @@ -35,4 +38,14 @@ extern int cmd_bml_erase_partition(const char *partition, const char *filesystem extern int cmd_bml_mount_partition(const char *partition, const char *mount_point, const char *filesystem, int read_only); extern int cmd_bml_get_partition_device(const char *partition, char *device); +extern int device_flash_type(); +enum flash_type { + UNSUPPORTED = -1, + UNKNOWN = 0, + MTD = 1, + MMC = 2, + BML = 3 +}; + +#endif \ No newline at end of file