Re: [PATCH master 1/3] resource: return NULL for error in request_barebox_region

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
>> ---
>>  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 |





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux