include/linux/kernel.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
Provide some basic comments about the system_states and what they imply.
Also convert the comments to kernel-doc format.
Split the enum declaration from the definition of the system_state
variable so that kernel-doc notation works cleanly with it.
This is picked up by Documentation/driver-api/basics.rst so it
does not need further inclusion in the kernel docbooks.
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Rafael J. Wysocki <rafael@kernel.org> # v1
---
v2: add Rafael's Ack.
v3: add Andrew
v4: add DOC: so that this DOC: block can be used in Documentation/
add Greg K-H
add Jon Corbet, Mauro Chehab, & linux-doc
v5: split enum declaration and definition (Jani Nikula)
drop the DOC: block since it is no longer needed
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Len Brown <len.brown@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: linux-doc@vger.kernel.org
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
---
include/linux/kernel.h | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
--- linux-next-20250819.orig/include/linux/kernel.h
+++ linux-next-20250819/include/linux/kernel.h
@@ -164,11 +164,23 @@ extern int root_mountflags;
extern bool early_boot_irqs_disabled;
-/*
- * Values used for system_state. Ordering of the states must not be changed
+/**
+ * enum system_states - Values used for system_state.
+ *
+ * * @SYSTEM_BOOTING: %0, no init needed
+ * * @SYSTEM_SCHEDULING: system is ready for scheduling; OK to use RCU
+ * * @SYSTEM_FREEING_INITMEM: system is freeing all of initmem; almost running
+ * * @SYSTEM_RUNNING: system is up and running
+ * * @SYSTEM_HALT: system entered clean system halt state
+ * * @SYSTEM_POWER_OFF: system entered shutdown/clean power off state
+ * * @SYSTEM_RESTART: system entered emergency power off or normal restart
+ * * @SYSTEM_SUSPEND: system entered suspend or hibernate state
+ *
+ * Note:
+ * Ordering of the states must not be changed
* as code checks for <, <=, >, >= STATE.
*/
-extern enum system_states {
+enum system_states {
SYSTEM_BOOTING,
SYSTEM_SCHEDULING,
SYSTEM_FREEING_INITMEM,
@@ -177,7 +189,8 @@ extern enum system_states {
SYSTEM_POWER_OFF,
SYSTEM_RESTART,
SYSTEM_SUSPEND,
-} system_state;
+};
+extern enum system_states system_state;
/*
* General tracing related utility functions - trace_printk(),
Em Fri, 5 Sep 2025 22:27:58 -0700 Randy Dunlap <rdunlap@infradead.org> escreveu: > Provide some basic comments about the system_states and what they imply. > Also convert the comments to kernel-doc format. > > Split the enum declaration from the definition of the system_state > variable so that kernel-doc notation works cleanly with it. > This is picked up by Documentation/driver-api/basics.rst so it > does not need further inclusion in the kernel docbooks. > > Signed-off-by: Randy Dunlap <rdunlap@infradead.org> > Acked-by: Rafael J. Wysocki <rafael@kernel.org> # v1 > --- > v2: add Rafael's Ack. > v3: add Andrew > v4: add DOC: so that this DOC: block can be used in Documentation/ > add Greg K-H > add Jon Corbet, Mauro Chehab, & linux-doc > v5: split enum declaration and definition (Jani Nikula) > drop the DOC: block since it is no longer needed > > Cc: Andrew Morton <akpm@linux-foundation.org> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > Cc: "Rafael J. Wysocki" <rafael@kernel.org> > Cc: Pavel Machek <pavel@ucw.cz> > Cc: Len Brown <len.brown@intel.com> > Cc: linux-pm@vger.kernel.org > Cc: Jonathan Corbet <corbet@lwn.net> > Cc: Jani Nikula <jani.nikula@linux.intel.com> > Cc: linux-doc@vger.kernel.org > Cc: Mauro Carvalho Chehab <mchehab@kernel.org> > Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com> > --- > include/linux/kernel.h | 21 +++++++++++++++++---- > 1 file changed, 17 insertions(+), 4 deletions(-) > > --- linux-next-20250819.orig/include/linux/kernel.h > +++ linux-next-20250819/include/linux/kernel.h > @@ -164,11 +164,23 @@ extern int root_mountflags; > > extern bool early_boot_irqs_disabled; > > -/* > - * Values used for system_state. Ordering of the states must not be changed > +/** > + * enum system_states - Values used for system_state. > + * > + * * @SYSTEM_BOOTING: %0, no init needed > + * * @SYSTEM_SCHEDULING: system is ready for scheduling; OK to use RCU > + * * @SYSTEM_FREEING_INITMEM: system is freeing all of initmem; almost running > + * * @SYSTEM_RUNNING: system is up and running > + * * @SYSTEM_HALT: system entered clean system halt state > + * * @SYSTEM_POWER_OFF: system entered shutdown/clean power off state > + * * @SYSTEM_RESTART: system entered emergency power off or normal restart > + * * @SYSTEM_SUSPEND: system entered suspend or hibernate state You forgot to drop the extra asterisk at the above. definitions. Fixing it, feel free to add: Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> > + * > + * Note: > + * Ordering of the states must not be changed > * as code checks for <, <=, >, >= STATE. > */ > -extern enum system_states { > +enum system_states { > SYSTEM_BOOTING, > SYSTEM_SCHEDULING, > SYSTEM_FREEING_INITMEM, > @@ -177,7 +189,8 @@ extern enum system_states { > SYSTEM_POWER_OFF, > SYSTEM_RESTART, > SYSTEM_SUSPEND, > -} system_state; > +}; > +extern enum system_states system_state; > > /* > * General tracing related utility functions - trace_printk(), Thanks, Mauro
On 9/6/25 1:58 AM, Mauro Carvalho Chehab wrote: > Em Fri, 5 Sep 2025 22:27:58 -0700 > Randy Dunlap <rdunlap@infradead.org> escreveu: > >> Provide some basic comments about the system_states and what they imply. >> Also convert the comments to kernel-doc format. >> >> Split the enum declaration from the definition of the system_state >> variable so that kernel-doc notation works cleanly with it. >> This is picked up by Documentation/driver-api/basics.rst so it >> does not need further inclusion in the kernel docbooks. >> >> Signed-off-by: Randy Dunlap <rdunlap@infradead.org> >> Acked-by: Rafael J. Wysocki <rafael@kernel.org> # v1 >> --- >> v2: add Rafael's Ack. >> v3: add Andrew >> v4: add DOC: so that this DOC: block can be used in Documentation/ >> add Greg K-H >> add Jon Corbet, Mauro Chehab, & linux-doc >> v5: split enum declaration and definition (Jani Nikula) >> drop the DOC: block since it is no longer needed >> >> Cc: Andrew Morton <akpm@linux-foundation.org> >> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> >> Cc: "Rafael J. Wysocki" <rafael@kernel.org> >> Cc: Pavel Machek <pavel@ucw.cz> >> Cc: Len Brown <len.brown@intel.com> >> Cc: linux-pm@vger.kernel.org >> Cc: Jonathan Corbet <corbet@lwn.net> >> Cc: Jani Nikula <jani.nikula@linux.intel.com> >> Cc: linux-doc@vger.kernel.org >> Cc: Mauro Carvalho Chehab <mchehab@kernel.org> >> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com> >> --- >> include/linux/kernel.h | 21 +++++++++++++++++---- >> 1 file changed, 17 insertions(+), 4 deletions(-) >> >> --- linux-next-20250819.orig/include/linux/kernel.h >> +++ linux-next-20250819/include/linux/kernel.h >> @@ -164,11 +164,23 @@ extern int root_mountflags; >> >> extern bool early_boot_irqs_disabled; >> >> -/* >> - * Values used for system_state. Ordering of the states must not be changed >> +/** >> + * enum system_states - Values used for system_state. >> + * > >> + * * @SYSTEM_BOOTING: %0, no init needed >> + * * @SYSTEM_SCHEDULING: system is ready for scheduling; OK to use RCU >> + * * @SYSTEM_FREEING_INITMEM: system is freeing all of initmem; almost running >> + * * @SYSTEM_RUNNING: system is up and running >> + * * @SYSTEM_HALT: system entered clean system halt state >> + * * @SYSTEM_POWER_OFF: system entered shutdown/clean power off state >> + * * @SYSTEM_RESTART: system entered emergency power off or normal restart >> + * * @SYSTEM_SUSPEND: system entered suspend or hibernate state > > You forgot to drop the extra asterisk at the above. definitions. Oops, thanks for catching that. Will fix. -- ~Randy
© 2016 - 2025 Red Hat, Inc.