mtd->size revisited
Trent Piepho
tpiepho at freescale.com
Wed Apr 9 19:27:02 EDT 2008
On Wed, 9 Apr 2008, Vernon Sauder wrote:
> Bruce_Leonard at selinc.com wrote:
>
> While I agree that it would be great to support larger devices, I'm
> going to ask a dumb question: does this have to grow to a 64-bit number?
> Can it be in KB or something? If device sizes are always divisible by
> 1KB, we don't need the bottom 10 bits anyway. That would seem an easier
> change in some ways.
It's more efficient that way too.
Instead of just changing the size to uint64_t, it might be better to create a
new type which can be 32 or 64. Once you start using the right type
everywhere you usually don't have to change much code. The only exception is
printf format strings, which can be a pain.
Or like Vern said, just shift off the bottom bits. define MTD_SIZE_SHIFT to
the number of bits to shift off. One can then make trivial macros/inline
functions mtd_size_to_kb(), mtd_size_to_bytes(), mtd_size_to_pages(), etc.
when code actually cares about the units. I imagine a lot of code doesn't
care if it's bytes or kilobytes, as long as everything uses the same units.
More information about the linux-mtd
mailing list