mirror of
https://github.com/pengutronix/genimage.git
synced 2024-11-23 09:43:50 +08:00
crc32: add function to allow splitting the crc calculation
This is needed when the input data is not available in on continuous block. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
This commit is contained in:
parent
2b4cd00b0e
commit
a7cd4bb8f7
9
crc32.c
9
crc32.c
@ -48,9 +48,9 @@ static const uint32_t crc32_tab[] = {
|
||||
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
|
||||
};
|
||||
|
||||
uint32_t crc32(const void *data, size_t len)
|
||||
uint32_t crc32_next(const void *data, size_t len, uint32_t last_crc)
|
||||
{
|
||||
uint32_t crc = ~0;
|
||||
uint32_t crc = ~last_crc;
|
||||
const char *p = data;
|
||||
|
||||
while(len--)
|
||||
@ -58,3 +58,8 @@ uint32_t crc32(const void *data, size_t len)
|
||||
|
||||
return ~crc;
|
||||
}
|
||||
|
||||
uint32_t crc32(const void *data, size_t len)
|
||||
{
|
||||
return crc32_next(data, len, 0);
|
||||
}
|
||||
|
@ -169,5 +169,6 @@ char *uuid_random(void);
|
||||
unsigned long long image_dir_size(struct image *image);
|
||||
|
||||
uint32_t crc32(const void *data, size_t len);
|
||||
uint32_t crc32_next(const void *data, size_t len, uint32_t last_crc);
|
||||
|
||||
#endif /* __PTX_IMAGE_H */
|
||||
|
Loading…
Reference in New Issue
Block a user