diff mbox series

ALSA: pcm: use bit field on snd_pcm

Message ID 878s9m212i.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
State New, archived
Headers show
Series ALSA: pcm: use bit field on snd_pcm | expand

Commit Message

Kuninori Morimoto Dec. 25, 2020, 12:21 a.m. UTC
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

snd_pcm's internal, nonatomic, no_device_suspend are defined as bool.
But we can reduce struct size if we use bit field for these.
This patch converts these.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/pcm.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Takashi Iwai Dec. 25, 2020, 8:02 a.m. UTC | #1
On Fri, 25 Dec 2020 01:21:43 +0100,
Kuninori Morimoto wrote:
> 
> 
> From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
> 
> snd_pcm's internal, nonatomic, no_device_suspend are defined as bool.
> But we can reduce struct size if we use bit field for these.
> This patch converts these.
> 
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>

Practically seen, this doesn't reduce the struct size at all, as bool
is usually a byte type.  And, a byte access is even better from the
performance and concurrency POV.

So, unless there is any better reason, I don't think it worth to
switch to bit fields.


thanks,

Takashi

> ---
>  include/sound/pcm.h | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/include/sound/pcm.h b/include/sound/pcm.h
> index 2336bf9243e1..e836741d2708 100644
> --- a/include/sound/pcm.h
> +++ b/include/sound/pcm.h
> @@ -520,12 +520,13 @@ struct snd_pcm {
>  	wait_queue_head_t open_wait;
>  	void *private_data;
>  	void (*private_free) (struct snd_pcm *pcm);
> -	bool internal; /* pcm is for internal use only */
> -	bool nonatomic; /* whole PCM operations are in non-atomic context */
> -	bool no_device_suspend; /* don't invoke device PM suspend */
>  #if IS_ENABLED(CONFIG_SND_PCM_OSS)
>  	struct snd_pcm_oss oss;
>  #endif
> +	/* bit field */
> +	unsigned int internal:1; /* pcm is for internal use only */
> +	unsigned int nonatomic:1; /* whole PCM operations are in non-atomic context */
> +	unsigned int no_device_suspend:1; /* don't invoke device PM suspend */
>  };
>  
>  /*
> -- 
> 2.25.1
>
diff mbox series

Patch

diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 2336bf9243e1..e836741d2708 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -520,12 +520,13 @@  struct snd_pcm {
 	wait_queue_head_t open_wait;
 	void *private_data;
 	void (*private_free) (struct snd_pcm *pcm);
-	bool internal; /* pcm is for internal use only */
-	bool nonatomic; /* whole PCM operations are in non-atomic context */
-	bool no_device_suspend; /* don't invoke device PM suspend */
 #if IS_ENABLED(CONFIG_SND_PCM_OSS)
 	struct snd_pcm_oss oss;
 #endif
+	/* bit field */
+	unsigned int internal:1; /* pcm is for internal use only */
+	unsigned int nonatomic:1; /* whole PCM operations are in non-atomic context */
+	unsigned int no_device_suspend:1; /* don't invoke device PM suspend */
 };
 
 /*