All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Markus Klotzbücher" <mk@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH]: tools: fix fw_printenv tool to compile again
Date: Mon, 26 Nov 2007 17:46:30 +0100	[thread overview]
Message-ID: <87r6idhs49.fsf@denx.de> (raw)


This patch updates the fw_printenv/fw_setenv userspace tool to include
the correct mtd header in order to compile again. Along with this a
number of warnings are fixed.

Signed-off-by: Markus Klotzbuecher <mk@denx.de>

diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index f723b5b..2b055bb 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -31,16 +31,14 @@
 #include <sys/ioctl.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <linux/mtd/mtd.h>
+#include <mtd/mtd-user.h>
 #include "fw_env.h"
 
-typedef unsigned char uchar;
-
 #define	CMD_GETENV	"fw_printenv"
 #define	CMD_SETENV	"fw_setenv"
 
 typedef struct envdev_s {
-	uchar devname[16];		/* Device name */
+	char devname[16];		/* Device name */
 	ulong devoff;			/* Device offset */
 	ulong env_size;			/* environment size */
 	ulong erase_size;		/* device erase size */
@@ -60,22 +58,22 @@ static int curdev;
 
 typedef struct environment_s {
 	ulong crc;			/* CRC32 over data bytes    */
-	uchar flags;			/* active or obsolete */
-	uchar *data;
+	unsigned char flags;		/* active or obsolete */
+	char *data;
 } env_t;
 
 static env_t environment;
 
 static int HaveRedundEnv = 0;
 
-static uchar active_flag = 1;
-static uchar obsolete_flag = 0;
+static unsigned char active_flag = 1;
+static unsigned char obsolete_flag = 0;
 
 
 #define XMK_STR(x)	#x
 #define MK_STR(x)	XMK_STR(x)
 
-static uchar default_environment[] = {
+static char default_environment[] = {
 #if defined(CONFIG_BOOTARGS)
 	"bootargs=" CONFIG_BOOTARGS "\0"
 #endif
@@ -155,7 +153,7 @@ static uchar default_environment[] = {
 };
 
 static int flash_io (int mode);
-static uchar *envmatch (uchar * s1, uchar * s2);
+static char *envmatch (char * s1, char * s2);
 static int env_init (void);
 static int parse_config (void);
 
@@ -175,15 +173,15 @@ static inline ulong getenvsize (void)
  * Search the environment for a variable.
  * Return the value, if found, or NULL, if not found.
  */
-unsigned char *fw_getenv (unsigned char *name)
+char *fw_getenv (char *name)
 {
-	uchar *env, *nxt;
+	char *env, *nxt;
 
 	if (env_init ())
 		return (NULL);
 
 	for (env = environment.data; *env; env = nxt + 1) {
-		uchar *val;
+		char *val;
 
 		for (nxt = env; *nxt; ++nxt) {
 			if (nxt >= &environment.data[ENV_SIZE]) {
@@ -206,7 +204,7 @@ unsigned char *fw_getenv (unsigned char *name)
  */
 void fw_printenv (int argc, char *argv[])
 {
-	uchar *env, *nxt;
+	char *env, *nxt;
 	int i, n_flag;
 
 	if (env_init ())
@@ -241,8 +239,8 @@ void fw_printenv (int argc, char *argv[])
 	}
 
 	for (i = 1; i < argc; ++i) {	/* print single env variables   */
-		uchar *name = argv[i];
-		uchar *val = NULL;
+		char *name = argv[i];
+		char *val = NULL;
 
 		for (env = environment.data; *env; env = nxt + 1) {
 
@@ -279,9 +277,9 @@ void fw_printenv (int argc, char *argv[])
 int fw_setenv (int argc, char *argv[])
 {
 	int i, len;
-	uchar *env, *nxt;
-	uchar *oldval = NULL;
-	uchar *name;
+	char *env, *nxt;
+	char *oldval = NULL;
+	char *name;
 
 	if (argc < 2) {
 		return (EINVAL);
@@ -361,7 +359,7 @@ int fw_setenv (int argc, char *argv[])
 	while ((*env = *name++) != '\0')
 		env++;
 	for (i = 2; i < argc; ++i) {
-		uchar *val = argv[i];
+		char *val = argv[i];
 
 		*env = (i == 2) ? '=' : ' ';
 		while ((*++env = *val++) != '\0');
@@ -373,7 +371,7 @@ int fw_setenv (int argc, char *argv[])
   WRITE_FLASH:
 
 	/* Update CRC */
-	environment.crc = crc32 (0, environment.data, ENV_SIZE);
+	environment.crc = crc32 (0, (uint8_t*) environment.data, ENV_SIZE);
 
 	/* write environment back to flash */
 	if (flash_io (O_RDWR)) {
@@ -569,7 +567,7 @@ static int flash_io (int mode)
  * If the names match, return the value of s2, else NULL.
  */
 
-static uchar *envmatch (uchar * s1, uchar * s2)
+static char *envmatch (char * s1, char * s2)
 {
 
 	while (*s1 == *s2++)
@@ -586,10 +584,10 @@ static uchar *envmatch (uchar * s1, uchar * s2)
 static int env_init (void)
 {
 	int crc1, crc1_ok;
-	uchar *addr1;
+	char *addr1;
 
 	int crc2, crc2_ok;
-	uchar flag1, flag2, *addr2;
+	char flag1, flag2, *addr2;
 
 	if (parse_config ())		/* should fill envdevices */
 		return 1;
@@ -608,7 +606,7 @@ static int env_init (void)
 		return (errno);
 	}
 
-	crc1_ok = ((crc1 = crc32 (0, environment.data, ENV_SIZE))
+	crc1_ok = ((crc1 = crc32 (0, (uint8_t *) environment.data, ENV_SIZE))
 			   == environment.crc);
 	if (!HaveRedundEnv) {
 		if (!crc1_ok) {
@@ -632,7 +630,7 @@ static int env_init (void)
 			return (errno);
 		}
 
-		crc2_ok = ((crc2 = crc32 (0, environment.data, ENV_SIZE))
+		crc2_ok = ((crc2 = crc32 (0, (uint8_t *) environment.data, ENV_SIZE))
 				   == environment.crc);
 		flag2 = environment.flags;
 
diff --git a/tools/env/fw_env.h b/tools/env/fw_env.h
index 13c45a2..58607de 100644
--- a/tools/env/fw_env.h
+++ b/tools/env/fw_env.h
@@ -47,8 +47,8 @@
 	"ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; " 	\
 	"bootm"
 
-extern		void  fw_printenv(int argc, char *argv[]);
-extern unsigned char *fw_getenv  (unsigned char *name);
-extern		int   fw_setenv  (int argc, char *argv[]);
+extern void  fw_printenv(int argc, char *argv[]);
+extern char *fw_getenv  (char *name);
+extern int fw_setenv  (int argc, char *argv[]);
 
 extern unsigned	long  crc32	 (unsigned long, const unsigned char *, unsigned);



Best regards

Markus Klotzb?cher

--
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office@denx.de

             reply	other threads:[~2007-11-26 16:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-26 16:46 Markus Klotzbücher [this message]
2007-11-26 17:04 ` [U-Boot-Users] [PATCH]: tools: fix fw_printenv tool to compile again Ben Warren
2007-11-26 22:19 ` Wolfgang Denk
2007-11-27  9:23   ` Markus Klotzbücher
2007-11-27 15:34     ` Ben Warren
2007-11-27 20:33       ` Markus Klotzbücher
2007-11-27 20:46         ` Ben Warren
2007-11-27 20:56         ` Jerry Van Baren
2007-11-27 22:12           ` Wolfgang Denk
2007-11-27 22:06       ` Wolfgang Denk
2007-11-27 22:30         ` Ben Warren
2008-01-09  7:51     ` Wolfgang Denk
2008-01-09 15:19       ` Markus Klotzbücher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r6idhs49.fsf@denx.de \
    --to=mk@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.