Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6833c452 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown
Browse files

ASoC: add snd_soc_of_get_dai_name() default of_xlate



Current snd_soc_of_get_dai_name() needs .of_xlate_dai_name()
callback on each component drivers.
But required behavior on almost all these drivers is
just returns its indexed driver's name.

This patch adds this feature as default behavior.
.of_xlate_dai_name() can overwrite it.

Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 7cc302d2
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -644,10 +644,12 @@ struct snd_soc_component_driver {
struct snd_soc_component {
	const char *name;
	int id;
	int num_dai;
	struct device *dev;
	struct list_head list;

	struct snd_soc_dai_driver *dai_drv;
	int num_dai;

	const struct snd_soc_component_driver *driver;
};

+24 −4
Original line number Diff line number Diff line
@@ -4023,6 +4023,7 @@ __snd_soc_register_component(struct device *dev,

	cmpnt->dev	= dev;
	cmpnt->driver	= cmpnt_drv;
	cmpnt->dai_drv	= dai_drv;
	cmpnt->num_dai	= num_dai;

	/*
@@ -4548,12 +4549,31 @@ int snd_soc_of_get_dai_name(struct device_node *of_node,
		if (pos->dev->of_node != args.np)
			continue;

		if (!pos->driver->of_xlate_dai_name) {
			ret = -ENOSYS;
		if (pos->driver->of_xlate_dai_name) {
			ret = pos->driver->of_xlate_dai_name(pos, &args, dai_name);
		} else {
			int id = -1;

			switch (args.args_count) {
			case 0:
				id = 0; /* same as dai_drv[0] */
				break;
			case 1:
				id = args.args[0];
				break;
			default:
				/* not supported */
				break;
			}

		ret = pos->driver->of_xlate_dai_name(pos, &args, dai_name);
			if (id < 0 || id >= pos->num_dai) {
				ret = -EINVAL;
			} else {
				*dai_name = pos->dai_drv[id].name;
				ret = 0;
			}
		}

		break;
	}
	mutex_unlock(&client_mutex);