Skip to contentSkip to conversation

iio/adc: ingenic: fix (MIPS) ingenic-adc build errors

PATCH In review Randy Dunlap 3 participants 5 messages Nov 10, 2021 – Nov 14, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 iio/adc: ingenic: fix (MIPS) ingenic-adc build errors

MIPS does not always provide clk*() interfaces and there are no always-present stubs for them, so depending on "MIPS || COMPILE_TEST" is not strong enough to prevent build errors.

Likewise MACH_INGENIC_SOC || COMPILE_TEST is not strong enough since if only COMPILE_TEST=y (with some other MIPS MACH_ or CPU or BOARD setting), there are still the same build errors.

It looks like depending on MACH_INGENIC is the only thing that is sufficient here in order to prevent build errors.

mips-linux-ld: drivers/iio/adc/ingenic-adc.o: in function `jz4770_adc_init_clk_div':
ingenic-adc.c:(.text+0xe4): undefined reference to `clk_get_parent'
mips-linux-ld: drivers/iio/adc/ingenic-adc.o: in function `jz4725b_adc_init_clk_div':
ingenic-adc.c:(.text+0x1b8): undefined reference to `clk_get_parent'

Fixes 1a78daea107d ("IIO: add Ingenic JZ47xx ADC driver.")
Cc Artur Rojek <[email protected]>
Cc Paul Cercueil <[email protected]>
Cc Jonathan Cameron <[email protected]>
Cc Lars-Peter Clausen <[email protected]>
Cc Florian Fainelli <[email protected]>
Cc Andy Shevchenko <[email protected]>

---
v2: use MACH_INGENIC instead of MACH_INGENIC_SOC (thanks, Paul)

 drivers/iio/adc/Kconfig |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/Kconfig +1 -1
@@ -501,7 +501,7 @@ config INA2XX_ADC
 
 config INGENIC_ADC
 	tristate "Ingenic JZ47xx SoCs ADC driver"
-	depends on MIPS || COMPILE_TEST
+	depends on MACH_INGENIC
 	select IIO_BUFFER
 	help
 	  Say yes here to build support for the Ingenic JZ47xx SoCs ADC unit.
maintainer
#1 lore raw
Quoted 16 lines · On Tue, 9 Nov 2021 18:37:55 -0800 Randy Dunlap <[email protected]> wrote:

MIPS does not always provide clk*() interfaces and there are no always-present stubs for them, so depending on "MIPS || COMPILE_TEST" is not strong enough to prevent build errors.

Likewise MACH_INGENIC_SOC || COMPILE_TEST is not strong enough since if only COMPILE_TEST=y (with some other MIPS MACH_ or CPU or BOARD setting), there are still the same build errors.

It looks like depending on MACH_INGENIC is the only thing that is sufficient here in order to prevent build errors.

mips-linux-ld: drivers/iio/adc/ingenic-adc.o: in function `jz4770_adc_init_clk_div':
ingenic-adc.c:(.text+0xe4): undefined reference to `clk_get_parent'
mips-linux-ld: drivers/iio/adc/ingenic-adc.o: in function `jz4725b_adc_init_clk_div':
ingenic-adc.c:(.text+0x1b8): undefined reference to `clk_get_parent'

Quoted 11 lines
Fixes 1a78daea107d ("IIO: add Ingenic JZ47xx ADC driver.")
Cc Artur Rojek <[email protected]>
Cc Paul Cercueil <[email protected]>
Cc Jonathan Cameron <[email protected]>
Cc Lars-Peter Clausen <[email protected]>
Cc Florian Fainelli <[email protected]>
Cc Andy Shevchenko <[email protected]>

I'm a bit confused. There are stubs in include/linux/clk.h for these. Why do those not apply here? Are these platforms built with CONFIG_CLK but don't provide all the functions?

