Skip to contentSkip to conversation

x86/mm: use WARN_ONCE

PATCH In review Jason Wang 2 participants 2 messages Jul 26, 2021

Subsystems (2)
lore
Share & tools
lore

Jason Wang

author
#0 lore raw

PATCH 1/1 x86/mm: use WARN_ONCE

printk + WARN_ON_ONCE can be just WARN_ONCE.

---
 arch/x86/mm/ioremap.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/mm/ioremap.c +2 -3
index 60ade7dd71bd..3e57035ef9e3 100644
@@ -195,9 +195,8 @@ __ioremap_caller(resource_size_t phys_addr, unsigned long size,
 		return NULL;
 
 	if (!phys_addr_valid(phys_addr)) {
-		printk(KERN_WARNING "ioremap: invalid physical address %llx\n",
-		       (unsigned long long)phys_addr);
-		WARN_ON_ONCE(1);
+		WARN_ONCE(1, "ioremap: invalid physical address %llx\n",
+			  (unsigned long long)phys_addr);
 		return NULL;
 	}
 
Signature · 1 line
2.32.0
maintainer
#1 lore raw
Quoted 14 lines · Jason Wang

printk + WARN_ON_ONCE can be just WARN_ONCE.

---
 arch/x86/mm/ioremap.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
arch/x86/mm/ioremap.c +0 -0
index 60ade7dd71bd..3e57035ef9e3 100644
@@ -195,9 +195,8 @@ __ioremap_caller(resource_size_t phys_addr, unsigned long size,
 		return NULL;

arch/x86/mm/ioremap.c __ioremap_caller(resource_size_t phys_addr, unsigned long size, · line 202

Quoted 10 lines
arch/x86/mm/ioremap.c +2 -3
 
 	if (!phys_addr_valid(phys_addr)) {
-		printk(KERN_WARNING "ioremap: invalid physical address %llx\n",
-		       (unsigned long long)phys_addr);
-		WARN_ON_ONCE(1);
+		WARN_ONCE(1, "ioremap: invalid physical address %llx\n",
+			  (unsigned long long)phys_addr);
 		return NULL;
 	}
 

This isn't a no-op change. Before, it would KERN_WARNING once per event and dump a trace once. Now it will only print anything at all once.