Skip to content

Commit 8f68fa2

Browse files
akpm00torvalds
authored andcommitted
ipc/util.c: use register_hotmemory_notifier()
Squishes a statement-with-no-effect warning, removes some ifdefs and shrinks .text by one byte! Note that this code fails to check for blocking_notifier_chain_register() failures. Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent f02c696 commit 8f68fa2

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

‎ipc/util.c‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/msg.h>
2424
#include <linux/vmalloc.h>
2525
#include <linux/slab.h>
26+
#include <linux/notifier.h>
2627
#include <linux/capability.h>
2728
#include <linux/highuid.h>
2829
#include <linux/security.h>
@@ -47,19 +48,16 @@ struct ipc_proc_iface {
4748
int (*show)(struct seq_file *, void *);
4849
};
4950

50-
#ifdef CONFIG_MEMORY_HOTPLUG
51-
5251
static void ipc_memory_notifier(struct work_struct *work)
5352
{
5453
ipcns_notify(IPCNS_MEMCHANGED);
5554
}
5655

57-
static DECLARE_WORK(ipc_memory_wq, ipc_memory_notifier);
58-
59-
6056
static int ipc_memory_callback(struct notifier_block *self,
6157
unsigned long action, void *arg)
6258
{
59+
static DECLARE_WORK(ipc_memory_wq, ipc_memory_notifier);
60+
6361
switch (action) {
6462
case MEM_ONLINE: /* memory successfully brought online */
6563
case MEM_OFFLINE: /* or offline: it's time to recompute msgmni */
@@ -85,7 +83,10 @@ static int ipc_memory_callback(struct notifier_block *self,
8583
return NOTIFY_OK;
8684
}
8785

88-
#endif /* CONFIG_MEMORY_HOTPLUG */
86+
static struct notifier_block ipc_memory_nb = {
87+
.notifier_call = ipc_memory_callback,
88+
.priority = IPC_CALLBACK_PRI,
89+
};
8990

9091
/**
9192
* ipc_init - initialise IPC subsystem
@@ -102,7 +103,7 @@ static int __init ipc_init(void)
102103
sem_init();
103104
msg_init();
104105
shm_init();
105-
hotplug_memory_notifier(ipc_memory_callback, IPC_CALLBACK_PRI);
106+
register_hotmemory_notifier(&ipc_memory_nb);
106107
register_ipcns_notifier(&init_ipc_ns);
107108
return 0;
108109
}

0 commit comments

Comments
 (0)