All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick DELAUNAY <patrick.delaunay@foss.st.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3 2/7] lmb: add lmb_is_reserved_flags
Date: Tue, 4 May 2021 14:22:02 +0200	[thread overview]
Message-ID: <3cfe2ffb-15b0-7d7b-415a-abd28b17a7a9@foss.st.com> (raw)
In-Reply-To: <CAPnjgZ2OecZEktCN6i8TKpVmGFQFCZLFcQ37s7-+9FVg6Vi+9Q@mail.gmail.com>


On 4/29/21 6:10 PM, Simon Glass wrote:
> Hi Patrick,
>
> On Wed, 28 Apr 2021 at 03:23, Patrick Delaunay
> <patrick.delaunay@foss.st.com> wrote:
>> Add a new function lmb_is_reserved_flags to check is a
>> address is reserved with a specific flags.
>>
>> This function can be used to check if an address was
>> reserved with no-map flags with:
>>
>> lmb_is_reserved_flags(lmb, addr, LMB_NOMAP);
>>
>> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
>> ---
>>
>> (no changes since v1)
>>
>>   include/lmb.h |  1 +
>>   lib/lmb.c     | 10 ++++++++--
>>   2 files changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/lmb.h b/include/lmb.h
>> index aa196c63bf..6537d56e18 100644
>> --- a/include/lmb.h
>> +++ b/include/lmb.h
>> @@ -91,6 +91,7 @@ extern phys_addr_t lmb_alloc_addr(struct lmb *lmb, phys_addr_t base,
>>                                    phys_size_t size);
>>   extern phys_size_t lmb_get_free_size(struct lmb *lmb, phys_addr_t addr);
>>   extern int lmb_is_reserved(struct lmb *lmb, phys_addr_t addr);
>> +extern int lmb_is_reserved_flags(struct lmb *lmb, phys_addr_t addr, int flags);
> drop extern and please add a function comment


I chosed to use extern to by aligned with other function and the linux 
memblock library.

But I will drop them in v4



>>   extern long lmb_free(struct lmb *lmb, phys_addr_t base, phys_size_t size);
>>
>>   extern void lmb_dump_all(struct lmb *lmb);
>> diff --git a/lib/lmb.c b/lib/lmb.c
>> index 69700bf9ba..e270e86186 100644
>> --- a/lib/lmb.c
>> +++ b/lib/lmb.c
>> @@ -443,7 +443,7 @@ phys_size_t lmb_get_free_size(struct lmb *lmb, phys_addr_t addr)
>>          return 0;
>>   }
>>
>> -int lmb_is_reserved(struct lmb *lmb, phys_addr_t addr)
>> +int lmb_is_reserved_flags(struct lmb *lmb, phys_addr_t addr, int flags)
>>   {
>>          int i;
>>
>> @@ -451,11 +451,17 @@ int lmb_is_reserved(struct lmb *lmb, phys_addr_t addr)
>>                  phys_addr_t upper = lmb->reserved.region[i].base +
>>                          lmb->reserved.region[i].size - 1;
>>                  if ((addr >= lmb->reserved.region[i].base) && (addr <= upper))
>> -                       return 1;
>> +                       return !!((lmb->reserved.region[i].flags & flags)
>> +                                  == flags);
> I don't know what flags is since there is no comment, but it seems
> that you should drop the !!()


Yes, it is a old C-coding habit.


>>          }
>>          return 0;
>>   }
>>
>> +int lmb_is_reserved(struct lmb *lmb, phys_addr_t addr)
>> +{
>> +       return lmb_is_reserved_flags(lmb, addr, LMB_NONE);
>> +}
>> +
>>   __weak void board_lmb_reserve(struct lmb *lmb)
>>   {
>>          /* please define platform specific board_lmb_reserve() */
>> --
>> 2.17.1
>>
> Regards,
> Simon

  reply	other threads:[~2021-05-04 12:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-28 10:23 [PATCH v3 0/7] arm: cache: cp15: don't map reserved region with no-map property Patrick Delaunay
2021-04-28 10:23 ` [PATCH v3 1/7] lmb: Add support of flags for no-map properties Patrick Delaunay
2021-04-29 16:10   ` Simon Glass
2021-04-28 10:23 ` [PATCH v3 2/7] lmb: add lmb_is_reserved_flags Patrick Delaunay
2021-04-29 16:10   ` Simon Glass
2021-05-04 12:22     ` Patrick DELAUNAY [this message]
2021-04-28 10:23 ` [PATCH v3 3/7] lmb: add lmb_dump_region() function Patrick Delaunay
2021-04-29 16:10   ` Simon Glass
2021-04-28 10:23 ` [PATCH v3 4/7] test: lmb: add test for lmb_reserve_flags Patrick Delaunay
2021-04-29 16:10   ` Simon Glass
2021-04-28 10:23 ` [PATCH v3 5/7] image-fdt: save no-map parameter of reserve-memory Patrick Delaunay
2021-04-29 16:10   ` Simon Glass
2021-04-30  1:46     ` Bin Meng
2021-04-30  6:21     ` Ard Biesheuvel
2021-05-04 12:45     ` Patrick DELAUNAY
2021-04-28 10:23 ` [PATCH v3 6/7] stm32mp: Increase the reserved memory in board_get_usable_ram_top Patrick Delaunay
2021-04-28 10:23 ` [PATCH v3 7/7] stm32mp: don't map the reserved region with no-map property Patrick Delaunay

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=3cfe2ffb-15b0-7d7b-415a-abd28b17a7a9@foss.st.com \
    --to=patrick.delaunay@foss.st.com \
    --cc=u-boot@lists.denx.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.