]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
xen/notifier: simplify using notifier_[to|from]_errno()
authorJuergen Gross <jgross@suse.com>
Fri, 2 Dec 2022 09:30:58 +0000 (10:30 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 2 Dec 2022 09:30:58 +0000 (10:30 +0100)
Today all users of notifier_from_errno() and notifier_to_errno() are
Handling the success case the same way, by using

  !rc ? NOTIFY_DONE : notifier_from_errno(rc)

or

  (notifier_rc == NOTIFY_DONE) ? 0 : notifier_to_errno(notifier_rc);

Simplify the use cases by moving the handling of the success case into
the functions.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Dario Faggioli <dfaggioli@suse.com> # xen/common/sched/
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <jgrall@amazon.com>
18 files changed:
xen/arch/arm/cpuerrata.c
xen/arch/arm/gic-v3-lpi.c
xen/arch/arm/irq.c
xen/arch/arm/percpu.c
xen/arch/arm/smpboot.c
xen/arch/x86/acpi/cpu_idle.c
xen/arch/x86/cpu/mcheck/mce.c
xen/arch/x86/cpu/mcheck/mce_intel.c
xen/arch/x86/cpu/mwait-idle.c
xen/arch/x86/genapic/x2apic.c
xen/arch/x86/hvm/hvm.c
xen/arch/x86/percpu.c
xen/arch/x86/psr.c
xen/arch/x86/smpboot.c
xen/common/cpu.c
xen/common/sched/core.c
xen/common/sched/cpupool.c
xen/include/xen/notifier.h

index ae649d16ef022af5774f1aaaa9e43e376e7edb88..5952111b7242191743b6b636f0bc007d03d04357 100644 (file)
@@ -724,7 +724,7 @@ static int cpu_errata_callback(struct notifier_block *nfb,
         break;
     }
 
-    return !rc ? NOTIFY_DONE : notifier_from_errno(rc);
+    return notifier_from_errno(rc);
 }
 
 static struct notifier_block cpu_errata_nfb = {
index 61d90eb386e14c55997af5190168c047d83872e2..f0b7ef17da8b59ccb32b77048091f7ca87fe0847 100644 (file)
@@ -402,7 +402,7 @@ static int cpu_callback(struct notifier_block *nfb, unsigned long action,
         break;
     }
 
-    return !rc ? NOTIFY_DONE : notifier_from_errno(rc);
+    return notifier_from_errno(rc);
 }
 
 static struct notifier_block cpu_nfb = {
index fd0c15fffd9300c4c1c8bf4f8cba8ff98a11af42..00fadbc35469d92a71cab6b1a76bfc752e39dbf0 100644 (file)
@@ -148,7 +148,7 @@ static int cpu_callback(struct notifier_block *nfb, unsigned long action,
         break;
     }
 
-    return !rc ? NOTIFY_DONE : notifier_from_errno(rc);
+    return notifier_from_errno(rc);
 }
 
 static struct notifier_block cpu_nfb = {
index 25442c48fe90dc93446e4671cd8439de51e68446..67eb821ff670e06188a813c9e6cd70d4747d1f4c 100644 (file)
@@ -68,7 +68,7 @@ static int cpu_percpu_callback(
         break;
     }
 
-    return !rc ? NOTIFY_DONE : notifier_from_errno(rc);
+    return notifier_from_errno(rc);
 }
 
 static struct notifier_block cpu_percpu_nfb = {
index f7bda3a18b48a9886d5569a9fb5952e356a9fa4b..bfa988c162da9cc35cb315073ca8b499704e9716 100644 (file)
@@ -562,7 +562,7 @@ static int cpu_smpboot_callback(struct notifier_block *nfb,
         break;
     }
 
-    return !rc ? NOTIFY_DONE : notifier_from_errno(rc);
+    return notifier_from_errno(rc);
 }
 
 static struct notifier_block cpu_smpboot_nfb = {
index 557bc6ef8642fc4cf9e65d0807f72b3336925f75..427c8c89c5c438d610de3470f0daf1840c7cb0ee 100644 (file)
@@ -1663,7 +1663,7 @@ static int cf_check cpu_callback(
         break;
     }
 
-    return !rc ? NOTIFY_DONE : notifier_from_errno(rc);
+    return notifier_from_errno(rc);
 }
 
 static struct notifier_block cpu_nfb = {
index f68e31b6439872afd9c5e6fc0f86fe41fb652624..3e93bdd8dab4f9b22e20c753565c18785e022f08 100644 (file)
@@ -757,7 +757,7 @@ static int cf_check cpu_callback(
         break;
     }
 
-    return !rc ? NOTIFY_DONE : notifier_from_errno(rc);
+    return notifier_from_errno(rc);
 }
 
 static struct notifier_block cpu_nfb = {
index 28a605a5cbc7775c33eeb6bd765bf4ca331eb481..301533722d1ae3973c99319cd7d85c3face8870a 100644 (file)
@@ -951,7 +951,7 @@ static int cf_check cpu_callback(
         break;
     }
 
-    return !rc ? NOTIFY_DONE : notifier_from_errno(rc);
+    return notifier_from_errno(rc);
 }
 
 static struct notifier_block cpu_nfb = {
index ffdc6fb2fc0e731072647cafb0803c6c9070e915..9e981e7e26dceff1a75c76b073a59a3fc0dcc800 100644 (file)
@@ -1537,7 +1537,7 @@ static int cf_check mwait_idle_cpu_init(
                dev = processor_powers[cpu];
                if (!rc && cpuidle_current_governor->enable)
                        rc = cpuidle_current_governor->enable(dev);
-               return !rc ? NOTIFY_DONE : notifier_from_errno(rc);
+               return notifier_from_errno(rc);
 
        case CPU_ONLINE:
                if (!dev)
index 7dfc793514b22ed45e6100109242581a23ac78b7..f73390cdb017caae149d2e1057723958a66ee7ae 100644 (file)
@@ -221,7 +221,7 @@ static int cf_check update_clusterinfo(
         break;
     }
 
-    return !err ? NOTIFY_DONE : notifier_from_errno(err);
+    return notifier_from_errno(err);
 }
 
 static struct notifier_block x2apic_cpu_nfb = {
index ae4368ec4b338cf8c6cb14d383f612c91c98e800..02f5f3b35990f1dd577926c5e420303d087fc585 100644 (file)
@@ -139,7 +139,7 @@ static int cf_check cpu_callback(
         break;
     }
 
-    return !rc ? NOTIFY_DONE : notifier_from_errno(rc);
+    return notifier_from_errno(rc);
 }
 
 static struct notifier_block cpu_nfb = {
index 46460689b73d4e70595eae98c03e1de87b810017..288050cdbaa70ec797165d3e0ff266d5371f4d9a 100644 (file)
@@ -86,7 +86,7 @@ static int cf_check cpu_percpu_callback(
         break;
     }
 
-    return !rc ? NOTIFY_DONE : notifier_from_errno(rc);
+    return notifier_from_errno(rc);
 }
 
 static struct notifier_block cpu_percpu_nfb = {
index ccb761998f9aba289ef24f3ae8fc5b53e2084bde..a1e0af27c5f6eb72fbe7ebf384c25f09553c725e 100644 (file)
@@ -1663,7 +1663,7 @@ static int cf_check cpu_callback(
         break;
     }
 
-    return !rc ? NOTIFY_DONE : notifier_from_errno(rc);
+    return notifier_from_errno(rc);
 }
 
 static struct notifier_block cpu_nfb = {
index b46fd9ab18e426863ce958e20a77e1e47caecb76..a238aa1f14926ac7ab9efd84675c39406a69b154 100644 (file)
@@ -1144,7 +1144,7 @@ static int cf_check cpu_smpboot_callback(
         break;
     }
 
-    return !rc ? NOTIFY_DONE : notifier_from_errno(rc);
+    return notifier_from_errno(rc);
 }
 
 static struct notifier_block cpu_smpboot_nfb = {
index 778b6820b7546eea4bbd07c29a18dc16909a4d61..8709db4d29575ebc88a37ed0d441054573d21627 100644 (file)
@@ -82,7 +82,7 @@ static int cpu_notifier_call_chain(unsigned int cpu, unsigned long action,
 {
     void *hcpu = (void *)(long)cpu;
     int notifier_rc = notifier_call_chain(&cpu_chain, action, hcpu, nb);
-    int ret = (notifier_rc == NOTIFY_DONE) ? 0 : notifier_to_errno(notifier_rc);
+    int ret =  notifier_to_errno(notifier_rc);
 
     BUG_ON(ret && nofail);
 
index 43132ff6e030f97157351c7363b9681dce0010f3..022f548652e80ddac5e42c62d3a90b8e53e1395a 100644 (file)
@@ -2903,7 +2903,7 @@ static int cf_check cpu_schedule_callback(
 
     rcu_read_unlock(&sched_res_rculock);
 
-    return !rc ? NOTIFY_DONE : notifier_from_errno(rc);
+    return notifier_from_errno(rc);
 }
 
 static struct notifier_block cpu_schedule_nfb = {
index bdf6030ab083d2e9d21db0ea4f6e1acca1ccd42b..2e094b0cfa46a5f8d862e0febcef79e37c54e343 100644 (file)
@@ -1074,7 +1074,7 @@ static int cf_check cpu_callback(
         break;
     }
 
-    return !rc ? NOTIFY_DONE : notifier_from_errno(rc);
+    return notifier_from_errno(rc);
 }
 
 static struct notifier_block cpu_nfb = {
index 0921213298be5972c647cc3624a873848e85e8f9..3d6017d4f72f5f6e8c775f47486b44172242dcb8 100644 (file)
@@ -58,13 +58,13 @@ int notifier_call_chain(
 /* Encapsulate (negative) errno value. */
 static inline int notifier_from_errno(int err)
 {
-    return NOTIFY_STOP_MASK | -err;
+    return err ? (NOTIFY_STOP_MASK | -err) : NOTIFY_DONE;
 }
 
 /* Restore (negative) errno value from notify return value. */
 static inline int notifier_to_errno(int ret)
 {
-    return -(ret & ~NOTIFY_STOP_MASK);
+    return (ret == NOTIFY_DONE) ? 0 : -(ret & ~NOTIFY_STOP_MASK);
 }
 
 #endif /* __XEN_NOTIFIER_H__ */