Hi Geert, On Tuesday, July 11, 2017, Geert Uytterhoeven wrote: > > zeroing out the bottom 2 bits of count for out math. > > s/out/our/ Thank you! > > - buf8 = (u8 *)(buf + (count >> 2)); > > + buf8 = (u8 *)buf + (count & ~3); > > count %= 4; > > While correct, this is IMHO still difficult to understand for the casual > reader. > > Given the code before casts to "u32 *", and uses "count >>2", and the code > after also casts to "u32 *", what about getting rid of all casts like: > > u32 data = 0; > u32 *buf32 = buf; > > if (is_read) > sd_ctrl_read32_rep(host, CTL_SD_DATA_PORT, buf32, > count >> 2); > else > sd_ctrl_write32_rep(host, CTL_SD_DATA_PORT, buf32, > count >> 2); > > /* if count was multiple of 4 */ > if (!(count & 0x3)) > return; > > buf32 += count >> 2; > count %= 4; > > if (is_read) { > sd_ctrl_read32_rep(host, CTL_SD_DATA_PORT, &data, 1); > memcpy(buf32, &data, count); > } else { > memcpy(&data, buf32, count); > sd_ctrl_write32_rep(host, CTL_SD_DATA_PORT, &data, 1); > } > > return; > } > Good idea. I just tried it and it seems to work. I'll resend a patch. > u32 *buf32 = buf; GCC didn't like this line without casting buf to a u32 *. It threw an error, not just a warning. Go figure. Question: > u32 data = 0; Any special reason why you are initializing this to 0???? Thank you, Chris ��.n��������+%������w��{.n�����{��i��)��jg��������ݢj����G�������j:+v���w�m������w�������h�����٥