ASoC: rsnd: save priv in struct rsnd_dai
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Thu, 15 Jan 2015 08:08:34 +0000 (08:08 +0000)
committerMark Brown <broonie@kernel.org>
Thu, 15 Jan 2015 11:37:48 +0000 (11:37 +0000)
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>
sound/soc/sh/rcar/core.c
sound/soc/sh/rcar/dvc.c
sound/soc/sh/rcar/rsnd.h
sound/soc/sh/rcar/src.c
sound/soc/sh/rcar/ssi.c

index 6fa8709571ffb1ff89d8067a67d140d1510d0048..f0bb137da31b1636fd667593c1b036fa4afef88b 100644 (file)
@@ -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
index 4ddca4f380c7ba5dfccbc1ec3b25fc829cbbc770..38a5f334a6a75d78762322d71e7f3dbc1d7f08cf 100644 (file)
@@ -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);
index 61545357f036ed86805bcae454e085d36b936942..11a1c412f1f13bcca286dbd335fda17fc1775070 100644 (file)
@@ -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)) &&                \
index 0d136cdc4ada79f4a3e4984634df886d42286838..8c22d2112a1d8a501112a8de84897ce669a60b87 100644 (file)
@@ -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);
        }
index b5a2fd61029db7523be5bd6610a522c14941dd8e..9b89f6cf7680e8e68e366570c7624d85a625adb8 100644 (file)
@@ -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);
        }