W dniu 15 czerwca 2011 14:09 uÅytkownik Arend van Spriel <arend@xxxxxxxxxxxx> napisaÅ: > On 06/15/2011 01:53 PM, RafaÅ MiÅecki wrote: >> >> Âstatic u8 bcma_sprom_crc(const u16 *sprom) >> Â{ >> - Â Â Â int word; >> - Â Â Â u8 crc = 0xFF; >> + Â Â Â u8 crc; >> + Â Â Â u8 sprom2[SSB_SPROMSIZE_WORDS_R4 * 2 - 1]; >> + Â Â Â u8 table[CRC8_TABLE_SIZE]; >> + Â Â Â u16 word; >> >> + Â Â Â /* u16 to u8 */ >> Â Â Â Âfor (word = 0; word< ÂSSB_SPROMSIZE_WORDS_R4 - 1; word++) { >> - Â Â Â Â Â Â Â crc = bcma_crc8(crc, sprom[word]& Â0x00FF); >> - Â Â Â Â Â Â Â crc = bcma_crc8(crc, (sprom[word]& Â0xFF00)>> Â8); >> + Â Â Â Â Â Â Â sprom2[word * 2] = sprom[word]& Â0x00FF; >> + Â Â Â Â Â Â Â sprom2[(word * 2) + 1] = (sprom[word]& Â0xFF00)>> Â8; >> Â Â Â Â} >> - Â Â Â crc = bcma_crc8(crc, sprom[SSB_SPROMSIZE_WORDS_R4 - 1]& Â0x00FF); >> + Â Â Â /* 127th byte */ >> + Â Â Â sprom2[(SSB_SPROMSIZE_WORDS_R4 * 2) - 2] = >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â sprom[SSB_SPROMSIZE_WORDS_R4 - 1]& >> Â0x00FF; >> + >> + Â Â Â /* Prepare table, 0xAB is x^8 + x^7 + x^6 + x^4 + x^2 + 1 */ >> + Â Â Â crc8_populate_lsb(table, 0xAB); >> + >> + Â Â Â /* Calculate */ >> + Â Â Â crc = crc8(table, sprom2, (SSB_SPROMSIZE_WORDS_R4 * 2) - 1, 0xFF); >> Â Â Â Âcrc ^= 0xFF; >> >> Â Â Â Âreturn crc; > > You could do (I think): > > crc8_populate_lsb(table, 0xAB); > for (word = 0; word< ÂSSB_SPROMSIZE_WORDS_R4; word++) { > Â Â Â Âu16 val = cpu_to_le16(sprom[word]); > Â Â Â Âcrc = crc8(table,&val, sizeof(u16), crc); > } Maybe not a perfect/optimal solution (crc8 focuses on tables, we do double loop instead) but should work. Thanks for the tip. -- RafaÅ -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html