aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorManu Abraham <abraham.manu@gmail.com>2009-01-27 09:03:16 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-13 12:19:16 -0400
commitb5d067b8e331ce78f4a81eb220965ffa36069d3f (patch)
tree13690acd899d5d2e550af383e6af8b0e49aeceff /drivers/media
parentd284e4f71dd42826fb60df33846ba310310c6c51 (diff)
V4L/DVB (10975): Bug: Use signed types, Offsets and range can be negative
Code simplification: use in kernel macros Signed-off-by: Manu Abraham <manu@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/dvb/frontends/stb0899_algo.c14
-rw-r--r--drivers/media/dvb/frontends/stb0899_priv.h12
2 files changed, 11 insertions, 15 deletions
diff --git a/drivers/media/dvb/frontends/stb0899_algo.c b/drivers/media/dvb/frontends/stb0899_algo.c
index a67d1775a43c..2da55ec20392 100644
--- a/drivers/media/dvb/frontends/stb0899_algo.c
+++ b/drivers/media/dvb/frontends/stb0899_algo.c
@@ -156,7 +156,7 @@ static void stb0899_first_subrange(struct stb0899_state *state)
156 } 156 }
157 157
158 if (range > 0) 158 if (range > 0)
159 internal->sub_range = MIN(internal->srch_range, range); 159 internal->sub_range = min(internal->srch_range, range);
160 else 160 else
161 internal->sub_range = 0; 161 internal->sub_range = 0;
162 162
@@ -185,7 +185,7 @@ static enum stb0899_status stb0899_check_tmg(struct stb0899_state *state)
185 timing = stb0899_read_reg(state, STB0899_RTF); 185 timing = stb0899_read_reg(state, STB0899_RTF);
186 186
187 if (lock >= 42) { 187 if (lock >= 42) {
188 if ((lock > 48) && (ABS(timing) >= 110)) { 188 if ((lock > 48) && (abs(timing) >= 110)) {
189 internal->status = ANALOGCARRIER; 189 internal->status = ANALOGCARRIER;
190 dprintk(state->verbose, FE_DEBUG, 1, "-->ANALOG Carrier !"); 190 dprintk(state->verbose, FE_DEBUG, 1, "-->ANALOG Carrier !");
191 } else { 191 } else {
@@ -222,7 +222,7 @@ static enum stb0899_status stb0899_search_tmg(struct stb0899_state *state)
222 index++; 222 index++;
223 derot_freq += index * internal->direction * derot_step; /* next derot zig zag position */ 223 derot_freq += index * internal->direction * derot_step; /* next derot zig zag position */
224 224
225 if (ABS(derot_freq) > derot_limit) 225 if (abs(derot_freq) > derot_limit)
226 next_loop--; 226 next_loop--;
227 227
228 if (next_loop) { 228 if (next_loop) {
@@ -298,7 +298,7 @@ static enum stb0899_status stb0899_search_carrier(struct stb0899_state *state)
298 last_derot_freq = derot_freq; 298 last_derot_freq = derot_freq;
299 derot_freq += index * internal->direction * internal->derot_step; /* next zig zag derotator position */ 299 derot_freq += index * internal->direction * internal->derot_step; /* next zig zag derotator position */
300 300
301 if(ABS(derot_freq) > derot_limit) 301 if(abs(derot_freq) > derot_limit)
302 next_loop--; 302 next_loop--;
303 303
304 if (next_loop) { 304 if (next_loop) {
@@ -400,7 +400,7 @@ static enum stb0899_status stb0899_search_data(struct stb0899_state *state)
400 if ((internal->status != CARRIEROK) || (stb0899_check_data(state) != DATAOK)) { 400 if ((internal->status != CARRIEROK) || (stb0899_check_data(state) != DATAOK)) {
401 401
402 derot_freq += index * internal->direction * derot_step; /* next zig zag derotator position */ 402 derot_freq += index * internal->direction * derot_step; /* next zig zag derotator position */
403 if (ABS(derot_freq) > derot_limit) 403 if (abs(derot_freq) > derot_limit)
404 next_loop--; 404 next_loop--;
405 405
406 if (next_loop) { 406 if (next_loop) {
@@ -467,7 +467,7 @@ static void next_sub_range(struct stb0899_state *state)
467 467
468 if (internal->sub_dir > 0) { 468 if (internal->sub_dir > 0) {
469 old_sub_range = internal->sub_range; 469 old_sub_range = internal->sub_range;
470 internal->sub_range = MIN((internal->srch_range / 2) - 470 internal->sub_range = min((internal->srch_range / 2) -
471 (internal->tuner_offst + internal->sub_range / 2), 471 (internal->tuner_offst + internal->sub_range / 2),
472 internal->sub_range); 472 internal->sub_range);
473 473
@@ -771,7 +771,7 @@ static long Log2Int(int number)
771 int i; 771 int i;
772 772
773 i = 0; 773 i = 0;
774 while ((1 << i) <= ABS(number)) 774 while ((1 << i) <= abs(number))
775 i++; 775 i++;
776 776
777 if (number == 0) 777 if (number == 0)
diff --git a/drivers/media/dvb/frontends/stb0899_priv.h b/drivers/media/dvb/frontends/stb0899_priv.h
index 24619e3689db..82395b912815 100644
--- a/drivers/media/dvb/frontends/stb0899_priv.h
+++ b/drivers/media/dvb/frontends/stb0899_priv.h
@@ -59,10 +59,6 @@
59#define MAKEWORD32(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) 59#define MAKEWORD32(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
60#define MAKEWORD16(a, b) (((a) << 8) | (b)) 60#define MAKEWORD16(a, b) (((a) << 8) | (b))
61 61
62#define MIN(x, y) ((x) <= (y) ? (x) : (y))
63#define MAX(x, y) ((x) >= (y) ? (x) : (y))
64#define ABS(x) ((x) >= 0 ? (x) : -(x))
65
66#define LSB(x) ((x & 0xff)) 62#define LSB(x) ((x & 0xff))
67#define MSB(y) ((y >> 8) & 0xff) 63#define MSB(y) ((y >> 8) & 0xff)
68 64
@@ -168,10 +164,10 @@ struct stb0899_internal {
168 u32 freq; /* Demod internal Frequency */ 164 u32 freq; /* Demod internal Frequency */
169 u32 srate; /* Demod internal Symbol rate */ 165 u32 srate; /* Demod internal Symbol rate */
170 enum stb0899_fec fecrate; /* Demod internal FEC rate */ 166 enum stb0899_fec fecrate; /* Demod internal FEC rate */
171 u32 srch_range; /* Demod internal Search Range */ 167 s32 srch_range; /* Demod internal Search Range */
172 u32 sub_range; /* Demod current sub range (Hz) */ 168 s32 sub_range; /* Demod current sub range (Hz) */
173 u32 tuner_step; /* Tuner step (Hz) */ 169 s32 tuner_step; /* Tuner step (Hz) */
174 u32 tuner_offst; /* Relative offset to carrier (Hz) */ 170 s32 tuner_offst; /* Relative offset to carrier (Hz) */
175 u32 tuner_bw; /* Current bandwidth of the tuner (Hz) */ 171 u32 tuner_bw; /* Current bandwidth of the tuner (Hz) */
176 172
177 s32 mclk; /* Masterclock Divider factor (binary) */ 173 s32 mclk; /* Masterclock Divider factor (binary) */