That sounds highly error prone and rather defeats the object of the stubs. Could we either provide the missing stubs, or solve this some other way. I'm not keen to massively cut the build coverage this driver is getting by dropping COMPILE_TEST if there is any route to avoid doing so.

Based on the guess than any platform with clks must be able to turn them on I grepped for int clk_enable() and there seem to be only two possiblities bcm63xx and lantiq as sources of the build breakage.

Jonathan

Quoted 17 lines

---
v2: use MACH_INGENIC instead of MACH_INGENIC_SOC (thanks, Paul)

 drivers/iio/adc/Kconfig |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/Kconfig +1 -1
@@ -501,7 +501,7 @@ config INA2XX_ADC
 
 config INGENIC_ADC
 	tristate "Ingenic JZ47xx SoCs ADC driver"
-	depends on MIPS || COMPILE_TEST
+	depends on MACH_INGENIC
 	select IIO_BUFFER
 	help
 	  Say yes here to build support for the Ingenic JZ47xx SoCs ADC unit.
#2 lore raw
Quoted 31 lines · Jonathan Cameron
Quoted 16 lines · On Tue, 9 Nov 2021 18:37:55 -0800 Randy Dunlap <[email protected]> wrote:

MIPS does not always provide clk*() interfaces and there are no always-present stubs for them, so depending on "MIPS || COMPILE_TEST" is not strong enough to prevent build errors.

Likewise MACH_INGENIC_SOC || COMPILE_TEST is not strong enough since if only COMPILE_TEST=y (with some other MIPS MACH_ or CPU or BOARD setting), there are still the same build errors.

It looks like depending on MACH_INGENIC is the only thing that is sufficient here in order to prevent build errors.

mips-linux-ld: drivers/iio/adc/ingenic-adc.o: in function `jz4770_adc_init_clk_div':
ingenic-adc.c:(.text+0xe4): undefined reference to `clk_get_parent'
mips-linux-ld: drivers/iio/adc/ingenic-adc.o: in function `jz4725b_adc_init_clk_div':
ingenic-adc.c:(.text+0x1b8): undefined reference to `clk_get_parent'

Quoted 11 lines
Fixes 1a78daea107d ("IIO: add Ingenic JZ47xx ADC driver.")
Cc Artur Rojek <[email protected]>
Cc Paul Cercueil <[email protected]>
Cc Jonathan Cameron <[email protected]>
Cc Lars-Peter Clausen <[email protected]>
Cc Florian Fainelli <[email protected]>
Cc Andy Shevchenko <[email protected]>
Quoted 8 lines

I'm a bit confused. There are stubs in include/linux/clk.h for these. Why do those not apply here? Are these platforms built with CONFIG_CLK but don't provide all the functions?

That sounds highly error prone and rather defeats the object of the stubs. Could we either provide the missing stubs, or solve this some other way. I'm not keen to massively cut the build coverage this driver is getting by dropping COMPILE_TEST if there is any route to avoid doing so.

I'm all for that (above), but it's a mess.

Quoted 3 lines

Based on the guess than any platform with clks must be able to turn them on I grepped for int clk_enable() and there seem to be only two possiblities bcm63xx and lantiq as sources of the build breakage.

CONFIG_BCM63XX=y
# CONFIG_MACH_INGENIC_SOC is not set
CONFIG_INGENIC_ADC=y
CONFIG_HAVE_CLK=y

According to the build error messages (above), clk_get_parent() is missing. Looking at <linux/clk.h>, for CONFIG_HAVE_CLK=y, there is a prototype for clk_get_parent(), and if CONFIG_HAVE_CLK is not set, there is a stub for it.

Now look at drivers/clk/clk.c and drivers/clk/Makefile:

clk_get_parent() is defined in clk.c, which is built when CONFIG_COMMON_CLK=y, but that is not set in this .config file.

CONFIG_HAVE_CLK=y, but that doesn't get clk_get_parent() compiled.

So to me it is a disparity or incongruity between HAVE_CLK and COMMON_CLK.

