alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Eldad Zack <eldad@fogrefinery.com>
Cc: alsa-devel@alsa-project.org, Daniel Mack <zonque@gmail.com>,
	Clemens Ladisch <clemens@ladisch.de>
Subject: Re: [PATCH, for-next] ALSA: usb-audio: use FMTBITs in parse_audio_format_i
Date: Mon, 22 Apr 2013 13:49:45 +0200	[thread overview]
Message-ID: <s5hk3nu4wfa.wl%tiwai@suse.de> (raw)
In-Reply-To: <alpine.LNX.2.00.1304221339450.5788@xoschi>

At Mon, 22 Apr 2013 13:47:23 +0200 (CEST),
Eldad Zack wrote:
> 
> 
> 
> On Mon, 22 Apr 2013, Takashi Iwai wrote:
> 
> > At Mon, 22 Apr 2013 13:29:41 +0200 (CEST),
> > Eldad Zack wrote:
> > > 
> > > 
> > > 
> > > On Mon, 22 Apr 2013, Takashi Iwai wrote:
> > > 
> > > > At Mon, 22 Apr 2013 01:44:04 +0200,
> > > > Eldad Zack wrote:
> > > > > 
> > > > > Replace the usage of SNDRV_PCM_FORMAT_* macros with the equivalent
> > > > > SNDRV_PCM_FMTBIT_* macros, and the result be can assigned directly
> > > > > to the formats field.
> > > > 
> > > > Note that SNDRV_PCM_FMTBIT_* are 64bit integer.  And it makes sense to
> > > > use FMTBIT only when multiple formats are supposed.  For a single
> > > > format, keeping SNDRV_PCM_FORMAT_* is more reasonable.
> > > > 
> > > > In other words, a proper fix would be to replace the type of variable
> > > > format with snd_pcm_format_t, and cast at converting to format bits
> > > > like
> > > > 	1ULL << (unsigned int)pcm_format
> > > 
> > > I see your point. I just figured making the assignment directly would
> > > make sense just for this case.
> > > 
> > > There are a couple of other places with the same conversion that 
> > > "break" the strong typing - how about something like this:
> > > 
> > > 	#define pcm_format_to_bits(fmt) (1uLL << ((__force int)(fmt)))
> > > 
> > > Or an equivalent function?
> > 
> > Yep, I just wanted to propose that :)
> 
> Cool :)
> 
> I think a function would be better so the format can be checked to use
> the correct type as well, and put it in pcm.h:
> 
> static inline u64 pcm_format_to_bits(snd_pcm_format_t pcm_format)
> {
> 	return 1ULL << (__force int) pcm_format;
> }
> 
> If that looks good I'll search for all the relevant places and change 
> them (in one patch).

It looks good.


thanks,

Takashi

  reply	other threads:[~2013-04-22 11:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-21 23:44 [PATCH, for-next] ALSA: usb-audio: use FMTBITs in parse_audio_format_i Eldad Zack
2013-04-22  8:51 ` Takashi Iwai
2013-04-22 11:29   ` Eldad Zack
2013-04-22 11:34     ` Takashi Iwai
2013-04-22 11:47       ` Eldad Zack
2013-04-22 11:49         ` Takashi Iwai [this message]
2013-04-22 23:00           ` [PATCH, for-next 1/2] ALSA: pcm_format_to_bits strong-typed conversion Eldad Zack
2013-04-22 23:00             ` [PATCH, for-next 2/2] ALSA: asihpi: add format support check in snd_card_asihpi_capture_formats Eldad Zack

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=s5hk3nu4wfa.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=eldad@fogrefinery.com \
    --cc=zonque@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).