Skip to content

Commit c55befc

Browse files
arndbgregkh
authored andcommitted
iio: stm32: fix adc/trigger link error
commit 6d745ee upstream. The ADC driver can trigger on either the timer or the lptim trigger, but it only uses a Kconfig 'select' statement to ensure that the first of the two is present. When the lptim trigger is enabled as a loadable module, and the adc driver is built-in, we now get a link error: drivers/iio/adc/stm32-adc.o: In function `stm32_adc_get_trig_extsel': stm32-adc.c:(.text+0x4e0): undefined reference to `is_stm32_lptim_trigger' We could use a second 'select' statement and always have both trigger drivers enabled when the adc driver is, but it seems that the lptimer trigger was intentionally left optional, so it seems better to keep it that way. This adds a hack to use 'IS_REACHABLE()' rather than 'IS_ENABLED()', which avoids the link error, but instead leads to the lptimer trigger not being used in the broken configuration. I've added a runtime warning for this case to help users figure out what they did wrong if this should ever be done by accident. Fixes: f0b638a ("iio: adc: stm32: add support for lptimer triggers") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c5a5c47 commit c55befc

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎include/linux/iio/timer/stm32-lptim-trigger.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@
1616
#define LPTIM2_OUT "lptim2_out"
1717
#define LPTIM3_OUT "lptim3_out"
1818

19-
#if IS_ENABLED(CONFIG_IIO_STM32_LPTIMER_TRIGGER)
19+
#if IS_REACHABLE(CONFIG_IIO_STM32_LPTIMER_TRIGGER)
2020
bool is_stm32_lptim_trigger(struct iio_trigger *trig);
2121
#else
2222
static inline bool is_stm32_lptim_trigger(struct iio_trigger *trig)
2323
{
24+
#if IS_ENABLED(CONFIG_IIO_STM32_LPTIMER_TRIGGER)
25+
pr_warn_once("stm32 lptim_trigger not linked in\n");
26+
#endif
2427
return false;
2528
}
2629
#endif

0 commit comments

Comments
 (0)