aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolin Chen <Guangyu.Chen@freescale.com>2014-05-08 23:45:47 -0400
committerNicolin Chen <Guangyu.Chen@freescale.com>2014-06-19 05:07:24 -0400
commit993e5323c96c5e21b56ae161aa3c91ad08e6aeb3 (patch)
tree001f747104e65ecf3b2b796f3b80afc99788f1e2
parentc7f61d3947459aaa0b776c6449535e3ce410e7c0 (diff)
ENGR00318773-2 mxc: asrc: Abstract a helper function for duplicated wait_for_compeltion code
After dropping the extra task for last period buffer fetching, we have a total symmetrical wait_for_compeltion here so it's better to abstract a function to make the driver neat. Acked-by: Wang Shengjiu <b02247@freescale.com> Signed-off-by: Nicolin Chen <Guangyu.Chen@freescale.com>
-rw-r--r--drivers/mxc/asrc/mxc_asrc.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/drivers/mxc/asrc/mxc_asrc.c b/drivers/mxc/asrc/mxc_asrc.c
index 4c198fc46738..c8a7246fbc9b 100644
--- a/drivers/mxc/asrc/mxc_asrc.c
+++ b/drivers/mxc/asrc/mxc_asrc.c
@@ -999,7 +999,6 @@ int mxc_asrc_process_io_buffer(struct asrc_pair_params *params,
999{ 999{
1000 void *last_vaddr = params->output_last_period.dma_vaddr; 1000 void *last_vaddr = params->output_last_period.dma_vaddr;
1001 unsigned int *last_len = &params->output_last_period.length; 1001 unsigned int *last_len = &params->output_last_period.length;
1002 enum asrc_pair_index index = params->index;
1003 unsigned int dma_len, *buf_len; 1002 unsigned int dma_len, *buf_len;
1004 struct completion *complete; 1003 struct completion *complete;
1005 unsigned long lock_flags; 1004 unsigned long lock_flags;
@@ -1044,16 +1043,9 @@ int mxc_asrc_process_io_buffer(struct asrc_pair_params *params,
1044 return 0; 1043 return 0;
1045} 1044}
1046 1045
1047int mxc_asrc_process_buffer(struct asrc_pair_params *params, 1046int mxc_asrc_process_buffer_pre(struct completion *complete,
1048 struct asrc_convert_buffer *pbuf) 1047 enum asrc_pair_index index, bool in)
1049{ 1048{
1050 enum asrc_pair_index index = params->index;
1051 struct completion *complete;
1052 int ret;
1053 bool in;
1054
1055 complete = &params->output_complete;
1056 in = false;
1057 if (!wait_for_completion_interruptible_timeout(complete, 10 * HZ)) { 1049 if (!wait_for_completion_interruptible_timeout(complete, 10 * HZ)) {
1058 pair_err("%sput dma task timeout\n", in ? "in" : "out"); 1050 pair_err("%sput dma task timeout\n", in ? "in" : "out");
1059 return -ETIME; 1051 return -ETIME;
@@ -1064,17 +1056,24 @@ int mxc_asrc_process_buffer(struct asrc_pair_params *params,
1064 1056
1065 init_completion(complete); 1057 init_completion(complete);
1066 1058
1067 complete = &params->input_complete; 1059 return 0;
1068 in = true; 1060}
1069 if (!wait_for_completion_interruptible_timeout(complete, 10 * HZ)) {
1070 pair_err("%sput dma task timeout\n", in ? "in" : "out");
1071 return -ETIME;
1072 } else if (signal_pending(current)) {
1073 pair_err("%sput task forcibly aborted\n", in ? "in" : "out");
1074 return -ERESTARTSYS;
1075 }
1076 1061
1077 init_completion(complete); 1062int mxc_asrc_process_buffer(struct asrc_pair_params *params,
1063 struct asrc_convert_buffer *pbuf)
1064{
1065 enum asrc_pair_index index = params->index;
1066 int ret;
1067
1068 /* Ouput task should be finished earilier */
1069 ret = mxc_asrc_process_buffer_pre(&params->output_complete, index, false);
1070 if (ret)
1071 return ret;
1072
1073 /* ...then input task*/
1074 ret = mxc_asrc_process_buffer_pre(&params->input_complete, index, true);
1075 if (ret)
1076 return ret;
1078 1077
1079 ret = mxc_asrc_process_io_buffer(params, pbuf, true); 1078 ret = mxc_asrc_process_io_buffer(params, pbuf, true);
1080 if (ret) { 1079 if (ret) {