On Saturday 19 April 2008 05:54:06 [EMAIL PROTECTED] wrote:
> The current code checks for the special signature that signifies
> a revision 4 SPROM. A rev. 8 SPROM with a 440-byte length has been
> found, but any special code for it is unknown. The the check should
> be relaxed. With this patch, if the CRC is incorrect for a 256-byte
> SPROM, the code will immediately check for a 440-byte SPROM. If there
> is still a CRC error, the size is set to 440 bytes, which allows dumping
> of most of any 512-byte SPROM if/when one is encountered.
> 
> The code has also been modified to test for cases where the CRC check
> results in a false positive, but the revision number is wrong.
> 
> Signed-off-by: Larry Finger <[EMAIL PROTECTED]>
> ---
> 
> 
> 
> Index: wireless-testing/drivers/ssb/pci.c
> ===================================================================
> --- wireless-testing.orig/drivers/ssb/pci.c
> +++ wireless-testing/drivers/ssb/pci.c
> @@ -497,6 +497,7 @@ static int ssb_pci_sprom_get(struct ssb_
>  {
>       int err = -ENOMEM;
>       u16 *buf;
> +     u16 revision;
>  
>       buf = kcalloc(SSB_SPROMSIZE_WORDS_R123, sizeof(u16), GFP_KERNEL);
>       if (!buf)
> @@ -504,19 +505,32 @@ static int ssb_pci_sprom_get(struct ssb_
>       bus->sprom_size = SSB_SPROMSIZE_WORDS_R123;
>       sprom_do_read(bus, buf);
>       err = sprom_check_crc(buf, bus->sprom_size);
> -     if (err) {
> -             /* check for rev 4 sprom - has special signature */
> -             if (buf[32] == 0x5372) {
> -                     kfree(buf);
> -                     buf = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
> -                                   GFP_KERNEL);
> -                     if (!buf)
> -                             goto out;
> -                     bus->sprom_size = SSB_SPROMSIZE_WORDS_R4;
> -                     sprom_do_read(bus, buf);
> -                     err = sprom_check_crc(buf, bus->sprom_size);
> +     if (!err) {
> +             /* crc is OK - make sure we should be expecting 256 bytes */
> +             revision = buf[SSB_SPROMSIZE_WORDS_R123 - 1] & 0x00FF;
> +             if (revision > 3) {
> +                     ssb_printk(KERN_WARNING PFX "Warning: SPROM CRC"
> +                                " and revision are inconsistent\n");
> +                     goto sprom_440;
>               }
> -             if (err)
> +     } else {
> +             /* try for a 440 byte SPROM - revision 4 and higher */
> +sprom_440:

Uh, oh. I like gotos, but this is horrible. :)

Please put
revision = buf[SSB_SPROMSIZE_WORDS_R123 - 1] & 0x00FF;
before the condition and do
        if (err || revision > 3) {
                if (revision > 3)
                        WARNING
                ...

> +             kfree(buf);
> +             buf = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
> +                           GFP_KERNEL);
> +             if (!buf)
> +                     goto out;
> +             bus->sprom_size = SSB_SPROMSIZE_WORDS_R4;
> +             sprom_do_read(bus, buf);
> +             err = sprom_check_crc(buf, bus->sprom_size);
> +             if (!err) {
> +                     /* crc is OK - Are we expecting 440 bytes? */
> +                     revision = buf[SSB_SPROMSIZE_WORDS_R4 - 1] & 0x00FF;
> +                     if (revision < 4 || revision == 0xFF)
> +                             ssb_printk(KERN_WARNING PFX "Warning: SPROM CRC"
> +                                        " and revision are inconsistent\n");
> +             } else
>                       ssb_printk(KERN_WARNING PFX "WARNING: Invalid"
>                                  " SPROM CRC (corrupt SPROM)\n");
>       }



-- 
Greetings Michael.
_______________________________________________
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev

Reply via email to