Lines Matching refs:res

149 static void free_resource(struct resource *res)  in free_resource()  argument
151 if (!res) in free_resource()
154 if (!PageSlab(virt_to_head_page(res))) { in free_resource()
156 res->sibling = bootmem_resource_free; in free_resource()
157 bootmem_resource_free = res; in free_resource()
160 kfree(res); in free_resource()
166 struct resource *res = NULL; in alloc_resource() local
170 res = bootmem_resource_free; in alloc_resource()
171 bootmem_resource_free = res->sibling; in alloc_resource()
175 if (res) in alloc_resource()
176 memset(res, 0, sizeof(struct resource)); in alloc_resource()
178 res = kzalloc(sizeof(struct resource), flags); in alloc_resource()
180 return res; in alloc_resource()
328 static int find_next_iomem_res(struct resource *res, unsigned long desc, in find_next_iomem_res() argument
335 BUG_ON(!res); in find_next_iomem_res()
337 start = res->start; in find_next_iomem_res()
338 end = res->end; in find_next_iomem_res()
347 if ((p->flags & res->flags) != res->flags) in find_next_iomem_res()
363 if (res->start < p->start) in find_next_iomem_res()
364 res->start = p->start; in find_next_iomem_res()
365 if (res->end > p->end) in find_next_iomem_res()
366 res->end = p->end; in find_next_iomem_res()
367 res->flags = p->flags; in find_next_iomem_res()
368 res->desc = p->desc; in find_next_iomem_res()
372 static int __walk_iomem_res_desc(struct resource *res, unsigned long desc, in __walk_iomem_res_desc() argument
377 u64 orig_end = res->end; in __walk_iomem_res_desc()
380 while ((res->start < res->end) && in __walk_iomem_res_desc()
381 !find_next_iomem_res(res, desc, first_level_children_only)) { in __walk_iomem_res_desc()
382 ret = (*func)(res, arg); in __walk_iomem_res_desc()
386 res->start = res->end + 1; in __walk_iomem_res_desc()
387 res->end = orig_end; in __walk_iomem_res_desc()
410 struct resource res; in walk_iomem_res_desc() local
412 res.start = start; in walk_iomem_res_desc()
413 res.end = end; in walk_iomem_res_desc()
414 res.flags = flags; in walk_iomem_res_desc()
416 return __walk_iomem_res_desc(&res, desc, false, arg, func); in walk_iomem_res_desc()
430 struct resource res; in walk_system_ram_res() local
432 res.start = start; in walk_system_ram_res()
433 res.end = end; in walk_system_ram_res()
434 res.flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; in walk_system_ram_res()
436 return __walk_iomem_res_desc(&res, IORES_DESC_NONE, true, in walk_system_ram_res()
447 struct resource res; in walk_mem_res() local
449 res.start = start; in walk_mem_res()
450 res.end = end; in walk_mem_res()
451 res.flags = IORESOURCE_MEM | IORESOURCE_BUSY; in walk_mem_res()
453 return __walk_iomem_res_desc(&res, IORES_DESC_NONE, true, in walk_mem_res()
467 struct resource res; in walk_system_ram_range() local
472 res.start = (u64) start_pfn << PAGE_SHIFT; in walk_system_ram_range()
473 res.end = ((u64)(start_pfn + nr_pages) << PAGE_SHIFT) - 1; in walk_system_ram_range()
474 res.flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; in walk_system_ram_range()
475 orig_end = res.end; in walk_system_ram_range()
476 while ((res.start < res.end) && in walk_system_ram_range()
477 (find_next_iomem_res(&res, IORES_DESC_NONE, true) >= 0)) { in walk_system_ram_range()
478 pfn = (res.start + PAGE_SIZE - 1) >> PAGE_SHIFT; in walk_system_ram_range()
479 end_pfn = (res.end + 1) >> PAGE_SHIFT; in walk_system_ram_range()
484 res.start = res.end + 1; in walk_system_ram_range()
485 res.end = orig_end; in walk_system_ram_range()
571 static void resource_clip(struct resource *res, resource_size_t min, in resource_clip() argument
574 if (res->start < min) in resource_clip()
575 res->start = min; in resource_clip()
576 if (res->end > max) in resource_clip()
577 res->end = max; in resource_clip()
757 struct resource *res; in lookup_resource() local
760 for (res = root->child; res; res = res->sibling) { in lookup_resource()
761 if (res->start == start) in lookup_resource()
766 return res; in lookup_resource()
927 static int __adjust_resource(struct resource *res, resource_size_t start, in __adjust_resource() argument
930 struct resource *tmp, *parent = res->parent; in __adjust_resource()
940 if (res->sibling && (res->sibling->start <= end)) in __adjust_resource()
944 if (tmp != res) { in __adjust_resource()
945 while (tmp->sibling != res) in __adjust_resource()
952 for (tmp = res->child; tmp; tmp = tmp->sibling) in __adjust_resource()
956 res->start = start; in __adjust_resource()
957 res->end = end; in __adjust_resource()
974 int adjust_resource(struct resource *res, resource_size_t start, in adjust_resource() argument
980 result = __adjust_resource(res, start, size); in adjust_resource()
992 struct resource *res = alloc_resource(GFP_ATOMIC); in __reserve_region_with_split() local
996 if (!res) in __reserve_region_with_split()
999 res->name = name; in __reserve_region_with_split()
1000 res->start = start; in __reserve_region_with_split()
1001 res->end = end; in __reserve_region_with_split()
1002 res->flags = type | IORESOURCE_BUSY; in __reserve_region_with_split()
1003 res->desc = IORES_DESC_NONE; in __reserve_region_with_split()
1007 conflict = __request_resource(parent, res); in __reserve_region_with_split()
1011 res = next_res; in __reserve_region_with_split()
1017 if (conflict->start <= res->start && in __reserve_region_with_split()
1018 conflict->end >= res->end) { in __reserve_region_with_split()
1019 free_resource(res); in __reserve_region_with_split()
1025 if (conflict->start > res->start) { in __reserve_region_with_split()
1026 end = res->end; in __reserve_region_with_split()
1027 res->end = conflict->start - 1; in __reserve_region_with_split()
1031 free_resource(res); in __reserve_region_with_split()
1041 res->start = conflict->end + 1; in __reserve_region_with_split()
1082 resource_size_t resource_alignment(struct resource *res) in resource_alignment() argument
1084 switch (res->flags & (IORESOURCE_SIZEALIGN | IORESOURCE_STARTALIGN)) { in resource_alignment()
1086 return resource_size(res); in resource_alignment()
1088 return res->start; in resource_alignment()
1120 struct resource *res = alloc_resource(GFP_KERNEL); in __request_region() local
1122 if (!res) in __request_region()
1125 res->name = name; in __request_region()
1126 res->start = start; in __request_region()
1127 res->end = start + n - 1; in __request_region()
1134 res->flags = resource_type(parent) | resource_ext_type(parent); in __request_region()
1135 res->flags |= IORESOURCE_BUSY | flags; in __request_region()
1136 res->desc = parent->desc; in __request_region()
1138 conflict = __request_resource(parent, res); in __request_region()
1157 free_resource(res); in __request_region()
1158 res = NULL; in __request_region()
1162 return res; in __request_region()
1186 struct resource *res = *p; in __release_region() local
1188 if (!res) in __release_region()
1190 if (res->start <= start && res->end >= end) { in __release_region()
1191 if (!(res->flags & IORESOURCE_BUSY)) { in __release_region()
1192 p = &res->child; in __release_region()
1195 if (res->start != start || res->end != end) in __release_region()
1197 *p = res->sibling; in __release_region()
1199 if (res->flags & IORESOURCE_MUXED) in __release_region()
1201 free_resource(res); in __release_region()
1204 p = &res->sibling; in __release_region()
1240 struct resource *res; in release_mem_region_adjustable() local
1255 while ((res = *p)) { in release_mem_region_adjustable()
1256 if (res->start >= end) in release_mem_region_adjustable()
1260 if (res->start > start || res->end < end) { in release_mem_region_adjustable()
1261 p = &res->sibling; in release_mem_region_adjustable()
1265 if (!(res->flags & IORESOURCE_MEM)) in release_mem_region_adjustable()
1268 if (!(res->flags & IORESOURCE_BUSY)) { in release_mem_region_adjustable()
1269 p = &res->child; in release_mem_region_adjustable()
1274 if (res->start == start && res->end == end) { in release_mem_region_adjustable()
1276 *p = res->sibling; in release_mem_region_adjustable()
1277 free_resource(res); in release_mem_region_adjustable()
1279 } else if (res->start == start && res->end != end) { in release_mem_region_adjustable()
1281 ret = __adjust_resource(res, end + 1, in release_mem_region_adjustable()
1282 res->end - end); in release_mem_region_adjustable()
1283 } else if (res->start != start && res->end == end) { in release_mem_region_adjustable()
1285 ret = __adjust_resource(res, res->start, in release_mem_region_adjustable()
1286 start - res->start); in release_mem_region_adjustable()
1293 new_res->name = res->name; in release_mem_region_adjustable()
1295 new_res->end = res->end; in release_mem_region_adjustable()
1296 new_res->flags = res->flags; in release_mem_region_adjustable()
1297 new_res->desc = res->desc; in release_mem_region_adjustable()
1298 new_res->parent = res->parent; in release_mem_region_adjustable()
1299 new_res->sibling = res->sibling; in release_mem_region_adjustable()
1302 ret = __adjust_resource(res, res->start, in release_mem_region_adjustable()
1303 start - res->start); in release_mem_region_adjustable()
1306 res->sibling = new_res; in release_mem_region_adjustable()
1371 static int devm_resource_match(struct device *dev, void *res, void *data) in devm_resource_match() argument
1373 struct resource **ptr = res; in devm_resource_match()
1398 static void devm_region_release(struct device *dev, void *res) in devm_region_release() argument
1400 struct region_devres *this = res; in devm_region_release()
1405 static int devm_region_match(struct device *dev, void *res, void *match_data) in devm_region_match() argument
1407 struct region_devres *this = res, *match = match_data; in devm_region_match()
1418 struct resource *res; in __devm_request_region() local
1429 res = __request_region(parent, start, n, name, 0); in __devm_request_region()
1430 if (res) in __devm_request_region()
1435 return res; in __devm_request_region()
1469 struct resource *res = reserve + x; in reserve_setup() local
1476 res->flags = IORESOURCE_IO; in reserve_setup()
1479 res->flags = IORESOURCE_MEM; in reserve_setup()
1482 res->name = "reserved"; in reserve_setup()
1483 res->start = io_start; in reserve_setup()
1484 res->end = io_start + io_num - 1; in reserve_setup()
1485 res->flags |= IORESOURCE_BUSY; in reserve_setup()
1486 res->desc = IORES_DESC_NONE; in reserve_setup()
1487 res->child = NULL; in reserve_setup()
1488 if (request_resource(parent, res) == 0) in reserve_setup()
1590 struct resource_entry *resource_list_create_entry(struct resource *res, in resource_list_create_entry() argument
1598 entry->res = res ? res : &entry->__res; in resource_list_create_entry()