Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Cezary Rojewski <cezary.rojewski@intel.com>
Cc: tiwai@suse.de, alsa-devel@alsa-project.org, broonie@kernel.org,
	Randy Dunlap <rdunlap@infradead.org>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Subject: Re: [RFC PATCH] ASoC: Intel: use common helpers to detect CPUs
Date: Wed, 19 Jun 2019 14:08:26 +0300	[thread overview]
Message-ID: <20190619110826.GC9224@smile.fi.intel.com> (raw)
In-Reply-To: <7ceb9ba8-74d9-4985-e760-40003dfbef3e@intel.com>

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

  reply	other threads:[~2019-06-19 11:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-28 20:02 [RFC PATCH] ASoC: Intel: use common helpers to detect CPUs Pierre-Louis Bossart
2019-05-29  5:18 ` Takashi Iwai
2019-06-17 14:47 ` Mark Brown
2019-06-17 15:31   ` Pierre-Louis Bossart
2019-06-17 16:18     ` Andy Shevchenko
2019-06-18 11:02       ` Amadeusz Sławiński
2019-06-18 19:26 ` Cezary Rojewski
2019-06-19 11:08   ` Andy Shevchenko [this message]
2019-06-19 11:52     ` Pierre-Louis Bossart
2019-06-19 13:04       ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190619110826.GC9224@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=rdunlap@infradead.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox