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:
Michael Olbrich 2021-01-12 08:43:44 +01:00
parent 2b4cd00b0e
commit a7cd4bb8f7
2 changed files with 8 additions and 2 deletions

View File

@ -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);
}

View File

@ -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 */