[PATCH 1/6] mci: use struct cid
Alexander Shiyan
eagle.alexander923 at gmail.com
Mon Mar 17 02:41:22 PDT 2025
Hello.
> Linux has a struct mmc_cid where the CID data is parsed into whereas
> in barebox we call the UNSTUFF_BITS macro whenever we need a field
> from the CID data. Do it like Linux and parse the CID data into the
> same struct. While at it convert the UNSTUFF_BITS macro into a
> unstuff_bits static inline function.
...
> diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
> index 7ec2643b8d..34ea775813 100644
> --- a/drivers/mci/mci-core.c
> +++ b/drivers/mci/mci-core.c
> @@ -26,19 +26,19 @@
>
> #define MAX_BUFFER_NUMBER 0xffffffff
>
> -#define UNSTUFF_BITS(resp,start,size) \
> - ({ \
> - const int __size = size; \
> - const u32 __mask = (__size < 32 ? 1 << __size : 0) - 1; \
> - const int __off = 3 - ((start) / 32); \
> - const int __shft = (start) & 31; \
> - u32 __res; \
> - \
> - __res = resp[__off] >> __shft; \
> - if (__size + __shft > 32) \
> - __res |= resp[__off-1] << ((32 - __shft) % 32); \
> - __res & __mask; \
> - })
> +static inline u32 unstuff_bits(const u32 *resp, int start, int size)
> +{
> + const int __size = size;
> + const u32 __mask = (__size < 32 ? 1 << __size : 0) - 1;
> + const int __off = 3 - (start / 32);
> + const int __shft = start & 31;
> + u32 __res = resp[__off] >> __shft;
> +
> + if (__size + __shft > 32)
> + __res |= resp[__off - 1] << ((32 - __shft) % 32);
> +
> + return __res & __mask;
> +}
For board specific code where the eMMC ID is used as a unique identifier,
it would be useful to have this function in the header.
More information about the barebox
mailing list