ASoC: soc-core: add for_each_rtd_components() and replace
ALSA SoC has for_each_rtdcom() which is link list for rtd-component which is called as rtdcom. The relationship image is like below rtdcom rtdcom rtdcom component component component rtd->component_list -> list -> list -> list ... Here, the pointer get via normal link list is rtdcom, Thus, current for_each loop is like below, and need to get component via rtdcom->component for_each_rtdcom(rtd, rtdcom) { component = rtdcom->component; ... } but usually, user want to get pointer from for_each_xxx is component directly, like below. for_each_rtd_component(rtd, rtdcom, component) { ... } This patch expands list_for_each_entry manually, and enable to get component directly from for_each macro. Because of it, the macro becoming difficult to read, but macro itself becoming useful. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/878spm64m4.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:

committed by
Mark Brown

parent
5a4c9f054c
commit
2b544dd7b4
@@ -420,13 +420,10 @@ int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream)
|
||||
struct snd_soc_component *component;
|
||||
struct snd_soc_rtdcom_list *rtdcom;
|
||||
|
||||
for_each_rtdcom(rtd, rtdcom) {
|
||||
component = rtdcom->component;
|
||||
|
||||
/* FIXME: use 1st pointer */
|
||||
/* FIXME: use 1st pointer */
|
||||
for_each_rtd_components(rtd, rtdcom, component)
|
||||
if (component->driver->pointer)
|
||||
return component->driver->pointer(component, substream);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -438,14 +435,11 @@ int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
|
||||
struct snd_soc_component *component;
|
||||
struct snd_soc_rtdcom_list *rtdcom;
|
||||
|
||||
for_each_rtdcom(rtd, rtdcom) {
|
||||
component = rtdcom->component;
|
||||
|
||||
/* FIXME: use 1st ioctl */
|
||||
/* FIXME: use 1st ioctl */
|
||||
for_each_rtd_components(rtd, rtdcom, component)
|
||||
if (component->driver->ioctl)
|
||||
return component->driver->ioctl(component, substream,
|
||||
cmd, arg);
|
||||
}
|
||||
|
||||
return snd_pcm_lib_ioctl(substream, cmd, arg);
|
||||
}
|
||||
@@ -458,14 +452,11 @@ int snd_soc_pcm_component_copy_user(struct snd_pcm_substream *substream,
|
||||
struct snd_soc_rtdcom_list *rtdcom;
|
||||
struct snd_soc_component *component;
|
||||
|
||||
for_each_rtdcom(rtd, rtdcom) {
|
||||
component = rtdcom->component;
|
||||
|
||||
/* FIXME. it returns 1st copy now */
|
||||
/* FIXME. it returns 1st copy now */
|
||||
for_each_rtd_components(rtd, rtdcom, component)
|
||||
if (component->driver->copy_user)
|
||||
return component->driver->copy_user(
|
||||
component, substream, channel, pos, buf, bytes);
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -478,10 +469,8 @@ struct page *snd_soc_pcm_component_page(struct snd_pcm_substream *substream,
|
||||
struct snd_soc_component *component;
|
||||
struct page *page;
|
||||
|
||||
for_each_rtdcom(rtd, rtdcom) {
|
||||
component = rtdcom->component;
|
||||
|
||||
/* FIXME. it returns 1st page now */
|
||||
/* FIXME. it returns 1st page now */
|
||||
for_each_rtd_components(rtd, rtdcom, component) {
|
||||
if (component->driver->page) {
|
||||
page = component->driver->page(component,
|
||||
substream, offset);
|
||||
@@ -500,14 +489,11 @@ int snd_soc_pcm_component_mmap(struct snd_pcm_substream *substream,
|
||||
struct snd_soc_rtdcom_list *rtdcom;
|
||||
struct snd_soc_component *component;
|
||||
|
||||
for_each_rtdcom(rtd, rtdcom) {
|
||||
component = rtdcom->component;
|
||||
|
||||
/* FIXME. it returns 1st mmap now */
|
||||
/* FIXME. it returns 1st mmap now */
|
||||
for_each_rtd_components(rtd, rtdcom, component)
|
||||
if (component->driver->mmap)
|
||||
return component->driver->mmap(component,
|
||||
substream, vma);
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -519,9 +505,7 @@ int snd_soc_pcm_component_new(struct snd_pcm *pcm)
|
||||
struct snd_soc_component *component;
|
||||
int ret;
|
||||
|
||||
for_each_rtdcom(rtd, rtdcom) {
|
||||
component = rtdcom->component;
|
||||
|
||||
for_each_rtd_components(rtd, rtdcom, component) {
|
||||
if (component->driver->pcm_construct) {
|
||||
ret = component->driver->pcm_construct(component, rtd);
|
||||
if (ret < 0)
|
||||
@@ -538,10 +522,7 @@ void snd_soc_pcm_component_free(struct snd_pcm *pcm)
|
||||
struct snd_soc_rtdcom_list *rtdcom;
|
||||
struct snd_soc_component *component;
|
||||
|
||||
for_each_rtdcom(rtd, rtdcom) {
|
||||
component = rtdcom->component;
|
||||
|
||||
for_each_rtd_components(rtd, rtdcom, component)
|
||||
if (component->driver->pcm_destruct)
|
||||
component->driver->pcm_destruct(component, pcm);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user