[PATCH 11/25] ASoC: soc-component: add snd_soc_component_copy_user()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>

Current ALSA SoC is directly using component->driver->ops->xxx,
thus, it is deep nested, and makes code difficult to read,
and is not good for encapsulation.
This patch adds new snd_soc_component_copy_user() and use it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>
---
 include/sound/soc-component.h |  4 ++++
 sound/soc/soc-component.c     | 13 +++++++++++++
 sound/soc/soc-pcm.c           | 11 +++++------
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h
index 8230519..b86aecf 100644
--- a/include/sound/soc-component.h
+++ b/include/sound/soc-component.h
@@ -342,5 +342,9 @@ int snd_soc_component_pointer(struct snd_soc_component *component,
 int snd_soc_component_ioctl(struct snd_soc_component *component,
 			    struct snd_pcm_substream *substream,
 			    unsigned int cmd, void *arg);
+int snd_soc_component_copy_user(struct snd_soc_component *component,
+				struct snd_pcm_substream *substream,
+				int channel, unsigned long pos,
+				void __user *buf, unsigned long bytes);
 
 #endif /* __SOC_COMPONENT_H */
diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index dbc8295..881450d2 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -368,3 +368,16 @@ int snd_soc_component_ioctl(struct snd_soc_component *component,
 
 	return -ENOTSUPP;
 }
+
+int snd_soc_component_copy_user(struct snd_soc_component *component,
+				struct snd_pcm_substream *substream,
+				int channel, unsigned long pos,
+				void __user *buf, unsigned long bytes)
+{
+	if (component->driver->ops &&
+	    component->driver->ops->copy_user)
+		return component->driver->ops->copy_user(substream, channel,
+							 pos, buf, bytes);
+
+	return -ENOTSUPP;
+}
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 064d16c..f1d3404 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2862,17 +2862,16 @@ static int soc_rtdcom_copy_user(struct snd_pcm_substream *substream, int channel
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
 	struct snd_soc_rtdcom_list *rtdcom;
 	struct snd_soc_component *component;
+	int ret;
 
 	for_each_rtdcom(rtd, rtdcom) {
 		component = rtdcom->component;
 
-		if (!component->driver->ops ||
-		    !component->driver->ops->copy_user)
-			continue;
-
+		ret = snd_soc_component_copy_user(component, substream, channel,
+						  pos, buf, bytes);
 		/* FIXME. it returns 1st copy now */
-		return component->driver->ops->copy_user(substream, channel,
-							 pos, buf, bytes);
+		if (ret != -ENOTSUPP)
+			return ret;
 	}
 
 	return -EINVAL;
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux