Re: [PATCH 2/2] ASoC: SOF: core: fix undefined nocodec reference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux