[kernel/2.6.37] refresh patches
[openwrt.git] / package / uboot-envtools / patches / 001-crc32_func_signature.patch
1 --- a/crc32.c
2 +++ b/crc32.c
3 @@ -8,21 +8,16 @@
4 * For conditions of distribution and use, see copyright notice in zlib.h
5 */
6
7 -#ifndef USE_HOSTCC
8 -#include <common.h>
9 -#endif
10 -#include <compiler.h>
11 -#include <u-boot/crc.h>
12 +#include <stdint.h>
13 +#include <asm/byteorder.h>
14 +
15 +#include "zlib.h"
16
17 -#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
18 -#include <watchdog.h>
19 -#endif
20 -#include "u-boot/zlib.h"
21
22 #define local static
23 #define ZEXPORT /* empty */
24
25 -#define tole(x) cpu_to_le32(x)
26 +#define tole(x) __constant_cpu_to_le32(x)
27
28 #ifdef DYNAMIC_CRC_TABLE
29
30 @@ -151,7 +146,7 @@ tole(0xb40bbe37L), tole(0xc30c8ea1L), to
31
32 #if 0
33 /* =========================================================================
34 - * This function can be used by asm versions of crc32()
35 + * This function can be used by asm versions of uboot_crc32()
36 */
37 const uint32_t * ZEXPORT get_crc_table()
38 {
39 @@ -183,7 +178,7 @@ uint32_t ZEXPORT crc32_no_comp(uint32_t
40 if (crc_table_empty)
41 make_crc_table();
42 #endif
43 - crc = cpu_to_le32(crc);
44 + crc = __cpu_to_le32(crc);
45 /* Align it */
46 if (((long)b) & 3 && len) {
47 uint8_t *p = (uint8_t *)b;
48 @@ -212,11 +207,11 @@ uint32_t ZEXPORT crc32_no_comp(uint32_t
49 } while (--len);
50 }
51
52 - return le32_to_cpu(crc);
53 + return __le32_to_cpu(crc);
54 }
55 #undef DO_CRC
56
57 -uint32_t ZEXPORT crc32 (uint32_t crc, const Bytef *p, uInt len)
58 +uint32_t ZEXPORT uboot_crc32 (uint32_t crc, const Bytef *p, uInt len)
59 {
60 return crc32_no_comp(crc ^ 0xffffffffL, p, len) ^ 0xffffffffL;
61 }
62 @@ -239,12 +234,12 @@ uint32_t ZEXPORT crc32_wd (uint32_t crc,
63 chunk = end - curr;
64 if (chunk > chunk_sz)
65 chunk = chunk_sz;
66 - crc = crc32 (crc, curr, chunk);
67 + crc = uboot_crc32 (crc, curr, chunk);
68 curr += chunk;
69 WATCHDOG_RESET ();
70 }
71 #else
72 - crc = crc32 (crc, buf, len);
73 + crc = uboot_crc32 (crc, buf, len);
74 #endif
75
76 return crc;
77 --- a/fw_env.c
78 +++ b/fw_env.c
79 @@ -34,6 +34,7 @@
80 #include <sys/ioctl.h>
81 #include <sys/stat.h>
82 #include <unistd.h>
83 +#include <zlib.h>
84
85 #ifdef MTD_OLD
86 # include <stdint.h>
87 @@ -210,13 +211,14 @@ static char default_environment[] = {
88 static int flash_io (int mode);
89 static char *envmatch (char * s1, char * s2);
90 static int parse_config (void);
91 +uint32_t uboot_crc32 (uint32_t crc, const Bytef *p, uInt len);
92
93 #if defined(CONFIG_FILE)
94 static int get_config (char *);
95 #endif
96 -static inline ulong getenvsize (void)
97 +static inline uint32_t getenvsize (void)
98 {
99 - ulong rc = CONFIG_ENV_SIZE - sizeof (long);
100 + uint32_t rc = CONFIG_ENV_SIZE - sizeof (uint32_t);
101
102 if (HaveRedundEnv)
103 rc -= sizeof (char);
104 @@ -346,7 +348,7 @@ int fw_env_close(void)
105 /*
106 * Update CRC
107 */
108 - *environment.crc = crc32(0, (uint8_t *) environment.data, ENV_SIZE);
109 + *environment.crc = uboot_crc32(0, (uint8_t *) environment.data, ENV_SIZE);
110
111 /* write environment back to flash */
112 if (flash_io(O_RDWR)) {
113 @@ -802,7 +804,7 @@ static int flash_write_buf (int dev, int
114 data = malloc (erase_len);
115 if (!data) {
116 fprintf (stderr,
117 - "Cannot malloc %u bytes: %s\n",
118 + "Cannot malloc %zu bytes: %s\n",
119 erase_len, strerror (errno));
120 return -1;
121 }
122 @@ -1107,7 +1109,7 @@ int fw_env_open(void)
123 if (flash_io (O_RDONLY))
124 return -1;
125
126 - crc0 = crc32 (0, (uint8_t *) environment.data, ENV_SIZE);
127 + crc0 = uboot_crc32 (0, (uint8_t *) environment.data, ENV_SIZE);
128 crc0_ok = (crc0 == *environment.crc);
129 if (!HaveRedundEnv) {
130 if (!crc0_ok) {
131 @@ -1151,7 +1153,7 @@ int fw_env_open(void)
132 return -1;
133 }
134
135 - crc1 = crc32 (0, (uint8_t *) redundant->data, ENV_SIZE);
136 + crc1 = uboot_crc32 (0, (uint8_t *) redundant->data, ENV_SIZE);
137 crc1_ok = (crc1 == redundant->crc);
138 flag1 = redundant->flags;
139
This page took 0.046574 seconds and 5 git commands to generate.