zephyr/kernel
Ulf Magnusson ec3eff57e0 Kconfig: Use the first default with a satisfied condition
Up until now, Zephyr has patched Kconfig to use the last 'default' with
a satisfied condition, instead of the first one. I'm not sure why the
patch was added (it predates Kconfiglib), but I suspect it's related to
Kconfig.defconfig files.

There are at least three problems with the patch:

  1. It's inconsistent with how Kconfig works in other projects, which
     might confuse newcomers.

  2. Due to oversights, earlier 'range' properties are still preferred,
     as well as earlier 'default' properties on choices.

     In addition to being inconsistent, this makes it impossible to
     override 'range' properties and choice 'default' properties if the
     base definition of the symbol/choice already has 'range'/'default'
     properties.

     I've seen errors caused by the inconsistency, and I suspect there
     are more.

  3. A fork of Kconfiglib that adds the patch needs to be maintained.

Get rid of the patch and go back to standard Kconfig behavior, as
follows:

  1. Include the Kconfig.defconfig files first instead of last in
     Kconfig.zephyr.

  2. Include boards/Kconfig and arch/<arch>/Kconfig first instead of
     last in arch/Kconfig.

  3. Include arch/<arch>/soc/*/Kconfig first instead of last in
     arch/<arch>/Kconfig.

  4. Swap a few other 'source's to preserve behavior for some scattered
     symbols with multiple definitions.

     Swap 'source's in some no-op cases too, where it might match the
     intent.

  5. Reverse the defaults on symbol definitions that have more than one
     default.

     Skip defaults that are mutually exclusive, e.g. where each default
     has an 'if <some board>' condition. They are already safe.

  6. Remove the prefer-later-defaults patch from Kconfiglib.

Testing was done with a Python script that lists all Kconfig
symbols/choices with multiple defaults, along with a whitelist of fixed
symbols. The script also verifies that there are no "unreachable"
defaults hidden by defaults without conditions

As an additional test, zephyr/.config was generated before and after the
change for several samples and checked to be identical (after sorting).

This commit includes some default-related cleanups as well:

  - Simplify some symbol definitions, e.g. where a default has 'if FOO'
    when the symbol already has 'depends on FOO'.

  - Remove some redundant 'default ""' for string symbols. This is the
    implicit default.

Piggyback fixes for swapped ranges on BT_L2CAP_RX_MTU and
BT_L2CAP_TX_MTU (caused by confusing inconsistency).

Piggyback some fixes for style nits too, e.g. unindented help texts.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-08-10 12:38:28 -07:00
..
include userspace: add functions for copying to/from user 2018-07-31 07:47:15 -07:00
CMakeLists.txt kernel: Cmake: Add __ZEPHYR_SUPERVISOR__ macro for kernel files. 2018-05-15 17:48:18 +03:00
Kconfig Kconfig: Use the first default with a satisfied condition 2018-08-10 12:38:28 -07:00
Kconfig.event_logger kernel: Kconfig: Remove redundant 'default n' properties 2018-06-22 15:21:14 -04:00
Kconfig.power_mgmt kernel: Kconfig: Remove redundant 'default n' properties 2018-06-22 15:21:14 -04:00
alert.c syscalls: remove policy from handler checks 2018-05-17 23:34:03 +03:00
atomic_c.c license: Replace Apache boilerplate with SPDX tag 2017-01-19 03:50:58 +00:00
compiler_stack_protect.c kernel: add CODE_UNREACHABLE in _StackCheckHandler 2018-04-17 10:50:12 -07:00
device.c kernel: device: Only compare strings if pointer comparison fails 2018-02-15 17:31:59 -08:00
errno.c kernel: fix errno access for user mode 2018-07-19 16:44:59 -07:00
idle.c kernel: idle: Define _sys_soc_resume functions conditionally 2018-07-19 17:12:58 -04:00
init.c userspace: compartmentalized app memory organization 2018-07-25 12:02:01 -07:00
int_latency_bench.c Convert remaining code to using newly introduced integer sized types 2017-04-21 11:38:23 -05:00
mailbox.c kernel: Fix sloppy wait queue API 2018-05-18 01:48:48 +03:00
mem_domain.c kernel: mem_domain: Fix compile issues 2018-03-05 10:47:00 -06:00
mem_slab.c kernel: mem_slab: Reschedule in k_mem_slab_free only when necessary. 2018-05-18 20:16:50 +03:00
mempool.c kernel/mempool: Handle transient failure condition 2018-05-27 09:55:04 -04:00
msg_q.c kernel: Wait queues aren't dlists anymore 2018-05-19 07:00:55 +03:00
mutex.c kernel: Fix sloppy wait queue API 2018-05-18 01:48:48 +03:00
pipes.c kernel: Wait queues aren't dlists anymore 2018-05-19 07:00:55 +03:00
poll.c coverage: kernel: poll: Cleanup redundant code to improve coverage 2018-07-31 20:39:19 -04:00
queue.c kernel/drivers: fix compile warnings 2018-07-01 22:58:23 +02:00
sched.c kernel: Cleanup _ms_to_ticks(). 2018-07-03 22:46:39 -04:00
sem.c kernel: Fix sloppy wait queue API 2018-05-18 01:48:48 +03:00
smp.c kernel: Rework SMP irq_lock() compatibility layer 2018-05-02 10:00:17 -07:00
stack.c kernel: Wait queues aren't dlists anymore 2018-05-19 07:00:55 +03:00
sys_clock.c syscalls: remove policy from handler checks 2018-05-17 23:34:03 +03:00
system_work_q.c kernel: introduce stack definition macros 2017-06-09 18:53:28 -04:00
thread.c kernel: fix errno access for user mode 2018-07-19 16:44:59 -07:00
thread_abort.c syscalls: remove policy from handler checks 2018-05-17 23:34:03 +03:00
timer.c kernel: Fix sloppy wait queue API 2018-05-18 01:48:48 +03:00
userspace.c kernel: threads: assign index no. to dynamically created threads 2018-08-09 09:20:14 -07:00
userspace_handler.c syscalls: remove policy from handler checks 2018-05-17 23:34:03 +03:00
version.c kernel: version: no need to store version in RAM 2017-09-07 16:34:50 -07:00
work_q.c work_q: Correctly clear pending flag in delayed work queue, update docs 2018-02-13 18:08:57 -05:00