mirror of https://gitee.com/openkylin/linux.git
ASoC: rsnd: save priv in struct rsnd_dai
Current rsnd driver has rsnd_mod_to_priv() macro, and struct rsnd_mod has struct rsnd_priv pointer. But, it is waste of memory from data structure point of view. Today we can link mod <-> io <-> rdai each other, so saving priv in rdai is very reasonable. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
690602fcd8
commit
1b13d118ee
|
@ -149,14 +149,12 @@ char *rsnd_mod_dma_name(struct rsnd_mod *mod)
|
|||
return mod->ops->dma_name(mod);
|
||||
}
|
||||
|
||||
void rsnd_mod_init(struct rsnd_priv *priv,
|
||||
struct rsnd_mod *mod,
|
||||
void rsnd_mod_init(struct rsnd_mod *mod,
|
||||
struct rsnd_mod_ops *ops,
|
||||
struct clk *clk,
|
||||
enum rsnd_mod_type type,
|
||||
int id)
|
||||
{
|
||||
mod->priv = priv;
|
||||
mod->id = id;
|
||||
mod->ops = ops;
|
||||
mod->type = type;
|
||||
|
@ -868,6 +866,7 @@ static int rsnd_dai_probe(struct platform_device *pdev,
|
|||
* init rsnd_dai
|
||||
*/
|
||||
snprintf(rdai[i].name, RSND_DAI_NAME_SIZE, "rsnd-dai.%d", i);
|
||||
rdai[i].priv = priv;
|
||||
|
||||
/*
|
||||
* init snd_soc_dai_driver
|
||||
|
|
|
@ -351,7 +351,7 @@ int rsnd_dvc_probe(struct platform_device *pdev,
|
|||
|
||||
dvc->info = &info->dvc_info[i];
|
||||
|
||||
rsnd_mod_init(priv, &dvc->mod, &rsnd_dvc_ops,
|
||||
rsnd_mod_init(&dvc->mod, &rsnd_dvc_ops,
|
||||
clk, RSND_MOD_DVC, i);
|
||||
|
||||
dev_dbg(dev, "CMD%d probed\n", i);
|
||||
|
|
|
@ -221,7 +221,6 @@ struct rsnd_dai_stream;
|
|||
struct rsnd_mod {
|
||||
int id;
|
||||
enum rsnd_mod_type type;
|
||||
struct rsnd_priv *priv;
|
||||
struct rsnd_mod_ops *ops;
|
||||
struct rsnd_dma dma;
|
||||
struct rsnd_dai_stream *io;
|
||||
|
@ -256,7 +255,7 @@ struct rsnd_mod {
|
|||
#define __rsnd_mod_call_pcm_new 0
|
||||
#define __rsnd_mod_call_fallback 0
|
||||
|
||||
#define rsnd_mod_to_priv(mod) ((mod)->priv)
|
||||
#define rsnd_mod_to_priv(mod) (rsnd_io_to_priv(rsnd_mod_to_io(mod)))
|
||||
#define rsnd_mod_to_dma(mod) (&(mod)->dma)
|
||||
#define rsnd_dma_to_mod(_dma) container_of((_dma), struct rsnd_mod, dma)
|
||||
#define rsnd_mod_to_io(mod) ((mod)->io)
|
||||
|
@ -264,8 +263,7 @@ struct rsnd_mod {
|
|||
#define rsnd_mod_hw_start(mod) clk_prepare_enable((mod)->clk)
|
||||
#define rsnd_mod_hw_stop(mod) clk_disable_unprepare((mod)->clk)
|
||||
|
||||
void rsnd_mod_init(struct rsnd_priv *priv,
|
||||
struct rsnd_mod *mod,
|
||||
void rsnd_mod_init(struct rsnd_mod *mod,
|
||||
struct rsnd_mod_ops *ops,
|
||||
struct clk *clk,
|
||||
enum rsnd_mod_type type,
|
||||
|
@ -291,6 +289,7 @@ struct rsnd_dai_stream {
|
|||
#define rsnd_io_to_mod_src(io) ((io)->mod[RSND_MOD_SRC])
|
||||
#define rsnd_io_to_mod_dvc(io) ((io)->mod[RSND_MOD_DVC])
|
||||
#define rsnd_io_to_rdai(io) ((io)->rdai)
|
||||
#define rsnd_io_to_priv(io) (rsnd_rdai_to_priv(rsnd_io_to_rdai(io)))
|
||||
#define rsnd_io_is_play(io) (&rsnd_io_to_rdai(io)->playback == io)
|
||||
#define rsnd_io_to_runtime(io) ((io)->substream ? \
|
||||
(io)->substream->runtime : NULL)
|
||||
|
@ -300,6 +299,7 @@ struct rsnd_dai {
|
|||
char name[RSND_DAI_NAME_SIZE];
|
||||
struct rsnd_dai_stream playback;
|
||||
struct rsnd_dai_stream capture;
|
||||
struct rsnd_priv *priv;
|
||||
|
||||
unsigned int clk_master:1;
|
||||
unsigned int bit_clk_inv:1;
|
||||
|
@ -310,6 +310,7 @@ struct rsnd_dai {
|
|||
|
||||
#define rsnd_rdai_nr(priv) ((priv)->rdai_nr)
|
||||
#define rsnd_rdai_is_clk_master(rdai) ((rdai)->clk_master)
|
||||
#define rsnd_rdai_to_priv(rdai) ((rdai)->priv)
|
||||
#define for_each_rsnd_dai(rdai, priv, i) \
|
||||
for (i = 0; \
|
||||
(i < rsnd_rdai_nr(priv)) && \
|
||||
|
|
|
@ -889,7 +889,7 @@ int rsnd_src_probe(struct platform_device *pdev,
|
|||
|
||||
src->info = &info->src_info[i];
|
||||
|
||||
rsnd_mod_init(priv, &src->mod, ops, clk, RSND_MOD_SRC, i);
|
||||
rsnd_mod_init(&src->mod, ops, clk, RSND_MOD_SRC, i);
|
||||
|
||||
dev_dbg(dev, "SRC%d probed\n", i);
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ static void rsnd_ssi_status_check(struct rsnd_mod *mod,
|
|||
static int rsnd_ssi_master_clk_start(struct rsnd_ssi *ssi,
|
||||
struct rsnd_dai_stream *io)
|
||||
{
|
||||
struct rsnd_priv *priv = rsnd_mod_to_priv(&ssi->mod);
|
||||
struct rsnd_priv *priv = rsnd_io_to_priv(io);
|
||||
struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io);
|
||||
struct device *dev = rsnd_priv_to_dev(priv);
|
||||
int i, j, ret;
|
||||
|
@ -179,7 +179,7 @@ static void rsnd_ssi_master_clk_stop(struct rsnd_ssi *ssi)
|
|||
static void rsnd_ssi_hw_start(struct rsnd_ssi *ssi,
|
||||
struct rsnd_dai_stream *io)
|
||||
{
|
||||
struct rsnd_priv *priv = rsnd_mod_to_priv(&ssi->mod);
|
||||
struct rsnd_priv *priv = rsnd_io_to_priv(io);
|
||||
struct rsnd_dai *rdai = rsnd_io_to_rdai(io);
|
||||
struct device *dev = rsnd_priv_to_dev(priv);
|
||||
u32 cr_mode;
|
||||
|
@ -730,7 +730,7 @@ int rsnd_ssi_probe(struct platform_device *pdev,
|
|||
else if (rsnd_ssi_pio_available(ssi))
|
||||
ops = &rsnd_ssi_pio_ops;
|
||||
|
||||
rsnd_mod_init(priv, &ssi->mod, ops, clk, RSND_MOD_SSI, i);
|
||||
rsnd_mod_init(&ssi->mod, ops, clk, RSND_MOD_SSI, i);
|
||||
|
||||
rsnd_ssi_parent_clk_setup(priv, ssi);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue