mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-02 20:44:00 +00: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
1 changed files with 26 additions and 29 deletions
|
@ -328,25 +328,23 @@ EXPORT_SYMBOL(release_resource);
|
||||||
* -1.
|
* -1.
|
||||||
*
|
*
|
||||||
* This function walks the whole tree and not just first level children
|
* 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,
|
static int find_next_iomem_res(resource_size_t start, resource_size_t end,
|
||||||
unsigned long flags, unsigned long desc,
|
unsigned long flags, unsigned long desc,
|
||||||
bool first_level_children_only,
|
bool first_lvl, struct resource *res)
|
||||||
struct resource *res)
|
|
||||||
{
|
{
|
||||||
struct resource *p;
|
struct resource *p;
|
||||||
bool sibling_only = false;
|
|
||||||
|
|
||||||
BUG_ON(!res);
|
if (!res)
|
||||||
BUG_ON(start >= end);
|
return -EINVAL;
|
||||||
|
|
||||||
if (first_level_children_only)
|
if (start >= end)
|
||||||
sibling_only = true;
|
return -EINVAL;
|
||||||
|
|
||||||
read_lock(&resource_lock);
|
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)
|
if ((p->flags & flags) != flags)
|
||||||
continue;
|
continue;
|
||||||
if ((desc != IORES_DESC_NONE) && (desc != p->desc))
|
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,
|
static int __walk_iomem_res_desc(resource_size_t start, resource_size_t end,
|
||||||
unsigned long flags, unsigned long desc,
|
unsigned long flags, unsigned long desc,
|
||||||
bool first_level_children_only, void *arg,
|
bool first_lvl, void *arg,
|
||||||
int (*func)(struct resource *, void *))
|
int (*func)(struct resource *, void *))
|
||||||
{
|
{
|
||||||
struct resource res;
|
struct resource res;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
while (start < end &&
|
while (start < end &&
|
||||||
!find_next_iomem_res(start, end, flags, desc,
|
!find_next_iomem_res(start, end, flags, desc, first_lvl, &res)) {
|
||||||
first_level_children_only, &res)) {
|
|
||||||
ret = (*func)(&res, arg);
|
ret = (*func)(&res, arg);
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
break;
|
||||||
|
@ -392,7 +389,7 @@ static int __walk_iomem_res_desc(resource_size_t start, resource_size_t end,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Walks through iomem resources and calls func() with matching resource
|
* Walks through iomem resources and calls func() with matching resource
|
||||||
* ranges. This walks through whole tree and not just first level children.
|
* 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
|
* 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.
|
* ranges.
|
||||||
*/
|
*/
|
||||||
int walk_system_ram_res(u64 start, u64 end, void *arg,
|
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;
|
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.
|
* It is to be used only for System RAM.
|
||||||
*/
|
*/
|
||||||
int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages,
|
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;
|
resource_size_t start, end;
|
||||||
unsigned long flags;
|
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.
|
* @constraint: the size and alignment constraints to be met.
|
||||||
*/
|
*/
|
||||||
static int reallocate_resource(struct resource *root, struct resource *old,
|
static int reallocate_resource(struct resource *root, struct resource *old,
|
||||||
resource_size_t newsize,
|
resource_size_t newsize,
|
||||||
struct resource_constraint *constraint)
|
struct resource_constraint *constraint)
|
||||||
{
|
{
|
||||||
int err=0;
|
int err=0;
|
||||||
struct resource new = *old;
|
struct resource new = *old;
|
||||||
|
@ -960,7 +957,7 @@ skip:
|
||||||
* Existing children of the resource are assumed to be immutable.
|
* Existing children of the resource are assumed to be immutable.
|
||||||
*/
|
*/
|
||||||
int adjust_resource(struct resource *res, resource_size_t start,
|
int adjust_resource(struct resource *res, resource_size_t start,
|
||||||
resource_size_t size)
|
resource_size_t size)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
@ -971,9 +968,9 @@ int adjust_resource(struct resource *res, resource_size_t start,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(adjust_resource);
|
EXPORT_SYMBOL(adjust_resource);
|
||||||
|
|
||||||
static void __init __reserve_region_with_split(struct resource *root,
|
static void __init
|
||||||
resource_size_t start, resource_size_t end,
|
__reserve_region_with_split(struct resource *root, resource_size_t start,
|
||||||
const char *name)
|
resource_size_t end, const char *name)
|
||||||
{
|
{
|
||||||
struct resource *parent = root;
|
struct resource *parent = root;
|
||||||
struct resource *conflict;
|
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,
|
void __init
|
||||||
resource_size_t start, resource_size_t end,
|
reserve_region_with_split(struct resource *root, resource_size_t start,
|
||||||
const char *name)
|
resource_size_t end, const char *name)
|
||||||
{
|
{
|
||||||
int abort = 0;
|
int abort = 0;
|
||||||
|
|
||||||
|
@ -1160,7 +1157,7 @@ EXPORT_SYMBOL(__request_region);
|
||||||
* The described resource region must match a currently busy region.
|
* The described resource region must match a currently busy region.
|
||||||
*/
|
*/
|
||||||
void __release_region(struct resource *parent, resource_size_t start,
|
void __release_region(struct resource *parent, resource_size_t start,
|
||||||
resource_size_t n)
|
resource_size_t n)
|
||||||
{
|
{
|
||||||
struct resource **p;
|
struct resource **p;
|
||||||
resource_size_t end;
|
resource_size_t end;
|
||||||
|
@ -1222,7 +1219,7 @@ EXPORT_SYMBOL(__release_region);
|
||||||
* simplicity. Enhance this logic when necessary.
|
* simplicity. Enhance this logic when necessary.
|
||||||
*/
|
*/
|
||||||
int release_mem_region_adjustable(struct resource *parent,
|
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 **p;
|
||||||
struct resource *res;
|
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;
|
this->start == match->start && this->n == match->n;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct resource * __devm_request_region(struct device *dev,
|
struct resource *
|
||||||
struct resource *parent, resource_size_t start,
|
__devm_request_region(struct device *dev, struct resource *parent,
|
||||||
resource_size_t n, const char *name)
|
resource_size_t start, resource_size_t n, const char *name)
|
||||||
{
|
{
|
||||||
struct region_devres *dr = NULL;
|
struct region_devres *dr = NULL;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
|
|
Loading…
Add table
Reference in a new issue