@@ -328,25 +328,23 @@ EXPORT_SYMBOL(release_resource);
328328 * -1.
329329 *
330330 * This function walks the whole tree and not just first level children
331- * unless @first_level_children_only is true.
331+ * unless @first_lvl is true.
332332 */
333333static int find_next_iomem_res (resource_size_t start , resource_size_t end ,
334334 unsigned long flags , unsigned long desc ,
335- bool first_level_children_only ,
336- struct resource * res )
335+ bool first_lvl , struct resource * res )
337336{
338337 struct resource * p ;
339- bool sibling_only = false;
340338
341- BUG_ON (!res );
342- BUG_ON ( start >= end ) ;
339+ if (!res )
340+ return - EINVAL ;
343341
344- if (first_level_children_only )
345- sibling_only = true ;
342+ if (start >= end )
343+ return - EINVAL ;
346344
347345 read_lock (& resource_lock );
348346
349- for (p = iomem_resource .child ; p ; p = next_resource (p , sibling_only )) {
347+ for (p = iomem_resource .child ; p ; p = next_resource (p , first_lvl )) {
350348 if ((p -> flags & flags ) != flags )
351349 continue ;
352350 if ((desc != IORES_DESC_NONE ) && (desc != p -> desc ))
@@ -373,15 +371,14 @@ static int find_next_iomem_res(resource_size_t start, resource_size_t end,
373371
374372static int __walk_iomem_res_desc (resource_size_t start , resource_size_t end ,
375373 unsigned long flags , unsigned long desc ,
376- bool first_level_children_only , void * arg ,
374+ bool first_lvl , void * arg ,
377375 int (* func )(struct resource * , void * ))
378376{
379377 struct resource res ;
380378 int ret = -1 ;
381379
382380 while (start < end &&
383- !find_next_iomem_res (start , end , flags , desc ,
384- first_level_children_only , & res )) {
381+ !find_next_iomem_res (start , end , flags , desc , first_lvl , & res )) {
385382 ret = (* func )(& res , arg );
386383 if (ret )
387384 break ;
@@ -392,7 +389,7 @@ static int __walk_iomem_res_desc(resource_size_t start, resource_size_t end,
392389 return ret ;
393390}
394391
395- /*
392+ /**
396393 * Walks through iomem resources and calls func() with matching resource
397394 * ranges. This walks through whole tree and not just first level children.
398395 * All the memory ranges which overlap start,end and also match flags and
@@ -421,7 +418,7 @@ EXPORT_SYMBOL_GPL(walk_iomem_res_desc);
421418 * ranges.
422419 */
423420int walk_system_ram_res (u64 start , u64 end , void * arg ,
424- int (* func )(struct resource * , void * ))
421+ int (* func )(struct resource * , void * ))
425422{
426423 unsigned long flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY ;
427424
@@ -450,7 +447,7 @@ int walk_mem_res(u64 start, u64 end, void *arg,
450447 * It is to be used only for System RAM.
451448 */
452449int walk_system_ram_range (unsigned long start_pfn , unsigned long nr_pages ,
453- void * arg , int (* func )(unsigned long , unsigned long , void * ))
450+ void * arg , int (* func )(unsigned long , unsigned long , void * ))
454451{
455452 resource_size_t start , end ;
456453 unsigned long flags ;
@@ -646,8 +643,8 @@ static int find_resource(struct resource *root, struct resource *new,
646643 * @constraint: the size and alignment constraints to be met.
647644 */
648645static int reallocate_resource (struct resource * root , struct resource * old ,
649- resource_size_t newsize ,
650- struct resource_constraint * constraint )
646+ resource_size_t newsize ,
647+ struct resource_constraint * constraint )
651648{
652649 int err = 0 ;
653650 struct resource new = * old ;
@@ -960,7 +957,7 @@ static int __adjust_resource(struct resource *res, resource_size_t start,
960957 * Existing children of the resource are assumed to be immutable.
961958 */
962959int adjust_resource (struct resource * res , resource_size_t start ,
963- resource_size_t size )
960+ resource_size_t size )
964961{
965962 int result ;
966963
@@ -971,9 +968,9 @@ int adjust_resource(struct resource *res, resource_size_t start,
971968}
972969EXPORT_SYMBOL (adjust_resource );
973970
974- static void __init __reserve_region_with_split ( struct resource * root ,
975- resource_size_t start , resource_size_t end ,
976- const char * name )
971+ static void __init
972+ __reserve_region_with_split ( struct resource * root , resource_size_t start ,
973+ resource_size_t end , const char * name )
977974{
978975 struct resource * parent = root ;
979976 struct resource * conflict ;
@@ -1032,9 +1029,9 @@ static void __init __reserve_region_with_split(struct resource *root,
10321029
10331030}
10341031
1035- void __init reserve_region_with_split ( struct resource * root ,
1036- resource_size_t start , resource_size_t end ,
1037- const char * name )
1032+ void __init
1033+ reserve_region_with_split ( struct resource * root , resource_size_t start ,
1034+ resource_size_t end , const char * name )
10381035{
10391036 int abort = 0 ;
10401037
@@ -1160,7 +1157,7 @@ EXPORT_SYMBOL(__request_region);
11601157 * The described resource region must match a currently busy region.
11611158 */
11621159void __release_region (struct resource * parent , resource_size_t start ,
1163- resource_size_t n )
1160+ resource_size_t n )
11641161{
11651162 struct resource * * p ;
11661163 resource_size_t end ;
@@ -1222,7 +1219,7 @@ EXPORT_SYMBOL(__release_region);
12221219 * simplicity. Enhance this logic when necessary.
12231220 */
12241221int release_mem_region_adjustable (struct resource * parent ,
1225- resource_size_t start , resource_size_t size )
1222+ resource_size_t start , resource_size_t size )
12261223{
12271224 struct resource * * p ;
12281225 struct resource * res ;
@@ -1398,9 +1395,9 @@ static int devm_region_match(struct device *dev, void *res, void *match_data)
13981395 this -> start == match -> start && this -> n == match -> n ;
13991396}
14001397
1401- struct resource * __devm_request_region ( struct device * dev ,
1402- struct resource * parent , resource_size_t start ,
1403- resource_size_t n , const char * name )
1398+ struct resource *
1399+ __devm_request_region ( struct device * dev , struct resource * parent ,
1400+ resource_size_t start , resource_size_t n , const char * name )
14041401{
14051402 struct region_devres * dr = NULL ;
14061403 struct resource * res ;
0 commit comments