[PATCH 1/3] mmc: Convert hs400_tuning flag from u8 to bool

Paul Barker paul.barker.ct at bp.renesas.com
Tue Feb 20 15:41:00 CET 2024


On 20/02/2024 11:27, Marek Vasut wrote:
> On 2/20/24 11:57, Paul Barker wrote:
>> On 20/02/2024 08:37, Marek Vasut wrote:
>>> This hs400_tuning is a flag, make it bool. No functional change.
>>> This will be useful in the following patch, which adds another
>>> more generic flag, where the compiler can better use the space
>>> now reserved for the u8 to store more flags in it.
>>
>> The minimum size for a bool is one byte so there likely won't be any
>> improvement in struct size from using bool instead of u8 for
>> `hs400_tuning` here and `tuning` added in the next patch. I still think
>> it's a good change to make though, bool is the right type for an on/off
>> flag.
> 
> The compiler does not do boolean packing in structures ?

The compiler will only pack booleans if you explicitly say that only
one bit of memory is needed, e.g.:

    bool tuning:1;
    bool hs400_tuning:1;

Otherwise the assumption is that you may wish to take the address of
each field and so each one must have a distinct address in memory.

Thanks,

-- 
Paul Barker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0x27F4B3459F002257.asc
Type: application/pgp-keys
Size: 3520 bytes
Desc: OpenPGP public key
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20240220/b556bbf0/attachment.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 236 bytes
Desc: OpenPGP digital signature
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20240220/b556bbf0/attachment.sig>


More information about the U-Boot mailing list