From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lukasz Majewski Date: Wed, 07 May 2014 12:17:26 +0200 Subject: [U-Boot] [PATCH v2] lib:crc32: Allow setting of the initial crc32 value In-Reply-To: <201405071025.52611.marex@denx.de> References: <1399295277-28334-1-git-send-email-l.majewski@samsung.com> <1399443021-11748-1-git-send-email-l.majewski@samsung.com> <201405071025.52611.marex@denx.de> Message-ID: <20140507121726.509de3a2@amdc2363> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Marek, > On Wednesday, May 07, 2014 at 08:10:20 AM, Lukasz Majewski wrote: > > [...] > > > --- a/lib/crc32.c > > +++ b/lib/crc32.c > > @@ -255,9 +255,12 @@ uint32_t ZEXPORT crc32_wd (uint32_t crc, > > void crc32_wd_buf(const unsigned char *input, unsigned int ilen, > > unsigned char *output, unsigned int chunk_sz) > > { > > - uint32_t crc; > > + uint32_t crc = 0; > > > > - crc = crc32_wd(0, input, ilen, chunk_sz); > > + if (*output) > > + memcpy(&crc, output, sizeof(crc)); > > Won't some sort of put_unaligned() work here ? The $crc is uint32_t > afterall, so it might be a jiff faster. We are concerned here with the use case of copying 4 bytes from unaligned buffer defined on some architectures. I suppose, that the performance would be the same for both. However, since memcpy() is already used in this function, I would prefer to use it here. > Please correct me if I'm > wrong. > > > + > > + crc = crc32_wd(crc, input, ilen, chunk_sz); > > crc = htonl(crc); > > memcpy(output, &crc, sizeof(crc)); > > } > > Best regards, > Marek Vasut -- Best regards, Lukasz Majewski Samsung R&D Institute Poland (SRPOL) | Linux Platform Group