media: dvb-frontends: delete jump targets
authorMarkus Elfring <elfring@users.sourceforge.net>
Wed, 30 Aug 2017 06:44:29 +0000 (02:44 -0400)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Sat, 23 Sep 2017 12:23:59 +0000 (08:23 -0400)
* Return directly after a call of the function "kzalloc" failed
  at the beginning.

* Move a bit of exception handling code into an if branch.

* Delete jump targets which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
drivers/media/dvb-frontends/cx24113.c
drivers/media/dvb-frontends/cx24116.c
drivers/media/dvb-frontends/ds3000.c
drivers/media/dvb-frontends/mb86a20s.c

index 2c5502c..ee1f704 100644 (file)
@@ -556,7 +556,7 @@ struct dvb_frontend *cx24113_attach(struct dvb_frontend *fe,
        int rc;
 
        if (!state)
-               goto error;
+               return NULL;
 
        /* setup the state */
        state->config = config;
index 531c586..8fb3f09 100644 (file)
@@ -226,10 +226,8 @@ static int cx24116_writeregN(struct cx24116_state *state, int reg,
        u8 *buf;
 
        buf = kmalloc(len + 1, GFP_KERNEL);
-       if (buf == NULL) {
-               ret = -ENOMEM;
-               goto error;
-       }
+       if (!buf)
+               return -ENOMEM;
 
        *(buf) = reg;
        memcpy(buf + 1, data, len);
@@ -250,7 +248,6 @@ static int cx24116_writeregN(struct cx24116_state *state, int reg,
                ret = -EREMOTEIO;
        }
 
-error:
        kfree(buf);
 
        return ret;
@@ -1128,7 +1125,7 @@ struct dvb_frontend *cx24116_attach(const struct cx24116_config *config,
        /* allocate memory for the internal state */
        state = kzalloc(sizeof(*state), GFP_KERNEL);
        if (state == NULL)
-               goto error1;
+               return NULL;
 
        state->config = config;
        state->i2c = i2c;
@@ -1137,8 +1134,9 @@ struct dvb_frontend *cx24116_attach(const struct cx24116_config *config,
        ret = (cx24116_readreg(state, 0xFF) << 8) |
                cx24116_readreg(state, 0xFE);
        if (ret != 0x0501) {
+               kfree(state);
                printk(KERN_INFO "Invalid probe, probably not a CX24116 device\n");
-               goto error2;
+               return NULL;
        }
 
        /* create dvb_frontend */
@@ -1146,9 +1144,6 @@ struct dvb_frontend *cx24116_attach(const struct cx24116_config *config,
                sizeof(struct dvb_frontend_ops));
        state->frontend.demodulator_priv = state;
        return &state->frontend;
-
-error2: kfree(state);
-error1: return NULL;
 }
 EXPORT_SYMBOL(cx24116_attach);
 
index 3e347d0..bd4f827 100644 (file)
@@ -841,7 +841,7 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config,
        /* allocate memory for the internal state */
        state = kzalloc(sizeof(*state), GFP_KERNEL);
        if (!state)
-               goto error2;
+               return NULL;
 
        state->config = config;
        state->i2c = i2c;
@@ -850,8 +850,9 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config,
        /* check if the demod is present */
        ret = ds3000_readreg(state, 0x00) & 0xfe;
        if (ret != 0xe0) {
+               kfree(state);
                printk(KERN_ERR "Invalid probe, probably not a DS3000\n");
-               goto error3;
+               return NULL;
        }
 
        printk(KERN_INFO "DS3000 chip version: %d.%d attached.\n",
@@ -869,11 +870,6 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config,
         */
        ds3000_set_voltage(&state->frontend, SEC_VOLTAGE_OFF);
        return &state->frontend;
-
-error3:
-       kfree(state);
-error2:
-       return NULL;
 }
 EXPORT_SYMBOL(ds3000_attach);
 
index ba7a433..bdaf9d2 100644 (file)
@@ -2073,7 +2073,7 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config,
        /* allocate memory for the internal state */
        state = kzalloc(sizeof(*state), GFP_KERNEL);
        if (!state)
-               goto error;
+               return NULL;
 
        /* setup the state */
        state->config = config;
@@ -2086,22 +2086,16 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config,
 
        /* Check if it is a mb86a20s frontend */
        rev = mb86a20s_readreg(state, 0);
-
-       if (rev == 0x13) {
-               dev_info(&i2c->dev,
-                        "Detected a Fujitsu mb86a20s frontend\n");
-       } else {
+       if (rev != 0x13) {
+               kfree(state);
                dev_dbg(&i2c->dev,
                        "Frontend revision %d is unknown - aborting.\n",
                       rev);
-               goto error;
+               return NULL;
        }
 
+       dev_info(&i2c->dev, "Detected a Fujitsu mb86a20s frontend\n");
        return &state->frontend;
-
-error:
-       kfree(state);
-       return NULL;
 }
 EXPORT_SYMBOL(mb86a20s_attach);