aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2014-02-21 03:50:01 -0500
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-11-03 11:53:14 -0500
commit66ae9fc237c1192414c12094443521d956199be8 (patch)
tree70ffe6cc166ed339277071859381f934b82e1945
parent9fd1f310a13ab16034cbda4f874eafadc8f80caf (diff)
[media] stv090x: remove indent levels in stv090x_get_coldlock()
This code is needlessly complicated and checkpatch.pl complains that we go over the 80 characters per line limit. If we flip the "if (!lock) {" test to "if (lock) return;" then we can remove an indent level from the rest of the function. We can add two returns in the "if (state->srate >= 10000000) {" condition and move the else statement back an additional indent level. There is another "if (!lock) {" check which can be removed since we have already checked "lock" and know it is zero at this point. This second check on "lock" is also a problem because it sets off a static checker warning. I have reviewed this code for some time to see if something else was intended, but have concluded that it was simply an oversight and should be removed. Removing this duplicative check gains us an third indent level. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r--drivers/media/dvb-frontends/stv090x.c162
1 files changed, 80 insertions, 82 deletions
diff --git a/drivers/media/dvb-frontends/stv090x.c b/drivers/media/dvb-frontends/stv090x.c
index 23e872f84742..93f4979ea6e9 100644
--- a/drivers/media/dvb-frontends/stv090x.c
+++ b/drivers/media/dvb-frontends/stv090x.c
@@ -2146,7 +2146,7 @@ static int stv090x_get_coldlock(struct stv090x_state *state, s32 timeout_dmd)
2146 2146
2147 u32 reg; 2147 u32 reg;
2148 s32 car_step, steps, cur_step, dir, freq, timeout_lock; 2148 s32 car_step, steps, cur_step, dir, freq, timeout_lock;
2149 int lock = 0; 2149 int lock;
2150 2150
2151 if (state->srate >= 10000000) 2151 if (state->srate >= 10000000)
2152 timeout_lock = timeout_dmd / 3; 2152 timeout_lock = timeout_dmd / 3;
@@ -2154,98 +2154,96 @@ static int stv090x_get_coldlock(struct stv090x_state *state, s32 timeout_dmd)
2154 timeout_lock = timeout_dmd / 2; 2154 timeout_lock = timeout_dmd / 2;
2155 2155
2156 lock = stv090x_get_dmdlock(state, timeout_lock); /* cold start wait */ 2156 lock = stv090x_get_dmdlock(state, timeout_lock); /* cold start wait */
2157 if (!lock) { 2157 if (lock)
2158 if (state->srate >= 10000000) { 2158 return lock;
2159 if (stv090x_chk_tmg(state)) {
2160 if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1f) < 0)
2161 goto err;
2162 if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x15) < 0)
2163 goto err;
2164 lock = stv090x_get_dmdlock(state, timeout_dmd);
2165 } else {
2166 lock = 0;
2167 }
2168 } else {
2169 if (state->srate <= 4000000)
2170 car_step = 1000;
2171 else if (state->srate <= 7000000)
2172 car_step = 2000;
2173 else if (state->srate <= 10000000)
2174 car_step = 3000;
2175 else
2176 car_step = 5000;
2177
2178 steps = (state->search_range / 1000) / car_step;
2179 steps /= 2;
2180 steps = 2 * (steps + 1);
2181 if (steps < 0)
2182 steps = 2;
2183 else if (steps > 12)
2184 steps = 12;
2185
2186 cur_step = 1;
2187 dir = 1;
2188
2189 if (!lock) {
2190 freq = state->frequency;
2191 state->tuner_bw = stv090x_car_width(state->srate, state->rolloff) + state->srate;
2192 while ((cur_step <= steps) && (!lock)) {
2193 if (dir > 0)
2194 freq += cur_step * car_step;
2195 else
2196 freq -= cur_step * car_step;
2197
2198 /* Setup tuner */
2199 if (stv090x_i2c_gate_ctrl(state, 1) < 0)
2200 goto err;
2201 2159
2202 if (state->config->tuner_set_frequency) { 2160 if (state->srate >= 10000000) {
2203 if (state->config->tuner_set_frequency(fe, freq) < 0) 2161 if (stv090x_chk_tmg(state)) {
2204 goto err_gateoff; 2162 if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1f) < 0)
2205 } 2163 goto err;
2164 if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x15) < 0)
2165 goto err;
2166 return stv090x_get_dmdlock(state, timeout_dmd);
2167 }
2168 return 0;
2169 }
2206 2170
2207 if (state->config->tuner_set_bandwidth) { 2171 if (state->srate <= 4000000)
2208 if (state->config->tuner_set_bandwidth(fe, state->tuner_bw) < 0) 2172 car_step = 1000;
2209 goto err_gateoff; 2173 else if (state->srate <= 7000000)
2210 } 2174 car_step = 2000;
2175 else if (state->srate <= 10000000)
2176 car_step = 3000;
2177 else
2178 car_step = 5000;
2211 2179
2212 if (stv090x_i2c_gate_ctrl(state, 0) < 0) 2180 steps = (state->search_range / 1000) / car_step;
2213 goto err; 2181 steps /= 2;
2182 steps = 2 * (steps + 1);
2183 if (steps < 0)
2184 steps = 2;
2185 else if (steps > 12)
2186 steps = 12;
2214 2187
2215 msleep(50); 2188 cur_step = 1;
2189 dir = 1;
2216 2190
2217 if (stv090x_i2c_gate_ctrl(state, 1) < 0) 2191 freq = state->frequency;
2218 goto err; 2192 state->tuner_bw = stv090x_car_width(state->srate, state->rolloff) + state->srate;
2193 while ((cur_step <= steps) && (!lock)) {
2194 if (dir > 0)
2195 freq += cur_step * car_step;
2196 else
2197 freq -= cur_step * car_step;
2219 2198
2220 if (state->config->tuner_get_status) { 2199 /* Setup tuner */
2221 if (state->config->tuner_get_status(fe, &reg) < 0) 2200 if (stv090x_i2c_gate_ctrl(state, 1) < 0)
2222 goto err_gateoff; 2201 goto err;
2223 }
2224 2202
2225 if (reg) 2203 if (state->config->tuner_set_frequency) {
2226 dprintk(FE_DEBUG, 1, "Tuner phase locked"); 2204 if (state->config->tuner_set_frequency(fe, freq) < 0)
2227 else 2205 goto err_gateoff;
2228 dprintk(FE_DEBUG, 1, "Tuner unlocked"); 2206 }
2229 2207
2230 if (stv090x_i2c_gate_ctrl(state, 0) < 0) 2208 if (state->config->tuner_set_bandwidth) {
2231 goto err; 2209 if (state->config->tuner_set_bandwidth(fe, state->tuner_bw) < 0)
2210 goto err_gateoff;
2211 }
2232 2212
2233 STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1c); 2213 if (stv090x_i2c_gate_ctrl(state, 0) < 0)
2234 if (STV090x_WRITE_DEMOD(state, CFRINIT1, 0x00) < 0) 2214 goto err;
2235 goto err;
2236 if (STV090x_WRITE_DEMOD(state, CFRINIT0, 0x00) < 0)
2237 goto err;
2238 if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1f) < 0)
2239 goto err;
2240 if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x15) < 0)
2241 goto err;
2242 lock = stv090x_get_dmdlock(state, (timeout_dmd / 3));
2243 2215
2244 dir *= -1; 2216 msleep(50);
2245 cur_step++; 2217
2246 } 2218 if (stv090x_i2c_gate_ctrl(state, 1) < 0)
2247 } 2219 goto err;
2220
2221 if (state->config->tuner_get_status) {
2222 if (state->config->tuner_get_status(fe, &reg) < 0)
2223 goto err_gateoff;
2248 } 2224 }
2225
2226 if (reg)
2227 dprintk(FE_DEBUG, 1, "Tuner phase locked");
2228 else
2229 dprintk(FE_DEBUG, 1, "Tuner unlocked");
2230
2231 if (stv090x_i2c_gate_ctrl(state, 0) < 0)
2232 goto err;
2233
2234 STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1c);
2235 if (STV090x_WRITE_DEMOD(state, CFRINIT1, 0x00) < 0)
2236 goto err;
2237 if (STV090x_WRITE_DEMOD(state, CFRINIT0, 0x00) < 0)
2238 goto err;
2239 if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x1f) < 0)
2240 goto err;
2241 if (STV090x_WRITE_DEMOD(state, DMDISTATE, 0x15) < 0)
2242 goto err;
2243 lock = stv090x_get_dmdlock(state, (timeout_dmd / 3));
2244
2245 dir *= -1;
2246 cur_step++;
2249 } 2247 }
2250 2248
2251 return lock; 2249 return lock;