ASoC: compress: Correct handling of copy callback

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/290df4d3ab192821b66857c05346b23056ee9545
Commit:     290df4d3ab192821b66857c05346b23056ee9545
Parent:     4fbd8d194f06c8a3fd2af1ce560ddb31f7ec8323
Refname:    refs/heads/master
Author:     Charles Keepax <[email protected]>
AuthorDate: Fri Jan 26 13:08:43 2018 +0000
Committer:  Mark Brown <[email protected]>
CommitDate: Fri Jan 26 15:22:52 2018 +0000

    ASoC: compress: Correct handling of copy callback
    
    The soc_compr_copy callback is currently broken. Since the
    changes to move the compr_ops over to the component the return
    value is not correctly propagated, always returning zero on
    success rather than the number of bytes copied. This causes
    user-space to stall continuously reading as it does not believe
    it has received any data.
    
    Furthermore, the changes to move the compr_ops over to the
    component iterate through the list of components and will call
    the copy callback for any that have compressed ops. There isn't
    currently any consensus on the mechanism to combine the results
    of multiple copy callbacks.
    
    To fix this issue for now halt searching the component list when
    we locate a copy callback and return the result of that single
    callback. Additional work should probably be done to look at the
    other ops, tidy things up, and work out if we want to support
    multiple components on a single compressed, but this is the only
    fix required to get things working again.
    
    Fixes: 9e7e3738ab0e ("ASoC: snd_soc_component_driver has snd_compr_ops")
    Signed-off-by: Charles Keepax <[email protected]>
    Signed-off-by: Mark Brown <[email protected]>
    Cc: [email protected]
---
 sound/soc/soc-compress.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index d9b1e6417fb9..1507117d1185 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -944,7 +944,7 @@ static int soc_compr_copy(struct snd_compr_stream *cstream,
 	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_component *component;
 	struct snd_soc_rtdcom_list *rtdcom;
-	int ret = 0, __ret;
+	int ret = 0;
 
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
@@ -965,10 +965,10 @@ static int soc_compr_copy(struct snd_compr_stream *cstream,
 		    !component->driver->compr_ops->copy)
 			continue;
 
-		__ret = component->driver->compr_ops->copy(cstream, buf, count);
-		if (__ret < 0)
-			ret = __ret;
+		ret = component->driver->compr_ops->copy(cstream, buf, count);
+		break;
 	}
+
 err:
 	mutex_unlock(&rtd->pcm_mutex);
 	return ret;
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.