Re: [PATCH 04/10] mci: turn bool members into bitfield in struct mci

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 30, 2024 at 09:19:23AM +0200, Ahmad Fatoum wrote:
> In preparation for adding more boolean flags, turn the current two bools
> into two bits sharing the same u8-sized member.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
> ---
>  include/mci.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/mci.h b/include/mci.h
> index 773aed896c96..4f1ff9dc57c8 100644
> --- a/include/mci.h
> +++ b/include/mci.h
> @@ -568,8 +568,8 @@ struct mci {
>  	unsigned csd[4];	/**< card's "card specific data register" */
>  	unsigned cid[4];	/**< card's "card identification register" */
>  	unsigned short rca;	/**< relative card address */
> -	bool sdio;              /**< card is a SDIO card */
> -	bool high_capacity;	/**< high capacity card is connected (OCR -> OCR_HCS) */
> +	u8 sdio:1;              /**< card is a SDIO card */
> +	u8 high_capacity:1;	/**< high capacity card is connected (OCR -> OCR_HCS) */

This doesn't seem to be necessary. They share the same byte in either
way. From a quick test:

struct foo {
	u16 a;
	bool b;
	bool c;
	u32 d;
};

struct bar {
	u16 a;
	u8 b:1;
	u8 c:1;
	u32 d;
};

printf("%d %d\n", sizeof(struct foo), sizeof(struct bar));

The result is 8 for both structs.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux