X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=common%2Fcmd_cramfs.c;h=1d31326bd648277826514031271568cfe1fa9ffb;hb=b8970748817bbc07ac1576c9f4c728efd2590218;hp=55e2d36b51d8ed8e660d85b278fc30ef117a5f11;hpb=a7709d926dbc7cb1541034fcf2b21ce3e838cb12;p=u-boot diff --git a/common/cmd_cramfs.c b/common/cmd_cramfs.c index 55e2d36b51..1d31326bd6 100644 --- a/common/cmd_cramfs.c +++ b/common/cmd_cramfs.c @@ -1,18 +1,5 @@ /* - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * 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 - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA + * SPDX-License-Identifier: GPL-2.0+ * * based on: cmd_jffs2.c * @@ -43,7 +30,13 @@ #endif #ifdef CONFIG_CRAMFS_CMDLINE -flash_info_t flash_info[1]; +#include + +#ifdef CONFIG_SYS_NO_FLASH +# define OFFSET_ADJUSTMENT 0 +#else +# define OFFSET_ADJUSTMENT (flash_info[id.num].start[0]) +#endif #ifndef CONFIG_CMD_JFFS2 #include @@ -98,7 +91,7 @@ extern int cramfs_info (struct part_info *info); * @param argv arguments list * @return 0 on success, 1 otherwise */ -int do_cramfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +int do_cramfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { char *filename; int size; @@ -119,7 +112,7 @@ int do_cramfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) dev.id = &id; part.dev = &dev; /* fake the address offset */ - part.offset = addr - flash_info[id.num].start[0]; + part.offset = addr - OFFSET_ADJUSTMENT; /* pre-set Boot file name */ if ((filename = getenv("bootfile")) == NULL) { @@ -140,11 +133,9 @@ int do_cramfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) size = cramfs_load ((char *) offset, &part, filename); if (size > 0) { - char buf[10]; printf("### CRAMFS load complete: %d bytes loaded to 0x%lx\n", size, offset); - sprintf(buf, "%x", size); - setenv("filesize", buf); + setenv_hex("filesize", size); } else { printf("### CRAMFS LOAD ERROR<%x> for %s!\n", size, filename); } @@ -163,7 +154,7 @@ int do_cramfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) * @param argv arguments list * @return 0 on success, 1 otherwise */ -int do_cramfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +int do_cramfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { char *filename = "/"; int ret; @@ -182,7 +173,7 @@ int do_cramfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) dev.id = &id; part.dev = &dev; /* fake the address offset */ - part.offset = addr - flash_info[id.num].start[0]; + part.offset = addr - OFFSET_ADJUSTMENT; if (argc == 2) filename = argv[1]; @@ -199,14 +190,14 @@ int do_cramfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) /***************************************************/ U_BOOT_CMD( cramfsload, 3, 0, do_cramfs_load, - "cramfsload\t- load binary file from a filesystem image", + "load binary file from a filesystem image", "[ off ] [ filename ]\n" " - load binary file from address 'cramfsaddr'\n" " with offset 'off'\n" ); U_BOOT_CMD( cramfsls, 2, 1, do_cramfs_ls, - "cramfsls\t- list files in a directory (default /)", + "list files in a directory (default /)", "[ directory ]\n" " - list files in a directory.\n" );