From: Alexander Shiyan <eagle.alexander923@gmail.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: "open list:BAREBOX" <barebox@lists.infradead.org>
Subject: Re: [PATCH 1/6] mci: use struct cid
Date: Mon, 17 Mar 2025 12:41:22 +0300 [thread overview]
Message-ID: <CAP1tNvTCxfq7wnfwhmvMhKga67h4YUw4RebJYGxcb4o2Yw2btQ@mail.gmail.com> (raw)
In-Reply-To: <20250317-mci-misc-cleanup-v1-1-24b4d6f5d31a@pengutronix.de>
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.
next prev parent reply other threads:[~2025-03-17 9:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-17 9:34 [PATCH 0/6] mci: some cleanups Sascha Hauer
2025-03-17 9:34 ` [PATCH 1/6] mci: use struct cid Sascha Hauer
2025-03-17 9:41 ` Alexander Shiyan [this message]
2025-03-17 10:53 ` Sascha Hauer
2025-03-17 9:34 ` [PATCH 2/6] mmc: merge block read/write functions Sascha Hauer
2025-03-17 9:34 ` [PATCH 3/6] mci: cleanup code around ready_for_use flag Sascha Hauer
2025-03-17 9:34 ` [PATCH 4/6] mci: mci_spi: remove stray return 0 Sascha Hauer
2025-03-17 9:34 ` [PATCH 5/6] mci: mci_spi: fix warning message Sascha Hauer
2025-03-17 9:34 ` [PATCH 6/6] mci: mci_spi: use mci_of_parse() Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAP1tNvTCxfq7wnfwhmvMhKga67h4YUw4RebJYGxcb4o2Yw2btQ@mail.gmail.com \
--to=eagle.alexander923@gmail.com \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox