mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 03:00:54 +07:00
resource: Clean it up a bit
- Drop BUG_ON()s and do normal error handling instead, in find_next_iomem_res(). - Align function arguments on opening braces. - Get rid of local var sibling_only in find_next_iomem_res(). - Shorten unnecessarily long first_level_children_only arg name. Signed-off-by: Borislav Petkov <bp@suse.de> CC: Andrew Morton <akpm@linux-foundation.org> CC: Bjorn Helgaas <bhelgaas@google.com> CC: Brijesh Singh <brijesh.singh@amd.com> CC: Dan Williams <dan.j.williams@intel.com> CC: H. Peter Anvin <hpa@zytor.com> CC: Lianbo Jiang <lijiang@redhat.com> CC: Takashi Iwai <tiwai@suse.de> CC: Thomas Gleixner <tglx@linutronix.de> CC: Tom Lendacky <thomas.lendacky@amd.com> CC: Vivek Goyal <vgoyal@redhat.com> CC: Yaowei Bai <baiyaowei@cmss.chinamobile.com> CC: bhe@redhat.com CC: dan.j.williams@intel.com CC: dyoung@redhat.com CC: kexec@lists.infradead.org CC: mingo@redhat.com Link: <new submission>
This commit is contained in:
parent
010a93bf97
commit
b69c2e20f6
@ -328,25 +328,23 @@ EXPORT_SYMBOL(release_resource);
|
||||
* -1.
|
||||
*
|
||||
* This function walks the whole tree and not just first level children
|
||||
* unless @first_level_children_only is true.
|
||||
* unless @first_lvl is true.
|
||||
*/
|
||||
static int find_next_iomem_res(resource_size_t start, resource_size_t end,
|
||||
unsigned long flags, unsigned long desc,
|
||||
bool first_level_children_only,
|
||||
struct resource *res)
|
||||
bool first_lvl, struct resource *res)
|
||||
{
|
||||
struct resource *p;
|
||||
bool sibling_only = false;
|
||||
|
||||
BUG_ON(!res);
|
||||
BUG_ON(start >= end);
|
||||
if (!res)
|
||||
return -EINVAL;
|
||||
|
||||
if (first_level_children_only)
|
||||
sibling_only = true;
|
||||
if (start >= end)
|
||||
return -EINVAL;
|
||||
|
||||
read_lock(&resource_lock);
|
||||
|
||||
for (p = iomem_resource.child; p; p = next_resource(p, sibling_only)) {
|
||||
for (p = iomem_resource.child; p; p = next_resource(p, first_lvl)) {
|
||||
if ((p->flags & flags) != flags)
|
||||
continue;
|
||||
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,
|
||||
|
||||
static int __walk_iomem_res_desc(resource_size_t start, resource_size_t end,
|
||||
unsigned long flags, unsigned long desc,
|
||||
bool first_level_children_only, void *arg,
|
||||
bool first_lvl, void *arg,
|
||||
int (*func)(struct resource *, void *))
|
||||
{
|
||||
struct resource res;
|
||||
int ret = -1;
|
||||
|
||||
while (start < end &&
|
||||
!find_next_iomem_res(start, end, flags, desc,
|
||||
first_level_children_only, &res)) {
|
||||
!find_next_iomem_res(start, end, flags, desc, first_lvl, &res)) {
|
||||
ret = (*func)(&res, arg);
|
||||
if (ret)
|
||||
break;
|
||||
@ -392,7 +389,7 @@ static int __walk_iomem_res_desc(resource_size_t start, resource_size_t end,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Walks through iomem resources and calls func() with matching resource
|
||||
* ranges. This walks through whole tree and not just first level children.
|
||||
* All the memory ranges which overlap start,end and also match flags and
|
||||
@ -421,7 +418,7 @@ EXPORT_SYMBOL_GPL(walk_iomem_res_desc);
|
||||
* ranges.
|
||||
*/
|
||||
int walk_system_ram_res(u64 start, u64 end, void *arg,
|
||||
int (*func)(struct resource *, void *))
|
||||
int (*func)(struct resource *, void *))
|
||||
{
|
||||
unsigned long flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
|
||||
|
||||
@ -450,7 +447,7 @@ int walk_mem_res(u64 start, u64 end, void *arg,
|
||||
* It is to be used only for System RAM.
|
||||
*/
|
||||
int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages,
|
||||
void *arg, int (*func)(unsigned long, unsigned long, void *))
|
||||
void *arg, int (*func)(unsigned long, unsigned long, void *))
|
||||
{
|
||||
resource_size_t start, end;
|
||||
unsigned long flags;
|
||||
@ -646,8 +643,8 @@ static int find_resource(struct resource *root, struct resource *new,
|
||||
* @constraint: the size and alignment constraints to be met.
|
||||
*/
|
||||
static int reallocate_resource(struct resource *root, struct resource *old,
|
||||
resource_size_t newsize,
|
||||
struct resource_constraint *constraint)
|
||||
resource_size_t newsize,
|
||||
struct resource_constraint *constraint)
|
||||
{
|
||||
int err=0;
|
||||
struct resource new = *old;
|
||||
@ -960,7 +957,7 @@ static int __adjust_resource(struct resource *res, resource_size_t start,
|
||||
* Existing children of the resource are assumed to be immutable.
|
||||
*/
|
||||
int adjust_resource(struct resource *res, resource_size_t start,
|
||||
resource_size_t size)
|
||||
resource_size_t size)
|
||||
{
|
||||
int result;
|
||||
|
||||
@ -971,9 +968,9 @@ int adjust_resource(struct resource *res, resource_size_t start,
|
||||
}
|
||||
EXPORT_SYMBOL(adjust_resource);
|
||||
|
||||
static void __init __reserve_region_with_split(struct resource *root,
|
||||
resource_size_t start, resource_size_t end,
|
||||
const char *name)
|
||||
static void __init
|
||||
__reserve_region_with_split(struct resource *root, resource_size_t start,
|
||||
resource_size_t end, const char *name)
|
||||
{
|
||||
struct resource *parent = root;
|
||||
struct resource *conflict;
|
||||
@ -1032,9 +1029,9 @@ static void __init __reserve_region_with_split(struct resource *root,
|
||||
|
||||
}
|
||||
|
||||
void __init reserve_region_with_split(struct resource *root,
|
||||
resource_size_t start, resource_size_t end,
|
||||
const char *name)
|
||||
void __init
|
||||
reserve_region_with_split(struct resource *root, resource_size_t start,
|
||||
resource_size_t end, const char *name)
|
||||
{
|
||||
int abort = 0;
|
||||
|
||||
@ -1160,7 +1157,7 @@ EXPORT_SYMBOL(__request_region);
|
||||
* The described resource region must match a currently busy region.
|
||||
*/
|
||||
void __release_region(struct resource *parent, resource_size_t start,
|
||||
resource_size_t n)
|
||||
resource_size_t n)
|
||||
{
|
||||
struct resource **p;
|
||||
resource_size_t end;
|
||||
@ -1222,7 +1219,7 @@ EXPORT_SYMBOL(__release_region);
|
||||
* simplicity. Enhance this logic when necessary.
|
||||
*/
|
||||
int release_mem_region_adjustable(struct resource *parent,
|
||||
resource_size_t start, resource_size_t size)
|
||||
resource_size_t start, resource_size_t size)
|
||||
{
|
||||
struct resource **p;
|
||||
struct resource *res;
|
||||
@ -1398,9 +1395,9 @@ static int devm_region_match(struct device *dev, void *res, void *match_data)
|
||||
this->start == match->start && this->n == match->n;
|
||||
}
|
||||
|
||||
struct resource * __devm_request_region(struct device *dev,
|
||||
struct resource *parent, resource_size_t start,
|
||||
resource_size_t n, const char *name)
|
||||
struct resource *
|
||||
__devm_request_region(struct device *dev, struct resource *parent,
|
||||
resource_size_t start, resource_size_t n, const char *name)
|
||||
{
|
||||
struct region_devres *dr = NULL;
|
||||
struct resource *res;
|
||||
|
Loading…
Reference in New Issue
Block a user