From: Sascha Hauer <s.hauer@pengutronix.de>
To: Alexander Shiyan <eagle.alexander923@gmail.com>
Cc: "open list:BAREBOX" <barebox@lists.infradead.org>
Subject: Re: [PATCH 1/6] mci: use struct cid
Date: Mon, 17 Mar 2025 11:53:00 +0100 [thread overview]
Message-ID: <Z9f_DK_AlkhH3jOO@pengutronix.de> (raw)
In-Reply-To: <CAP1tNvTCxfq7wnfwhmvMhKga67h4YUw4RebJYGxcb4o2Yw2btQ@mail.gmail.com>
On Mon, Mar 17, 2025 at 12:41:22PM +0300, Alexander Shiyan wrote:
> 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.
Wouldn't you rather use something like getenv("mmc0.cid_psn") then?
We could also introduce some mmc helper function for convenience.
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 |
next prev parent reply other threads:[~2025-03-17 10:59 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
2025-03-17 10:53 ` Sascha Hauer [this message]
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=Z9f_DK_AlkhH3jOO@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=eagle.alexander923@gmail.com \
/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