*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
*/
/*
- * JFFS2/CRAMFS/ROMFS support
+ * JFFS2/CRAMFS support
*/
#include <common.h>
#include <command.h>
#include <jffs2/jffs2.h>
#include <linux/list.h>
#include <linux/ctype.h>
-
-#if (CONFIG_COMMANDS & CFG_CMD_JFFS2)
-
#include <cramfs/cramfs_fs.h>
-#if (CONFIG_COMMANDS & CFG_CMD_NAND)
+#if defined(CONFIG_CMD_NAND)
#ifdef CFG_NAND_LEGACY
#include <linux/mtd/nand_legacy.h>
#else /* !CFG_NAND_LEGACY */
#include <linux/mtd/nand.h>
#include <nand.h>
#endif /* !CFG_NAND_LEGACY */
-#endif /* (CONFIG_COMMANDS & CFG_CMD_NAND) */
+#endif
/* enable/disable debugging messages */
#define DEBUG_JFFS
#undef DEBUG_JFFS
-#ifdef DEBUG_JFFS
+#ifdef DEBUG_JFFS
# define DEBUGF(fmt, args...) printf(fmt ,##args)
#else
# define DEBUGF(fmt, args...)
extern int cramfs_ls (struct part_info *info, char *filename);
extern int cramfs_info (struct part_info *info);
-extern int romfs_check (struct part_info *info);
-extern int romfs_load (char *loadoffset, struct part_info *info, char *filename);
-extern int romfs_ls (struct part_info *info, char *filename);
-extern int romfs_info (struct part_info *info);
-
static struct part_info* jffs2_part_info(struct mtd_device *dev, unsigned int part_num);
/* command line only routines */
static int device_del(struct mtd_device *dev);
/**
- * Parses a string into a number. The number stored at ptr is
+ * Parses a string into a number. The number stored at ptr is
* potentially suffixed with K (for kilobytes, or 1024 bytes),
* M (for megabytes, or 1048576 bytes), or G (for gigabytes, or
- * 1073741824). If the number is suffixed with K, M, or G, then
+ * 1073741824). If the number is suffixed with K, M, or G, then
* the return value is the number multiplied by one kilobyte, one
* megabyte, or one gigabyte, respectively.
*
*/
static int part_validate_nor(struct mtdids *id, struct part_info *part)
{
-#if (CONFIG_COMMANDS & CFG_CMD_FLASH)
+#if defined(CONFIG_CMD_FLASH)
/* info for FLASH chips */
extern flash_info_t flash_info[];
flash_info_t *flash;
*/
static int part_validate_nand(struct mtdids *id, struct part_info *part)
{
-#if defined(CONFIG_JFFS2_NAND) && (CONFIG_COMMANDS & CFG_CMD_NAND)
+#if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND)
/* info for NAND chips */
nand_info_t *nand;
return 1;
}
- /* allocate memory */
+ /* allocate memory */
part = (struct part_info *)malloc(sizeof(struct part_info) + name_len);
if (!part) {
printf("out of memory\n");
static int device_validate(u8 type, u8 num, u32 *size)
{
if (type == MTD_DEV_TYPE_NOR) {
-#if (CONFIG_COMMANDS & CFG_CMD_FLASH)
+#if defined(CONFIG_CMD_FLASH)
if (num < CFG_MAX_FLASH_BANKS) {
extern flash_info_t flash_info[];
*size = flash_info[num].size;
printf("support for FLASH devices not present\n");
#endif
} else if (type == MTD_DEV_TYPE_NAND) {
-#if defined(CONFIG_JFFS2_NAND) && (CONFIG_COMMANDS & CFG_CMD_NAND)
+#if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND)
if (num < CFG_MAX_NAND_DEVICE) {
#ifndef CFG_NAND_LEGACY
*size = nand_info[num].size;
return NULL;
}
-/*************************************************/
-/* U-boot commands */
-/*************************************************/
+/***************************************************/
+/* U-boot commands */
+/***************************************************/
/**
* Routine implementing fsload u-boot command. This routine tries to load
if ((part = jffs2_part_info(current_dev, current_partnum))){
- /* check partition type for JFFS2, cramfs, romfs */
- if (cramfs_check(part)) {
- fsname = "CRAMFS";
- } else if (romfs_check(part)) {
- fsname = "ROMFS";
- } else {
- fsname = "JFFS2";
- }
+ /* check partition type for cramfs */
+ fsname = (cramfs_check(part) ? "CRAMFS" : "JFFS2");
printf("### %s loading '%s' to 0x%lx\n", fsname, filename, offset);
if (cramfs_check(part)) {
size = cramfs_load ((char *) offset, part, filename);
- } else if (romfs_check(part)){
- size = romfs_load ((char *) offset, part, filename);
} else {
- /* if this is not cramfs or romfs assume jffs2 */
+ /* if this is not cramfs assume jffs2 */
size = jffs2_1pass_load((char *)offset, part, filename);
}
/* check partition type for cramfs */
if (cramfs_check(part)) {
ret = cramfs_ls (part, filename);
- } else if (romfs_check(part)) {
- ret = romfs_ls (part, filename);
} else {
- /* if this is not cramfs or romfs assume jffs2 */
+ /* if this is not cramfs assume jffs2 */
ret = jffs2_1pass_ls(part, filename);
}
int do_jffs2_fsinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
struct part_info *part;
+ char *fsname;
int ret;
/* make sure we are in sync with env variables */
if ((part = jffs2_part_info(current_dev, current_partnum))){
/* check partition type for cramfs */
- puts("### filesystem type is ");
+ fsname = (cramfs_check(part) ? "CRAMFS" : "JFFS2");
+ printf("### filesystem type is %s\n", fsname);
if (cramfs_check(part)) {
- puts("CRAMFS\n");
ret = cramfs_info (part);
- } else if (romfs_check(part)) {
- puts("ROMFS\n");
- ret = romfs_info (part);
} else {
- /* if this is not cramfs or romfs assume jffs2 */
- puts("JFFS2\n");
+ /* if this is not cramfs assume jffs2 */
ret = jffs2_1pass_info(part);
}
#endif /* #ifdef CONFIG_JFFS2_CMDLINE */
/***************************************************/
-
-#endif /* CFG_CMD_JFFS2 */