mb86a20s: some smatch fixes
A message that is not in the archive (sent off-list or not yet received): 20130401072529.GL18466@mwanda
cover mb86a20s: some smatch fixes
As pointed by Dan Carpenter, there are two smatch warnings on this driver:
drivers/media/dvb-frontends/mb86a20s.c:1897 mb86a20s_set_frontend() error: buffer overflow 'mb86a20s_subchannel' 8 <= 8 drivers/media/dvb-frontends/mb86a20s.c:644 mb86a20s_layer_bitrate() error: buffer overflow 'state->estimated_rate' 3 <= 3
While both of them are trivial, one of the errors were due to a bad cut-and-paste silly error, plus the abuse of "i" on loops and array indexes.
So, let's fix both errors and remove the "i" temp var abuse on the driver.
Mauro Carvalho Chehab (5):
[media] mb86a20s: Use a macro for the number of layers [media] mb86a20s: Fix estimate_rate setting
[media] mb86a20s: fix audio sub-channel check
[media] mb86a20s: Use 'layer' instead of 'i' on all places [media] mb86a20s: better name temp vars at mb86a20s_layer_bitrate()
drivers/media/dvb-frontends/mb86a20s.c | 213 +++++++++++++++++---------------- 1 file changed, 108 insertions(+), 105 deletions(-)
Signature · 1 line
1.8.1.4
PATCH 1/5 mb86a20s: Use a macro for the number of layers
Instead of using the magic number "3", use NUM_LAYERS macro on all places that are related to the ISDB-T layers.
This makes the source code a little more readable.
No functional changes.
--- drivers/media/dvb-frontends/mb86a20s.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-)
drivers/media/dvb-frontends/mb86a20s.c +17 -15
@@ -20,6 +20,8 @@#include "dvb_frontend.h" #include "mb86a20s.h" +#define NUM_LAYERS 3 +static int debug =1 ;module_param (debug, int,0644 );MODULE_PARM_DESC (debug,"Activates frontend debugging (default:0)" );
@@ -48,7 +50,7 @@ struct mb86a20s_state {bool inversion;u32 subchannel; -u32 estimated_rate[3 ]; +u32 estimated_rate[NUM_LAYERS ];unsigned long get_strength_time;bool need_init;
@@ -666,7 +668,7 @@ static int mb86a20s_get_frontend(struct dvb_frontend *fe)/* Get per-layer data */ -for (i =0 ; i <3 ; i++) { +for (i =0 ; i <NUM_LAYERS ; i++) {dev_dbg (&state->i2c->dev,"%s: getting data for layer %c.\n" , __func__,'A' + i);
@@ -828,7 +830,7 @@ static int mb86a20s_get_pre_ber(struct dvb_frontend *fe,dev_dbg (&state->i2c->dev,"%s called.\n" , __func__); -if (layer >=3 ) +if (layer >=NUM_LAYERS )return -EINVAL ;/* Check if the BER measures are already available */
@@ -962,7 +964,7 @@ static int mb86a20s_get_post_ber(struct dvb_frontend *fe,dev_dbg (&state->i2c->dev,"%s called.\n" , __func__); -if (layer >=3 ) +if (layer >=NUM_LAYERS )return -EINVAL ;/* Check if the BER measures are already available */
@@ -1089,7 +1091,7 @@ static int mb86a20s_get_blk_error(struct dvb_frontend *fe,u32 collect_rate;dev_dbg (&state->i2c->dev,"%s called.\n" , __func__); -if (layer >=3 ) +if (layer >=NUM_LAYERS )return -EINVAL ;/* Check if the PER measures are already available */
@@ -1476,7 +1478,7 @@ static int mb86a20s_get_blk_error_layer_CNR(struct dvb_frontend *fe) }/* Read all layers */ -for (i =0 ; i <3 ; i++) { +for (i =0 ; i <NUM_LAYERS ; i++) {if (!(c->isdbt_layer_enabled & (1 << i))) { c->cnr.stat[1 + i].scale =FE_SCALE_NOT_AVAILABLE ;continue ;
@@ -1565,20 +1567,20 @@ static void mb86a20s_stats_not_ready(struct dvb_frontend *fe) c->strength.len =1 ;/* Per-layer stats - 3 layers + global */ - c->cnr.len =4 ; - c->pre_bit_error.len =4 ; - c->pre_bit_count.len =4 ; - c->post_bit_error.len =4 ; - c->post_bit_count.len =4 ; - c->block_error.len =4 ; - c->block_count.len =4 ; + c->cnr.len =NUM_LAYERS +1 ; + c->pre_bit_error.len =NUM_LAYERS +1 ; + c->pre_bit_count.len =NUM_LAYERS +1 ; + c->post_bit_error.len =NUM_LAYERS +1 ; + c->post_bit_count.len =NUM_LAYERS +1 ; + c->block_error.len =NUM_LAYERS +1 ; + c->block_count.len =NUM_LAYERS +1 ;/* Signal is always available */ c->strength.stat[0 ].scale =FE_SCALE_RELATIVE ; c->strength.stat[0 ].uvalue =0 ;/* Put all of them at FE_SCALE_NOT_AVAILABLE */ -for (i =0 ; i <4 ; i++) { +for (i =0 ; i <NUM_LAYERS +1 ; i++) { c->cnr.stat[i].scale =FE_SCALE_NOT_AVAILABLE ; c->pre_bit_error.stat[i].scale =FE_SCALE_NOT_AVAILABLE ; c->pre_bit_count.stat[i].scale =FE_SCALE_NOT_AVAILABLE ;
@@ -1617,7 +1619,7 @@ static int mb86a20s_get_stats(struct dvb_frontend *fe, int status_nr)if (status_nr <9 )return 0 ; -for (i =0 ; i <3 ; i++) { +for (i =0 ; i <NUM_LAYERS ; i++) {if (c->isdbt_layer_enabled & (1 << i)) {/* Layer is active and has rc segments */ active_layers++;
Signature · 1 line
1.8.1.4
PATCH 2/5 mb86a20s: Fix estimate_rate setting
In reply to Mauro Carvalho ChehabAs reported by Dan Carpenter <[email protected]>:
Smatch warnings: drivers/media/dvb-frontends/mb86a20s.c:644 mb86a20s_layer_bitrate() error: buffer overflow 'state->estimated_rate' 3 <= 3
What happens there is that estimate_rate index should be the layer number, and not the guard interval.
--- drivers/media/dvb-frontends/mb86a20s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb-frontends/mb86a20s.c +1 -1
@@ -642,7 +642,7 @@ static void mb86a20s_layer_bitrate(struct dvb_frontend *fe, u32 layer, __func__,'A' + layer, segment * isdbt_rate[m][f][i]/1000 , rate, rate); - state->estimated_rate[i] = rate; + state->estimated_rate[layer] = rate; }
Signature · 1 line
1.8.1.4
PATCH 3/5 mb86a20s: fix audio sub-channel check
In reply to Mauro Carvalho ChehabAs reported by Dan Carpenter <[email protected]>
FYI, there are new smatch warnings show up in:
tree: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next master head: da17d7bda957ae4697b6abc0793f74fb9b50b58f commit: 04fa725e7b1c22c583dd71a8cd85b8d997edfce3 [media] mb86a20s: Implement set_frontend cache logic New smatch warnings: drivers/media/dvb-frontends/mb86a20s.c:1897 mb86a20s_set_frontend() error: buffer overflow 'mb86a20s_subchannel' 8 <= 8 04fa725e Mauro Carvalho Chehab 2013-03-04 1894 if (c->isdbt_sb_subchannel > ARRAY_SIZE(mb86a20s_subchannel)) 04fa725e Mauro Carvalho Chehab 2013-03-04 1895 c->isdbt_sb_subchannel = 0; 04fa725e Mauro Carvalho Chehab 2013-03-04 1896 04fa725e Mauro Carvalho Chehab 2013-03-04 @1897 state->subchannel = mb86a20s_subchannel[c->isdbt_sb_subchannel];
--- drivers/media/dvb-frontends/mb86a20s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb-frontends/mb86a20s.c +1 -1
@@ -1915,7 +1915,7 @@ static int mb86a20s_set_frontend(struct dvb_frontend *fe)if (!c->isdbt_sb_mode) { state->subchannel =0 ; }else { -if (c->isdbt_sb_subchannel >ARRAY_SIZE (mb86a20s_subchannel)) +if (c->isdbt_sb_subchannel >=ARRAY_SIZE (mb86a20s_subchannel)) c->isdbt_sb_subchannel =0 ; state->subchannel = mb86a20s_subchannel[c->isdbt_sb_subchannel];
Signature · 1 line
1.8.1.4
PATCH 4/5 mb86a20s: Use 'layer' instead of 'i' on all places
In reply to Mauro Carvalho ChehabWe're using the anonymous 'i' to indicate the layer number on several places on the driver. That's not good, as some cut-and-paste type of change might be doing the wrong thing.
So, call it as "layer" everywhere.
--- drivers/media/dvb-frontends/mb86a20s.c | 148 ++++++++++++++++----------------- 1 file changed, 74 insertions(+), 74 deletions(-)
drivers/media/dvb-frontends/mb86a20s.c +74 -74
@@ -650,7 +650,7 @@ static int mb86a20s_get_frontend(struct dvb_frontend *fe) {struct mb86a20s_state *state = fe->demodulator_priv;struct dtv_frontend_properties *c = &fe->dtv_property_cache; -int i, rc; +int layer, rc;dev_dbg (&state->i2c->dev,"%s called.\n" , __func__);
@@ -668,43 +668,43 @@ static int mb86a20s_get_frontend(struct dvb_frontend *fe)/* Get per-layer data */ -for (i =0 ; i <NUM_LAYERS ; i++) { +for (layer =0 ; layer <NUM_LAYERS ; layer++) {dev_dbg (&state->i2c->dev,"%s: getting data for layer %c.\n" , - __func__,'A' + i); + __func__,'A' + layer); - rc =mb86a20s_get_segment_count (state, i); + rc =mb86a20s_get_segment_count (state, layer);if (rc <0 ) goto noperlayer_error;if (rc >=0 && rc <14 ) { - c->layer[i].segment_count = rc; + c->layer[layer].segment_count = rc; }else { - c->layer[i].segment_count =0 ; - state->estimated_rate[i] =0 ; + c->layer[layer].segment_count =0 ; + state->estimated_rate[layer] =0 ;continue ; } - c->isdbt_layer_enabled |=1 << i; - rc =mb86a20s_get_modulation (state, i); + c->isdbt_layer_enabled |=1 << layer; + rc =mb86a20s_get_modulation (state, layer);if (rc <0 ) goto noperlayer_error;dev_dbg (&state->i2c->dev,"%s: modulation %d.\n" , __func__, rc); - c->layer[i].modulation = rc; - rc =mb86a20s_get_fec (state, i); + c->layer[layer].modulation = rc; + rc =mb86a20s_get_fec (state, layer);if (rc <0 ) goto noperlayer_error;dev_dbg (&state->i2c->dev,"%s: FEC %d.\n" , __func__, rc); - c->layer[i].fec = rc; - rc =mb86a20s_get_interleaving (state, i); + c->layer[layer].fec = rc; + rc =mb86a20s_get_interleaving (state, layer);if (rc <0 ) goto noperlayer_error;dev_dbg (&state->i2c->dev,"%s: interleaving %d.\n" , __func__, rc); - c->layer[i].interleaving = rc; -mb86a20s_layer_bitrate (fe, i, c->layer[i].modulation, - c->layer[i].fec, - c->layer[i].interleaving, - c->layer[i].segment_count); + c->layer[layer].interleaving = rc; +mb86a20s_layer_bitrate (fe, layer, c->layer[layer].modulation, + c->layer[layer].fec, + c->layer[layer].interleaving, + c->layer[layer].segment_count); } rc =mb86a20s_writereg (state,0x6d ,0x84 );
@@ -1456,7 +1456,7 @@ static int mb86a20s_get_blk_error_layer_CNR(struct dvb_frontend *fe)struct mb86a20s_state *state = fe->demodulator_priv;struct dtv_frontend_properties *c = &fe->dtv_property_cache;u32 mer, cnr; -int rc, val, i; +int rc, val, layer;struct linear_segments *segs;unsigned segs_len;
@@ -1478,27 +1478,27 @@ static int mb86a20s_get_blk_error_layer_CNR(struct dvb_frontend *fe) }/* Read all layers */ -for (i =0 ; i <NUM_LAYERS ; i++) { -if (!(c->isdbt_layer_enabled & (1 << i))) { - c->cnr.stat[1 + i].scale =FE_SCALE_NOT_AVAILABLE ; +for (layer =0 ; layer <NUM_LAYERS ; layer++) { +if (!(c->isdbt_layer_enabled & (1 << layer))) { + c->cnr.stat[1 + layer].scale =FE_SCALE_NOT_AVAILABLE ;continue ; } - rc =mb86a20s_writereg (state,0x50 ,0x52 + i *3 ); + rc =mb86a20s_writereg (state,0x50 ,0x52 + layer *3 );if (rc <0 )return rc; rc =mb86a20s_readreg (state,0x51 );if (rc <0 )return rc; mer = rc <<16 ; - rc =mb86a20s_writereg (state,0x50 ,0x53 + i *3 ); + rc =mb86a20s_writereg (state,0x50 ,0x53 + layer *3 );if (rc <0 )return rc; rc =mb86a20s_readreg (state,0x51 );if (rc <0 )return rc; mer |= rc <<8 ; - rc =mb86a20s_writereg (state,0x50 ,0x54 + i *3 ); + rc =mb86a20s_writereg (state,0x50 ,0x54 + layer *3 );if (rc <0 )return rc; rc =mb86a20s_readreg (state,0x51 );
@@ -1506,7 +1506,7 @@ static int mb86a20s_get_blk_error_layer_CNR(struct dvb_frontend *fe)return rc; mer |= rc; -switch (c->layer[i].modulation) { +switch (c->layer[layer].modulation) {case DQPSK :case QPSK : segs = cnr_qpsk_table;
@@ -1524,12 +1524,12 @@ static int mb86a20s_get_blk_error_layer_CNR(struct dvb_frontend *fe) } cnr =interpolate_value (mer, segs, segs_len); - c->cnr.stat[1 + i].scale =FE_SCALE_DECIBEL ; - c->cnr.stat[1 + i].svalue = cnr; + c->cnr.stat[1 + layer].scale =FE_SCALE_DECIBEL ; + c->cnr.stat[1 + layer].svalue = cnr;dev_dbg (&state->i2c->dev,"%s: CNR for layer %c is %d.%03d dB (MER = %d).\n" , - __func__,'A' + i, cnr /1000 , cnr %1000 , mer); + __func__,'A' + layer, cnr /1000 , cnr %1000 , mer); }
@@ -1557,7 +1557,7 @@ static void mb86a20s_stats_not_ready(struct dvb_frontend *fe) {struct mb86a20s_state *state = fe->demodulator_priv;struct dtv_frontend_properties *c = &fe->dtv_property_cache; -int i; +int layer;dev_dbg (&state->i2c->dev,"%s called.\n" , __func__);
@@ -1580,14 +1580,14 @@ static void mb86a20s_stats_not_ready(struct dvb_frontend *fe) c->strength.stat[0 ].uvalue =0 ;/* Put all of them at FE_SCALE_NOT_AVAILABLE */ -for (i =0 ; i <NUM_LAYERS +1 ; i++) { - c->cnr.stat[i].scale =FE_SCALE_NOT_AVAILABLE ; - c->pre_bit_error.stat[i].scale =FE_SCALE_NOT_AVAILABLE ; - c->pre_bit_count.stat[i].scale =FE_SCALE_NOT_AVAILABLE ; - c->post_bit_error.stat[i].scale =FE_SCALE_NOT_AVAILABLE ; - c->post_bit_count.stat[i].scale =FE_SCALE_NOT_AVAILABLE ; - c->block_error.stat[i].scale =FE_SCALE_NOT_AVAILABLE ; - c->block_count.stat[i].scale =FE_SCALE_NOT_AVAILABLE ; +for (layer =0 ; layer <NUM_LAYERS +1 ; layer++) { + c->cnr.stat[layer].scale =FE_SCALE_NOT_AVAILABLE ; + c->pre_bit_error.stat[layer].scale =FE_SCALE_NOT_AVAILABLE ; + c->pre_bit_count.stat[layer].scale =FE_SCALE_NOT_AVAILABLE ; + c->post_bit_error.stat[layer].scale =FE_SCALE_NOT_AVAILABLE ; + c->post_bit_count.stat[layer].scale =FE_SCALE_NOT_AVAILABLE ; + c->block_error.stat[layer].scale =FE_SCALE_NOT_AVAILABLE ; + c->block_count.stat[layer].scale =FE_SCALE_NOT_AVAILABLE ; } }
@@ -1595,7 +1595,7 @@ static int mb86a20s_get_stats(struct dvb_frontend *fe, int status_nr) {struct mb86a20s_state *state = fe->demodulator_priv;struct dtv_frontend_properties *c = &fe->dtv_property_cache; -int rc =0 , i; +int rc =0 , layer;u32 bit_error =0 , bit_count =0 ;u32 t_pre_bit_error =0 , t_pre_bit_count =0 ;u32 t_post_bit_error =0 , t_post_bit_count =0 ;
@@ -1619,90 +1619,90 @@ static int mb86a20s_get_stats(struct dvb_frontend *fe, int status_nr)if (status_nr <9 )return 0 ; -for (i =0 ; i <NUM_LAYERS ; i++) { -if (c->isdbt_layer_enabled & (1 << i)) { +for (layer =0 ; layer <NUM_LAYERS ; layer++) { +if (c->isdbt_layer_enabled & (1 << layer)) {/* Layer is active and has rc segments */ active_layers++;/* Handle BER before vterbi */ - rc =mb86a20s_get_pre_ber (fe, i, + rc =mb86a20s_get_pre_ber (fe, layer, &bit_error, &bit_count);if (rc >=0 ) { - c->pre_bit_error.stat[1 + i].scale =FE_SCALE_COUNTER ; - c->pre_bit_error.stat[1 + i].uvalue += bit_error; - c->pre_bit_count.stat[1 + i].scale =FE_SCALE_COUNTER ; - c->pre_bit_count.stat[1 + i].uvalue += bit_count; + c->pre_bit_error.stat[1 + layer].scale =FE_SCALE_COUNTER ; + c->pre_bit_error.stat[1 + layer].uvalue += bit_error; + c->pre_bit_count.stat[1 + layer].scale =FE_SCALE_COUNTER ; + c->pre_bit_count.stat[1 + layer].uvalue += bit_count; }else if (rc != -EBUSY ) {/* * If an I/O error happened, * measures are now unavailable */ - c->pre_bit_error.stat[1 + i].scale =FE_SCALE_NOT_AVAILABLE ; - c->pre_bit_count.stat[1 + i].scale =FE_SCALE_NOT_AVAILABLE ; + c->pre_bit_error.stat[1 + layer].scale =FE_SCALE_NOT_AVAILABLE ; + c->pre_bit_count.stat[1 + layer].scale =FE_SCALE_NOT_AVAILABLE ;dev_err (&state->i2c->dev,"%s: Can't get BER for layer %c (error %d).\n" , - __func__,'A' + i, rc); + __func__,'A' + layer, rc); } -if (c->block_error.stat[1 + i].scale !=FE_SCALE_NOT_AVAILABLE ) +if (c->block_error.stat[1 + layer].scale !=FE_SCALE_NOT_AVAILABLE ) pre_ber_layers++;/* Handle BER post vterbi */ - rc =mb86a20s_get_post_ber (fe, i, + rc =mb86a20s_get_post_ber (fe, layer, &bit_error, &bit_count);if (rc >=0 ) { - c->post_bit_error.stat[1 + i].scale =FE_SCALE_COUNTER ; - c->post_bit_error.stat[1 + i].uvalue += bit_error; - c->post_bit_count.stat[1 + i].scale =FE_SCALE_COUNTER ; - c->post_bit_count.stat[1 + i].uvalue += bit_count; + c->post_bit_error.stat[1 + layer].scale =FE_SCALE_COUNTER ; + c->post_bit_error.stat[1 + layer].uvalue += bit_error; + c->post_bit_count.stat[1 + layer].scale =FE_SCALE_COUNTER ; + c->post_bit_count.stat[1 + layer].uvalue += bit_count; }else if (rc != -EBUSY ) {/* * If an I/O error happened, * measures are now unavailable */ - c->post_bit_error.stat[1 + i].scale =FE_SCALE_NOT_AVAILABLE ; - c->post_bit_count.stat[1 + i].scale =FE_SCALE_NOT_AVAILABLE ; + c->post_bit_error.stat[1 + layer].scale =FE_SCALE_NOT_AVAILABLE ; + c->post_bit_count.stat[1 + layer].scale =FE_SCALE_NOT_AVAILABLE ;dev_err (&state->i2c->dev,"%s: Can't get BER for layer %c (error %d).\n" , - __func__,'A' + i, rc); + __func__,'A' + layer, rc); } -if (c->block_error.stat[1 + i].scale !=FE_SCALE_NOT_AVAILABLE ) +if (c->block_error.stat[1 + layer].scale !=FE_SCALE_NOT_AVAILABLE ) post_ber_layers++;/* Handle Block errors for PER/UCB reports */ - rc =mb86a20s_get_blk_error (fe, i, + rc =mb86a20s_get_blk_error (fe, layer, &block_error, &block_count);if (rc >=0 ) { - c->block_error.stat[1 + i].scale =FE_SCALE_COUNTER ; - c->block_error.stat[1 + i].uvalue += block_error; - c->block_count.stat[1 + i].scale =FE_SCALE_COUNTER ; - c->block_count.stat[1 + i].uvalue += block_count; + c->block_error.stat[1 + layer].scale =FE_SCALE_COUNTER ; + c->block_error.stat[1 + layer].uvalue += block_error; + c->block_count.stat[1 + layer].scale =FE_SCALE_COUNTER ; + c->block_count.stat[1 + layer].uvalue += block_count; }else if (rc != -EBUSY ) {/* * If an I/O error happened, * measures are now unavailable */ - c->block_error.stat[1 + i].scale =FE_SCALE_NOT_AVAILABLE ; - c->block_count.stat[1 + i].scale =FE_SCALE_NOT_AVAILABLE ; + c->block_error.stat[1 + layer].scale =FE_SCALE_NOT_AVAILABLE ; + c->block_count.stat[1 + layer].scale =FE_SCALE_NOT_AVAILABLE ;dev_err (&state->i2c->dev,"%s: Can't get PER for layer %c (error %d).\n" , - __func__,'A' + i, rc); + __func__,'A' + layer, rc); } -if (c->block_error.stat[1 + i].scale !=FE_SCALE_NOT_AVAILABLE ) +if (c->block_error.stat[1 + layer].scale !=FE_SCALE_NOT_AVAILABLE ) per_layers++;/* Update total preBER */ - t_pre_bit_error += c->pre_bit_error.stat[1 + i].uvalue; - t_pre_bit_count += c->pre_bit_count.stat[1 + i].uvalue; + t_pre_bit_error += c->pre_bit_error.stat[1 + layer].uvalue; + t_pre_bit_count += c->pre_bit_count.stat[1 + layer].uvalue;/* Update total postBER */ - t_post_bit_error += c->post_bit_error.stat[1 + i].uvalue; - t_post_bit_count += c->post_bit_count.stat[1 + i].uvalue; + t_post_bit_error += c->post_bit_error.stat[1 + layer].uvalue; + t_post_bit_count += c->post_bit_count.stat[1 + layer].uvalue;/* Update total PER */ - t_block_error += c->block_error.stat[1 + i].uvalue; - t_block_count += c->block_count.stat[1 + i].uvalue; + t_block_error += c->block_error.stat[1 + layer].uvalue; + t_block_count += c->block_count.stat[1 + layer].uvalue; } }
Signature · 1 line
1.8.1.4
PATCH 5/5 mb86a20s: better name temp vars at mb86a20s_layer_bitrate()
In reply to Mauro Carvalho ChehabUsing 'i' for the guard interval temporary var is a bad idea, as 'i' is generally used by "anonymous" indexes.
Let's rename modulation, fec and guard interval temp vars with a meaningful name, as that makes easier to understand the code and avoids cut-and-paste types of error.
--- drivers/media/dvb-frontends/mb86a20s.c | 37 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-)
drivers/media/dvb-frontends/mb86a20s.c +19 -18
@@ -566,12 +566,13 @@ static u32 isdbt_rate[3][5][4] = { };static void mb86a20s_layer_bitrate (struct dvb_frontend *fe,u32 layer, -u32 modulation,u32 fec,u32 interleaving, +u32 modulation,u32 forward_error_correction, +u32 interleaving,u32 segment) {struct mb86a20s_state *state = fe->demodulator_priv;u32 rate; -int m, f, i; +int mod, fec, guard;/* * If modulation/fec/interleaving is not detected, the default is
@@ -582,54 +583,54 @@ static void mb86a20s_layer_bitrate(struct dvb_frontend *fe, u32 layer,case DQPSK :case QPSK :default : - m =0 ; + mod =0 ;break ;case QAM_16 : - m =1 ; + mod =1 ;break ;case QAM_64 : - m =2 ; + mod =2 ;break ; } -switch (fec) { +switch (forward_error_correction) {default :case FEC_1_2 :case FEC_AUTO : - f =0 ; + fec =0 ;break ;case FEC_2_3 : - f =1 ; + fec =1 ;break ;case FEC_3_4 : - f =2 ; + fec =2 ;break ;case FEC_5_6 : - f =3 ; + fec =3 ;break ;case FEC_7_8 : - f =4 ; + fec =4 ;break ; }switch (interleaving) {default :case GUARD_INTERVAL_1_4 : - i =0 ; + guard =0 ;break ;case GUARD_INTERVAL_1_8 : - i =1 ; + guard =1 ;break ;case GUARD_INTERVAL_1_16 : - i =2 ; + guard =2 ;break ;case GUARD_INTERVAL_1_32 : - i =3 ; + guard =3 ;break ; }/* Samples BER at BER_SAMPLING_RATE seconds */ - rate = isdbt_rate[m][f][i] * segment *BER_SAMPLING_RATE ; + rate = isdbt_rate[mod][fec][guard] * segment *BER_SAMPLING_RATE ;/* Avoids sampling too quickly or to overflow the register */ if (rate <256 )
@@ -639,13 +640,13 @@ static void mb86a20s_layer_bitrate(struct dvb_frontend *fe, u32 layer,dev_dbg (&state->i2c->dev,"%s: layer %c bitrate: %d kbps; counter = %d (0x%06x)\n" , - __func__,'A' + layer, segment * isdbt_rate[m][f][i]/1000 , + __func__,'A' + layer, + segment * isdbt_rate[mod][fec][guard]/1000 , rate, rate); state->estimated_rate[layer] = rate; } -static int mb86a20s_get_frontend (struct dvb_frontend *fe) {struct mb86a20s_state *state = fe->demodulator_priv;
Signature · 1 line
1.8.1.4