[PATCH] Remove hardcoded number of CFI chips
andrzej.mialkowski at inetia.pl
andrzej.mialkowski at inetia.pl
Thu Nov 6 15:13:24 EST 2003
Cytowanie Deepak Saxena <dsaxena at plexity.net>:
>
> All,
>
> The attached patch is an update of the patch I posted about a month
> ago [1] that removes the hardcoded CFI_MAX_CHIPS, which was originally
> written by Andrzej Mialkowski @ Intel. This patch fixes two issues:
>
> - Get rid of extra structure probe_info that was just carrying around
> a long* variable.
This 'stupid' single field structure was intentional to allow easier expansion
if somebody fill need for additional fields.
>
> - Fix bug in bitmap size on systems with 2-8 chips. The old patch had:
>
> + max_chips = map->size >> cfi.chipshift;
> + probe.chip_map = kmalloc((max_chips + 7) / 8, GFP_KERNEL);
>
> This would cause systems with 2-8 chips to be allocated only one
> byte for the bitmap instead of the 2 needed. Fixed code does:
>
> + max_chips = map->size >> cfi.chipshift;
> + chip_map = kmalloc((max_chips / 8) + ((max_chip % 8) ? 1 : 0),
> GFP_KERNEL);
>
Why I need two bytes to store up to 8 bits? By the way 2/8 + 2?1:0 = 1.
Initially I thought to put higher alignment here for instance ((max_chips +
31) / 32)*4) but found no reason to do this. Maybe I was wrong...
Andrzej
More information about the linux-mtd
mailing list