* [PATCH] ASoC: soc-cache: Add reg_size as a member to snd_soc_codec
@ 2011-01-12 10:38 Dimitris Papastamos
2011-01-12 11:14 ` Liam Girdwood
2011-01-12 14:57 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Dimitris Papastamos @ 2011-01-12 10:38 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood; +Cc: alsa-devel, patches
Simplify the use of reg_size, by calculating it once and storing it in
the codec structure for later reference. The value of reg_size is
reg_cache_size * reg_word_size.
Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
---
include/sound/soc.h | 1 +
sound/soc/soc-cache.c | 26 ++++++++------------------
sound/soc/soc-core.c | 1 +
3 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index c477058..d609232 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -459,6 +459,7 @@ struct snd_soc_codec {
struct list_head card_list;
int num_dai;
enum snd_soc_compress_type compress_type;
+ size_t reg_size; /* reg_cache_size * reg_word_size */
/* runtime */
struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c
index 2f1d596..1a36b36 100644
--- a/sound/soc/soc-cache.c
+++ b/sound/soc/soc-cache.c
@@ -1100,34 +1100,28 @@ static inline int snd_soc_lzo_get_blkindex(struct snd_soc_codec *codec,
unsigned int reg)
{
const struct snd_soc_codec_driver *codec_drv;
- size_t reg_size;
codec_drv = codec->driver;
- reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size;
return (reg * codec_drv->reg_word_size) /
- DIV_ROUND_UP(reg_size, snd_soc_lzo_block_count());
+ DIV_ROUND_UP(codec->reg_size, snd_soc_lzo_block_count());
}
static inline int snd_soc_lzo_get_blkpos(struct snd_soc_codec *codec,
unsigned int reg)
{
const struct snd_soc_codec_driver *codec_drv;
- size_t reg_size;
codec_drv = codec->driver;
- reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size;
- return reg % (DIV_ROUND_UP(reg_size, snd_soc_lzo_block_count()) /
+ return reg % (DIV_ROUND_UP(codec->reg_size, snd_soc_lzo_block_count()) /
codec_drv->reg_word_size);
}
static inline int snd_soc_lzo_get_blksize(struct snd_soc_codec *codec)
{
const struct snd_soc_codec_driver *codec_drv;
- size_t reg_size;
codec_drv = codec->driver;
- reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size;
- return DIV_ROUND_UP(reg_size, snd_soc_lzo_block_count());
+ return DIV_ROUND_UP(codec->reg_size, snd_soc_lzo_block_count());
}
static int snd_soc_lzo_cache_sync(struct snd_soc_codec *codec)
@@ -1287,7 +1281,7 @@ static int snd_soc_lzo_cache_exit(struct snd_soc_codec *codec)
static int snd_soc_lzo_cache_init(struct snd_soc_codec *codec)
{
struct snd_soc_lzo_ctx **lzo_blocks;
- size_t reg_size, bmp_size;
+ size_t bmp_size;
const struct snd_soc_codec_driver *codec_drv;
int ret, tofree, i, blksize, blkcount;
const char *p, *end;
@@ -1295,7 +1289,6 @@ static int snd_soc_lzo_cache_init(struct snd_soc_codec *codec)
ret = 0;
codec_drv = codec->driver;
- reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size;
/*
* If we have not been given a default register cache
@@ -1307,8 +1300,7 @@ static int snd_soc_lzo_cache_init(struct snd_soc_codec *codec)
tofree = 1;
if (!codec->reg_def_copy) {
- codec->reg_def_copy = kzalloc(reg_size,
- GFP_KERNEL);
+ codec->reg_def_copy = kzalloc(codec->reg_size, GFP_KERNEL);
if (!codec->reg_def_copy)
return -ENOMEM;
}
@@ -1356,7 +1348,7 @@ static int snd_soc_lzo_cache_init(struct snd_soc_codec *codec)
blksize = snd_soc_lzo_get_blksize(codec);
p = codec->reg_def_copy;
- end = codec->reg_def_copy + reg_size;
+ end = codec->reg_def_copy + codec->reg_size;
/* compress the register map and fill the lzo blocks */
for (i = 0; i < blkcount; ++i, p += blksize) {
lzo_blocks[i]->src = p;
@@ -1441,16 +1433,14 @@ static int snd_soc_flat_cache_exit(struct snd_soc_codec *codec)
static int snd_soc_flat_cache_init(struct snd_soc_codec *codec)
{
const struct snd_soc_codec_driver *codec_drv;
- size_t reg_size;
codec_drv = codec->driver;
- reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size;
if (codec->reg_def_copy)
codec->reg_cache = kmemdup(codec->reg_def_copy,
- reg_size, GFP_KERNEL);
+ codec->reg_size, GFP_KERNEL);
else
- codec->reg_cache = kzalloc(reg_size, GFP_KERNEL);
+ codec->reg_cache = kzalloc(codec->reg_size, GFP_KERNEL);
if (!codec->reg_cache)
return -ENOMEM;
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 04475c1..cbac50b 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3500,6 +3500,7 @@ int snd_soc_register_codec(struct device *dev,
/* allocate CODEC register cache */
if (codec_drv->reg_cache_size && codec_drv->reg_word_size) {
reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size;
+ codec->reg_size = reg_size;
/* it is necessary to make a copy of the default register cache
* because in the case of using a compression type that requires
* the default register cache to be marked as __devinitconst the
--
1.7.3.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: soc-cache: Add reg_size as a member to snd_soc_codec
2011-01-12 10:38 [PATCH] ASoC: soc-cache: Add reg_size as a member to snd_soc_codec Dimitris Papastamos
@ 2011-01-12 11:14 ` Liam Girdwood
2011-01-12 14:57 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Liam Girdwood @ 2011-01-12 11:14 UTC (permalink / raw)
To: Dimitris Papastamos; +Cc: alsa-devel, Mark Brown, patches
On Wed, 2011-01-12 at 10:38 +0000, Dimitris Papastamos wrote:
> Simplify the use of reg_size, by calculating it once and storing it in
> the codec structure for later reference. The value of reg_size is
> reg_cache_size * reg_word_size.
>
> Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
> ---
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
--
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: soc-cache: Add reg_size as a member to snd_soc_codec
2011-01-12 10:38 [PATCH] ASoC: soc-cache: Add reg_size as a member to snd_soc_codec Dimitris Papastamos
2011-01-12 11:14 ` Liam Girdwood
@ 2011-01-12 14:57 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2011-01-12 14:57 UTC (permalink / raw)
To: Dimitris Papastamos; +Cc: alsa-devel, patches, Liam Girdwood
On Wed, Jan 12, 2011 at 10:38:58AM +0000, Dimitris Papastamos wrote:
> Simplify the use of reg_size, by calculating it once and storing it in
> the codec structure for later reference. The value of reg_size is
> reg_cache_size * reg_word_size.
>
> Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-01-12 14:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-12 10:38 [PATCH] ASoC: soc-cache: Add reg_size as a member to snd_soc_codec Dimitris Papastamos
2011-01-12 11:14 ` Liam Girdwood
2011-01-12 14:57 ` 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).