Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755345AbdIFQR2 (ORCPT ); Wed, 6 Sep 2017 12:17:28 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:48240 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752462AbdIFQRY (ORCPT ); Wed, 6 Sep 2017 12:17:24 -0400 Subject: Re: [PATCH] iio: stm32: fix adc/trigger link error To: Arnd Bergmann , Jonathan Cameron CC: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Maxime Coquelin , Alexandre Torgue , Lee Jones , , , References: <20170906125722.2522781-1-arnd@arndb.de> From: Fabrice Gasnier Message-ID: <50ec54e0-85f7-8c32-475c-9b27a4e6ebd3@st.com> Date: Wed, 6 Sep 2017 18:16:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170906125722.2522781-1-arnd@arndb.de> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.75.127.50] X-ClientProxiedBy: SFHDAG6NODE1.st.com (10.75.127.16) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-09-06_06:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2204 Lines: 56 On 09/06/2017 02:56 PM, Arnd Bergmann wrote: > 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. Hi Arnd, This is correct, not all stm32 have this hardware. > > 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: f0b638a7f6db ("iio: adc: stm32: add support for lptimer triggers") > Signed-off-by: Arnd Bergmann Tested-by: Fabrice Gasnier Many thanks for the fix, Best Regards, Fabrice > --- > include/linux/iio/timer/stm32-lptim-trigger.h | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/include/linux/iio/timer/stm32-lptim-trigger.h b/include/linux/iio/timer/stm32-lptim-trigger.h > index 34d59bfdce2d..464458d20b16 100644 > --- a/include/linux/iio/timer/stm32-lptim-trigger.h > +++ b/include/linux/iio/timer/stm32-lptim-trigger.h > @@ -16,11 +16,14 @@ > #define LPTIM2_OUT "lptim2_out" > #define LPTIM3_OUT "lptim3_out" > > -#if IS_ENABLED(CONFIG_IIO_STM32_LPTIMER_TRIGGER) > +#if IS_REACHABLE(CONFIG_IIO_STM32_LPTIMER_TRIGGER) > bool is_stm32_lptim_trigger(struct iio_trigger *trig); > #else > static inline bool is_stm32_lptim_trigger(struct iio_trigger *trig) > { > +#if IS_ENABLED(CONFIG_IIO_STM32_LPTIMER_TRIGGER) > + pr_warn_once("stm32 lptim_trigger not linked in\n"); > +#endif > return false; > } > #endif >