[alsa-devel] [RFC PATCH] ASoC: Intel: use common helpers to detect CPUs

Andy Shevchenko andriy.shevchenko at linux.intel.com
Wed Jun 19 13:08:26 CEST 2019


On Tue, Jun 18, 2019 at 09:26:50PM +0200, Cezary Rojewski wrote:
> On 2019-05-28 22:02, Pierre-Louis Bossart wrote:
> > We have duplicated code in multiple locations (atom, machine drivers,
> > SOF) to detect Baytrail, Cherrytrail and other SOCs. This is not very
> > elegant, and introduces dependencies on CONFIG_X86 that prevent
> > COMPILE_TEST from working.
> > 
> > Add common helpers to provide same functionality in a cleaner
> > way. This will also help support the DMI-based quirks being introduced
> > to handle SOF/SST autodetection.

> > +#define ICPU(model)	{ X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, }

We have macros for this in intel-family.h.

> > +#define SOC_INTEL_IS_CPU(soc, type)				\
> > +static inline bool soc_intel_is_##soc(void)			\
> > +{								\
> > +	static const struct x86_cpu_id soc##_cpu_ids[] = {	\
> > +		ICPU(type),					\
> 
> I understand there is a separate discussion going on, hope I don't get fried
> for throwing small code review.
> 
> Consider using same arg name for both ICPU and SOC_INTEL_IS_CPU macros,
> whether it's "model" or "type". It's more readable that way.
> 
> > +		{}						\
> > +	};							\
> > +	const struct x86_cpu_id *id;				\
> > +								\
> > +	id = x86_match_cpu(soc##_cpu_ids);			\
> > +	if (id)							\
> > +		return true;					\
> > +	return false;						\
> 
> Tenary operator should prove usefull here.

In this way it is simple
	return !!x86_match_cpu(...);

No conditional needed at all.

> 
> > +}

-- 
With Best Regards,
Andy Shevchenko




More information about the Alsa-devel mailing list