Skip to contentSkip to conversation

notifiers: split notifier.h into subsystem headers

PATCH In review Amerigo Wang 4 participants 16 messages Jun 22, 2011 – Jun 23, 2011

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

cover notifiers: split notifier.h into subsystem headers

Now we define all kinds of notifiers in notifier.h, this is not necessary at all, since different subsystems use different notifiers, they are almost non-related with each other.

This can also save much build time. Suppose I add a new netdevice event, really I don't have to recompile all the source, just network related. Without this patch, all the source will be recompiled.

I move the notify events near to their subsystem notifier registers, so that they can be found more easily.

In case of conflicts, I hope Andrew Morton would take the whole patchset, rather than different subsystem maintainers take their own.

---
 drivers/mmc/core/core.c   |    3 ++
 include/linux/cpu.h       |   33 ++++++++++++++++++
 include/linux/netdevice.h |   36 ++++++++++++++++++--
 include/linux/notifier.h  |   82 +++-----------------------------------------
 include/linux/reboot.h    |    5 +++
 include/linux/suspend.h   |    8 ++++
 include/linux/vt.h        |    7 ++++
 kernel/notifier.c         |   31 -----------------
 kernel/sys.c              |   32 +++++++++++++++++-
 net/rds/page.c            |    1 +
 10 files changed, 127 insertions(+), 111 deletions(-)
#1 lore raw

PATCH 1/5 cpu: move cpu notifiers into cpu.h

It is not necessary to share the same notifier.h.

---
 include/linux/cpu.h      |   33 +++++++++++++++++++++++++++++++++
 include/linux/notifier.h |   34 ++--------------------------------
 net/rds/page.c           |    1 +
 3 files changed, 36 insertions(+), 32 deletions(-)
include/linux/cpu.h +33 -0
index 5f09323..b1a635a 100644
@@ -70,6 +70,39 @@ enum {
 	CPU_PRI_WORKQUEUE	= 5,
 };
 
+#define CPU_ONLINE		0x0002 /* CPU (unsigned)v is up */
+#define CPU_UP_PREPARE		0x0003 /* CPU (unsigned)v coming up */
+#define CPU_UP_CANCELED		0x0004 /* CPU (unsigned)v NOT coming up */
+#define CPU_DOWN_PREPARE	0x0005 /* CPU (unsigned)v going down */
+#define CPU_DOWN_FAILED		0x0006 /* CPU (unsigned)v NOT going down */
+#define CPU_DEAD		0x0007 /* CPU (unsigned)v dead */
+#define CPU_DYING		0x0008 /* CPU (unsigned)v not running any task,
+					* not handling interrupts, soon dead.
+					* Called on the dying cpu, interrupts
+					* are already disabled. Must not
+					* sleep, must not fail */
+#define CPU_POST_DEAD		0x0009 /* CPU (unsigned)v dead, cpu_hotplug
+					* lock is dropped */
+#define CPU_STARTING		0x000A /* CPU (unsigned)v soon running.
+					* Called on the new cpu, just before
+					* enabling interrupts. Must not sleep,
+					* must not fail */
+
+/* Used for CPU hotplug events occurring while tasks are frozen due to a suspend
+ * operation in progress
+ */
+#define CPU_TASKS_FROZEN	0x0010
+
+#define CPU_ONLINE_FROZEN	(CPU_ONLINE | CPU_TASKS_FROZEN)
+#define CPU_UP_PREPARE_FROZEN	(CPU_UP_PREPARE | CPU_TASKS_FROZEN)
+#define CPU_UP_CANCELED_FROZEN	(CPU_UP_CANCELED | CPU_TASKS_FROZEN)
+#define CPU_DOWN_PREPARE_FROZEN	(CPU_DOWN_PREPARE | CPU_TASKS_FROZEN)
+#define CPU_DOWN_FAILED_FROZEN	(CPU_DOWN_FAILED | CPU_TASKS_FROZEN)
+#define CPU_DEAD_FROZEN		(CPU_DEAD | CPU_TASKS_FROZEN)
+#define CPU_DYING_FROZEN	(CPU_DYING | CPU_TASKS_FROZEN)
+#define CPU_STARTING_FROZEN	(CPU_STARTING | CPU_TASKS_FROZEN)
+
+
 #ifdef CONFIG_SMP
 /* Need to know about CPUs going up/down? */
 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
include/linux/notifier.h +2 -32
index c0688b0..9eb25fc 100644
@@ -185,6 +185,8 @@ static inline int notifier_to_errno(int ret)
  *	VC switch chains (for loadable kernel svgalib VC switch helpers) etc...
  */
  
+/* CPU notfiers are defined in include/linux/cpu.h. */
+
 /* netdevice notifier chain. Please remember to update the rtnetlink
  * notification exclusion list in rtnetlink_event() when adding new
  * types.
@@ -220,38 +222,6 @@ static inline int notifier_to_errno(int ret)
 
 #define NETLINK_URELEASE	0x0001	/* Unicast netlink socket released */
 
-#define CPU_ONLINE		0x0002 /* CPU (unsigned)v is up */
-#define CPU_UP_PREPARE		0x0003 /* CPU (unsigned)v coming up */
-#define CPU_UP_CANCELED		0x0004 /* CPU (unsigned)v NOT coming up */
-#define CPU_DOWN_PREPARE	0x0005 /* CPU (unsigned)v going down */
-#define CPU_DOWN_FAILED		0x0006 /* CPU (unsigned)v NOT going down */
-#define CPU_DEAD		0x0007 /* CPU (unsigned)v dead */
-#define CPU_DYING		0x0008 /* CPU (unsigned)v not running any task,
-					* not handling interrupts, soon dead.
-					* Called on the dying cpu, interrupts
-					* are already disabled. Must not
-					* sleep, must not fail */
-#define CPU_POST_DEAD		0x0009 /* CPU (unsigned)v dead, cpu_hotplug
-					* lock is dropped */
-#define CPU_STARTING		0x000A /* CPU (unsigned)v soon running.
-					* Called on the new cpu, just before
-					* enabling interrupts. Must not sleep,
-					* must not fail */
-
-/* Used for CPU hotplug events occurring while tasks are frozen due to a suspend
- * operation in progress
- */
-#define CPU_TASKS_FROZEN	0x0010
-
-#define CPU_ONLINE_FROZEN	(CPU_ONLINE | CPU_TASKS_FROZEN)
-#define CPU_UP_PREPARE_FROZEN	(CPU_UP_PREPARE | CPU_TASKS_FROZEN)
-#define CPU_UP_CANCELED_FROZEN	(CPU_UP_CANCELED | CPU_TASKS_FROZEN)
-#define CPU_DOWN_PREPARE_FROZEN	(CPU_DOWN_PREPARE | CPU_TASKS_FROZEN)
-#define CPU_DOWN_FAILED_FROZEN	(CPU_DOWN_FAILED | CPU_TASKS_FROZEN)
-#define CPU_DEAD_FROZEN		(CPU_DEAD | CPU_TASKS_FROZEN)
-#define CPU_DYING_FROZEN	(CPU_DYING | CPU_TASKS_FROZEN)
-#define CPU_STARTING_FROZEN	(CPU_STARTING | CPU_TASKS_FROZEN)
-
 /* Hibernation and suspend events */
 #define PM_HIBERNATION_PREPARE	0x0001 /* Going to hibernate */
 #define PM_POST_HIBERNATION	0x0002 /* Hibernation finished */
net/rds/page.c +1 -0
index d8acdeb..b82d63e 100644
@@ -32,6 +32,7 @@
  */
 #include <linux/highmem.h>
 #include <linux/gfp.h>
+#include <linux/cpu.h>
 
 #include "rds.h"
 
Signature · 1 line
1.7.4.4
#2 lore raw

PATCH 2/5 net: move netdevice notifiers into netdevice.h

In reply to Amerigo Wang

It is not necessary to share the same notifier.h.

---
 include/linux/netdevice.h |   36 +++++++++++++++++++++++++++++++++---
 include/linux/notifier.h  |   28 +---------------------------
 2 files changed, 34 insertions(+), 30 deletions(-)
include/linux/netdevice.h +33 -3
index 54b8b4d..7c2026b 100644
@@ -1566,6 +1566,39 @@ struct packet_type {
 #include <linux/interrupt.h>
 #include <linux/notifier.h>
 
+/* netdevice notifier chain. Please remember to update the rtnetlink
+ * notification exclusion list in rtnetlink_event() when adding new
+ * types.
+ */
+#define NETDEV_UP	0x0001	/* For now you can't veto a device up/down */
+#define NETDEV_DOWN	0x0002
+#define NETDEV_REBOOT	0x0003	/* Tell a protocol stack a network interface
+				   detected a hardware crash and restarted
+				   - we can use this eg to kick tcp sessions
+				   once done */
+#define NETDEV_CHANGE	0x0004	/* Notify device state change */
+#define NETDEV_REGISTER 0x0005
+#define NETDEV_UNREGISTER	0x0006
+#define NETDEV_CHANGEMTU	0x0007
+#define NETDEV_CHANGEADDR	0x0008
+#define NETDEV_GOING_DOWN	0x0009
+#define NETDEV_CHANGENAME	0x000A
+#define NETDEV_FEAT_CHANGE	0x000B
+#define NETDEV_BONDING_FAILOVER 0x000C
+#define NETDEV_PRE_UP		0x000D
+#define NETDEV_PRE_TYPE_CHANGE	0x000E
+#define NETDEV_POST_TYPE_CHANGE	0x000F
+#define NETDEV_POST_INIT	0x0010
+#define NETDEV_UNREGISTER_BATCH 0x0011
+#define NETDEV_RELEASE		0x0012
+#define NETDEV_NOTIFY_PEERS	0x0013
+#define NETDEV_JOIN		0x0014
+
+extern int register_netdevice_notifier(struct notifier_block *nb);
+extern int unregister_netdevice_notifier(struct notifier_block *nb);
+extern int call_netdevice_notifiers(unsigned long val, struct net_device *dev);
+
+
 extern rwlock_t				dev_base_lock;		/* Device list lock */
 
 
@@ -1648,12 +1681,9 @@ static inline void unregister_netdevice(struct net_device *dev)
 extern int 		netdev_refcnt_read(const struct net_device *dev);
 extern void		free_netdev(struct net_device *dev);
 extern void		synchronize_net(void);
-extern int 		register_netdevice_notifier(struct notifier_block *nb);
-extern int		unregister_netdevice_notifier(struct notifier_block *nb);
 extern int		init_dummy_netdev(struct net_device *dev);
 extern void		netdev_resync_ops(struct net_device *dev);
 
-extern int call_netdevice_notifiers(unsigned long val, struct net_device *dev);
 extern struct net_device	*dev_get_by_index(struct net *net, int ifindex);
 extern struct net_device	*__dev_get_by_index(struct net *net, int ifindex);
 extern struct net_device	*dev_get_by_index_rcu(struct net *net, int ifindex);
include/linux/notifier.h +1 -27
index 9eb25fc..e8a858a 100644
@@ -187,33 +187,7 @@ static inline int notifier_to_errno(int ret)
  
 /* CPU notfiers are defined in include/linux/cpu.h. */
 
-/* netdevice notifier chain. Please remember to update the rtnetlink
- * notification exclusion list in rtnetlink_event() when adding new
- * types.
- */
-#define NETDEV_UP	0x0001	/* For now you can't veto a device up/down */
-#define NETDEV_DOWN	0x0002
-#define NETDEV_REBOOT	0x0003	/* Tell a protocol stack a network interface
-				   detected a hardware crash and restarted
-				   - we can use this eg to kick tcp sessions
-				   once done */
-#define NETDEV_CHANGE	0x0004	/* Notify device state change */
-#define NETDEV_REGISTER 0x0005
-#define NETDEV_UNREGISTER	0x0006
-#define NETDEV_CHANGEMTU	0x0007
-#define NETDEV_CHANGEADDR	0x0008
-#define NETDEV_GOING_DOWN	0x0009
-#define NETDEV_CHANGENAME	0x000A
-#define NETDEV_FEAT_CHANGE	0x000B
-#define NETDEV_BONDING_FAILOVER 0x000C
-#define NETDEV_PRE_UP		0x000D
-#define NETDEV_PRE_TYPE_CHANGE	0x000E
-#define NETDEV_POST_TYPE_CHANGE	0x000F
-#define NETDEV_POST_INIT	0x0010
-#define NETDEV_UNREGISTER_BATCH 0x0011
-#define NETDEV_RELEASE		0x0012
-#define NETDEV_NOTIFY_PEERS	0x0013
-#define NETDEV_JOIN		0x0014
+/* netdevice notifiers are defined in include/linux/netdevice.h */
 
 #define SYS_DOWN	0x0001	/* Notify of system down */
 #define SYS_RESTART	SYS_DOWN
Signature · 1 line
1.7.4.4
#3 lore raw

PATCH 3/5 sys: move reboot notifiers into reboot.h

In reply to Amerigo Wang

It is not necessary to share the same notifier.h. This patch already moves register_reboot_notifier() and unregister_reboot_notifier() from kernel/notifier.c to kernel/sys.c.

---
 include/linux/notifier.h |    5 +----
 include/linux/reboot.h   |    5 +++++
 kernel/notifier.c        |   31 -------------------------------
 kernel/sys.c             |   32 +++++++++++++++++++++++++++++++-
 4 files changed, 37 insertions(+), 36 deletions(-)
include/linux/notifier.h +1 -4
index e8a858a..145c436 100644
@@ -189,10 +189,7 @@ static inline int notifier_to_errno(int ret)
 
 /* netdevice notifiers are defined in include/linux/netdevice.h */
 
-#define SYS_DOWN	0x0001	/* Notify of system down */
-#define SYS_RESTART	SYS_DOWN
-#define SYS_HALT	0x0002	/* Notify of system halt */
-#define SYS_POWER_OFF	0x0003	/* Notify of system power off */
+/* reboot notifiers are defined in include/linux/reboot.h. */
 
 #define NETLINK_URELEASE	0x0001	/* Unicast netlink socket released */
 
include/linux/reboot.h +5 -0
index 3005d5a..e0879a7 100644
@@ -39,6 +39,11 @@
 
 #include <linux/notifier.h>
 
+#define SYS_DOWN	0x0001	/* Notify of system down */
+#define SYS_RESTART	SYS_DOWN
+#define SYS_HALT	0x0002	/* Notify of system halt */
+#define SYS_POWER_OFF	0x0003	/* Notify of system power off */
+
 extern int register_reboot_notifier(struct notifier_block *);
 extern int unregister_reboot_notifier(struct notifier_block *);
 
kernel/notifier.c +0 -31
index 2488ba7..8d7b435 100644
@@ -525,37 +525,6 @@ void srcu_init_notifier_head(struct srcu_notifier_head *nh)
 }
 EXPORT_SYMBOL_GPL(srcu_init_notifier_head);
 
-/**
- *	register_reboot_notifier - Register function to be called at reboot time
- *	@nb: Info about notifier function to be called
- *
- *	Registers a function with the list of functions
- *	to be called at reboot time.
- *
- *	Currently always returns zero, as blocking_notifier_chain_register()
- *	always returns zero.
- */
-int register_reboot_notifier(struct notifier_block *nb)
-{
-	return blocking_notifier_chain_register(&reboot_notifier_list, nb);
-}
-EXPORT_SYMBOL(register_reboot_notifier);
-
-/**
- *	unregister_reboot_notifier - Unregister previously registered reboot notifier
- *	@nb: Hook to be unregistered
- *
- *	Unregisters a previously registered reboot
- *	notifier function.
- *
- *	Returns zero on success, or %-ENOENT on failure.
- */
-int unregister_reboot_notifier(struct notifier_block *nb)
-{
-	return blocking_notifier_chain_unregister(&reboot_notifier_list, nb);
-}
-EXPORT_SYMBOL(unregister_reboot_notifier);
-
 static ATOMIC_NOTIFIER_HEAD(die_chain);
 
 int notrace __kprobes notify_die(enum die_val val, const char *str,
kernel/sys.c +31 -1
index e4128b2..a101ba3 100644
@@ -8,7 +8,6 @@
 #include <linux/mm.h>
 #include <linux/utsname.h>
 #include <linux/mman.h>
-#include <linux/notifier.h>
 #include <linux/reboot.h>
 #include <linux/prctl.h>
 #include <linux/highuid.h>
@@ -320,6 +319,37 @@ void kernel_restart_prepare(char *cmd)
 }
 
 /**
+ *	register_reboot_notifier - Register function to be called at reboot time
+ *	@nb: Info about notifier function to be called
+ *
+ *	Registers a function with the list of functions
+ *	to be called at reboot time.
+ *
+ *	Currently always returns zero, as blocking_notifier_chain_register()
+ *	always returns zero.
+ */
+int register_reboot_notifier(struct notifier_block *nb)
+{
+	return blocking_notifier_chain_register(&reboot_notifier_list, nb);
+}
+EXPORT_SYMBOL(register_reboot_notifier);
+
+/**
+ *	unregister_reboot_notifier - Unregister previously registered reboot notifier
+ *	@nb: Hook to be unregistered
+ *
+ *	Unregisters a previously registered reboot
+ *	notifier function.
+ *
+ *	Returns zero on success, or %-ENOENT on failure.
+ */
+int unregister_reboot_notifier(struct notifier_block *nb)
+{
+	return blocking_notifier_chain_unregister(&reboot_notifier_list, nb);
+}
+EXPORT_SYMBOL(unregister_reboot_notifier);
+
+/**
  *	kernel_restart - reboot the system
  *	@cmd: pointer to buffer containing command to execute for restart
  *		or %NULL
Signature · 1 line
1.7.4.4
#4 lore raw

PATCH 4/5 pm: move pm notifiers into suspend.h

In reply to Amerigo Wang

It is not necessary to share the same notifier.h.

---
 drivers/mmc/core/core.c  |    3 +++
 include/linux/notifier.h |   10 ++--------
 include/linux/suspend.h  |    8 ++++++++
 3 files changed, 13 insertions(+), 8 deletions(-)
drivers/mmc/core/core.c +3 -0
index 68091dd..2cd4ec5 100644
@@ -23,6 +23,9 @@
 #include <linux/log2.h>
 #include <linux/regulator/consumer.h>
 #include <linux/pm_runtime.h>
+#ifdef CONFIG_PM
+#include <linux/suspend.h>
+#endif
 
 #include <linux/mmc/card.h>
 #include <linux/mmc/host.h>
include/linux/notifier.h +2 -8
index 145c436..ae8f7d9 100644
@@ -191,15 +191,9 @@ static inline int notifier_to_errno(int ret)
 
 /* reboot notifiers are defined in include/linux/reboot.h. */
 
-#define NETLINK_URELEASE	0x0001	/* Unicast netlink socket released */
+/* Hibernation and suspend events are defined in include/linux/suspend.h. */
 
-/* Hibernation and suspend events */
-#define PM_HIBERNATION_PREPARE	0x0001 /* Going to hibernate */
-#define PM_POST_HIBERNATION	0x0002 /* Hibernation finished */
-#define PM_SUSPEND_PREPARE	0x0003 /* Going to suspend the system */
-#define PM_POST_SUSPEND		0x0004 /* Suspend finished */
-#define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
-#define PM_POST_RESTORE		0x0006 /* Restore failed */
+#define NETLINK_URELEASE	0x0001	/* Unicast netlink socket released */
 
 /* Console keyboard events.
  * Note: KBD_KEYCODE is always sent before KBD_UNBOUND_KEYCODE, KBD_UNICODE and
include/linux/suspend.h +8 -0
index 083ffea..95bc81c 100644
@@ -260,6 +260,14 @@ static inline int hibernate(void) { return -ENOSYS; }
 static inline bool system_entering_hibernation(void) { return false; }
 #endif /* CONFIG_HIBERNATION */
 
+/* Hibernation and suspend events */
+#define PM_HIBERNATION_PREPARE	0x0001 /* Going to hibernate */
+#define PM_POST_HIBERNATION	0x0002 /* Hibernation finished */
+#define PM_SUSPEND_PREPARE	0x0003 /* Going to suspend the system */
+#define PM_POST_SUSPEND		0x0004 /* Suspend finished */
+#define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
+#define PM_POST_RESTORE		0x0006 /* Restore failed */
+
 #ifdef CONFIG_PM_SLEEP
 void save_processor_state(void);
 void restore_processor_state(void);
Signature · 1 line
1.7.4.4
#5 lore raw

Re: [PATCH 4/5] pm: move pm notifiers into suspend.h

Quoted 15 lines · Amerigo Wang

It is not necessary to share the same notifier.h.

---
 drivers/mmc/core/core.c  |    3 +++
 include/linux/notifier.h |   10 ++--------
 include/linux/suspend.h  |    8 ++++++++
 3 files changed, 13 insertions(+), 8 deletions(-)
drivers/mmc/core/core.c +0 -0
index 68091dd..2cd4ec5 100644

drivers/mmc/core/core.c line 28

Quoted 6 lines
drivers/mmc/core/core.c +3 -0
@@ -23,6 +23,9 @@
 #include <linux/log2.h>
 #include <linux/regulator/consumer.h>
 #include <linux/pm_runtime.h>
+#ifdef CONFIG_PM
+#include <linux/suspend.h>
+#endif

I don't think the #ifdef in necessary. Any dependencies on CONFIG_PM (or CONFIG_SUSPEND etc.) should be taken care of inside of suspend.h. This file should be fixed if they aren't.

Quoted 34 lines
drivers/mmc/core/core.c +0 -0
 #include <linux/mmc/card.h>
 #include <linux/mmc/host.h>
include/linux/notifier.h +2 -8
index 145c436..ae8f7d9 100644
@@ -191,15 +191,9 @@ static inline int notifier_to_errno(int ret)
 
 /* reboot notifiers are defined in include/linux/reboot.h. */
 
-#define NETLINK_URELEASE	0x0001	/* Unicast netlink socket released */
+/* Hibernation and suspend events are defined in include/linux/suspend.h. */
 
-/* Hibernation and suspend events */
-#define PM_HIBERNATION_PREPARE	0x0001 /* Going to hibernate */
-#define PM_POST_HIBERNATION	0x0002 /* Hibernation finished */
-#define PM_SUSPEND_PREPARE	0x0003 /* Going to suspend the system */
-#define PM_POST_SUSPEND		0x0004 /* Suspend finished */
-#define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
-#define PM_POST_RESTORE		0x0006 /* Restore failed */
+#define NETLINK_URELEASE	0x0001	/* Unicast netlink socket released */
 
 /* Console keyboard events.
  * Note: KBD_KEYCODE is always sent before KBD_UNBOUND_KEYCODE, KBD_UNICODE and
include/linux/suspend.h +1 -0
index 083ffea..95bc81c 100644
@@ -260,6 +260,14 @@ static inline int hibernate(void) { return -ENOSYS; }
 static inline bool system_entering_hibernation(void) { return false; }
 #endif /* CONFIG_HIBERNATION */
 
+/* Hibernation and suspend events */

include/linux/suspend.h static inline int hibernate(void) { return -ENOSYS; } · line 273

Quoted 10 lines
include/linux/suspend.h +7 -0
+#define PM_HIBERNATION_PREPARE	0x0001 /* Going to hibernate */
+#define PM_POST_HIBERNATION	0x0002 /* Hibernation finished */
+#define PM_SUSPEND_PREPARE	0x0003 /* Going to suspend the system */
+#define PM_POST_SUSPEND		0x0004 /* Suspend finished */
+#define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
+#define PM_POST_RESTORE		0x0006 /* Restore failed */
+
 #ifdef CONFIG_PM_SLEEP
 void save_processor_state(void);
 void restore_processor_state(void);

Thanks,
Rafael

author
#6 lore raw

Re: [PATCH 4/5] pm: move pm notifiers into suspend.h

Quoted 7 lines · Rafael J. Wysocki
Quoted 3 lines

+#ifdef CONFIG_PM

Quoted 2 lines

+#include<linux/suspend.h>
+#endif

I don't think the #ifdef in necessary. Any dependencies on CONFIG_PM (or CONFIG_SUSPEND etc.) should be taken care of inside of suspend.h. This file should be fixed if they aren't.

Ok, please check the updated version below.

Thanks.

Author: Amerigo Wang <[email protected]>

pm: move pm notifiers into suspend.h

---

drivers/mmc/core/core.c +1 -0
index 68091dd..503dbc9 100644
@@ -23,6 +23,7 @@
 #include <linux/log2.h>
 #include <linux/regulator/consumer.h>
 #include <linux/pm_runtime.h>
+#include <linux/suspend.h>
 
 #include <linux/mmc/card.h>
 #include <linux/mmc/host.h>
include/linux/notifier.h +2 -8
index 145c436..ae8f7d9 100644
@@ -191,15 +191,9 @@ static inline int notifier_to_errno(int ret)
 
 /* reboot notifiers are defined in include/linux/reboot.h. */
 
-#define NETLINK_URELEASE	0x0001	/* Unicast netlink socket released */
+/* Hibernation and suspend events are defined in include/linux/suspend.h. */
 
-/* Hibernation and suspend events */
-#define PM_HIBERNATION_PREPARE	0x0001 /* Going to hibernate */
-#define PM_POST_HIBERNATION	0x0002 /* Hibernation finished */
-#define PM_SUSPEND_PREPARE	0x0003 /* Going to suspend the system */
-#define PM_POST_SUSPEND		0x0004 /* Suspend finished */
-#define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
-#define PM_POST_RESTORE		0x0006 /* Restore failed */
+#define NETLINK_URELEASE	0x0001	/* Unicast netlink socket released */
 
 /* Console keyboard events.
  * Note: KBD_KEYCODE is always sent before KBD_UNBOUND_KEYCODE, KBD_UNICODE and
include/linux/suspend.h +8 -0
index 083ffea..95bc81c 100644
@@ -260,6 +260,14 @@ static inline int hibernate(void) { return -ENOSYS; }
 static inline bool system_entering_hibernation(void) { return false; }
 #endif /* CONFIG_HIBERNATION */
 
+/* Hibernation and suspend events */
+#define PM_HIBERNATION_PREPARE	0x0001 /* Going to hibernate */
+#define PM_POST_HIBERNATION	0x0002 /* Hibernation finished */
+#define PM_SUSPEND_PREPARE	0x0003 /* Going to suspend the system */
+#define PM_POST_SUSPEND		0x0004 /* Suspend finished */
+#define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
+#define PM_POST_RESTORE		0x0006 /* Restore failed */
+
 #ifdef CONFIG_PM_SLEEP
 void save_processor_state(void);
 void restore_processor_state(void);
#7 lore raw

Re: [PATCH 4/5] pm: move pm notifiers into suspend.h

Quoted 10 lines · Cong Wang
Quoted 7 lines · Rafael J. Wysocki
Quoted 3 lines

+#ifdef CONFIG_PM

Quoted 2 lines

+#include<linux/suspend.h>
+#endif

I don't think the #ifdef in necessary. Any dependencies on CONFIG_PM (or CONFIG_SUSPEND etc.) should be taken care of inside of suspend.h. This file should be fixed if they aren't.

Ok, please check the updated version below.

That's fine by me. Please feel free to add my ACK to the patch.

Thanks,
Rafael

#8 lore raw

Re: [PATCH 4/5] pm: move pm notifiers into suspend.h

In reply to Cong Wang
Quoted 10 lines · Cong Wang
Quoted 7 lines · Rafael J. Wysocki
Quoted 3 lines

+#ifdef CONFIG_PM

Quoted 2 lines

+#include<linux/suspend.h>
+#endif

I don't think the #ifdef in necessary. Any dependencies on CONFIG_PM (or CONFIG_SUSPEND etc.) should be taken care of inside of suspend.h. This file should be fixed if they aren't.

Ok, please check the updated version below.

That's fine by me. Please feel free to add my ACK to the patch.

Thanks,
Rafael
_______________________________________________
linux-pm mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/linux-pm

#9 lore raw

Re: [PATCH 4/5] pm: move pm notifiers into suspend.h

In reply to Cong Wang
Quoted 11 lines · Cong Wang

??? 2011???06???23??? 03:49, Rafael J. Wysocki ??????:

Quoted 7 lines
Quoted 3 lines

+#ifdef CONFIG_PM

Quoted 2 lines

+#include<linux/suspend.h>
+#endif

I don't think the #ifdef in necessary. Any dependencies on CONFIG_PM (or CONFIG_SUSPEND etc.) should be taken care of inside of suspend.h. This file should be fixed if they aren't.

Ok, please check the updated version below.

Quoted 8 lines

Thanks.

Author: Amerigo Wang <[email protected]>

pm: move pm notifiers into suspend.h

ACK.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#10 lore raw

Re: [PATCH 4/5] pm: move pm notifiers into suspend.h

In reply to Cong Wang
Quoted 11 lines · Cong Wang

??? 2011???06???23??? 03:49, Rafael J. Wysocki ??????:

Quoted 7 lines
Quoted 3 lines

+#ifdef CONFIG_PM

Quoted 2 lines

+#include<linux/suspend.h>
+#endif

I don't think the #ifdef in necessary. Any dependencies on CONFIG_PM (or CONFIG_SUSPEND etc.) should be taken care of inside of suspend.h. This file should be fixed if they aren't.

Ok, please check the updated version below.

Quoted 8 lines

Thanks.

Author: Amerigo Wang <[email protected]>

pm: move pm notifiers into suspend.h

ACK.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
author
#11 lore raw

Re: [PATCH 4/5] pm: move pm notifiers into suspend.h

In reply to Rafael J. Wysocki
Quoted 7 lines · Rafael J. Wysocki
Quoted 3 lines

+#ifdef CONFIG_PM

Quoted 2 lines

+#include<linux/suspend.h>
+#endif

I don't think the #ifdef in necessary. Any dependencies on CONFIG_PM (or CONFIG_SUSPEND etc.) should be taken care of inside of suspend.h. This file should be fixed if they aren't.

Ok, please check the updated version below.

Thanks.

Author: Amerigo Wang <[email protected]>

pm: move pm notifiers into suspend.h

---

drivers/mmc/core/core.c +1 -0
index 68091dd..503dbc9 100644
@@ -23,6 +23,7 @@
 #include <linux/log2.h>
 #include <linux/regulator/consumer.h>
 #include <linux/pm_runtime.h>
+#include <linux/suspend.h>
 
 #include <linux/mmc/card.h>
 #include <linux/mmc/host.h>
include/linux/notifier.h +2 -8
index 145c436..ae8f7d9 100644
@@ -191,15 +191,9 @@ static inline int notifier_to_errno(int ret)
 
 /* reboot notifiers are defined in include/linux/reboot.h. */
 
-#define NETLINK_URELEASE	0x0001	/* Unicast netlink socket released */
+/* Hibernation and suspend events are defined in include/linux/suspend.h. */
 
-/* Hibernation and suspend events */
-#define PM_HIBERNATION_PREPARE	0x0001 /* Going to hibernate */
-#define PM_POST_HIBERNATION	0x0002 /* Hibernation finished */
-#define PM_SUSPEND_PREPARE	0x0003 /* Going to suspend the system */
-#define PM_POST_SUSPEND		0x0004 /* Suspend finished */
-#define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
-#define PM_POST_RESTORE		0x0006 /* Restore failed */
+#define NETLINK_URELEASE	0x0001	/* Unicast netlink socket released */
 
 /* Console keyboard events.
  * Note: KBD_KEYCODE is always sent before KBD_UNBOUND_KEYCODE, KBD_UNICODE and
include/linux/suspend.h +8 -0
index 083ffea..95bc81c 100644
@@ -260,6 +260,14 @@ static inline int hibernate(void) { return -ENOSYS; }
 static inline bool system_entering_hibernation(void) { return false; }
 #endif /* CONFIG_HIBERNATION */
 
+/* Hibernation and suspend events */
+#define PM_HIBERNATION_PREPARE	0x0001 /* Going to hibernate */
+#define PM_POST_HIBERNATION	0x0002 /* Hibernation finished */
+#define PM_SUSPEND_PREPARE	0x0003 /* Going to suspend the system */
+#define PM_POST_SUSPEND		0x0004 /* Suspend finished */
+#define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
+#define PM_POST_RESTORE		0x0006 /* Restore failed */
+
 #ifdef CONFIG_PM_SLEEP
 void save_processor_state(void);
 void restore_processor_state(void);
#12 lore raw

Re: [PATCH 4/5] pm: move pm notifiers into suspend.h

In reply to Amerigo Wang
Quoted 15 lines · Amerigo Wang

It is not necessary to share the same notifier.h.

---
 drivers/mmc/core/core.c  |    3 +++
 include/linux/notifier.h |   10 ++--------
 include/linux/suspend.h  |    8 ++++++++
 3 files changed, 13 insertions(+), 8 deletions(-)
drivers/mmc/core/core.c +0 -0
index 68091dd..2cd4ec5 100644

drivers/mmc/core/core.c line 28

Quoted 6 lines
drivers/mmc/core/core.c +3 -0
@@ -23,6 +23,9 @@
 #include <linux/log2.h>
 #include <linux/regulator/consumer.h>
 #include <linux/pm_runtime.h>
+#ifdef CONFIG_PM
+#include <linux/suspend.h>
+#endif

I don't think the #ifdef in necessary. Any dependencies on CONFIG_PM (or CONFIG_SUSPEND etc.) should be taken care of inside of suspend.h. This file should be fixed if they aren't.

Quoted 34 lines
drivers/mmc/core/core.c +0 -0
 #include <linux/mmc/card.h>
 #include <linux/mmc/host.h>
include/linux/notifier.h +2 -8
index 145c436..ae8f7d9 100644
@@ -191,15 +191,9 @@ static inline int notifier_to_errno(int ret)
 
 /* reboot notifiers are defined in include/linux/reboot.h. */
 
-#define NETLINK_URELEASE	0x0001	/* Unicast netlink socket released */
+/* Hibernation and suspend events are defined in include/linux/suspend.h. */
 
-/* Hibernation and suspend events */
-#define PM_HIBERNATION_PREPARE	0x0001 /* Going to hibernate */
-#define PM_POST_HIBERNATION	0x0002 /* Hibernation finished */
-#define PM_SUSPEND_PREPARE	0x0003 /* Going to suspend the system */
-#define PM_POST_SUSPEND		0x0004 /* Suspend finished */
-#define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
-#define PM_POST_RESTORE		0x0006 /* Restore failed */
+#define NETLINK_URELEASE	0x0001	/* Unicast netlink socket released */
 
 /* Console keyboard events.
  * Note: KBD_KEYCODE is always sent before KBD_UNBOUND_KEYCODE, KBD_UNICODE and
include/linux/suspend.h +1 -0
index 083ffea..95bc81c 100644
@@ -260,6 +260,14 @@ static inline int hibernate(void) { return -ENOSYS; }
 static inline bool system_entering_hibernation(void) { return false; }
 #endif /* CONFIG_HIBERNATION */
 
+/* Hibernation and suspend events */

include/linux/suspend.h static inline int hibernate(void) { return -ENOSYS; } · line 273

Quoted 10 lines
include/linux/suspend.h +7 -0
+#define PM_HIBERNATION_PREPARE	0x0001 /* Going to hibernate */
+#define PM_POST_HIBERNATION	0x0002 /* Hibernation finished */
+#define PM_SUSPEND_PREPARE	0x0003 /* Going to suspend the system */
+#define PM_POST_SUSPEND		0x0004 /* Suspend finished */
+#define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
+#define PM_POST_RESTORE		0x0006 /* Restore failed */
+
 #ifdef CONFIG_PM_SLEEP
 void save_processor_state(void);
 void restore_processor_state(void);

Thanks,
Rafael

#13 lore raw

PATCH 4/5 pm: move pm notifiers into suspend.h

In reply to Amerigo Wang

It is not necessary to share the same notifier.h.

---
 drivers/mmc/core/core.c  |    3 +++
 include/linux/notifier.h |   10 ++--------
 include/linux/suspend.h  |    8 ++++++++
 3 files changed, 13 insertions(+), 8 deletions(-)
drivers/mmc/core/core.c +3 -0
index 68091dd..2cd4ec5 100644
@@ -23,6 +23,9 @@
 #include <linux/log2.h>
 #include <linux/regulator/consumer.h>
 #include <linux/pm_runtime.h>
+#ifdef CONFIG_PM
+#include <linux/suspend.h>
+#endif
 
 #include <linux/mmc/card.h>
 #include <linux/mmc/host.h>
include/linux/notifier.h +2 -8
index 145c436..ae8f7d9 100644
@@ -191,15 +191,9 @@ static inline int notifier_to_errno(int ret)
 
 /* reboot notifiers are defined in include/linux/reboot.h. */
 
-#define NETLINK_URELEASE	0x0001	/* Unicast netlink socket released */
+/* Hibernation and suspend events are defined in include/linux/suspend.h. */
 
-/* Hibernation and suspend events */
-#define PM_HIBERNATION_PREPARE	0x0001 /* Going to hibernate */
-#define PM_POST_HIBERNATION	0x0002 /* Hibernation finished */
-#define PM_SUSPEND_PREPARE	0x0003 /* Going to suspend the system */
-#define PM_POST_SUSPEND		0x0004 /* Suspend finished */
-#define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
-#define PM_POST_RESTORE		0x0006 /* Restore failed */
+#define NETLINK_URELEASE	0x0001	/* Unicast netlink socket released */
 
 /* Console keyboard events.
  * Note: KBD_KEYCODE is always sent before KBD_UNBOUND_KEYCODE, KBD_UNICODE and
include/linux/suspend.h +8 -0
index 083ffea..95bc81c 100644
@@ -260,6 +260,14 @@ static inline int hibernate(void) { return -ENOSYS; }
 static inline bool system_entering_hibernation(void) { return false; }
 #endif /* CONFIG_HIBERNATION */
 
+/* Hibernation and suspend events */
+#define PM_HIBERNATION_PREPARE	0x0001 /* Going to hibernate */
+#define PM_POST_HIBERNATION	0x0002 /* Hibernation finished */
+#define PM_SUSPEND_PREPARE	0x0003 /* Going to suspend the system */
+#define PM_POST_SUSPEND		0x0004 /* Suspend finished */
+#define PM_RESTORE_PREPARE	0x0005 /* Going to restore a saved image */
+#define PM_POST_RESTORE		0x0006 /* Restore failed */
+
 #ifdef CONFIG_PM_SLEEP
 void save_processor_state(void);
 void restore_processor_state(void);
Signature · 1 line
1.7.4.4
#14 lore raw

PATCH 5/5 vt: move vt notifiers into vt.h

In reply to Amerigo Wang

It is not necessary to share the same notifier.h.

---
 include/linux/notifier.h |    9 ++-------
 include/linux/vt.h       |    7 +++++++
 2 files changed, 9 insertions(+), 7 deletions(-)
include/linux/notifier.h +2 -7
index ae8f7d9..d65746e 100644
@@ -193,6 +193,8 @@ static inline int notifier_to_errno(int ret)
 
 /* Hibernation and suspend events are defined in include/linux/suspend.h. */
 
+/* Virtual Terminal events are defined in include/linux/vt.h. */
+
 #define NETLINK_URELEASE	0x0001	/* Unicast netlink socket released */
 
 /* Console keyboard events.
@@ -206,12 +208,5 @@ static inline int notifier_to_errno(int ret)
 
 extern struct blocking_notifier_head reboot_notifier_list;
 
-/* Virtual Terminal events. */
-#define VT_ALLOCATE		0x0001 /* Console got allocated */
-#define VT_DEALLOCATE		0x0002 /* Console will be deallocated */
-#define VT_WRITE		0x0003 /* A char got output */
-#define VT_UPDATE		0x0004 /* A bigger update occurred */
-#define VT_PREWRITE		0x0005 /* A char is about to be written to the console */
-
 #endif /* __KERNEL__ */
 #endif /* _LINUX_NOTIFIER_H */
include/linux/vt.h +7 -0
index d5dd0bc..30a8dd9 100644
@@ -86,6 +86,13 @@ struct vt_setactivate {
 
 #ifdef __KERNEL__
 
+/* Virtual Terminal events. */
+#define VT_ALLOCATE		0x0001 /* Console got allocated */
+#define VT_DEALLOCATE		0x0002 /* Console will be deallocated */
+#define VT_WRITE		0x0003 /* A char got output */
+#define VT_UPDATE		0x0004 /* A bigger update occurred */
+#define VT_PREWRITE		0x0005 /* A char is about to be written to the console */
+
 #ifdef CONFIG_VT_CONSOLE
 
 extern int vt_kmsg_redirect(int new);
Signature · 1 line
1.7.4.4
maintainer Acked-by on the v1 series
#15 lore raw
In reply to Amerigo Wang

From: Amerigo Wang <[email protected]>
Date: Wed, 22 Jun 2011 14:35:17 +0800

Quoted 8 lines

Now we define all kinds of notifiers in notifier.h, this is not necessary at all, since different subsystems use different notifiers, they are almost non-related with each other.

This can also save much build time. Suppose I add a new netdevice event, really I don't have to recompile all the source, just network related. Without this patch, all the source will be recompiled.

Quoted 7 lines

I move the notify events near to their subsystem notifier registers, so that they can be found more easily.

In case of conflicts, I hope Andrew Morton would take the whole patchset, rather than different subsystem maintainers take their own.

For networking bits: