alistair23-linux/drivers/staging/slicoss
David Matlack 55b62cdfe9 staging: slicoss: fix eeprom checksum code
Rewrite slic_eeprom_cksum() to fix bugs and make readable. This patch
technically has no effect on the user as failed eeprom checksums are
ignored anyway.

The original implementation had the following issues:

  1. 2 of the 3 unrolled loops had the following bug:

       while ((len -= 32) >= 0) {
               [...]
               sum += w[15];
               w = (u16 *)((ulong) w + 16);    /* verify */
       }

     This processes 32-bytes of data but only increments the word
     pointer by 16 bytes. Fixing both of these bugs seems to fix
     slic_eeprom_cksum().

  2. Non-descriptive variable names, use of unions, and macros that
     change local state make the code difficult to read.

  3. The checksum loop is unrolled which makes the code harder to
     reason about while providing small performance improvement:
      - max eeprom length is 0x80 bytes (MAX_EECODE_SIZE), that's
        only 0x40 iterations
      - checksum is only computed during pci probe(), so not very
        often

Tested on Mojave card

Signed-off-by: David Matlack <matlackdavid@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-23 20:13:12 +09:00
..
Kconfig
Makefile
README
slic.h staging: slicoss: remove gratuitous debug infrastructure 2014-05-23 20:08:33 +09:00
slichw.h
slicoss.c staging: slicoss: fix eeprom checksum code 2014-05-23 20:13:12 +09:00
TODO staging: slicoss: remove gratuitous debug infrastructure 2014-05-23 20:08:33 +09:00

This driver is supposed to support:

	Mojave cards (single port PCI Gigabit) both copper and fiber
	Oasis cards (single and dual port PCI-x Gigabit) copper and fiber
	Kalahari cards (dual and quad port PCI-e Gigabit) copper and fiber

The driver was actually tested on Oasis and Kalahari cards.