Russell- do you have any suggestions for how to straighten this out?

Quoted 20 lines

Jonathan

Quoted 17 lines

---
v2: use MACH_INGENIC instead of MACH_INGENIC_SOC (thanks, Paul)

  drivers/iio/adc/Kconfig |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/Kconfig +1 -1
@@ -501,7 +501,7 @@ config INA2XX_ADC
 
  config INGENIC_ADC
  	tristate "Ingenic JZ47xx SoCs ADC driver"
-	depends on MIPS || COMPILE_TEST
+	depends on MACH_INGENIC
  	select IIO_BUFFER
  	help
  	  Say yes here to build support for the Ingenic JZ47xx SoCs ADC unit.
Signature · 1 line
~Randy
#3 lore raw
Quoted 60 lines · Randy Dunlap
Quoted 31 lines · Jonathan Cameron
Quoted 16 lines · On Tue, 9 Nov 2021 18:37:55 -0800 Randy Dunlap <[email protected]> wrote:

MIPS does not always provide clk*() interfaces and there are no always-present stubs for them, so depending on "MIPS || COMPILE_TEST" is not strong enough to prevent build errors.

Likewise MACH_INGENIC_SOC || COMPILE_TEST is not strong enough since if only COMPILE_TEST=y (with some other MIPS MACH_ or CPU or BOARD setting), there are still the same build errors.

It looks like depending on MACH_INGENIC is the only thing that is sufficient here in order to prevent build errors.

mips-linux-ld: drivers/iio/adc/ingenic-adc.o: in function `jz4770_adc_init_clk_div':
ingenic-adc.c:(.text+0xe4): undefined reference to `clk_get_parent'
mips-linux-ld: drivers/iio/adc/ingenic-adc.o: in function `jz4725b_adc_init_clk_div':
ingenic-adc.c:(.text+0x1b8): undefined reference to `clk_get_parent'

Quoted 11 lines
Fixes 1a78daea107d ("IIO: add Ingenic JZ47xx ADC driver.")
Cc Artur Rojek <[email protected]>
Cc Paul Cercueil <[email protected]>
Cc Jonathan Cameron <[email protected]>
Cc Lars-Peter Clausen <[email protected]>
Cc Florian Fainelli <[email protected]>
Cc Andy Shevchenko <[email protected]>
Quoted 8 lines

I'm a bit confused. There are stubs in include/linux/clk.h for these. Why do those not apply here? Are these platforms built with CONFIG_CLK but don't provide all the functions?

That sounds highly error prone and rather defeats the object of the stubs. Could we either provide the missing stubs, or solve this some other way. I'm not keen to massively cut the build coverage this driver is getting by dropping COMPILE_TEST if there is any route to avoid doing so.

I'm all for that (above), but it's a mess.

Quoted 3 lines

Based on the guess than any platform with clks must be able to turn them on I grepped for int clk_enable() and there seem to be only two possiblities bcm63xx and lantiq as sources of the build breakage.

CONFIG_BCM63XX=y
# CONFIG_MACH_INGENIC_SOC is not set
CONFIG_INGENIC_ADC=y
CONFIG_HAVE_CLK=y

According to the build error messages (above), clk_get_parent() is missing. Looking at <linux/clk.h>, for CONFIG_HAVE_CLK=y, there is a prototype for clk_get_parent(), and if CONFIG_HAVE_CLK is not set, there is a stub for it.

Now look at drivers/clk/clk.c and drivers/clk/Makefile:

Quoted 7 lines

clk_get_parent() is defined in clk.c, which is built when CONFIG_COMMON_CLK=y, but that is not set in this .config file.

CONFIG_HAVE_CLK=y, but that doesn't get clk_get_parent() compiled.

So to me it is a disparity or incongruity between HAVE_CLK and COMMON_CLK.

HAVE_CLK means we have the clk API implemented. COMMON_CLK is one such implementation, and HAVE_LEGACY_CLK is another group of implementations.

BCM63XX has its own implementation and uses HAVE_LEGACY_CLK, which can be found in arch/mips/bcm63xx/clk.c.

If it doesn't support parent clocks, then it should provide a stub clk_get_parent() that returns NULL at the very least.

Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
#4 lore raw
Quoted 69 lines · Russell King (Oracle)
Quoted 60 lines · Randy Dunlap
Quoted 31 lines · Jonathan Cameron
Quoted 16 lines · On Tue, 9 Nov 2021 18:37:55 -0800 Randy Dunlap <[email protected]> wrote:

MIPS does not always provide clk*() interfaces and there are no always-present stubs for them, so depending on "MIPS || COMPILE_TEST" is not strong enough to prevent build errors.

Likewise MACH_INGENIC_SOC || COMPILE_TEST is not strong enough since if only COMPILE_TEST=y (with some other MIPS MACH_ or CPU or BOARD setting), there are still the same build errors.

It looks like depending on MACH_INGENIC is the only thing that is sufficient here in order to prevent build errors.

mips-linux-ld: drivers/iio/adc/ingenic-adc.o: in function `jz4770_adc_init_clk_div':
ingenic-adc.c:(.text+0xe4): undefined reference to `clk_get_parent'
mips-linux-ld: drivers/iio/adc/ingenic-adc.o: in function `jz4725b_adc_init_clk_div':
ingenic-adc.c:(.text+0x1b8): undefined reference to `clk_get_parent'

Quoted 11 lines
Fixes 1a78daea107d ("IIO: add Ingenic JZ47xx ADC driver.")
Cc Artur Rojek <[email protected]>
Cc Paul Cercueil <[email protected]>
Cc Jonathan Cameron <[email protected]>
Cc Lars-Peter Clausen <[email protected]>
Cc Florian Fainelli <[email protected]>
Cc Andy Shevchenko <[email protected]>
Quoted 8 lines

I'm a bit confused. There are stubs in include/linux/clk.h for these. Why do those not apply here? Are these platforms built with CONFIG_CLK but don't provide all the functions?

That sounds highly error prone and rather defeats the object of the stubs. Could we either provide the missing stubs, or solve this some other way. I'm not keen to massively cut the build coverage this driver is getting by dropping COMPILE_TEST if there is any route to avoid doing so.

I'm all for that (above), but it's a mess.

Quoted 3 lines

Based on the guess than any platform with clks must be able to turn them on I grepped for int clk_enable() and there seem to be only two possiblities bcm63xx and lantiq as sources of the build breakage.

CONFIG_BCM63XX=y
# CONFIG_MACH_INGENIC_SOC is not set
CONFIG_INGENIC_ADC=y
CONFIG_HAVE_CLK=y

According to the build error messages (above), clk_get_parent() is missing. Looking at <linux/clk.h>, for CONFIG_HAVE_CLK=y, there is a prototype for clk_get_parent(), and if CONFIG_HAVE_CLK is not set, there is a stub for it.

Now look at drivers/clk/clk.c and drivers/clk/Makefile:

Quoted 7 lines

clk_get_parent() is defined in clk.c, which is built when CONFIG_COMMON_CLK=y, but that is not set in this .config file.

CONFIG_HAVE_CLK=y, but that doesn't get clk_get_parent() compiled.

So to me it is a disparity or incongruity between HAVE_CLK and COMMON_CLK.

Quoted 9 lines

HAVE_CLK means we have the clk API implemented. COMMON_CLK is one such implementation, and HAVE_LEGACY_CLK is another group of implementations.

BCM63XX has its own implementation and uses HAVE_LEGACY_CLK, which can be found in arch/mips/bcm63xx/clk.c.

If it doesn't support parent clocks, then it should provide a stub clk_get_parent() that returns NULL at the very least.

Russell- thanks for the explanation.
That works nicely.

Jonathan, I'll send a different patch.

Signature · 1 line
~Randy