Messages in this thread | | | From | Masahiro Yamada <> | Date | Sun, 19 Apr 2020 05:07:43 +0900 | Subject | Re: [RFC PATCH 1/2] Kconfig: Introduce "uses" keyword |
| |
On Sun, Apr 19, 2020 at 4:11 AM Nicolas Pitre <nico@fluxnic.net> wrote: > > On Sun, 19 Apr 2020, Masahiro Yamada wrote: > > > (FOO || !FOO) is difficult to understand, but > > the behavior of "uses FOO" is as difficult to grasp. > > Can't this be expressed as the following instead: > > depends on FOO if FOO > > That would be a little clearer. > > > Nicolas
'depends on' does not take the 'if <expr>'
'depends on A if B' is the syntax sugar of 'depends on (A || !B), right ?
I do not know how clearer it would make things.
depends on (m || FOO != m) is another equivalent, but we are always talking about a matter of expression.
How important is it to stick to depends on (FOO || !FOO) or its equivalents?
If a driver wants to use the feature FOO in most usecases, 'depends on FOO' is sensible.
If FOO is just optional, you can get rid of the dependency, and IS_REACHABLE() will do logically correct things.
I do not think IS_REACHABLE() is too bad, but if it is confusing, we can add one more option to make it explicit.
config DRIVER_X tristate "driver x"
config DRIVER_X_USES_FOO bool "use FOO from driver X" depends on DRIVER_X depends on DRIVER_X <= FOO help DRIVER_X works without FOO, but Using FOO will provide better usability. Say Y if you want to make driver X use FOO.
Of course,
if (IS_ENABLED(CONFIG_DRIVER_X_USES_FOO)) foo_init();
works like
if (IS_REACHABLE(CONFIG_FOO)) foo_init();
At lease, it will eliminate a question like "I loaded the module FOO, I swear. But my built-in driver X still would not use FOO, why?"
-- Best Regards Masahiro Yamada
| |