[v2,1/2] resource: Replace printk(KERN_WARNING) by pr_warn(), printk() by pr_info()

Message ID 20221109155618.42276-1-andriy.shevchenko@linux.intel.com
State New
Headers
Series [v2,1/2] resource: Replace printk(KERN_WARNING) by pr_warn(), printk() by pr_info() |

Commit Message

Andy Shevchenko Nov. 9, 2022, 3:56 p.m. UTC
  Replace printk(KERN_WARNING) by pr_warn() and printk() by pr_info().

While at it, use %pa for the resource_size_t variables. With that,
for the sake of consistency, introduce a temporary variable for
the end address in iomem_map_sanity_check() like it's done in another
function in the same module.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
v2: updated changelog (Rafael), Cc'ed to Greg (Rafael)
 kernel/resource.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
  

Comments

Rafael J. Wysocki Nov. 9, 2022, 4:01 p.m. UTC | #1
On Wed, Nov 9, 2022 at 4:56 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> Replace printk(KERN_WARNING) by pr_warn() and printk() by pr_info().
>
> While at it, use %pa for the resource_size_t variables. With that,
> for the sake of consistency, introduce a temporary variable for
> the end address in iomem_map_sanity_check() like it's done in another
> function in the same module.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Rafael J. Wysocki <rafael@kernel.org>

> ---
> v2: updated changelog (Rafael), Cc'ed to Greg (Rafael)
>  kernel/resource.c | 17 +++++++----------
>  1 file changed, 7 insertions(+), 10 deletions(-)
>
> diff --git a/kernel/resource.c b/kernel/resource.c
> index 4c5e80b92f2f..ab32b015bd50 100644
> --- a/kernel/resource.c
> +++ b/kernel/resource.c
> @@ -888,7 +888,7 @@ void insert_resource_expand_to_fit(struct resource *root, struct resource *new)
>                 if (conflict->end > new->end)
>                         new->end = conflict->end;
>
> -               printk("Expanded resource %s due to conflict with %s\n", new->name, conflict->name);
> +               pr_info("Expanded resource %s due to conflict with %s\n", new->name, conflict->name);
>         }
>         write_unlock(&resource_lock);
>  }
> @@ -1283,9 +1283,7 @@ void __release_region(struct resource *parent, resource_size_t start,
>
>         write_unlock(&resource_lock);
>
> -       printk(KERN_WARNING "Trying to free nonexistent resource "
> -               "<%016llx-%016llx>\n", (unsigned long long)start,
> -               (unsigned long long)end);
> +       pr_warn("Trying to free nonexistent resource <%pa-%pa>\n", &start, &end);
>  }
>  EXPORT_SYMBOL(__release_region);
>
> @@ -1658,6 +1656,7 @@ __setup("reserve=", reserve_setup);
>  int iomem_map_sanity_check(resource_size_t addr, unsigned long size)
>  {
>         struct resource *p = &iomem_resource;
> +       resource_size_t end = addr + size - 1;
>         int err = 0;
>         loff_t l;
>
> @@ -1667,12 +1666,12 @@ int iomem_map_sanity_check(resource_size_t addr, unsigned long size)
>                  * We can probably skip the resources without
>                  * IORESOURCE_IO attribute?
>                  */
> -               if (p->start >= addr + size)
> +               if (p->start > end)
>                         continue;
>                 if (p->end < addr)
>                         continue;
>                 if (PFN_DOWN(p->start) <= PFN_DOWN(addr) &&
> -                   PFN_DOWN(p->end) >= PFN_DOWN(addr + size - 1))
> +                   PFN_DOWN(p->end) >= PFN_DOWN(end))
>                         continue;
>                 /*
>                  * if a resource is "BUSY", it's not a hardware resource
> @@ -1683,10 +1682,8 @@ int iomem_map_sanity_check(resource_size_t addr, unsigned long size)
>                 if (p->flags & IORESOURCE_BUSY)
>                         continue;
>
> -               printk(KERN_WARNING "resource sanity check: requesting [mem %#010llx-%#010llx], which spans more than %s %pR\n",
> -                      (unsigned long long)addr,
> -                      (unsigned long long)(addr + size - 1),
> -                      p->name, p);
> +               pr_warn("resource sanity check: requesting [mem %pa-%pa], which spans more than %s %pR\n",
> +                       &addr, &end, p->name, p);
>                 err = -1;
>                 break;
>         }
> --
> 2.35.1
>
  

Patch

diff --git a/kernel/resource.c b/kernel/resource.c
index 4c5e80b92f2f..ab32b015bd50 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -888,7 +888,7 @@  void insert_resource_expand_to_fit(struct resource *root, struct resource *new)
 		if (conflict->end > new->end)
 			new->end = conflict->end;
 
-		printk("Expanded resource %s due to conflict with %s\n", new->name, conflict->name);
+		pr_info("Expanded resource %s due to conflict with %s\n", new->name, conflict->name);
 	}
 	write_unlock(&resource_lock);
 }
@@ -1283,9 +1283,7 @@  void __release_region(struct resource *parent, resource_size_t start,
 
 	write_unlock(&resource_lock);
 
-	printk(KERN_WARNING "Trying to free nonexistent resource "
-		"<%016llx-%016llx>\n", (unsigned long long)start,
-		(unsigned long long)end);
+	pr_warn("Trying to free nonexistent resource <%pa-%pa>\n", &start, &end);
 }
 EXPORT_SYMBOL(__release_region);
 
@@ -1658,6 +1656,7 @@  __setup("reserve=", reserve_setup);
 int iomem_map_sanity_check(resource_size_t addr, unsigned long size)
 {
 	struct resource *p = &iomem_resource;
+	resource_size_t end = addr + size - 1;
 	int err = 0;
 	loff_t l;
 
@@ -1667,12 +1666,12 @@  int iomem_map_sanity_check(resource_size_t addr, unsigned long size)
 		 * We can probably skip the resources without
 		 * IORESOURCE_IO attribute?
 		 */
-		if (p->start >= addr + size)
+		if (p->start > end)
 			continue;
 		if (p->end < addr)
 			continue;
 		if (PFN_DOWN(p->start) <= PFN_DOWN(addr) &&
-		    PFN_DOWN(p->end) >= PFN_DOWN(addr + size - 1))
+		    PFN_DOWN(p->end) >= PFN_DOWN(end))
 			continue;
 		/*
 		 * if a resource is "BUSY", it's not a hardware resource
@@ -1683,10 +1682,8 @@  int iomem_map_sanity_check(resource_size_t addr, unsigned long size)
 		if (p->flags & IORESOURCE_BUSY)
 			continue;
 
-		printk(KERN_WARNING "resource sanity check: requesting [mem %#010llx-%#010llx], which spans more than %s %pR\n",
-		       (unsigned long long)addr,
-		       (unsigned long long)(addr + size - 1),
-		       p->name, p);
+		pr_warn("resource sanity check: requesting [mem %pa-%pa], which spans more than %s %pR\n",
+			&addr, &end, p->name, p);
 		err = -1;
 		break;
 	}