All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Arend van Spriel" <arend@broadcom.com>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"John W. Linville" <linville@tuxdriver.com>,
	"b43-dev@lists.infradead.org" <b43-dev@lists.infradead.org>
Subject: Re: [RFC][WORTH IT?][PATCH] bcma: make use of crc8 lib
Date: Wed, 15 Jun 2011 14:09:19 +0200	[thread overview]
Message-ID: <4DF8A0EF.5030702@broadcom.com> (raw)
In-Reply-To: <1308138814-12235-1-git-send-email-zajec5@gmail.com>

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


Gr. AvS

-- 
Almost nobody dances sober, unless they happen to be insane.
-- H.P. Lovecraft --



  reply	other threads:[~2011-06-15 12:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-15 11:53 [RFC][WORTH IT?][PATCH] bcma: make use of crc8 lib Rafał Miłecki
2011-06-15 11:53 ` Rafał Miłecki
2011-06-15 12:09 ` Arend van Spriel [this message]
2011-06-15 13:59   ` Arend van Spriel
2011-06-15 18:29   ` Rafał Miłecki
2011-06-15 18:29     ` Rafał Miłecki
2011-06-15 19:26     ` Arend van Spriel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DF8A0EF.5030702@broadcom.com \
    --to=arend@broadcom.com \
    --cc=b43-dev@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=zajec5@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.