From: Takashi Iwai Subject: Re: [PATCH 2/2] ASoC: SOF: core: fix undefined nocodec reference Date: Wed, 08 May 2019 18:26:15 +0200 Message-ID: References: <20190507163236.8783-1-pierre-louis.bossart@linux.intel.com> <20190507163236.8783-3-pierre-louis.bossart@linux.intel.com> <20190508062717.GK14916@sirena.org.uk> <44be7c35-1b4d-5183-ce4a-1def4126c55f@linux.intel.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id BEDDFF8075E for ; Wed, 8 May 2019 18:26:16 +0200 (CEST) In-Reply-To: <44be7c35-1b4d-5183-ce4a-1def4126c55f@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" To: Pierre-Louis Bossart Cc: alsa-devel@alsa-project.org, Mark Brown , kbuild-all@01.org List-Id: alsa-devel@alsa-project.org On Wed, 08 May 2019 18:21:36 +0200, Pierre-Louis Bossart wrote: > > > > On 5/8/19 1:27 AM, Mark Brown wrote: > > On Tue, May 07, 2019 at 11:32:36AM -0500, Pierre-Louis Bossart wrote: > >> The existing code mistakenly uses IS_ENABLED in C code instead of as > >> in conditional compilation, leading to the following error: > > > >> ld: sound/soc/sof/core.o: in function `sof_machine_check': > >> sound/soc/sof/core.c:279: undefined reference to `sof_nocodec_setup' > > > > There's nothing wrong with using IS_ENABLED() in C code - it can be > > cleaner than using an ifdef to help the compiler eliminate unneeded > > code. > > Agree, and we do make use of it. In this case it wasn't smart though. An alternative solution in such a case is to provide the dummy function. For example, in sound/sof.h, #if IS_ENABLED(CONFIG_SND_SOC_SOF_NOCODEC) int sof_nocodec_setup(struct device *dev, struct snd_sof_pdata *sof_pdata, struct snd_soc_acpi_mach *mach, const struct sof_dev_desc *desc, const struct snd_sof_dsp_ops *ops); #else static inline int sof_nocodec_setup(struct device *dev, struct snd_sof_pdata *sof_pdata, struct snd_soc_acpi_mach *mach, const struct sof_dev_desc *desc, const struct snd_sof_dsp_ops *ops) { return -ENODEV; } #endif Which one is better depends on the context and other part of code. Takashi