[PATCH 2/2] mtd: spi-nor: spansion: Discover current address mode by CRC

Tudor.Ambarus at microchip.com Tudor.Ambarus at microchip.com
Wed Oct 5 00:10:44 PDT 2022


Hi, Takahiro,

On 8/12/22 11:06, tkuw584924 at gmail.com wrote:
> +#define CRC32C_POLY    0x1edc6f41
> +static u32 cypress_nor_calc_crc32c(u32 len, u8 *buf)
> +{
> +       u32 crc = 0;
> +       int i;
> +
> +       while (len--) {
> +               crc ^= *buf++ << 24;
> +               for (i = 0; i < 8; i++)
> +                       crc = (crc << 1) ^ ((crc & 0x80000000) ? CRC32C_POLY :
> +                                           0);
> +       }
> +
> +       return crc;
> +}

I haven't gone through the details of the patch set, but I like the idea.
I stumbled on your crc implementation. Can't we use #include <linux/crc32.h>
instead?

-- 
Cheers,
ta


More information about the linux-mtd mailing list