Message ID | 20180504155918.21287-9-f4bug@amsat.org |
---|---|
State | New |
Headers | show |
Series | sdcard: proper implementation of CRC | expand |
On Fri, May 4, 2018 at 9:03 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote: > Fix style to keep patchew/checkpatch happy when moving this code > in the next patch. > Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Alistair > --- > hw/sd/sd.c | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > diff --git a/hw/sd/sd.c b/hw/sd/sd.c > index 3708ec1d72..a28ef8de5e 100644 > --- a/hw/sd/sd.c > +++ b/hw/sd/sd.c > @@ -243,12 +243,14 @@ static uint8_t sd_crc7(const void *message, size_t width) > uint8_t shift_reg = 0x00; > const uint8_t *msg = (const uint8_t *)message; > - for (i = 0; i < width; i ++, msg ++) > - for (bit = 7; bit >= 0; bit --) { > + for (i = 0; i < width; i++, msg++) { > + for (bit = 7; bit >= 0; bit--) { > shift_reg <<= 1; > - if ((shift_reg >> 7) ^ ((*msg >> bit) & 1)) > + if ((shift_reg >> 7) ^ ((*msg >> bit) & 1)) { > shift_reg ^= 0x89; > + } > } > + } > return shift_reg; > } > @@ -260,12 +262,14 @@ static uint16_t sd_crc16(const void *message, size_t width) > const uint16_t *msg = (const uint16_t *)message; > width <<= 1; > - for (i = 0; i < width; i ++, msg ++) > - for (bit = 15; bit >= 0; bit --) { > + for (i = 0; i < width; i++, msg++) { > + for (bit = 15; bit >= 0; bit--) { > shift_reg <<= 1; > - if ((shift_reg >> 15) ^ ((*msg >> bit) & 1)) > + if ((shift_reg >> 15) ^ ((*msg >> bit) & 1)) { > shift_reg ^= 0x1011; > + } > } > + } > return shift_reg; > } > -- > 2.17.0
diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 3708ec1d72..a28ef8de5e 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -243,12 +243,14 @@ static uint8_t sd_crc7(const void *message, size_t width) uint8_t shift_reg = 0x00; const uint8_t *msg = (const uint8_t *)message; - for (i = 0; i < width; i ++, msg ++) - for (bit = 7; bit >= 0; bit --) { + for (i = 0; i < width; i++, msg++) { + for (bit = 7; bit >= 0; bit--) { shift_reg <<= 1; - if ((shift_reg >> 7) ^ ((*msg >> bit) & 1)) + if ((shift_reg >> 7) ^ ((*msg >> bit) & 1)) { shift_reg ^= 0x89; + } } + } return shift_reg; } @@ -260,12 +262,14 @@ static uint16_t sd_crc16(const void *message, size_t width) const uint16_t *msg = (const uint16_t *)message; width <<= 1; - for (i = 0; i < width; i ++, msg ++) - for (bit = 15; bit >= 0; bit --) { + for (i = 0; i < width; i++, msg++) { + for (bit = 15; bit >= 0; bit--) { shift_reg <<= 1; - if ((shift_reg >> 15) ^ ((*msg >> bit) & 1)) + if ((shift_reg >> 15) ^ ((*msg >> bit) & 1)) { shift_reg ^= 0x1011; + } } + } return shift_reg; }
Fix style to keep patchew/checkpatch happy when moving this code in the next patch. Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> --- hw/sd/sd.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)