* [PATCH] ASoC: core: Convert single bit wide bitfields into bools
@ 2012-02-08 18:58 Mark Brown
2012-02-08 19:08 ` Trent Piepho
0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2012-02-08 18:58 UTC (permalink / raw)
To: Liam Girdwood; +Cc: alsa-devel, patches, Mark Brown
It's what they are, we've just been using these for historical reasons.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
include/sound/soc-dai.h | 12 ++++++------
include/sound/soc-dapm.h | 26 +++++++++++++-------------
include/sound/soc.h | 32 ++++++++++++++++----------------
3 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index 1a2b08c..53f9a1f 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -208,7 +208,7 @@ struct snd_soc_dai_driver {
/* DAI capabilities */
struct snd_soc_pcm_stream capture;
struct snd_soc_pcm_stream playback;
- unsigned int symmetric_rates:1;
+ bool symmetric_rates;
/* probe ordering - for components with runtime dependencies */
int probe_order;
@@ -230,13 +230,13 @@ struct snd_soc_dai {
struct snd_soc_dai_driver *driver;
/* DAI runtime info */
- unsigned int capture_active:1; /* stream is in use */
- unsigned int playback_active:1; /* stream is in use */
- unsigned int symmetric_rates:1;
+ bool capture_active; /* stream is in use */
+ bool playback_active; /* stream is in use */
+ bool symmetric_rates;
struct snd_pcm_runtime *runtime;
unsigned int active;
- unsigned char pop_wait:1;
- unsigned char probed:1;
+ bool pop_wait;
+ bool probed;
/* DAI DMA data */
void *playback_dma_data;
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index db8435a..99661c0 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -456,9 +456,9 @@ struct snd_soc_dapm_path {
struct snd_kcontrol *kcontrol;
/* status */
- u32 connect:1; /* source and sink widgets are connected */
- u32 walked:1; /* path has been walked */
- u32 weak:1; /* path ignored for power management */
+ bool connect; /* source and sink widgets are connected */
+ bool walked; /* path has been walked */
+ bool weak; /* path ignored for power management */
int (*connected)(struct snd_soc_dapm_widget *source,
struct snd_soc_dapm_widget *sink);
@@ -488,16 +488,16 @@ struct snd_soc_dapm_widget {
unsigned int mask; /* non-shifted mask */
unsigned int on_val; /* on state value */
unsigned int off_val; /* off state value */
- unsigned char power:1; /* block power status */
- unsigned char invert:1; /* invert the power bit */
- unsigned char active:1; /* active stream on DAC, ADC's */
- unsigned char connected:1; /* connected codec pin */
- unsigned char new:1; /* cnew complete */
- unsigned char ext:1; /* has external widgets */
- unsigned char force:1; /* force state */
- unsigned char ignore_suspend:1; /* kept enabled over suspend */
- unsigned char new_power:1; /* power from this run */
- unsigned char power_checked:1; /* power checked this run */
+ bool power; /* block power status */
+ bool invert; /* invert the power bit */
+ bool active; /* active stream on DAC, ADC's */
+ bool connected; /* connected codec pin */
+ bool new; /* cnew complete */
+ bool ext; /* has external widgets */
+ bool force; /* force state */
+ bool ignore_suspend; /* kept enabled over suspend */
+ bool new_power; /* power from this run */
+ bool power_checked; /* power checked this run */
int subseq; /* sort within widget type */
int (*power_check)(struct snd_soc_dapm_widget *w);
diff --git a/include/sound/soc.h b/include/sound/soc.h
index d1e7a6a..466b1f3 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -571,14 +571,14 @@ struct snd_soc_codec {
/* runtime */
struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */
unsigned int active;
- unsigned int cache_bypass:1; /* Suppress access to the cache */
- unsigned int suspended:1; /* Codec is in suspend PM state */
- unsigned int probed:1; /* Codec has been probed */
- unsigned int ac97_registered:1; /* Codec has been AC97 registered */
- unsigned int ac97_created:1; /* Codec has been created by SoC */
- unsigned int sysfs_registered:1; /* codec has been sysfs registered */
- unsigned int cache_init:1; /* codec cache has been initialized */
- unsigned int using_regmap:1; /* using regmap access */
+ bool cache_bypass; /* Suppress access to the cache */
+ bool suspended; /* Codec is in suspend PM state */
+ bool probed; /* Codec has been probed */
+ bool ac97_registered; /* Codec has been AC97 registered */
+ bool ac97_created; /* Codec has been created by SoC */
+ bool sysfs_registered; /* codec has been sysfs registered */
+ bool cache_init; /* codec cache has been initialized */
+ bool using_regmap; /* using regmap access */
u32 cache_only; /* Suppress writes to hardware */
u32 cache_sync; /* Cache needs to be synced to hardware */
@@ -598,7 +598,7 @@ struct snd_soc_codec {
/* dapm */
struct snd_soc_dapm_context dapm;
- unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */
+ bool ignore_pmdown_time; /* pmdown_time is ignored at stop */
#ifdef CONFIG_DEBUG_FS
struct dentry *debugfs_codec_root;
@@ -712,8 +712,8 @@ struct snd_soc_platform {
struct device *dev;
struct snd_soc_platform_driver *driver;
- unsigned int suspended:1; /* platform is suspended */
- unsigned int probed:1;
+ bool suspended; /* platform is suspended */
+ bool probed;
struct snd_soc_card *card;
struct list_head list;
@@ -737,13 +737,13 @@ struct snd_soc_dai_link {
unsigned int dai_fmt; /* format to set on init */
/* Keep DAI active over suspend */
- unsigned int ignore_suspend:1;
+ bool ignore_suspend;
/* Symmetry requirements */
- unsigned int symmetric_rates:1;
+ bool symmetric_rates;
/* pmdown_time is ignored at stop */
- unsigned int ignore_pmdown_time:1;
+ bool ignore_pmdown_time;
/* codec/machine specific init - e.g. add machine controls */
int (*init)(struct snd_soc_pcm_runtime *rtd);
@@ -876,8 +876,8 @@ struct snd_soc_pcm_runtime {
enum snd_soc_pcm_subclass pcm_subclass;
struct snd_pcm_ops ops;
- unsigned int complete:1;
- unsigned int dev_registered:1;
+ bool complete;
+ bool dev_registered;
long pmdown_time;
--
1.7.9.rc1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: core: Convert single bit wide bitfields into bools
2012-02-08 18:58 [PATCH] ASoC: core: Convert single bit wide bitfields into bools Mark Brown
@ 2012-02-08 19:08 ` Trent Piepho
2012-02-08 19:13 ` Mark Brown
0 siblings, 1 reply; 5+ messages in thread
From: Trent Piepho @ 2012-02-08 19:08 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, patches, Liam Girdwood
Aren't you increasing the size of some of these structs considerably?
On Wed, Feb 8, 2012 at 1:58 PM, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> It's what they are, we've just been using these for historical reasons.
>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
> include/sound/soc-dai.h | 12 ++++++------
> include/sound/soc-dapm.h | 26 +++++++++++++-------------
> include/sound/soc.h | 32 ++++++++++++++++----------------
> 3 files changed, 35 insertions(+), 35 deletions(-)
>
> diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
> index 1a2b08c..53f9a1f 100644
> --- a/include/sound/soc-dai.h
> +++ b/include/sound/soc-dai.h
> @@ -208,7 +208,7 @@ struct snd_soc_dai_driver {
> /* DAI capabilities */
> struct snd_soc_pcm_stream capture;
> struct snd_soc_pcm_stream playback;
> - unsigned int symmetric_rates:1;
> + bool symmetric_rates;
>
> /* probe ordering - for components with runtime dependencies */
> int probe_order;
> @@ -230,13 +230,13 @@ struct snd_soc_dai {
> struct snd_soc_dai_driver *driver;
>
> /* DAI runtime info */
> - unsigned int capture_active:1; /* stream is in use */
> - unsigned int playback_active:1; /* stream is in use */
> - unsigned int symmetric_rates:1;
> + bool capture_active; /* stream is in use */
> + bool playback_active; /* stream is in use */
> + bool symmetric_rates;
> struct snd_pcm_runtime *runtime;
> unsigned int active;
> - unsigned char pop_wait:1;
> - unsigned char probed:1;
> + bool pop_wait;
> + bool probed;
>
> /* DAI DMA data */
> void *playback_dma_data;
> diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
> index db8435a..99661c0 100644
> --- a/include/sound/soc-dapm.h
> +++ b/include/sound/soc-dapm.h
> @@ -456,9 +456,9 @@ struct snd_soc_dapm_path {
> struct snd_kcontrol *kcontrol;
>
> /* status */
> - u32 connect:1; /* source and sink widgets are connected */
> - u32 walked:1; /* path has been walked */
> - u32 weak:1; /* path ignored for power management */
> + bool connect; /* source and sink widgets are connected */
> + bool walked; /* path has been walked */
> + bool weak; /* path ignored for power management */
>
> int (*connected)(struct snd_soc_dapm_widget *source,
> struct snd_soc_dapm_widget *sink);
> @@ -488,16 +488,16 @@ struct snd_soc_dapm_widget {
> unsigned int mask; /* non-shifted mask */
> unsigned int on_val; /* on state value */
> unsigned int off_val; /* off state value */
> - unsigned char power:1; /* block power status */
> - unsigned char invert:1; /* invert the power bit */
> - unsigned char active:1; /* active stream on DAC, ADC's */
> - unsigned char connected:1; /* connected codec pin */
> - unsigned char new:1; /* cnew complete */
> - unsigned char ext:1; /* has external widgets */
> - unsigned char force:1; /* force state */
> - unsigned char ignore_suspend:1; /* kept enabled over suspend */
> - unsigned char new_power:1; /* power from this run */
> - unsigned char power_checked:1; /* power checked this run */
> + bool power; /* block power status */
> + bool invert; /* invert the power bit */
> + bool active; /* active stream on DAC, ADC's */
> + bool connected; /* connected codec pin */
> + bool new; /* cnew complete */
> + bool ext; /* has external widgets */
> + bool force; /* force state */
> + bool ignore_suspend; /* kept enabled over suspend */
> + bool new_power; /* power from this run */
> + bool power_checked; /* power checked this run */
> int subseq; /* sort within widget type */
>
> int (*power_check)(struct snd_soc_dapm_widget *w);
> diff --git a/include/sound/soc.h b/include/sound/soc.h
> index d1e7a6a..466b1f3 100644
> --- a/include/sound/soc.h
> +++ b/include/sound/soc.h
> @@ -571,14 +571,14 @@ struct snd_soc_codec {
> /* runtime */
> struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */
> unsigned int active;
> - unsigned int cache_bypass:1; /* Suppress access to the cache */
> - unsigned int suspended:1; /* Codec is in suspend PM state */
> - unsigned int probed:1; /* Codec has been probed */
> - unsigned int ac97_registered:1; /* Codec has been AC97 registered */
> - unsigned int ac97_created:1; /* Codec has been created by SoC */
> - unsigned int sysfs_registered:1; /* codec has been sysfs registered */
> - unsigned int cache_init:1; /* codec cache has been initialized */
> - unsigned int using_regmap:1; /* using regmap access */
> + bool cache_bypass; /* Suppress access to the cache */
> + bool suspended; /* Codec is in suspend PM state */
> + bool probed; /* Codec has been probed */
> + bool ac97_registered; /* Codec has been AC97 registered */
> + bool ac97_created; /* Codec has been created by SoC */
> + bool sysfs_registered; /* codec has been sysfs registered */
> + bool cache_init; /* codec cache has been initialized */
> + bool using_regmap; /* using regmap access */
> u32 cache_only; /* Suppress writes to hardware */
> u32 cache_sync; /* Cache needs to be synced to hardware */
>
> @@ -598,7 +598,7 @@ struct snd_soc_codec {
>
> /* dapm */
> struct snd_soc_dapm_context dapm;
> - unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */
> + bool ignore_pmdown_time; /* pmdown_time is ignored at stop */
>
> #ifdef CONFIG_DEBUG_FS
> struct dentry *debugfs_codec_root;
> @@ -712,8 +712,8 @@ struct snd_soc_platform {
> struct device *dev;
> struct snd_soc_platform_driver *driver;
>
> - unsigned int suspended:1; /* platform is suspended */
> - unsigned int probed:1;
> + bool suspended; /* platform is suspended */
> + bool probed;
>
> struct snd_soc_card *card;
> struct list_head list;
> @@ -737,13 +737,13 @@ struct snd_soc_dai_link {
> unsigned int dai_fmt; /* format to set on init */
>
> /* Keep DAI active over suspend */
> - unsigned int ignore_suspend:1;
> + bool ignore_suspend;
>
> /* Symmetry requirements */
> - unsigned int symmetric_rates:1;
> + bool symmetric_rates;
>
> /* pmdown_time is ignored at stop */
> - unsigned int ignore_pmdown_time:1;
> + bool ignore_pmdown_time;
>
> /* codec/machine specific init - e.g. add machine controls */
> int (*init)(struct snd_soc_pcm_runtime *rtd);
> @@ -876,8 +876,8 @@ struct snd_soc_pcm_runtime {
> enum snd_soc_pcm_subclass pcm_subclass;
> struct snd_pcm_ops ops;
>
> - unsigned int complete:1;
> - unsigned int dev_registered:1;
> + bool complete;
> + bool dev_registered;
>
> long pmdown_time;
>
> --
> 1.7.9.rc1
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: core: Convert single bit wide bitfields into bools
2012-02-08 19:08 ` Trent Piepho
@ 2012-02-08 19:13 ` Mark Brown
2012-02-08 19:52 ` Trent Piepho
0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2012-02-08 19:13 UTC (permalink / raw)
To: Trent Piepho; +Cc: alsa-devel, patches, Liam Girdwood
[-- Attachment #1.1: Type: text/plain, Size: 308 bytes --]
On Wed, Feb 08, 2012 at 02:08:05PM -0500, Trent Piepho wrote:
Don't top post and trim the context from your replies. This is basic
stuff...
> Aren't you increasing the size of some of these structs considerably?
Hrm, possibly. I'd rather have hoped that the bool type would work a
bit more sanely here.
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: core: Convert single bit wide bitfields into bools
2012-02-08 19:13 ` Mark Brown
@ 2012-02-08 19:52 ` Trent Piepho
2012-02-08 20:05 ` Mark Brown
0 siblings, 1 reply; 5+ messages in thread
From: Trent Piepho @ 2012-02-08 19:52 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, patches, Liam Girdwood
On Wed, Feb 8, 2012 at 2:13 PM, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> On Wed, Feb 08, 2012 at 02:08:05PM -0500, Trent Piepho wrote:
>> Aren't you increasing the size of some of these structs considerably?
>
> Hrm, possibly. I'd rather have hoped that the bool type would work a
> bit more sanely here.
Linux defines bool as _Bool, which is a native type from C99. _Bools
in structs appear to be the same as unsigned char. They each take one
byte and have an alignment of one.
So in this struct:
@@ -208,7 +208,7 @@ struct snd_soc_dai_driver {
/* DAI capabilities */
struct snd_soc_pcm_stream capture;
struct snd_soc_pcm_stream playback;
- unsigned int symmetric_rates:1;
+ bool symmetric_rates;
/* probe ordering - for components with runtime dependencies */
int probe_order;
Changing from a bitfield to a bool doesn't make any difference, since
both will consume 4 bytes as the int probe_order will need that for
alignment. Of course it might be possible to have less passing space
by placing the bool or bitfield near other < 4 bytes members.
This struct:
@@ -230,13 +230,13 @@ struct snd_soc_dai {
struct snd_soc_dai_driver *driver;
/* DAI runtime info */
- unsigned int capture_active:1; /* stream is in use */
- unsigned int playback_active:1; /* stream is in use */
- unsigned int symmetric_rates:1;
+ bool capture_active; /* stream is in use */
+ bool playback_active; /* stream is in use */
+ bool symmetric_rates;
struct snd_pcm_runtime *runtime;
unsigned int active;
- unsigned char pop_wait:1;
- unsigned char probed:1;
+ bool pop_wait;
+ bool probed;
Doesn't actually take more space either, 8 bytes total. But if it was
re-ordered so these bitfields were all together then bitfields with
take four bytes vs 8 for the bools.
This struct on the other hand:
@@ -488,16 +488,16 @@ struct snd_soc_dapm_widget {
unsigned int mask; /* non-shifted mask */
unsigned int on_val; /* on state value */
unsigned int off_val; /* off state value */
- unsigned char power:1; /* block power status */
- unsigned char invert:1; /* invert the power bit */
- unsigned char active:1; /* active stream on
DAC, ADC's */
- unsigned char connected:1; /* connected codec pin */
- unsigned char new:1; /* cnew complete */
- unsigned char ext:1; /* has external widgets */
- unsigned char force:1; /* force state */
- unsigned char ignore_suspend:1; /* kept enabled over suspend */
- unsigned char new_power:1; /* power from this run */
- unsigned char power_checked:1; /* power checked this run */
+ bool power; /* block power status */
+ bool invert; /* invert the power bit */
+ bool active; /* active stream on
DAC, ADC's */
+ bool connected; /* connected codec pin */
+ bool new; /* cnew complete */
+ bool ext; /* has external widgets */
+ bool force; /* force state */
+ bool ignore_suspend; /* kept enabled over suspend */
+ bool new_power; /* power from this run */
+ bool power_checked; /* power checked this run */
int subseq; /* sort within widget type */
It uses 12 bytes for bools and 4 for bitfields.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: core: Convert single bit wide bitfields into bools
2012-02-08 19:52 ` Trent Piepho
@ 2012-02-08 20:05 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2012-02-08 20:05 UTC (permalink / raw)
To: Trent Piepho; +Cc: alsa-devel, patches, Liam Girdwood
[-- Attachment #1.1: Type: text/plain, Size: 312 bytes --]
On Wed, Feb 08, 2012 at 02:52:49PM -0500, Trent Piepho wrote:
> Linux defines bool as _Bool, which is a native type from C99. _Bools
> in structs appear to be the same as unsigned char. They each take one
> byte and have an alignment of one.
Well, that's a bit of a failure isn't it? Let's not bother then.
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-02-08 20:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-08 18:58 [PATCH] ASoC: core: Convert single bit wide bitfields into bools Mark Brown
2012-02-08 19:08 ` Trent Piepho
2012-02-08 19:13 ` Mark Brown
2012-02-08 19:52 ` Trent Piepho
2012-02-08 20:05 ` Mark Brown
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).