aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHenrik Sjoberg <henke@epact.se>2005-11-09 00:35:38 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-09 10:56:04 -0500
commitf1016dec71a4ff3cf49110137c87ab988bd316e6 (patch)
treedb3fcaf57efacaf3a5fc515ded09e2de04b2de30 /drivers
parentd28d57629ffcd30e11a6085e15ee1327fea60b60 (diff)
[PATCH] dvb: dst: protect dst_write_tuna from simultaneous writes
dst_write_tuna needs to be protected against simultaeneous writes, just like dst_command Signed-off-by: Henrik Sjoberg <henke@epact.se> Signed-off-by: Manu Abraham <manu@linuxtv.org> Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Cc: Johannes Stezenbach <js@linuxtv.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/dvb/bt8xx/dst.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/drivers/media/dvb/bt8xx/dst.c b/drivers/media/dvb/bt8xx/dst.c
index 0c718dca09ca..8977c7a313df 100644
--- a/drivers/media/dvb/bt8xx/dst.c
+++ b/drivers/media/dvb/bt8xx/dst.c
@@ -1077,7 +1077,7 @@ static int dst_get_tuna(struct dst_state *state)
1077 return 0; 1077 return 0;
1078 state->diseq_flags &= ~(HAS_LOCK); 1078 state->diseq_flags &= ~(HAS_LOCK);
1079 if (!dst_wait_dst_ready(state, NO_DELAY)) 1079 if (!dst_wait_dst_ready(state, NO_DELAY))
1080 return 0; 1080 return -EIO;
1081 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) 1081 if (state->type_flags & DST_TYPE_HAS_NEWTUNE)
1082 /* how to get variable length reply ???? */ 1082 /* how to get variable length reply ???? */
1083 retval = read_dst(state, state->rx_tuna, 10); 1083 retval = read_dst(state, state->rx_tuna, 10);
@@ -1085,22 +1085,21 @@ static int dst_get_tuna(struct dst_state *state)
1085 retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM); 1085 retval = read_dst(state, &state->rx_tuna[2], FIXED_COMM);
1086 if (retval < 0) { 1086 if (retval < 0) {
1087 dprintk(verbose, DST_DEBUG, 1, "read not successful"); 1087 dprintk(verbose, DST_DEBUG, 1, "read not successful");
1088 return 0; 1088 return retval;
1089 } 1089 }
1090 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { 1090 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
1091 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) { 1091 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[0], 9)) {
1092 dprintk(verbose, DST_INFO, 1, "checksum failure ? "); 1092 dprintk(verbose, DST_INFO, 1, "checksum failure ? ");
1093 return 0; 1093 return -EIO;
1094 } 1094 }
1095 } else { 1095 } else {
1096 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[2], 7)) { 1096 if (state->rx_tuna[9] != dst_check_sum(&state->rx_tuna[2], 7)) {
1097 dprintk(verbose, DST_INFO, 1, "checksum failure? "); 1097 dprintk(verbose, DST_INFO, 1, "checksum failure? ");
1098 return 0; 1098 return -EIO;
1099 } 1099 }
1100 } 1100 }
1101 if (state->rx_tuna[2] == 0 && state->rx_tuna[3] == 0) 1101 if (state->rx_tuna[2] == 0 && state->rx_tuna[3] == 0)
1102 return 0; 1102 return 0;
1103
1104 if (state->dst_type == DST_TYPE_IS_SAT) { 1103 if (state->dst_type == DST_TYPE_IS_SAT) {
1105 state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 8) + state->rx_tuna[3]; 1104 state->decode_freq = ((state->rx_tuna[2] & 0x7f) << 8) + state->rx_tuna[3];
1106 } else { 1105 } else {
@@ -1129,10 +1128,10 @@ static int dst_write_tuna(struct dvb_frontend *fe)
1129 dst_set_voltage(fe, SEC_VOLTAGE_13); 1128 dst_set_voltage(fe, SEC_VOLTAGE_13);
1130 } 1129 }
1131 state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE); 1130 state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE);
1132 1131 down(&state->dst_mutex);
1133 if ((dst_comm_init(state)) < 0) { 1132 if ((dst_comm_init(state)) < 0) {
1134 dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed."); 1133 dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed.");
1135 return -1; 1134 goto error;
1136 } 1135 }
1137 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) { 1136 if (state->type_flags & DST_TYPE_HAS_NEWTUNE) {
1138 state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9); 1137 state->tx_tuna[9] = dst_check_sum(&state->tx_tuna[0], 9);
@@ -1144,23 +1143,29 @@ static int dst_write_tuna(struct dvb_frontend *fe)
1144 if (retval < 0) { 1143 if (retval < 0) {
1145 dst_pio_disable(state); 1144 dst_pio_disable(state);
1146 dprintk(verbose, DST_DEBUG, 1, "write not successful"); 1145 dprintk(verbose, DST_DEBUG, 1, "write not successful");
1147 return retval; 1146 goto werr;
1148 } 1147 }
1149 if ((dst_pio_disable(state)) < 0) { 1148 if ((dst_pio_disable(state)) < 0) {
1150 dprintk(verbose, DST_DEBUG, 1, "DST PIO disable failed !"); 1149 dprintk(verbose, DST_DEBUG, 1, "DST PIO disable failed !");
1151 return -1; 1150 goto error;
1152 } 1151 }
1153 if ((read_dst(state, &reply, GET_ACK) < 0)) { 1152 if ((read_dst(state, &reply, GET_ACK) < 0)) {
1154 dprintk(verbose, DST_DEBUG, 1, "read verify not successful."); 1153 dprintk(verbose, DST_DEBUG, 1, "read verify not successful.");
1155 return -1; 1154 goto error;
1156 } 1155 }
1157 if (reply != ACK) { 1156 if (reply != ACK) {
1158 dprintk(verbose, DST_DEBUG, 1, "write not acknowledged 0x%02x ", reply); 1157 dprintk(verbose, DST_DEBUG, 1, "write not acknowledged 0x%02x ", reply);
1159 return 0; 1158 goto error;
1160 } 1159 }
1161 state->diseq_flags |= ATTEMPT_TUNE; 1160 state->diseq_flags |= ATTEMPT_TUNE;
1161 retval = dst_get_tuna(state);
1162werr:
1163 up(&state->dst_mutex);
1164 return retval;
1162 1165
1163 return dst_get_tuna(state); 1166error:
1167 up(&state->dst_mutex);
1168 return -EIO;
1164} 1169}
1165 1170
1166/* 1171/*