diff mbox series

[U-Boot,080/126] x86: Add a function to find the size of an mrccache record

Message ID 20190925145750.200592-81-sjg@chromium.org
State Accepted
Commit ca4e40887e9c8a60bd88f4a6668a3e53e7c899ae
Delegated to: Bin Meng
Headers show
Series x86: Add initial support for apollolake | expand

Commit Message

Simon Glass Sept. 25, 2019, 2:57 p.m. UTC
Move the code to determine the size of a cache record into a function so
we can use it elsewhere in this file.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/lib/mrccache.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Comments

Bin Meng Oct. 10, 2019, 5:09 a.m. UTC | #1
On Wed, Sep 25, 2019 at 10:59 PM Simon Glass <sjg@chromium.org> wrote:
>
> Move the code to determine the size of a cache record into a function so
> we can use it elsewhere in this file.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  arch/x86/lib/mrccache.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Bin Meng Oct. 11, 2019, 8:28 a.m. UTC | #2
On Thu, Oct 10, 2019 at 1:09 PM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> On Wed, Sep 25, 2019 at 10:59 PM Simon Glass <sjg@chromium.org> wrote:
> >
> > Move the code to determine the size of a cache record into a function so
> > we can use it elsewhere in this file.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> >  arch/x86/lib/mrccache.c | 15 ++++++++-------
> >  1 file changed, 8 insertions(+), 7 deletions(-)
> >
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

applied to u-boot-x86, thanks!
diff mbox series

Patch

diff --git a/arch/x86/lib/mrccache.c b/arch/x86/lib/mrccache.c
index be107627b80..33bb52039bd 100644
--- a/arch/x86/lib/mrccache.c
+++ b/arch/x86/lib/mrccache.c
@@ -17,19 +17,20 @@ 
 
 DECLARE_GLOBAL_DATA_PTR;
 
+static uint mrc_block_size(uint data_size)
+{
+	uint mrc_size = sizeof(struct mrc_data_container) + data_size;
+
+	return ALIGN(mrc_size, MRC_DATA_ALIGN);
+}
+
 static struct mrc_data_container *next_mrc_block(
 	struct mrc_data_container *cache)
 {
 	/* MRC data blocks are aligned within the region */
-	u32 mrc_size = sizeof(*cache) + cache->data_size;
 	u8 *region_ptr = (u8 *)cache;
 
-	if (mrc_size & (MRC_DATA_ALIGN - 1UL)) {
-		mrc_size &= ~(MRC_DATA_ALIGN - 1UL);
-		mrc_size += MRC_DATA_ALIGN;
-	}
-
-	region_ptr += mrc_size;
+	region_ptr += mrc_block_size(cache->data_size);
 
 	return (struct mrc_data_container *)region_ptr;
 }