RE: [PATCH v3 4/5] w1: ds2433: use the kernel bitmap implementation

From: David Laight
Date: Thu Nov 30 2023 - 09:52:21 EST


From: marc.ferland@xxxxxxxxx
> Sent: 30 November 2023 13:53
>
> The ds2433 driver uses the 'validcrc' variable to mark out which pages
> have been successfully (crc is valid) retrieved from the eeprom and
> placed in the internal 'memory' buffer (see CONFIG_W1_SLAVE_DS2433_CRC).
>
> The current implementation assumes that the number of pages will never
> go beyond 32 pages (bit field is a u32). This is fine for the ds2433
> since it only has 16 pages.
>
> Use a dynamically allocated bitmap so that we can support eeproms with
> more than 32 pages which is the case for the ds28ec20 (80 pages).

Dynamically allocating seems excessive.
Why not just make the maximum a compile-time constant (say 96 or 128)
and just check that the actual size isn't too big.

> As an added bonus, the code also gets easier on the eye.

and slower :-)

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)