2021-07-15 13:41:43

by Robert Richter

[permalink] [raw]
Subject: [PATCH] Documentation/kbuild: Document the kconfig choice default value

Document how choice defaults are determined:

Default of a choice is its first visible choice element [1]. Choice
elements do not support default attributes. [2]

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/kconfig/symbol.c?h=v5.14-rc1#n245
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/kconfig/menu.c?h=v5.14-rc1#n494

Signed-off-by: Robert Richter <[email protected]>
---
Documentation/kbuild/kconfig-language.rst | 3 +++
1 file changed, 3 insertions(+)

diff --git a/Documentation/kbuild/kconfig-language.rst b/Documentation/kbuild/kconfig-language.rst
index 98c24183d8c3..e4d3463594e1 100644
--- a/Documentation/kbuild/kconfig-language.rst
+++ b/Documentation/kbuild/kconfig-language.rst
@@ -417,6 +417,9 @@ definitions of that choice. If a [symbol] is associated to the choice,
then you may define the same choice (i.e. with the same entries) in another
place.

+The default value of a choice is set to the first visible choice element.
+Choice elements do not support the default attribute like menu entries do.
+
comment::

"comment" <prompt>
--
2.29.2


2021-07-18 09:38:16

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH] Documentation/kbuild: Document the kconfig choice default value

On Thu, Jul 15, 2021 at 6:26 PM Robert Richter <[email protected]> wrote:
>
> Document how choice defaults are determined:
>
> Default of a choice is its first visible choice element [1]. Choice
> elements do not support default attributes. [2]
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/kconfig/symbol.c?h=v5.14-rc1#n245
> [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/kconfig/menu.c?h=v5.14-rc1#n494
>
> Signed-off-by: Robert Richter <[email protected]>
> ---
> Documentation/kbuild/kconfig-language.rst | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/Documentation/kbuild/kconfig-language.rst b/Documentation/kbuild/kconfig-language.rst
> index 98c24183d8c3..e4d3463594e1 100644
> --- a/Documentation/kbuild/kconfig-language.rst
> +++ b/Documentation/kbuild/kconfig-language.rst
> @@ -417,6 +417,9 @@ definitions of that choice. If a [symbol] is associated to the choice,
> then you may define the same choice (i.e. with the same entries) in another
> place.
>
> +The default value of a choice is set to the first visible choice element.


The default value of a choice is set to the first visible choice element
unless it is explicitly set by the 'default' property.

... is more precise.




> +Choice elements do not support the default attribute like menu entries do.

I doubt this info is useful.
Rather, is it even confusing?


choices support 'default' but
choice elements (i.e. choice values) do not.









> +
> comment::
>
> "comment" <prompt>
> --
> 2.29.2
>


--
Best Regards
Masahiro Yamada

2021-07-19 09:17:59

by Robert Richter

[permalink] [raw]
Subject: [PATCH v2] Documentation/kbuild: Document the kconfig choice default value

On 18.07.21 18:36:31, Masahiro Yamada wrote:
> On Thu, Jul 15, 2021 at 6:26 PM Robert Richter <[email protected]> wrote:

> > --- a/Documentation/kbuild/kconfig-language.rst
> > +++ b/Documentation/kbuild/kconfig-language.rst
> > @@ -417,6 +417,9 @@ definitions of that choice. If a [symbol] is associated to the choice,
> > then you may define the same choice (i.e. with the same entries) in another
> > place.
> >
> > +The default value of a choice is set to the first visible choice element.
>
>
> The default value of a choice is set to the first visible choice element
> unless it is explicitly set by the 'default' property.
>
> ... is more precise.

Ah, ok. It becomes clear now, but how a value is set then in case the
type is tristate?

>
>
>
>
> > +Choice elements do not support the default attribute like menu entries do.
>
> I doubt this info is useful.
> Rather, is it even confusing?
>
>
> choices support 'default' but
> choice elements (i.e. choice values) do not.

I have added an example to the doc for clarification, v2 below.

Thanks,

-Robert


From 46ebd10dc11388ddce40aea70890000697a27165 Mon Sep 17 00:00:00 2001
From: Robert Richter <[email protected]>
Date: Wed, 14 Jul 2021 12:24:16 +0200
Subject: [PATCH v2] Documentation/kbuild: Document the kconfig choice default
value

Document how choice defaults are determined:

Default of a choice is its first visible choice element unless it is
explicitly set by the 'default' property [1]. Choice elements do not
support default attributes. [2]

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/kconfig/symbol.c?h=v5.14-rc1#n245
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/kconfig/menu.c?h=v5.14-rc1#n494

Signed-off-by: Robert Richter <[email protected]>
---
v2: clarification on 'default' attribute of a choice
added example
---
Documentation/kbuild/kconfig-language.rst | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/Documentation/kbuild/kconfig-language.rst b/Documentation/kbuild/kconfig-language.rst
index e4d3463594e1..d919dde0bcbf 100644
--- a/Documentation/kbuild/kconfig-language.rst
+++ b/Documentation/kbuild/kconfig-language.rst
@@ -417,8 +417,20 @@ definitions of that choice. If a [symbol] is associated to the choice,
then you may define the same choice (i.e. with the same entries) in another
place.

-The default value of a choice is set to the first visible choice element.
-Choice elements do not support the default attribute like menu entries do.
+The default value of a choice is set to the first visible choice
+element unless it is explicitly set by the 'default' property.
+
+Note:
+ Choice options do not support the 'default' attribute.
+
+E.g.::
+
+ choice
+ default C1
+ config C0
+ config C1
+ # no default attribute here
+ endchoice

comment::

--
2.29.2

2021-07-19 21:08:30

by Robert Richter

[permalink] [raw]
Subject: Re: [PATCH v2] Documentation/kbuild: Document the kconfig choice default value

On 19.07.21 11:16:09, Robert Richter wrote:
> @@ -417,8 +417,20 @@ definitions of that choice. If a [symbol] is associated to the choice,
> then you may define the same choice (i.e. with the same entries) in another
> place.
>
> -The default value of a choice is set to the first visible choice element.
> -Choice elements do not support the default attribute like menu entries do.

This patch was not properly rebased and does not apply. Will resend a v3.

Sorry for that.

-Robert

> +The default value of a choice is set to the first visible choice
> +element unless it is explicitly set by the 'default' property.
> +
> +Note:
> + Choice options do not support the 'default' attribute.
> +
> +E.g.::
> +
> + choice
> + default C1
> + config C0
> + config C1
> + # no default attribute here
> + endchoice
>
> comment::
>
> --
> 2.29.2
>