xen/notifier: simplify using notifier_[to|from]_errno()

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>
This commit is contained in:
Juergen Gross authored and Jan Beulich committed 2022-12-02 10:30:58 +01:00
1 parent 0f1dec89d3
commit f0752bc3b8
18 files changed
+19 -19

No files matched your search

+1 -1
View 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 = {
+1 -1
View 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 = {
+1 -1
View 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 = {
+1 -1
View 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 = {
+1 -1
View 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 = {
+1 -1
View 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 = {
+1 -1
View 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 = {
+1 -1
View 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 = {
+1 -1
View 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)
+1 -1
View 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 = {
+1 -1
View 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 = {
+1 -1
View 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 = {
+1 -1
View 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 = {
+1 -1
View 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 = {
+1 -1
View 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);
+1 -1
View 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 = {
+1 -1
View 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 = {
+2 -2
View 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__ */
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.