Merge branch 'stable/bug-fixes-rc2' of git://git.kernel.org/pub/scm/linux/kernel...
[pandora-kernel.git] / drivers / media / dvb / frontends / stv090x.c
index e3442a1..52d8712 100644 (file)
@@ -1424,7 +1424,7 @@ static int stv090x_start_search(struct stv090x_state *state)
                        if (STV090x_WRITE_DEMOD(state, CFRLOW0, 0x00) < 0)
                                goto err;
 
-                       /*enlarge the timing bandwith for Low SR*/
+                       /*enlarge the timing bandwidth for Low SR*/
                        if (STV090x_WRITE_DEMOD(state, RTCS2, 0x68) < 0)
                                goto err;
                } else {
@@ -1432,17 +1432,17 @@ static int stv090x_start_search(struct stv090x_state *state)
                        Set The carrier search up and low to auto mode */
                        if (STV090x_WRITE_DEMOD(state, CARCFG, 0xc4) < 0)
                                goto err;
-                       /*reduce the timing bandwith for high SR*/
+                       /*reduce the timing bandwidth for high SR*/
                        if (STV090x_WRITE_DEMOD(state, RTCS2, 0x44) < 0)
                                goto err;
                }
        } else {
                /* >= Cut 3 */
                if (state->srate <= 5000000) {
-                       /* enlarge the timing bandwith for Low SR */
+                       /* enlarge the timing bandwidth for Low SR */
                        STV090x_WRITE_DEMOD(state, RTCS2, 0x68);
                } else {
-                       /* reduce timing bandwith for high SR */
+                       /* reduce timing bandwidth for high SR */
                        STV090x_WRITE_DEMOD(state, RTCS2, 0x44);
                }
 
@@ -2482,7 +2482,7 @@ static int stv090x_sw_algo(struct stv090x_state *state)
                                        dvbs2_fly_wheel = STV090x_GETFIELD_Px(reg, FLYWHEEL_CPT_FIELD);
                                }
                                if (dvbs2_fly_wheel < 0xd) {
-                                       /*FALSE lock, The demod is loosing lock */
+                                       /*FALSE lock, The demod is losing lock */
                                        lock = 0;
                                        if (trials < 2) {
                                                if (state->internal->dev_ver >= 0x20) {
@@ -3202,7 +3202,7 @@ static enum stv090x_signal_state stv090x_algo(struct stv090x_state *state)
                        goto err;
                if (STV090x_WRITE_DEMOD(state, CORRELMANT, 0x70) < 0)
                        goto err;
-               if (stv090x_set_srate(state, 1000000) < 0) /* inital srate = 1Msps */
+               if (stv090x_set_srate(state, 1000000) < 0) /* initial srate = 1Msps */
                        goto err;
        } else {
                /* known srate */
@@ -4696,10 +4696,6 @@ static int stv090x_setup(struct dvb_frontend *fe)
        if (stv090x_write_reg(state, STV090x_TSTRES0, 0x00) < 0)
                goto err;
 
-       /* workaround for stuck DiSEqC output */
-       if (config->diseqc_envelope_mode)
-               stv090x_send_diseqc_burst(fe, SEC_MINI_A);
-
        return 0;
 err:
        dprintk(FE_ERROR, 1, "I/O error");
@@ -4784,30 +4780,36 @@ struct dvb_frontend *stv090x_attach(const struct stv090x_config *config,
                state->internal = temp_int->internal;
                state->internal->num_used++;
                dprintk(FE_INFO, 1, "Found Internal Structure!");
-               dprintk(FE_ERROR, 1, "Attaching %s demodulator(%d) Cut=0x%02x",
-                       state->device == STV0900 ? "STV0900" : "STV0903",
-                       demod,
-                       state->internal->dev_ver);
-               return &state->frontend;
        } else {
                state->internal = kmalloc(sizeof(struct stv090x_internal),
                                          GFP_KERNEL);
+               if (!state->internal)
+                       goto error;
                temp_int = append_internal(state->internal);
+               if (!temp_int) {
+                       kfree(state->internal);
+                       goto error;
+               }
                state->internal->num_used = 1;
                state->internal->mclk = 0;
                state->internal->dev_ver = 0;
                state->internal->i2c_adap = state->i2c;
                state->internal->i2c_addr = state->config->address;
                dprintk(FE_INFO, 1, "Create New Internal Structure!");
-       }
 
-       mutex_init(&state->internal->demod_lock);
-       mutex_init(&state->internal->tuner_lock);
+               mutex_init(&state->internal->demod_lock);
+               mutex_init(&state->internal->tuner_lock);
 
-       if (stv090x_setup(&state->frontend) < 0) {
-               dprintk(FE_ERROR, 1, "Error setting up device");
-               goto error;
+               if (stv090x_setup(&state->frontend) < 0) {
+                       dprintk(FE_ERROR, 1, "Error setting up device");
+                       goto err_remove;
+               }
        }
+
+       /* workaround for stuck DiSEqC output */
+       if (config->diseqc_envelope_mode)
+               stv090x_send_diseqc_burst(&state->frontend, SEC_MINI_A);
+
        dprintk(FE_ERROR, 1, "Attaching %s demodulator(%d) Cut=0x%02x",
               state->device == STV0900 ? "STV0900" : "STV0903",
               demod,
@@ -4815,6 +4817,9 @@ struct dvb_frontend *stv090x_attach(const struct stv090x_config *config,
 
        return &state->frontend;
 
+err_remove:
+       remove_dev(state->internal);
+       kfree(state->internal);
 error:
        kfree(state);
        return NULL;