]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ASoC: rsnd: add common mod confirm method
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Thu, 10 Sep 2015 07:03:08 +0000 (07:03 +0000)
committerMark Brown <broonie@kernel.org>
Mon, 14 Sep 2015 18:47:31 +0000 (19:47 +0100)
Renesas sound has SSI/SRC/DVC/MIX/ADG modules, and these have original
register mapping. Thus this driver is using regmap field, and each module
is using it based on each module ID.

Sometimes, each module needs other module to controlling. but current each
function is using just "mod" as parameter name. This is confusable.
For example, if SSI0 and SRC2 are connected, and if SRC module function
has bug of module access, and if it needs to control connected SSI,
SRC function will access to SSI2 (It should access to SSI0, but it uses
SRC's ID 2). This is easy to happen in current driver style.

To avoid this kind of confusable trouble, this patch adds module confirm
macro for debug purpose.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sh/rcar/adg.c
sound/soc/sh/rcar/core.c
sound/soc/sh/rcar/rsnd.h

index 9ff1736e6955fc50f06efed4139e9291ee9fb689..48bb38d384997efdbf2b3ff3233c1ec0f9ba399f 100644 (file)
@@ -81,19 +81,21 @@ int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_mod *mod,
        return 0;
 }
 
-static int rsnd_adg_set_src_timsel_gen2(struct rsnd_mod *mod,
+static int rsnd_adg_set_src_timsel_gen2(struct rsnd_mod *src_mod,
                                        struct rsnd_dai_stream *io,
                                        u32 timsel)
 {
-       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
+       struct rsnd_priv *priv = rsnd_mod_to_priv(src_mod);
        struct rsnd_adg *adg = rsnd_priv_to_adg(priv);
        struct rsnd_mod *adg_mod = rsnd_mod_get(adg);
        int is_play = rsnd_io_is_play(io);
-       int id = rsnd_mod_id(mod);
+       int id = rsnd_mod_id(src_mod);
        int shift = (id % 2) ? 16 : 0;
        u32 mask, ws;
        u32 in, out;
 
+       rsnd_mod_confirm_src(src_mod);
+
        ws = rsnd_adg_ssi_ws_timing_gen2(io);
 
        in  = (is_play) ? timsel : ws;
@@ -129,12 +131,12 @@ static int rsnd_adg_set_src_timsel_gen2(struct rsnd_mod *mod,
        return 0;
 }
 
-int rsnd_adg_set_convert_clk_gen2(struct rsnd_mod *mod,
+int rsnd_adg_set_convert_clk_gen2(struct rsnd_mod *src_mod,
                                  struct rsnd_dai_stream *io,
                                  unsigned int src_rate,
                                  unsigned int dst_rate)
 {
-       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
+       struct rsnd_priv *priv = rsnd_mod_to_priv(src_mod);
        struct rsnd_adg *adg = rsnd_priv_to_adg(priv);
        struct rsnd_mod *adg_mod = rsnd_mod_get(adg);
        struct device *dev = rsnd_priv_to_dev(priv);
@@ -149,6 +151,8 @@ int rsnd_adg_set_convert_clk_gen2(struct rsnd_mod *mod,
                adg->rbgb_rate_for_48khz_div_6, /* 0100: RBGB */
        };
 
+       rsnd_mod_confirm_src(src_mod);
+
        min = ~0;
        val = 0;
        en = 0;
@@ -186,7 +190,7 @@ int rsnd_adg_set_convert_clk_gen2(struct rsnd_mod *mod,
                return -EIO;
        }
 
-       ret = rsnd_adg_set_src_timsel_gen2(mod, io, val);
+       ret = rsnd_adg_set_src_timsel_gen2(src_mod, io, val);
        if (ret < 0) {
                dev_err(dev, "timsel error\n");
                return ret;
@@ -199,12 +203,14 @@ int rsnd_adg_set_convert_clk_gen2(struct rsnd_mod *mod,
        return 0;
 }
 
-int rsnd_adg_set_convert_timing_gen2(struct rsnd_mod *mod,
+int rsnd_adg_set_convert_timing_gen2(struct rsnd_mod *src_mod,
                                     struct rsnd_dai_stream *io)
 {
        u32 val = rsnd_adg_ssi_ws_timing_gen2(io);
 
-       return rsnd_adg_set_src_timsel_gen2(mod, io, val);
+       rsnd_mod_confirm_src(src_mod);
+
+       return rsnd_adg_set_src_timsel_gen2(src_mod, io, val);
 }
 
 int rsnd_adg_set_convert_clk_gen1(struct rsnd_priv *priv,
@@ -269,15 +275,17 @@ find_rate:
        return 0;
 }
 
-static void rsnd_adg_set_ssi_clk(struct rsnd_mod *mod, u32 val)
+static void rsnd_adg_set_ssi_clk(struct rsnd_mod *ssi_mod, u32 val)
 {
-       struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
+       struct rsnd_priv *priv = rsnd_mod_to_priv(ssi_mod);
        struct rsnd_adg *adg = rsnd_priv_to_adg(priv);
        struct rsnd_mod *adg_mod = rsnd_mod_get(adg);
-       int id = rsnd_mod_id(mod);
+       int id = rsnd_mod_id(ssi_mod);
        int shift = (id % 4) * 8;
        u32 mask = 0xFF << shift;
 
+       rsnd_mod_confirm_ssi(ssi_mod);
+
        val = val << shift;
 
        /*
index 870f94415abcfc7639f6f9b88f62fe4d6344574d..eec294da81e325ca4e9a545c3b750bc6283267d3 100644 (file)
@@ -127,6 +127,17 @@ MODULE_DEVICE_TABLE(of, rsnd_of_match);
 #define rsnd_info_id(priv, io, name) \
        ((io)->info->name - priv->info->name##_info)
 
+void rsnd_mod_make_sure(struct rsnd_mod *mod, enum rsnd_mod_type type)
+{
+       if (mod->type != type) {
+               struct rsnd_priv *priv = rsnd_mod_to_priv(mod);
+               struct device *dev = rsnd_priv_to_dev(priv);
+
+               dev_warn(dev, "%s[%d] is not your expected module\n",
+                        rsnd_mod_name(mod), rsnd_mod_id(mod));
+       }
+}
+
 /*
  *     rsnd_mod functions
  */
index f35d9cc61686cbfdd866ec97ed8adc44801d91ee..e4068d78616c0a6542d339aa356402ff0d92fbfc 100644 (file)
@@ -627,4 +627,15 @@ void rsnd_dvc_remove(struct platform_device *pdev,
                     struct rsnd_priv *priv);
 struct rsnd_mod *rsnd_dvc_mod_get(struct rsnd_priv *priv, int id);
 
+#ifdef DEBUG
+void rsnd_mod_make_sure(struct rsnd_mod *mod, enum rsnd_mod_type type);
+#define rsnd_mod_confirm_ssi(mssi)     rsnd_mod_make_sure(mssi, RSND_MOD_SSI)
+#define rsnd_mod_confirm_src(msrc)     rsnd_mod_make_sure(msrc, RSND_MOD_SRC)
+#define rsnd_mod_confirm_dvc(mdvc)     rsnd_mod_make_sure(mdvc, RSND_MOD_DVC)
+#else
+#define rsnd_mod_confirm_ssi(mssi)
+#define rsnd_mod_confirm_src(msrc)
+#define rsnd_mod_confirm_dvc(mdvc)
+#endif
+
 #endif