On 02/25/2013 01:57 AM, Kuninori Morimoto wrote:
ak4642 driver can be used from simple-card driver which requires .of_xlate_dai_name. This patch supports it.
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
+static int ak4642_of_xlate_dai_name(struct snd_soc_codec *codec,
struct of_phandle_args *spec,
const char **dai_name)
+{
- *dai_name = ak4642_dai.name;
- return 0;
+}
This seems fine, but I would be tempted to make that a common function; with body something like:
if codec->num_dai == 1: if spec->args_count: return error else: return codec->dais[0].name else: loop over all codec->dais if args->args[0] == dai->of_id: return dai return error
(similar to how drivers/gpio/gpiolib-of.c:of_gpio_simple_xlate() works).
That would allow the same function to be used by most CODECs/CPUs.