lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <34fb6a27a2c17c22c0ac93bebb0bbfd1a04d1833@intel.com>
Date: Fri, 05 Sep 2025 16:06:31 +0300
From: Jani Nikula <jani.nikula@...ux.intel.com>
To: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
Cc: Randy Dunlap <rdunlap@...radead.org>, linux-kernel@...r.kernel.org,
 "Rafael J. Wysocki" <rafael@...nel.org>, Andrew Morton
 <akpm@...ux-foundation.org>, Greg Kroah-Hartman
 <gregkh@...uxfoundation.org>, Pavel Machek <pavel@....cz>, Len Brown
 <len.brown@...el.com>, linux-pm@...r.kernel.org, Jonathan Corbet
 <corbet@....net>, linux-doc@...r.kernel.org, Mauro Carvalho Chehab
 <mchehab@...nel.org>, "James E.J. Bottomley"
 <James.Bottomley@...senPartnership.com>
Subject: Re: [PATCH v4] kernel.h: add comments for system_states

On Fri, 05 Sep 2025, Mauro Carvalho Chehab <mchehab+huawei@...nel.org> wrote:
> Em Fri, 05 Sep 2025 12:02:37 +0300
> Jani Nikula <jani.nikula@...ux.intel.com> escreveu:
>
>> On Wed, 03 Sep 2025, Randy Dunlap <rdunlap@...radead.org> wrote:
>> > Provide some basic comments about the system_states and what they imply.
>> > Also convert the comments to kernel-doc format.
>> >
>> > However, kernel-doc does not support kernel-doc notation on extern
>> > struct/union/typedef/enum/etc. So I made this a DOC: block so that
>> > I can use (insert) it into a Documentation (.rst) file and have it
>> > look decent.  
>> 
>> The simple workaround is to separate the enum type and the variable:
>> 
>> /**
>>  * kernel-doc for the enum
>>  */
>> enum system_states {
>> 	...
>> };
>> 
>> /**
>>  * kernel-doc for the variable
>>  */
>> extern enum system_states system_state;
>> 
>> BR,
>> Jani.
>> 
>> >
>> > Signed-off-by: Randy Dunlap <rdunlap@...radead.org>
>> > Acked-by: Rafael J. Wysocki <rafael@...nel.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
>> >
>> > Cc: Andrew Morton <akpm@...ux-foundation.org>
>> > Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
>> > Cc: "Rafael J. Wysocki" <rafael@...nel.org>
>> > Cc: Pavel Machek <pavel@....cz>
>> > Cc: Len Brown <len.brown@...el.com>
>> > Cc: linux-pm@...r.kernel.org
>> > Cc: Jonathan Corbet <corbet@....net>
>> > Cc: linux-doc@...r.kernel.org
>> > Cc: Mauro Carvalho Chehab <mchehab@...nel.org>
>> > Cc: "James E.J. Bottomley" <James.Bottomley@...senPartnership.com>
>> > ---
>> >  Documentation/driver-api/pm/devices.rst |    8 ++++++++
>> >  include/linux/kernel.h                  |   18 ++++++++++++++++--
>> >  2 files changed, 24 insertions(+), 2 deletions(-)
>> >
>> > --- linux-next-20250819.orig/include/linux/kernel.h
>> > +++ linux-next-20250819/include/linux/kernel.h
>> > @@ -164,8 +164,22 @@ extern int root_mountflags;
>> >  
>> >  extern bool early_boot_irqs_disabled;
>> >  
>> > -/*
>> > - * Values used for system_state. Ordering of the states must not be changed
>> > +/**
>> > + * DOC: General system_states available for drivers
>> > + *
>> > + * 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 {
>> > --- linux-next-20250819.orig/Documentation/driver-api/pm/devices.rst
>> > +++ linux-next-20250819/Documentation/driver-api/pm/devices.rst
>> > @@ -241,6 +241,14 @@ before reactivating its class I/O queues
>> >  More power-aware drivers might prepare the devices for triggering system wakeup
>> >  events.
>> >  
>> > +System states available for drivers
>> > +-----------------------------------
>> > +
>> > +These system states are available for drivers to help them determine how to
>> > +handle state transitions.
>> > +
>> > +.. kernel-doc:: include/linux/kernel.h
>> > +   :doc: General system_states available for drivers
>> >  
>> >  Call Sequence Guarantees
>> >  ------------------------
>> >  
>> 
>
> If the problem is with "extern" before enum, fixing kdoc be
> fairly trivial.

The non-trivial part is deciding whether you're documenting the enum
type or the variable. Both are equally valid options.

BR,
Jani.

>
> If you see:
>
> 	def dump_function(self, ln, prototype):
> 	
>      	# Prefixes that would be removed
>         sub_prefixes = [
> 	    ...
> 	    (r"^extern +", "", 0),	
> 	    ...
> 	}
>
>         for search, sub, flags in sub_prefixes:
>             prototype = KernRe(search, flags).sub(sub, prototype)
>
>
> we need something similar to that at:
> 	def dump_enum(self, ln, proto):
>
> alternatively, we could use a simpler approach modifying adding a
> non-group optional match for "extern". E.g:
>
> -	r = KernRe(r'enum\s+(\w*)\s*\{(.*)\}')
> +       r = KernRe(r'(?:extern\s+)?enum\s+(\w*)\s*\{(.*)\}')
>
> (untested)
>
> Regards,
> Mauro
>
>
> Thanks,
> Mauro

-- 
Jani Nikula, Intel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