[v2] mux: mmio: depend on REGMAP as the code has that dependency

Message ID 946cea0c-6d7f-c2e3-4412-4967ece40b94@axentia.se
State New
Headers
Series [v2] mux: mmio: depend on REGMAP as the code has that dependency |

Commit Message

Peter Rosin May 24, 2023, 12:52 p.m. UTC
  If CONFIG_REGMAP is not active, the build errors out like this:

../drivers/mux/mmio.c: In function ‘mux_mmio_probe’:
../drivers/mux/mmio.c:76:34: error: storage size of ‘field’ isn’t known
   76 |                 struct reg_field field;
      |                                  ^~~~~
In file included from ../include/linux/bits.h:21,
                 from ../include/linux/bitops.h:6,
                 from ../drivers/mux/mmio.c:8:
../include/linux/bits.h:23:28: error: first argument to ‘__builtin_choose_expr’ not a constant
   23 |         (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \
      |                            ^~~~~~~~~~~~~~~~~~~~~
../include/linux/build_bug.h:16:62: note: in definition of macro ‘BUILD_BUG_ON_ZERO’
   16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
      |                                                              ^
../include/linux/bits.h:37:10: note: in expansion of macro ‘GENMASK_INPUT_CHECK’
   37 |         (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
      |          ^~~~~~~~~~~~~~~~~~~
../drivers/mux/mmio.c:96:29: note: in expansion of macro ‘GENMASK’
   96 |                 if (mask != GENMASK(field.msb, field.lsb)) {
      |                             ^~~~~~~
../include/linux/build_bug.h:16:51: error: bit-field ‘<anonymous>’ width not an integer constant
   16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
      |                                                   ^
../include/linux/bits.h:23:10: note: in expansion of macro ‘BUILD_BUG_ON_ZERO’
   23 |         (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \
      |          ^~~~~~~~~~~~~~~~~
../include/linux/bits.h:37:10: note: in expansion of macro ‘GENMASK_INPUT_CHECK’
   37 |         (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
      |          ^~~~~~~~~~~~~~~~~~~
../drivers/mux/mmio.c:96:29: note: in expansion of macro ‘GENMASK’
   96 |                 if (mask != GENMASK(field.msb, field.lsb)) {
      |                             ^~~~~~~
../drivers/mux/mmio.c:102:29: error: implicit declaration of function ‘devm_regmap_field_alloc’ [-Werror=implicit-function-declaration]
  102 |                 fields[i] = devm_regmap_field_alloc(dev, regmap, field);
      |                             ^~~~~~~~~~~~~~~~~~~~~~~
../drivers/mux/mmio.c:76:34: warning: unused variable ‘field’ [-Wunused-variable]
   76 |                 struct reg_field field;
      |                                  ^~~~~

REGMAP is normally "selected", but that causes a recursive dependency.
But since REGMAP is "depended on" in other places, do so here as well.
The (implicit) REGMAP dependency was lost when the strict dependency
on MFD_SYSCON was removed.

Reported by: Randy Dunlap <rdunlap@infradead.org>
Fixes: 8ecfaca7926f ("mux: mmio: add generic regmap bitfield-based multiplexer")
Link: https://lore.kernel.org/lkml/64cf625b-2495-2382-0331-519d1cab0adf@infradead.org/
Signed-off-by: Peter Rosin <peda@axentia.se>
---
 drivers/mux/Kconfig | 1 +
 1 file changed, 1 insertion(+)

Note, there is a patch in linux-next that removes "|| COMPILE_TEST" from the
pre-existing depends.

Cheers,
Peter
  

Comments

Randy Dunlap June 11, 2023, 8:59 p.m. UTC | #1
Hi--

On 5/24/23 05:52, Peter Rosin wrote:
> If CONFIG_REGMAP is not active, the build errors out like this:
> 
> ../drivers/mux/mmio.c: In function ‘mux_mmio_probe’:
> ../drivers/mux/mmio.c:76:34: error: storage size of ‘field’ isn’t known
>    76 |                 struct reg_field field;
>       |                                  ^~~~~
> In file included from ../include/linux/bits.h:21,
>                  from ../include/linux/bitops.h:6,
>                  from ../drivers/mux/mmio.c:8:
> ../include/linux/bits.h:23:28: error: first argument to ‘__builtin_choose_expr’ not a constant
>    23 |         (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \
>       |                            ^~~~~~~~~~~~~~~~~~~~~
> ../include/linux/build_bug.h:16:62: note: in definition of macro ‘BUILD_BUG_ON_ZERO’
>    16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
>       |                                                              ^
> ../include/linux/bits.h:37:10: note: in expansion of macro ‘GENMASK_INPUT_CHECK’
>    37 |         (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
>       |          ^~~~~~~~~~~~~~~~~~~
> ../drivers/mux/mmio.c:96:29: note: in expansion of macro ‘GENMASK’
>    96 |                 if (mask != GENMASK(field.msb, field.lsb)) {
>       |                             ^~~~~~~
> ../include/linux/build_bug.h:16:51: error: bit-field ‘<anonymous>’ width not an integer constant
>    16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
>       |                                                   ^
> ../include/linux/bits.h:23:10: note: in expansion of macro ‘BUILD_BUG_ON_ZERO’
>    23 |         (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \
>       |          ^~~~~~~~~~~~~~~~~
> ../include/linux/bits.h:37:10: note: in expansion of macro ‘GENMASK_INPUT_CHECK’
>    37 |         (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
>       |          ^~~~~~~~~~~~~~~~~~~
> ../drivers/mux/mmio.c:96:29: note: in expansion of macro ‘GENMASK’
>    96 |                 if (mask != GENMASK(field.msb, field.lsb)) {
>       |                             ^~~~~~~
> ../drivers/mux/mmio.c:102:29: error: implicit declaration of function ‘devm_regmap_field_alloc’ [-Werror=implicit-function-declaration]
>   102 |                 fields[i] = devm_regmap_field_alloc(dev, regmap, field);
>       |                             ^~~~~~~~~~~~~~~~~~~~~~~
> ../drivers/mux/mmio.c:76:34: warning: unused variable ‘field’ [-Wunused-variable]
>    76 |                 struct reg_field field;
>       |                                  ^~~~~
> 
> REGMAP is normally "selected", but that causes a recursive dependency.
> But since REGMAP is "depended on" in other places, do so here as well.
> The (implicit) REGMAP dependency was lost when the strict dependency
> on MFD_SYSCON was removed.
> 
> Reported by: Randy Dunlap <rdunlap@infradead.org>
> Fixes: 8ecfaca7926f ("mux: mmio: add generic regmap bitfield-based multiplexer")
> Link: https://lore.kernel.org/lkml/64cf625b-2495-2382-0331-519d1cab0adf@infradead.org/
> Signed-off-by: Peter Rosin <peda@axentia.se>
> ---
>  drivers/mux/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> Note, there is a patch in linux-next that removes "|| COMPILE_TEST" from the
> pre-existing depends.
> 
> Cheers,
> Peter
> 
> diff --git a/drivers/mux/Kconfig b/drivers/mux/Kconfig
> index 80f015cf6e54..7f07ca06eb2b 100644
> --- a/drivers/mux/Kconfig
> +++ b/drivers/mux/Kconfig
> @@ -48,6 +48,7 @@ config MUX_GPIO
>  config MUX_MMIO
>  	tristate "MMIO/Regmap register bitfield-controlled Multiplexer"
>  	depends on OF
> +	depends on REGMAP

REGMAP is mostly selected, not depended on, so preferably

	select REGMAP

here whenever this patch is ready to be merged.

>  	help
>  	  MMIO/Regmap register bitfield-controlled Multiplexer controller.
>  

thanks.
  
Peter Rosin June 11, 2023, 9:04 p.m. UTC | #2
Hi!

2023-06-11 at 22:59, Randy Dunlap wrote:
> On 5/24/23 05:52, Peter Rosin wrote:
>> REGMAP is normally "selected", but that causes a recursive dependency.
>> But since REGMAP is "depended on" in other places, do so here as well.
>> The (implicit) REGMAP dependency was lost when the strict dependency
>> on MFD_SYSCON was removed.

*snip*

>> diff --git a/drivers/mux/Kconfig b/drivers/mux/Kconfig
>> index 80f015cf6e54..7f07ca06eb2b 100644
>> --- a/drivers/mux/Kconfig
>> +++ b/drivers/mux/Kconfig
>> @@ -48,6 +48,7 @@ config MUX_GPIO
>>  config MUX_MMIO
>>  	tristate "MMIO/Regmap register bitfield-controlled Multiplexer"
>>  	depends on OF
>> +	depends on REGMAP
> 
> REGMAP is mostly selected, not depended on, so preferably
> 
> 	select REGMAP
> 
> here whenever this patch is ready to be merged.

I would have preferred that as well, and if that was without problems I
would not be so hesitant as there are really few pre-existing "depends
on REGMAP".

I do not know what to do here and am not sure whom to ask for guidance.

Cheers,
Peter
  
Randy Dunlap June 11, 2023, 9:13 p.m. UTC | #3
On 6/11/23 14:04, Peter Rosin wrote:
> Hi!
> 
> 2023-06-11 at 22:59, Randy Dunlap wrote:
>> On 5/24/23 05:52, Peter Rosin wrote:
>>> REGMAP is normally "selected", but that causes a recursive dependency.
>>> But since REGMAP is "depended on" in other places, do so here as well.
>>> The (implicit) REGMAP dependency was lost when the strict dependency
>>> on MFD_SYSCON was removed.
> 
> *snip*
> 
>>> diff --git a/drivers/mux/Kconfig b/drivers/mux/Kconfig
>>> index 80f015cf6e54..7f07ca06eb2b 100644
>>> --- a/drivers/mux/Kconfig
>>> +++ b/drivers/mux/Kconfig
>>> @@ -48,6 +48,7 @@ config MUX_GPIO
>>>  config MUX_MMIO
>>>  	tristate "MMIO/Regmap register bitfield-controlled Multiplexer"
>>>  	depends on OF
>>> +	depends on REGMAP
>>
>> REGMAP is mostly selected, not depended on, so preferably
>>
>> 	select REGMAP
>>
>> here whenever this patch is ready to be merged.
> 
> I would have preferred that as well, and if that was without problems I
> would not be so hesitant as there are really few pre-existing "depends
> on REGMAP".
> 
> I do not know what to do here and am not sure whom to ask for guidance.

Oh, I did not recall all of that, but now that  you mention it, I do remember
that problem (cyclic dependencies...).
Sorry about that.
  

Patch

diff --git a/drivers/mux/Kconfig b/drivers/mux/Kconfig
index 80f015cf6e54..7f07ca06eb2b 100644
--- a/drivers/mux/Kconfig
+++ b/drivers/mux/Kconfig
@@ -48,6 +48,7 @@  config MUX_GPIO
 config MUX_MMIO
 	tristate "MMIO/Regmap register bitfield-controlled Multiplexer"
 	depends on OF
+	depends on REGMAP
 	help
 	  MMIO/Regmap register bitfield-controlled Multiplexer controller.