From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Marco Felsch <m.felsch@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH master 1/3] resource: return NULL for error in request_barebox_region
Date: Tue, 23 Jul 2024 08:07:28 +0200 [thread overview]
Message-ID: <f715bf30-0f27-4ea6-ba32-2c7c87e4051c@pengutronix.de> (raw)
In-Reply-To: <20240722174914.r3uwujez6gvuipsj@pengutronix.de>
On 22.07.24 19:49, Marco Felsch wrote:
> Hi Ahmad,
>
> On 24-07-22, Ahmad Fatoum wrote:
>> The function currently returns NULL for error if the range is in SDRAM
>> and couldn't be requested or an error pointer if the range is outside.
>>
>> Reduce the confusion by using only one way to indicate error. As
>> request_barebox_region is used to replace request_sdram_region calls and
>> that returns NULL on error, follow suit.
>>
>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>> ---
>> common/memory.c | 9 ++++++---
>> 1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/common/memory.c b/common/memory.c
>> index eb7838d03613..c155cb317f25 100644
>> --- a/common/memory.c
>> +++ b/common/memory.c
>> @@ -84,9 +84,12 @@ struct resource *request_barebox_region(const char *name,
>> resource_size_t end = start + size - 1;
>>
>> if (barebox_res && barebox_res->start <= start &&
>> - end <= barebox_res->end)
>> - return __request_region(barebox_res, start, end,
>> - name, IORESOURCE_MEM);
>> + end <= barebox_res->end) {
>> + struct resource *iores;
>> + iores = __request_region(barebox_res, start, end,
>> + name, IORESOURCE_MEM);
>> + return !IS_ERR(iores) ? iores : NULL;
>
> Of course a nit but IMHO
>
> return IS_ERR(iores) ? NULL : iores;
>
> is easier to read.
I wanted the successful case to be first.
>
> Regards,
> Marco
>
>> + }
>>
>> return request_sdram_region(name, start, size);
>> }
>> --
>> 2.39.2
>>
>>
>>
>
--
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:[~2024-07-23 6:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-22 17:06 Ahmad Fatoum
2024-07-22 17:06 ` [PATCH master 2/3] ARM: i.MX8M: scratch: fix initcall return code on request_barebox_region error Ahmad Fatoum
2024-07-22 17:06 ` [PATCH master 3/3] RISC-V: cpu: " Ahmad Fatoum
2024-07-22 17:49 ` [PATCH master 1/3] resource: return NULL for error in request_barebox_region Marco Felsch
2024-07-23 6:07 ` Ahmad Fatoum [this message]
2024-07-24 8:08 ` 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=f715bf30-0f27-4ea6-ba32-2c7c87e4051c@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=m.felsch@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