Re: [PATCH v3 4/5] w1: ds2433: use the kernel bitmap implementation
From: Marc Ferland
Date: Thu Nov 30 2023 - 10:10:58 EST
On Thu, Nov 30, 2023 at 9:52 AM David Laight <David.Laight@xxxxxxxxxx> wrote:
>
> 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 :-)
>
Sounds reasonable to me. Thanks for the tip!
Marc