[media] media: i2c: Convert to devm_kzalloc()
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Thu, 2 May 2013 11:29:43 +0000 (08:29 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 21 May 2013 10:52:15 +0000 (07:52 -0300)
Using the managed function the kfree() calls can be removed from the
probe error path and the remove handler.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
56 files changed:
drivers/media/i2c/ad9389b.c
drivers/media/i2c/adp1653.c
drivers/media/i2c/adv7170.c
drivers/media/i2c/adv7175.c
drivers/media/i2c/adv7180.c
drivers/media/i2c/adv7183.c
drivers/media/i2c/adv7393.c
drivers/media/i2c/adv7604.c
drivers/media/i2c/ak881x.c
drivers/media/i2c/as3645a.c
drivers/media/i2c/bt819.c
drivers/media/i2c/bt856.c
drivers/media/i2c/bt866.c
drivers/media/i2c/cs5345.c
drivers/media/i2c/cs53l32a.c
drivers/media/i2c/cx25840/cx25840-core.c
drivers/media/i2c/cx25840/cx25840-ir.c
drivers/media/i2c/ir-kbd-i2c.c
drivers/media/i2c/ks0127.c
drivers/media/i2c/m52790.c
drivers/media/i2c/m5mols/m5mols_core.c
drivers/media/i2c/msp3400-driver.c
drivers/media/i2c/mt9m032.c
drivers/media/i2c/mt9t001.c
drivers/media/i2c/mt9v011.c
drivers/media/i2c/mt9v032.c
drivers/media/i2c/noon010pc30.c
drivers/media/i2c/ov7640.c
drivers/media/i2c/ov7670.c
drivers/media/i2c/saa6588.c
drivers/media/i2c/saa7110.c
drivers/media/i2c/saa7115.c
drivers/media/i2c/saa7127.c
drivers/media/i2c/saa717x.c
drivers/media/i2c/saa7185.c
drivers/media/i2c/saa7191.c
drivers/media/i2c/sony-btf-mpx.c
drivers/media/i2c/sr030pc30.c
drivers/media/i2c/tda7432.c
drivers/media/i2c/tda9840.c
drivers/media/i2c/tea6415c.c
drivers/media/i2c/tea6420.c
drivers/media/i2c/tlv320aic23b.c
drivers/media/i2c/tvaudio.c
drivers/media/i2c/tvp5150.c
drivers/media/i2c/tw2804.c
drivers/media/i2c/tw9903.c
drivers/media/i2c/tw9906.c
drivers/media/i2c/uda1342.c
drivers/media/i2c/upd64031a.c
drivers/media/i2c/upd64083.c
drivers/media/i2c/vp27smpx.c
drivers/media/i2c/vpx3220.c
drivers/media/i2c/vs6624.c
drivers/media/i2c/wm8739.c
drivers/media/i2c/wm8775.c

index 58344b6c3a55ea19823553154d5c59294b268865..15043554cc8b4408ecbe55ebdbc6053d8e9fc170 100644 (file)
@@ -1188,15 +1188,14 @@ static int ad9389b_probe(struct i2c_client *client, const struct i2c_device_id *
        v4l_dbg(1, debug, client, "detecting ad9389b client on address 0x%x\n",
                        client->addr << 1);
 
-       state = kzalloc(sizeof(struct ad9389b_state), GFP_KERNEL);
+       state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
        if (!state)
                return -ENOMEM;
 
        /* Platform data */
        if (pdata == NULL) {
                v4l_err(client, "No platform data!\n");
-               err = -ENODEV;
-               goto err_free;
+               return -ENODEV;
        }
        memcpy(&state->pdata, pdata, sizeof(state->pdata));
 
@@ -1276,8 +1275,6 @@ err_entity:
        media_entity_cleanup(&sd->entity);
 err_hdl:
        v4l2_ctrl_handler_free(&state->hdl);
-err_free:
-       kfree(state);
        return err;
 }
 
@@ -1302,7 +1299,6 @@ static int ad9389b_remove(struct i2c_client *client)
        v4l2_device_unregister_subdev(sd);
        media_entity_cleanup(&sd->entity);
        v4l2_ctrl_handler_free(sd->ctrl_handler);
-       kfree(get_ad9389b_state(sd));
        return 0;
 }
 
index ef75abe5984c38f37c0025e9e38b85a8d45e44a9..873fe1949e986fb513103924d5377d7e5d219de4 100644 (file)
@@ -417,7 +417,7 @@ static int adp1653_probe(struct i2c_client *client,
        if (client->dev.platform_data == NULL)
                return -ENODEV;
 
-       flash = kzalloc(sizeof(*flash), GFP_KERNEL);
+       flash = devm_kzalloc(&client->dev, sizeof(*flash), GFP_KERNEL);
        if (flash == NULL)
                return -ENOMEM;
 
@@ -443,7 +443,6 @@ static int adp1653_probe(struct i2c_client *client,
 
 free_and_quit:
        v4l2_ctrl_handler_free(&flash->ctrls);
-       kfree(flash);
        return ret;
 }
 
@@ -455,7 +454,7 @@ static int adp1653_remove(struct i2c_client *client)
        v4l2_device_unregister_subdev(&flash->subdev);
        v4l2_ctrl_handler_free(&flash->ctrls);
        media_entity_cleanup(&flash->subdev.entity);
-       kfree(flash);
+
        return 0;
 }
 
index 6bc01fb98ff8bfad5c7c6e173d78f6151b6b3277..d07689d44354232be7ba18523ba728ed7a559451 100644 (file)
@@ -359,7 +359,7 @@ static int adv7170_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       encoder = kzalloc(sizeof(struct adv7170), GFP_KERNEL);
+       encoder = devm_kzalloc(&client->dev, sizeof(*encoder), GFP_KERNEL);
        if (encoder == NULL)
                return -ENOMEM;
        sd = &encoder->sd;
@@ -384,7 +384,6 @@ static int adv7170_remove(struct i2c_client *client)
        struct v4l2_subdev *sd = i2c_get_clientdata(client);
 
        v4l2_device_unregister_subdev(sd);
-       kfree(to_adv7170(sd));
        return 0;
 }
 
index c7640fab5730d8dadcab775129ac894dd370e6fe..eaefa50b8d2896c0f9fedd2d30c6a3a62597d9f7 100644 (file)
@@ -409,7 +409,7 @@ static int adv7175_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       encoder = kzalloc(sizeof(struct adv7175), GFP_KERNEL);
+       encoder = devm_kzalloc(&client->dev, sizeof(*encoder), GFP_KERNEL);
        if (encoder == NULL)
                return -ENOMEM;
        sd = &encoder->sd;
@@ -434,7 +434,6 @@ static int adv7175_remove(struct i2c_client *client)
        struct v4l2_subdev *sd = i2c_get_clientdata(client);
 
        v4l2_device_unregister_subdev(sd);
-       kfree(to_adv7175(sd));
        return 0;
 }
 
index afd561ab190d50a09789b6adafa92c38bb8294a4..3d14567803181a92b75ad23eba48cec58be9d2f7 100644 (file)
@@ -555,7 +555,7 @@ static int adv7180_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%02x (%s)\n",
                 client->addr, client->adapter->name);
 
-       state = kzalloc(sizeof(struct adv7180_state), GFP_KERNEL);
+       state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
        if (state == NULL) {
                ret = -ENOMEM;
                goto err;
@@ -582,7 +582,6 @@ err_free_ctrl:
 err_unreg_subdev:
        mutex_destroy(&state->mutex);
        v4l2_device_unregister_subdev(sd);
-       kfree(state);
 err:
        printk(KERN_ERR KBUILD_MODNAME ": Failed to probe: %d\n", ret);
        return ret;
@@ -607,7 +606,6 @@ static int adv7180_remove(struct i2c_client *client)
 
        mutex_destroy(&state->mutex);
        v4l2_device_unregister_subdev(sd);
-       kfree(to_state(sd));
        return 0;
 }
 
index 2bc032894bae7e3848145961462a7c058c420dac..56904174abc3038bdfffd4e8bef6e96cb2e297b4 100644 (file)
@@ -573,7 +573,7 @@ static int adv7183_probe(struct i2c_client *client,
        if (pin_array == NULL)
                return -EINVAL;
 
-       decoder = kzalloc(sizeof(struct adv7183), GFP_KERNEL);
+       decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL);
        if (decoder == NULL)
                return -ENOMEM;
 
@@ -583,8 +583,7 @@ static int adv7183_probe(struct i2c_client *client,
        if (gpio_request_one(decoder->reset_pin, GPIOF_OUT_INIT_LOW,
                             "ADV7183 Reset")) {
                v4l_err(client, "failed to request GPIO %d\n", decoder->reset_pin);
-               ret = -EBUSY;
-               goto err_free_decoder;
+               return -EBUSY;
        }
 
        if (gpio_request_one(decoder->oe_pin, GPIOF_OUT_INIT_HIGH,
@@ -646,8 +645,6 @@ err_free_oe:
        gpio_free(decoder->oe_pin);
 err_free_reset:
        gpio_free(decoder->reset_pin);
-err_free_decoder:
-       kfree(decoder);
        return ret;
 }
 
@@ -660,7 +657,6 @@ static int adv7183_remove(struct i2c_client *client)
        v4l2_ctrl_handler_free(sd->ctrl_handler);
        gpio_free(decoder->oe_pin);
        gpio_free(decoder->reset_pin);
-       kfree(decoder);
        return 0;
 }
 
index 3dc6098c7267716ddb2c05e9d312247dd8dfeee5..ec505098598ac122f40eea2b64ecb0e4fa7238a5 100644 (file)
@@ -410,7 +410,7 @@ static int adv7393_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       state = kzalloc(sizeof(struct adv7393_state), GFP_KERNEL);
+       state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
        if (state == NULL)
                return -ENOMEM;
 
@@ -444,16 +444,13 @@ static int adv7393_probe(struct i2c_client *client,
                int err = state->hdl.error;
 
                v4l2_ctrl_handler_free(&state->hdl);
-               kfree(state);
                return err;
        }
        v4l2_ctrl_handler_setup(&state->hdl);
 
        err = adv7393_initialize(&state->sd);
-       if (err) {
+       if (err)
                v4l2_ctrl_handler_free(&state->hdl);
-               kfree(state);
-       }
        return err;
 }
 
@@ -464,7 +461,6 @@ static int adv7393_remove(struct i2c_client *client)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&state->hdl);
-       kfree(state);
 
        return 0;
 }
index 31a63c9324fe245b1d981ae124836f20fd1d17c5..4cdcfc96aa5624ace01c4057ec433fb7275a554b 100644 (file)
@@ -1968,7 +1968,7 @@ static int adv7604_probe(struct i2c_client *client,
        v4l_dbg(1, debug, client, "detecting adv7604 client on address 0x%x\n",
                        client->addr << 1);
 
-       state = kzalloc(sizeof(struct adv7604_state), GFP_KERNEL);
+       state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
        if (!state) {
                v4l_err(client, "Could not allocate adv7604_state memory!\n");
                return -ENOMEM;
@@ -1977,8 +1977,7 @@ static int adv7604_probe(struct i2c_client *client,
        /* platform data */
        if (!pdata) {
                v4l_err(client, "No platform data!\n");
-               err = -ENODEV;
-               goto err_state;
+               return -ENODEV;
        }
        memcpy(&state->pdata, pdata, sizeof(state->pdata));
 
@@ -1991,8 +1990,7 @@ static int adv7604_probe(struct i2c_client *client,
        if (adv_smbus_read_byte_data_check(client, 0xfb, false) != 0x68) {
                v4l2_info(sd, "not an adv7604 on address 0x%x\n",
                                client->addr << 1);
-               err = -ENODEV;
-               goto err_state;
+               return -ENODEV;
        }
 
        /* control handlers */
@@ -2093,8 +2091,6 @@ err_i2c:
        adv7604_unregister_clients(state);
 err_hdl:
        v4l2_ctrl_handler_free(hdl);
-err_state:
-       kfree(state);
        return err;
 }
 
@@ -2111,7 +2107,6 @@ static int adv7604_remove(struct i2c_client *client)
        media_entity_cleanup(&sd->entity);
        adv7604_unregister_clients(to_state(sd));
        v4l2_ctrl_handler_free(sd->ctrl_handler);
-       kfree(to_state(sd));
        return 0;
 }
 
index fd47465e4f6a9f506771d729278444b1d131d66e..b918c3f29cbee4b97e08a98166e32aa788a593f4 100644 (file)
@@ -264,7 +264,7 @@ static int ak881x_probe(struct i2c_client *client,
                return -EIO;
        }
 
-       ak881x = kzalloc(sizeof(struct ak881x), GFP_KERNEL);
+       ak881x = devm_kzalloc(&client->dev, sizeof(*ak881x), GFP_KERNEL);
        if (!ak881x)
                return -ENOMEM;
 
@@ -282,7 +282,6 @@ static int ak881x_probe(struct i2c_client *client,
        default:
                dev_err(&client->dev,
                        "No ak881x chip detected, register read %x\n", data);
-               kfree(ak881x);
                return -ENODEV;
        }
 
@@ -331,7 +330,6 @@ static int ak881x_remove(struct i2c_client *client)
        struct ak881x *ak881x = to_ak881x(client);
 
        v4l2_device_unregister_subdev(&ak881x->subdev);
-       kfree(ak881x);
 
        return 0;
 }
index 58d523f2648f61894ff8ed98526fff077da79e91..301084b07887e9e13fa11b7772ff81dd85ed553e 100644 (file)
@@ -813,7 +813,7 @@ static int as3645a_probe(struct i2c_client *client,
        if (client->dev.platform_data == NULL)
                return -ENODEV;
 
-       flash = kzalloc(sizeof(*flash), GFP_KERNEL);
+       flash = devm_kzalloc(&client->dev, sizeof(*flash), GFP_KERNEL);
        if (flash == NULL)
                return -ENOMEM;
 
@@ -838,10 +838,8 @@ static int as3645a_probe(struct i2c_client *client,
        flash->led_mode = V4L2_FLASH_LED_MODE_NONE;
 
 done:
-       if (ret < 0) {
+       if (ret < 0)
                v4l2_ctrl_handler_free(&flash->ctrls);
-               kfree(flash);
-       }
 
        return ret;
 }
@@ -855,7 +853,6 @@ static int as3645a_remove(struct i2c_client *client)
        v4l2_ctrl_handler_free(&flash->ctrls);
        media_entity_cleanup(&flash->subdev.entity);
        mutex_destroy(&flash->power_lock);
-       kfree(flash);
 
        return 0;
 }
index 377bf05b1efd20a3dea2e4a048fc04c44b2f5d6d..ee9ed67e7910b47ee02c8a6f32c274ae13cee4d6 100644 (file)
@@ -425,7 +425,7 @@ static int bt819_probe(struct i2c_client *client,
        if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
                return -ENODEV;
 
-       decoder = kzalloc(sizeof(struct bt819), GFP_KERNEL);
+       decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL);
        if (decoder == NULL)
                return -ENOMEM;
        sd = &decoder->sd;
@@ -476,7 +476,6 @@ static int bt819_probe(struct i2c_client *client,
                int err = decoder->hdl.error;
 
                v4l2_ctrl_handler_free(&decoder->hdl);
-               kfree(decoder);
                return err;
        }
        v4l2_ctrl_handler_setup(&decoder->hdl);
@@ -490,7 +489,6 @@ static int bt819_remove(struct i2c_client *client)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&decoder->hdl);
-       kfree(decoder);
        return 0;
 }
 
index 7e5bd365c2391dcf94359b78d25c9b85a672ccf7..7e5011163b62e59e6f2fd60d31058efd7f37441e 100644 (file)
@@ -216,7 +216,7 @@ static int bt856_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       encoder = kzalloc(sizeof(struct bt856), GFP_KERNEL);
+       encoder = devm_kzalloc(&client->dev, sizeof(*encoder), GFP_KERNEL);
        if (encoder == NULL)
                return -ENOMEM;
        sd = &encoder->sd;
@@ -250,7 +250,6 @@ static int bt856_remove(struct i2c_client *client)
        struct v4l2_subdev *sd = i2c_get_clientdata(client);
 
        v4l2_device_unregister_subdev(sd);
-       kfree(to_bt856(sd));
        return 0;
 }
 
index 905320b67a1cacc01537dc7de04ece8be524e3f7..9355b924b471d00c61175d135e63cf6baadc78c2 100644 (file)
@@ -207,7 +207,7 @@ static int bt866_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       encoder = kzalloc(sizeof(*encoder), GFP_KERNEL);
+       encoder = devm_kzalloc(&client->dev, sizeof(*encoder), GFP_KERNEL);
        if (encoder == NULL)
                return -ENOMEM;
        sd = &encoder->sd;
@@ -220,7 +220,6 @@ static int bt866_remove(struct i2c_client *client)
        struct v4l2_subdev *sd = i2c_get_clientdata(client);
 
        v4l2_device_unregister_subdev(sd);
-       kfree(to_bt866(sd));
        return 0;
 }
 
index 1d2f7c8512b5d7b070abb546d44aec627b5b923c..841b9c49dcfaecdade95c7b496ac84378ac57e66 100644 (file)
@@ -190,7 +190,7 @@ static int cs5345_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       state = kzalloc(sizeof(struct cs5345_state), GFP_KERNEL);
+       state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
        if (state == NULL)
                return -ENOMEM;
        sd = &state->sd;
@@ -206,7 +206,6 @@ static int cs5345_probe(struct i2c_client *client,
                int err = state->hdl.error;
 
                v4l2_ctrl_handler_free(&state->hdl);
-               kfree(state);
                return err;
        }
        /* set volume/mute */
@@ -227,7 +226,6 @@ static int cs5345_remove(struct i2c_client *client)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&state->hdl);
-       kfree(state);
        return 0;
 }
 
index b293912206ebbe39e3fa2fbc5aec53e88ebac6f0..1082fb775ab230ff843589cd42de21fc97d7c36d 100644 (file)
@@ -175,7 +175,7 @@ static int cs53l32a_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       state = kzalloc(sizeof(struct cs53l32a_state), GFP_KERNEL);
+       state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
        if (state == NULL)
                return -ENOMEM;
        sd = &state->sd;
@@ -197,7 +197,6 @@ static int cs53l32a_probe(struct i2c_client *client,
                int err = state->hdl.error;
 
                v4l2_ctrl_handler_free(&state->hdl);
-               kfree(state);
                return err;
        }
 
@@ -228,7 +227,6 @@ static int cs53l32a_remove(struct i2c_client *client)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&state->hdl);
-       kfree(state);
        return 0;
 }
 
index 12fb9b2eb8873beb009debf001eddf4b6f35bf32..bdfec4c768fe67eef7420862c6ff35c13e2aeda1 100644 (file)
@@ -5190,7 +5190,7 @@ static int cx25840_probe(struct i2c_client *client,
                return -ENODEV;
        }
 
-       state = kzalloc(sizeof(struct cx25840_state), GFP_KERNEL);
+       state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
        if (state == NULL)
                return -ENOMEM;
 
@@ -5292,7 +5292,6 @@ static int cx25840_probe(struct i2c_client *client,
                int err = state->hdl.error;
 
                v4l2_ctrl_handler_free(&state->hdl);
-               kfree(state);
                return err;
        }
        if (!is_cx2583x(state))
@@ -5317,7 +5316,6 @@ static int cx25840_remove(struct i2c_client *client)
        cx25840_ir_remove(sd);
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&state->hdl);
-       kfree(state);
        return 0;
 }
 
index 9ae977b5983ae74943e98ca3ef25e6005aa6c22d..e6588ee5bdb01e4e1a1333ba614e122fe7a194d8 100644 (file)
@@ -1230,16 +1230,14 @@ int cx25840_ir_probe(struct v4l2_subdev *sd)
        if (!(is_cx23885(state) || is_cx23887(state)))
                return 0;
 
-       ir_state = kzalloc(sizeof(struct cx25840_ir_state), GFP_KERNEL);
+       ir_state = devm_kzalloc(&state->c->dev, sizeof(*ir_state), GFP_KERNEL);
        if (ir_state == NULL)
                return -ENOMEM;
 
        spin_lock_init(&ir_state->rx_kfifo_lock);
        if (kfifo_alloc(&ir_state->rx_kfifo,
-                       CX25840_IR_RX_KFIFO_SIZE, GFP_KERNEL)) {
-               kfree(ir_state);
+                       CX25840_IR_RX_KFIFO_SIZE, GFP_KERNEL))
                return -ENOMEM;
-       }
 
        ir_state->c = state->c;
        state->ir_state = ir_state;
@@ -1273,7 +1271,6 @@ int cx25840_ir_remove(struct v4l2_subdev *sd)
        cx25840_ir_tx_shutdown(sd);
 
        kfifo_free(&ir_state->rx_kfifo);
-       kfree(ir_state);
        state->ir_state = NULL;
        return 0;
 }
index 8e2f79cb045eabca9ce1686ec853723097daf4e4..82bf5679da3064d5a8ffd9da91c3d9e085d8d8bb 100644 (file)
@@ -295,7 +295,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
        unsigned short addr = client->addr;
        int err;
 
-       ir = kzalloc(sizeof(struct IR_i2c), GFP_KERNEL);
+       ir = devm_kzalloc(&client->dev, sizeof(*ir), GFP_KERNEL);
        if (!ir)
                return -ENOMEM;
 
@@ -398,10 +398,8 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
                 * internally
                 */
                rc = rc_allocate_device();
-               if (!rc) {
-                       err = -ENOMEM;
-                       goto err_out_free;
-               }
+               if (!rc)
+                       return -ENOMEM;
        }
        ir->rc = rc;
 
@@ -454,7 +452,6 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
  err_out_free:
        /* Only frees rc if it were allocated internally */
        rc_free_device(rc);
-       kfree(ir);
        return err;
 }
 
@@ -470,7 +467,6 @@ static int ir_remove(struct i2c_client *client)
                rc_unregister_device(ir->rc);
 
        /* free memory */
-       kfree(ir);
        return 0;
 }
 
index 04a6efa37cc376eb2c49637b26a499da8665439b..c7227763240ecf91df67ddc567c58bdbe06793c6 100644 (file)
@@ -685,7 +685,7 @@ static int ks0127_probe(struct i2c_client *client, const struct i2c_device_id *i
                client->addr == (I2C_KS0127_ADDON >> 1) ? "addon" : "on-board",
                client->addr << 1, client->adapter->name);
 
-       ks = kzalloc(sizeof(*ks), GFP_KERNEL);
+       ks = devm_kzalloc(&client->dev, sizeof(*ks), GFP_KERNEL);
        if (ks == NULL)
                return -ENOMEM;
        sd = &ks->sd;
@@ -708,7 +708,6 @@ static int ks0127_remove(struct i2c_client *client)
        v4l2_device_unregister_subdev(sd);
        ks0127_write(sd, KS_OFMTA, 0x20); /* tristate */
        ks0127_write(sd, KS_CMDA, 0x2c | 0x80); /* power down */
-       kfree(to_ks0127(sd));
        return 0;
 }
 
index 39f50fd2b8d2b570444362838ac12305e6b1a2a9..0d153f3b1a5b573788fe6dbfe5761120c6553a8b 100644 (file)
@@ -174,7 +174,7 @@ static int m52790_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       state = kzalloc(sizeof(struct m52790_state), GFP_KERNEL);
+       state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
        if (state == NULL)
                return -ENOMEM;
 
@@ -191,7 +191,6 @@ static int m52790_remove(struct i2c_client *client)
        struct v4l2_subdev *sd = i2c_get_clientdata(client);
 
        v4l2_device_unregister_subdev(sd);
-       kfree(to_state(sd));
        return 0;
 }
 
index f0b870c06376a3529e0474e48f0a6e273c57d18d..08ff082242c37c1722b68e66da5218ab328f0b81 100644 (file)
@@ -950,7 +950,7 @@ static int m5mols_probe(struct i2c_client *client,
                return -EINVAL;
        }
 
-       info = kzalloc(sizeof(struct m5mols_info), GFP_KERNEL);
+       info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL);
        if (!info)
                return -ENOMEM;
 
@@ -962,7 +962,7 @@ static int m5mols_probe(struct i2c_client *client,
        ret = gpio_request_one(pdata->gpio_reset, gpio_flags, "M5MOLS_NRST");
        if (ret) {
                dev_err(&client->dev, "Failed to request gpio: %d\n", ret);
-               goto out_free;
+               return ret;
        }
 
        ret = regulator_bulk_get(&client->dev, ARRAY_SIZE(supplies), supplies);
@@ -1015,8 +1015,6 @@ out_reg:
        regulator_bulk_free(ARRAY_SIZE(supplies), supplies);
 out_gpio:
        gpio_free(pdata->gpio_reset);
-out_free:
-       kfree(info);
        return ret;
 }
 
@@ -1032,7 +1030,7 @@ static int m5mols_remove(struct i2c_client *client)
        regulator_bulk_free(ARRAY_SIZE(supplies), supplies);
        gpio_free(info->pdata->gpio_reset);
        media_entity_cleanup(&sd->entity);
-       kfree(info);
+
        return 0;
 }
 
index 54a9dd394f45ad530a4f3eae29c604f6893b359a..ae92c20790e30718f71d1878e15b55cab2d78992 100644 (file)
@@ -707,7 +707,7 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
                return -ENODEV;
        }
 
-       state = kzalloc(sizeof(*state), GFP_KERNEL);
+       state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
        if (!state)
                return -ENOMEM;
 
@@ -732,7 +732,6 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
        if (state->rev1 == -1 || (state->rev1 == 0 && state->rev2 == 0)) {
                v4l_dbg(1, msp_debug, client,
                                "not an msp3400 (cannot read chip version)\n");
-               kfree(state);
                return -ENODEV;
        }
 
@@ -827,7 +826,6 @@ static int msp_probe(struct i2c_client *client, const struct i2c_device_id *id)
                int err = hdl->error;
 
                v4l2_ctrl_handler_free(hdl);
-               kfree(state);
                return err;
        }
 
@@ -889,7 +887,6 @@ static int msp_remove(struct i2c_client *client)
        msp_reset(client);
 
        v4l2_ctrl_handler_free(&state->hdl);
-       kfree(state);
        return 0;
 }
 
index 8edb3d8f7b909d614426b917f9a31a173d7d3399..cca704e02f79a37e0d6d5ff6560b51ac2b4f15db 100644 (file)
@@ -730,7 +730,7 @@ static int mt9m032_probe(struct i2c_client *client,
        if (!client->dev.platform_data)
                return -ENODEV;
 
-       sensor = kzalloc(sizeof(*sensor), GFP_KERNEL);
+       sensor = devm_kzalloc(&client->dev, sizeof(*sensor), GFP_KERNEL);
        if (sensor == NULL)
                return -ENOMEM;
 
@@ -860,7 +860,6 @@ error_ctrl:
        v4l2_ctrl_handler_free(&sensor->ctrls);
 error_sensor:
        mutex_destroy(&sensor->lock);
-       kfree(sensor);
        return ret;
 }
 
@@ -873,7 +872,6 @@ static int mt9m032_remove(struct i2c_client *client)
        v4l2_ctrl_handler_free(&sensor->ctrls);
        media_entity_cleanup(&subdev->entity);
        mutex_destroy(&sensor->lock);
-       kfree(sensor);
        return 0;
 }
 
index 2e189d8b71bb218725b76d894172420d30bdfe6a..796463466ef07ebd3707821c30c3bb5e0bdae427 100644 (file)
@@ -740,7 +740,7 @@ static int mt9t001_probe(struct i2c_client *client,
        if (ret < 0)
                return ret;
 
-       mt9t001 = kzalloc(sizeof(*mt9t001), GFP_KERNEL);
+       mt9t001 = devm_kzalloc(&client->dev, sizeof(*mt9t001), GFP_KERNEL);
        if (!mt9t001)
                return -ENOMEM;
 
@@ -801,7 +801,6 @@ done:
        if (ret < 0) {
                v4l2_ctrl_handler_free(&mt9t001->ctrls);
                media_entity_cleanup(&mt9t001->subdev.entity);
-               kfree(mt9t001);
        }
 
        return ret;
@@ -815,7 +814,6 @@ static int mt9t001_remove(struct i2c_client *client)
        v4l2_ctrl_handler_free(&mt9t001->ctrls);
        v4l2_device_unregister_subdev(subdev);
        media_entity_cleanup(&subdev->entity);
-       kfree(mt9t001);
        return 0;
 }
 
index 3f415fd12de34c76d4f33265fcdcc169edd852f1..c64c9d9e253d46de33f8f96ab14c229a191712a1 100644 (file)
@@ -526,7 +526,7 @@ static int mt9v011_probe(struct i2c_client *c,
             I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
                return -EIO;
 
-       core = kzalloc(sizeof(struct mt9v011), GFP_KERNEL);
+       core = devm_kzalloc(&c->dev, sizeof(struct mt9v011), GFP_KERNEL);
        if (!core)
                return -ENOMEM;
 
@@ -539,7 +539,6 @@ static int mt9v011_probe(struct i2c_client *c,
            (version != MT9V011_REV_B_VERSION)) {
                v4l2_info(sd, "*** unknown micron chip detected (0x%04x).\n",
                          version);
-               kfree(core);
                return -EINVAL;
        }
 
@@ -562,7 +561,6 @@ static int mt9v011_probe(struct i2c_client *c,
 
                v4l2_err(sd, "control initialization error %d\n", ret);
                v4l2_ctrl_handler_free(&core->ctrls);
-               kfree(core);
                return ret;
        }
        core->sd.ctrl_handler = &core->ctrls;
@@ -598,7 +596,7 @@ static int mt9v011_remove(struct i2c_client *c)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&core->ctrls);
-       kfree(to_mt9v011(sd));
+
        return 0;
 }
 
index 24ea6fd3ee8139abb387a4a2d5c63b9ac662fe0a..60c6f6739560ee105a1a1931c3d125d27b548ef2 100644 (file)
@@ -744,7 +744,7 @@ static int mt9v032_probe(struct i2c_client *client,
                return -EIO;
        }
 
-       mt9v032 = kzalloc(sizeof(*mt9v032), GFP_KERNEL);
+       mt9v032 = devm_kzalloc(&client->dev, sizeof(*mt9v032), GFP_KERNEL);
        if (!mt9v032)
                return -ENOMEM;
 
@@ -831,10 +831,8 @@ static int mt9v032_probe(struct i2c_client *client,
        mt9v032->pad.flags = MEDIA_PAD_FL_SOURCE;
        ret = media_entity_init(&mt9v032->subdev.entity, 1, &mt9v032->pad, 0);
 
-       if (ret < 0) {
+       if (ret < 0)
                v4l2_ctrl_handler_free(&mt9v032->ctrls);
-               kfree(mt9v032);
-       }
 
        return ret;
 }
@@ -847,7 +845,6 @@ static int mt9v032_remove(struct i2c_client *client)
        v4l2_ctrl_handler_free(&mt9v032->ctrls);
        v4l2_device_unregister_subdev(subdev);
        media_entity_cleanup(&subdev->entity);
-       kfree(mt9v032);
 
        return 0;
 }
index a115842ab9963b05188d99107ce126e2078b55c8..d205522e598e39c15b237bdac1e5895c502073ee 100644 (file)
@@ -712,7 +712,7 @@ static int noon010_probe(struct i2c_client *client,
                return -EIO;
        }
 
-       info = kzalloc(sizeof(*info), GFP_KERNEL);
+       info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL);
        if (!info)
                return -ENOMEM;
 
@@ -796,7 +796,6 @@ np_gpio_err:
 np_err:
        v4l2_ctrl_handler_free(&info->hdl);
        v4l2_device_unregister_subdev(sd);
-       kfree(info);
        return ret;
 }
 
@@ -817,7 +816,7 @@ static int noon010_remove(struct i2c_client *client)
                gpio_free(info->gpio_nstby);
 
        media_entity_cleanup(&sd->entity);
-       kfree(info);
+
        return 0;
 }
 
index b0cc927e8b19c5a7ff4211e97711954a4ca5147c..5e117abaa2ebbb4570069d3ea649782784c16070 100644 (file)
@@ -59,7 +59,7 @@ static int ov7640_probe(struct i2c_client *client,
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
                return -ENODEV;
 
-       sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
+       sd = devm_kzalloc(&client->dev, sizeof(*sd), GFP_KERNEL);
        if (sd == NULL)
                return -ENOMEM;
        v4l2_i2c_subdev_init(sd, client, &ov7640_ops);
@@ -71,7 +71,6 @@ static int ov7640_probe(struct i2c_client *client,
 
        if (write_regs(client, initial_registers) < 0) {
                v4l_err(client, "error initializing OV7640\n");
-               kfree(sd);
                return -ENODEV;
        }
 
@@ -84,7 +83,7 @@ static int ov7640_remove(struct i2c_client *client)
        struct v4l2_subdev *sd = i2c_get_clientdata(client);
 
        v4l2_device_unregister_subdev(sd);
-       kfree(sd);
+
        return 0;
 }
 
index 617ad3fff4aa2c4d355747ed703b92693a4bd5cc..d71602f4fb436b47c33904602772d9bb9d25b5b2 100644 (file)
@@ -1552,7 +1552,7 @@ static int ov7670_probe(struct i2c_client *client,
        struct ov7670_info *info;
        int ret;
 
-       info = kzalloc(sizeof(struct ov7670_info), GFP_KERNEL);
+       info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL);
        if (info == NULL)
                return -ENOMEM;
        sd = &info->sd;
@@ -1590,7 +1590,6 @@ static int ov7670_probe(struct i2c_client *client,
                v4l_dbg(1, debug, client,
                        "chip found @ 0x%x (%s) is not an ov7670 chip.\n",
                        client->addr << 1, client->adapter->name);
-               kfree(info);
                return ret;
        }
        v4l_info(client, "chip found @ 0x%02x (%s)\n",
@@ -1635,7 +1634,6 @@ static int ov7670_probe(struct i2c_client *client,
                int err = info->hdl.error;
 
                v4l2_ctrl_handler_free(&info->hdl);
-               kfree(info);
                return err;
        }
        /*
@@ -1659,7 +1657,6 @@ static int ov7670_remove(struct i2c_client *client)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&info->hdl);
-       kfree(info);
        return 0;
 }
 
index b4e1ccbd87ec630da2f8c3afaee95c7857c06a2a..729e78d94222661aec6608219f2e19889ed253f0 100644 (file)
@@ -478,17 +478,15 @@ static int saa6588_probe(struct i2c_client *client,
        v4l_info(client, "saa6588 found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       s = kzalloc(sizeof(*s), GFP_KERNEL);
+       s = devm_kzalloc(&client->dev, sizeof(*s), GFP_KERNEL);
        if (s == NULL)
                return -ENOMEM;
 
        s->buf_size = bufblocks * 3;
 
-       s->buffer = kmalloc(s->buf_size, GFP_KERNEL);
-       if (s->buffer == NULL) {
-               kfree(s);
+       s->buffer = devm_kzalloc(&client->dev, s->buf_size, GFP_KERNEL);
+       if (s->buffer == NULL)
                return -ENOMEM;
-       }
        sd = &s->sd;
        v4l2_i2c_subdev_init(sd, client, &saa6588_ops);
        spin_lock_init(&s->lock);
@@ -516,8 +514,6 @@ static int saa6588_remove(struct i2c_client *client)
 
        cancel_delayed_work_sync(&s->work);
 
-       kfree(s->buffer);
-       kfree(s);
        return 0;
 }
 
index 51cd4c8f052036bba8c49be3390176faac73ff3d..e4026aa93f42c5e2c1eaf7bb3f5f52d5625be433 100644 (file)
@@ -406,7 +406,7 @@ static int saa7110_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       decoder = kzalloc(sizeof(struct saa7110), GFP_KERNEL);
+       decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL);
        if (!decoder)
                return -ENOMEM;
        sd = &decoder->sd;
@@ -428,7 +428,6 @@ static int saa7110_probe(struct i2c_client *client,
                int err = decoder->hdl.error;
 
                v4l2_ctrl_handler_free(&decoder->hdl);
-               kfree(decoder);
                return err;
        }
        v4l2_ctrl_handler_setup(&decoder->hdl);
@@ -469,7 +468,6 @@ static int saa7110_remove(struct i2c_client *client)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&decoder->hdl);
-       kfree(decoder);
        return 0;
 }
 
index 52c717d977c937aff0e39c7194bf9089f0648c19..eecb92df5d960cbeded69482e2636dbfb3e8f468 100644 (file)
@@ -1614,7 +1614,7 @@ static int saa711x_probe(struct i2c_client *client,
        v4l_info(client, "saa711%c found (%s) @ 0x%x (%s)\n", chip_id, name,
                 client->addr << 1, client->adapter->name);
 
-       state = kzalloc(sizeof(struct saa711x_state), GFP_KERNEL);
+       state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
        if (state == NULL)
                return -ENOMEM;
        sd = &state->sd;
@@ -1640,7 +1640,6 @@ static int saa711x_probe(struct i2c_client *client,
                int err = hdl->error;
 
                v4l2_ctrl_handler_free(hdl);
-               kfree(state);
                return err;
        }
        v4l2_ctrl_auto_cluster(2, &state->agc, 0, true);
@@ -1712,7 +1711,6 @@ static int saa711x_remove(struct i2c_client *client)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(sd->ctrl_handler);
-       kfree(to_state(sd));
        return 0;
 }
 
index 8a47ac10927f0b172938d05e9425925a8da4eae4..9882c83c1c9369c52ba9727bc4ae6c9d065c5a26 100644 (file)
@@ -752,7 +752,7 @@ static int saa7127_probe(struct i2c_client *client,
        v4l_dbg(1, debug, client, "detecting saa7127 client on address 0x%x\n",
                        client->addr << 1);
 
-       state = kzalloc(sizeof(struct saa7127_state), GFP_KERNEL);
+       state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
        if (state == NULL)
                return -ENOMEM;
 
@@ -767,7 +767,6 @@ static int saa7127_probe(struct i2c_client *client,
        if ((saa7127_read(sd, 0) & 0xe4) != 0 ||
                        (saa7127_read(sd, 0x29) & 0x3f) != 0x1d) {
                v4l2_dbg(1, debug, sd, "saa7127 not found\n");
-               kfree(state);
                return -ENODEV;
        }
 
@@ -823,7 +822,6 @@ static int saa7127_remove(struct i2c_client *client)
        v4l2_device_unregister_subdev(sd);
        /* Turn off TV output */
        saa7127_set_video_enable(sd, 0);
-       kfree(to_state(sd));
        return 0;
 }
 
index cf3a0aa7e45e699b9e4ad597f2d0ec429f9a87c5..71328109642e15ccef16aa5e2ac18da972c86ed6 100644 (file)
@@ -1262,7 +1262,7 @@ static int saa717x_probe(struct i2c_client *client,
        if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
                return -EIO;
 
-       decoder = kzalloc(sizeof(struct saa717x_state), GFP_KERNEL);
+       decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL);
        if (decoder == NULL)
                return -ENOMEM;
 
@@ -1276,7 +1276,6 @@ static int saa717x_probe(struct i2c_client *client,
                id = saa717x_read(sd, 0x5a0);
        if (id != 0xc2 && id != 0x32 && id != 0xf2 && id != 0x6c) {
                v4l2_dbg(1, debug, sd, "saa717x not found (id=%02x)\n", id);
-               kfree(decoder);
                return -ENODEV;
        }
        if (id == 0xc2)
@@ -1316,7 +1315,6 @@ static int saa717x_probe(struct i2c_client *client,
                int err = hdl->error;
 
                v4l2_ctrl_handler_free(hdl);
-               kfree(decoder);
                return err;
        }
 
@@ -1353,7 +1351,6 @@ static int saa717x_remove(struct i2c_client *client)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(sd->ctrl_handler);
-       kfree(to_state(sd));
        return 0;
 }
 
index 2c6b65c76e2b9ad3ebd60cf18919a4640de88bef..e95a0edc7f3ed9318046440584f1177ef1f73f8a 100644 (file)
@@ -326,7 +326,7 @@ static int saa7185_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       encoder = kzalloc(sizeof(struct saa7185), GFP_KERNEL);
+       encoder = devm_kzalloc(&client->dev, sizeof(*encoder), GFP_KERNEL);
        if (encoder == NULL)
                return -ENOMEM;
        encoder->norm = V4L2_STD_NTSC;
@@ -352,7 +352,6 @@ static int saa7185_remove(struct i2c_client *client)
        v4l2_device_unregister_subdev(sd);
        /* SW: output off is active */
        saa7185_write(sd, 0x61, (encoder->reg[0x61]) | 0x40);
-       kfree(encoder);
        return 0;
 }
 
index d7d1670e0ca38db88dd1d93d55bf849eaef83a64..84f7899a40443463b0ea23207092aa15b8fac393 100644 (file)
@@ -605,7 +605,7 @@ static int saa7191_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       decoder = kzalloc(sizeof(*decoder), GFP_KERNEL);
+       decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL);
        if (!decoder)
                return -ENOMEM;
 
@@ -615,7 +615,6 @@ static int saa7191_probe(struct i2c_client *client,
        err = saa7191_write_block(sd, sizeof(initseq), initseq);
        if (err) {
                printk(KERN_ERR "SAA7191 initialization failed\n");
-               kfree(decoder);
                return err;
        }
 
@@ -636,7 +635,6 @@ static int saa7191_remove(struct i2c_client *client)
        struct v4l2_subdev *sd = i2c_get_clientdata(client);
 
        v4l2_device_unregister_subdev(sd);
-       kfree(to_saa7191(sd));
        return 0;
 }
 
index 38cbea98764c901924fdce080abb76569605b9d0..efa306165618021d8174b65fb93690178be5d783 100644 (file)
@@ -355,7 +355,7 @@ static int sony_btf_mpx_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       t = kzalloc(sizeof(struct sony_btf_mpx), GFP_KERNEL);
+       t = devm_kzalloc(&client->dev, sizeof(*t), GFP_KERNEL);
        if (t == NULL)
                return -ENOMEM;
 
@@ -374,7 +374,6 @@ static int sony_btf_mpx_remove(struct i2c_client *client)
        struct v4l2_subdev *sd = i2c_get_clientdata(client);
 
        v4l2_device_unregister_subdev(sd);
-       kfree(to_state(sd));
 
        return 0;
 }
index e9d95bda2ab1066a98c1b56d06e505322fe50ad2..4c5a9ee60c3ef148b78aa4c4d6c6d1b3b61aeeb4 100644 (file)
@@ -820,7 +820,7 @@ static int sr030pc30_probe(struct i2c_client *client,
        if (ret)
                return ret;
 
-       info = kzalloc(sizeof(*info), GFP_KERNEL);
+       info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL);
        if (!info)
                return -ENOMEM;
 
@@ -841,10 +841,8 @@ static int sr030pc30_probe(struct i2c_client *client,
 static int sr030pc30_remove(struct i2c_client *client)
 {
        struct v4l2_subdev *sd = i2c_get_clientdata(client);
-       struct sr030pc30_info *info = to_sr030pc30(sd);
 
        v4l2_device_unregister_subdev(sd);
-       kfree(info);
        return 0;
 }
 
index 28b5121881f5792397ff0a674220caa4b4d7108a..72af644fa05127f89548b9782cee62367823d445 100644 (file)
@@ -359,7 +359,7 @@ static int tda7432_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%02x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       t = kzalloc(sizeof(*t), GFP_KERNEL);
+       t = devm_kzalloc(&client->dev, sizeof(*t), GFP_KERNEL);
        if (!t)
                return -ENOMEM;
        sd = &t->sd;
@@ -380,7 +380,6 @@ static int tda7432_probe(struct i2c_client *client,
                int err = t->hdl.error;
 
                v4l2_ctrl_handler_free(&t->hdl);
-               kfree(t);
                return err;
        }
        v4l2_ctrl_cluster(2, &t->bass);
@@ -406,7 +405,6 @@ static int tda7432_remove(struct i2c_client *client)
        tda7432_set(sd);
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&t->hdl);
-       kfree(t);
        return 0;
 }
 
index 01441e35d88b5415e28470086072aefe45221366..3f1266246ca3ed4536a24e06df32d9e751eb5f73 100644 (file)
@@ -184,7 +184,7 @@ static int tda9840_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
+       sd = devm_kzalloc(&client->dev, sizeof(*sd), GFP_KERNEL);
        if (sd == NULL)
                return -ENOMEM;
        v4l2_i2c_subdev_init(sd, client, &tda9840_ops);
@@ -201,7 +201,6 @@ static int tda9840_remove(struct i2c_client *client)
        struct v4l2_subdev *sd = i2c_get_clientdata(client);
 
        v4l2_device_unregister_subdev(sd);
-       kfree(sd);
        return 0;
 }
 
index 3d5b06a5c308c9db906b995bea7830093cdeb655..52ebc384e4539a8ce577af906f479662482c3ca8 100644 (file)
@@ -152,7 +152,7 @@ static int tea6415c_probe(struct i2c_client *client,
 
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
-       sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
+       sd = devm_kzalloc(&client->dev, sizeof(*sd), GFP_KERNEL);
        if (sd == NULL)
                return -ENOMEM;
        v4l2_i2c_subdev_init(sd, client, &tea6415c_ops);
@@ -164,7 +164,6 @@ static int tea6415c_remove(struct i2c_client *client)
        struct v4l2_subdev *sd = i2c_get_clientdata(client);
 
        v4l2_device_unregister_subdev(sd);
-       kfree(sd);
        return 0;
 }
 
index 38757217a074f20eeea1eca7717a6ad4fef9535a..1f869742e3fe2bf579088eb66b5e65504ccdc065 100644 (file)
@@ -125,7 +125,7 @@ static int tea6420_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
+       sd = devm_kzalloc(&client->dev, sizeof(*sd), GFP_KERNEL);
        if (sd == NULL)
                return -ENOMEM;
        v4l2_i2c_subdev_init(sd, client, &tea6420_ops);
@@ -146,7 +146,6 @@ static int tea6420_remove(struct i2c_client *client)
        struct v4l2_subdev *sd = i2c_get_clientdata(client);
 
        v4l2_device_unregister_subdev(sd);
-       kfree(sd);
        return 0;
 }
 
index 809a75a558eef32b2e7c3fd32bb2ff536320ac13..ef87f7b09ea27e101fd6931327cc8238b33c8fec 100644 (file)
@@ -162,7 +162,7 @@ static int tlv320aic23b_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       state = kzalloc(sizeof(struct tlv320aic23b_state), GFP_KERNEL);
+       state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
        if (state == NULL)
                return -ENOMEM;
        sd = &state->sd;
@@ -191,7 +191,6 @@ static int tlv320aic23b_probe(struct i2c_client *client,
                int err = state->hdl.error;
 
                v4l2_ctrl_handler_free(&state->hdl);
-               kfree(state);
                return err;
        }
        v4l2_ctrl_handler_setup(&state->hdl);
@@ -205,7 +204,6 @@ static int tlv320aic23b_remove(struct i2c_client *client)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&state->hdl);
-       kfree(state);
        return 0;
 }
 
index b72a59d3216a68d94a3abda5ff4bc0637b87b805..fc69e9c27343e5e4cabf38670698e76565ed4592 100644 (file)
@@ -1910,7 +1910,7 @@ static int tvaudio_probe(struct i2c_client *client, const struct i2c_device_id *
                printk("\n");
        }
 
-       chip = kzalloc(sizeof(*chip), GFP_KERNEL);
+       chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
        if (!chip)
                return -ENOMEM;
        sd = &chip->sd;
@@ -1930,7 +1930,6 @@ static int tvaudio_probe(struct i2c_client *client, const struct i2c_device_id *
        }
        if (desc->name == NULL) {
                v4l2_dbg(1, debug, sd, "no matching chip description found\n");
-               kfree(chip);
                return -EIO;
        }
        v4l2_info(sd, "%s found @ 0x%x (%s)\n", desc->name, client->addr<<1, client->adapter->name);
@@ -2001,7 +2000,6 @@ static int tvaudio_probe(struct i2c_client *client, const struct i2c_device_id *
                int err = chip->hdl.error;
 
                v4l2_ctrl_handler_free(&chip->hdl);
-               kfree(chip);
                return err;
        }
        /* set controls to the default values */
@@ -2043,7 +2041,6 @@ static int tvaudio_remove(struct i2c_client *client)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&chip->hdl);
-       kfree(chip);
        return 0;
 }
 
index 485159a3c0b72f1739a7cd12feab3d6453910a1d..de9db3bf1ebd0febcde8c38893912eaa4a65c8b3 100644 (file)
@@ -1152,10 +1152,9 @@ static int tvp5150_probe(struct i2c_client *c,
             I2C_FUNC_SMBUS_READ_BYTE | I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
                return -EIO;
 
-       core = kzalloc(sizeof(struct tvp5150), GFP_KERNEL);
-       if (!core) {
+       core = devm_kzalloc(&c->dev, sizeof(*core), GFP_KERNEL);
+       if (!core)
                return -ENOMEM;
-       }
        sd = &core->sd;
        v4l2_i2c_subdev_init(sd, c, &tvp5150_ops);
 
@@ -1166,7 +1165,7 @@ static int tvp5150_probe(struct i2c_client *c,
        for (i = 0; i < 4; i++) {
                res = tvp5150_read(sd, TVP5150_MSB_DEV_ID + i);
                if (res < 0)
-                       goto free_core;
+                       return res;
                tvp5150_id[i] = res;
        }
 
@@ -1209,7 +1208,7 @@ static int tvp5150_probe(struct i2c_client *c,
        if (core->hdl.error) {
                res = core->hdl.error;
                v4l2_ctrl_handler_free(&core->hdl);
-               goto free_core;
+               return res;
        }
        v4l2_ctrl_handler_setup(&core->hdl);
 
@@ -1225,10 +1224,6 @@ static int tvp5150_probe(struct i2c_client *c,
        if (debug > 1)
                tvp5150_log_status(sd);
        return 0;
-
-free_core:
-       kfree(core);
-       return res;
 }
 
 static int tvp5150_remove(struct i2c_client *c)
@@ -1242,7 +1237,6 @@ static int tvp5150_remove(struct i2c_client *c)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&decoder->hdl);
-       kfree(to_tvp5150(sd));
        return 0;
 }
 
index c5dc2c3bf2d7ccca946aa47cbde481e3de141b2f..41a5c9b31006c3077f3900c0858b71c4c4fd997a 100644 (file)
@@ -368,8 +368,7 @@ static int tw2804_probe(struct i2c_client *client,
        if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
                return -ENODEV;
 
-       state = kzalloc(sizeof(struct tw2804), GFP_KERNEL);
-
+       state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
        if (state == NULL)
                return -ENOMEM;
        sd = &state->sd;
@@ -410,7 +409,6 @@ static int tw2804_probe(struct i2c_client *client,
        err = state->hdl.error;
        if (err) {
                v4l2_ctrl_handler_free(&state->hdl);
-               kfree(state);
                return err;
        }
 
@@ -427,7 +425,6 @@ static int tw2804_remove(struct i2c_client *client)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&state->hdl);
-       kfree(state);
        return 0;
 }
 
index 87880b19d8c3fcc633a6338f04ac634d3acf1929..285b759a5f7f11c74a9f24cec7f1f58bd0ef9b60 100644 (file)
@@ -215,7 +215,7 @@ static int tw9903_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%02x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       dec = kzalloc(sizeof(struct tw9903), GFP_KERNEL);
+       dec = devm_kzalloc(&client->dev, sizeof(*dec), GFP_KERNEL);
        if (dec == NULL)
                return -ENOMEM;
        sd = &dec->sd;
@@ -233,7 +233,6 @@ static int tw9903_probe(struct i2c_client *client,
                int err = hdl->error;
 
                v4l2_ctrl_handler_free(hdl);
-               kfree(dec);
                return err;
        }
 
@@ -242,7 +241,6 @@ static int tw9903_probe(struct i2c_client *client,
 
        if (write_regs(sd, initial_registers) < 0) {
                v4l2_err(client, "error initializing TW9903\n");
-               kfree(dec);
                return -EINVAL;
        }
 
@@ -255,7 +253,6 @@ static int tw9903_remove(struct i2c_client *client)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&to_state(sd)->hdl);
-       kfree(to_state(sd));
        return 0;
 }
 
index accd79e5a7fd8a4a7901d5bb010f515e6e51b351..f6bef25bd9ce8dacbc392046c6a04d6af5096422 100644 (file)
@@ -183,7 +183,7 @@ static int tw9906_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%02x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       dec = kzalloc(sizeof(struct tw9906), GFP_KERNEL);
+       dec = devm_kzalloc(&client->dev, sizeof(*dec), GFP_KERNEL);
        if (dec == NULL)
                return -ENOMEM;
        sd = &dec->sd;
@@ -201,7 +201,6 @@ static int tw9906_probe(struct i2c_client *client,
                int err = hdl->error;
 
                v4l2_ctrl_handler_free(hdl);
-               kfree(dec);
                return err;
        }
 
@@ -210,7 +209,6 @@ static int tw9906_probe(struct i2c_client *client,
 
        if (write_regs(sd, initial_registers) < 0) {
                v4l2_err(client, "error initializing TW9906\n");
-               kfree(dec);
                return -EINVAL;
        }
 
@@ -223,7 +221,6 @@ static int tw9906_remove(struct i2c_client *client)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&to_state(sd)->hdl);
-       kfree(to_state(sd));
        return 0;
 }
 
index 3af408556d27f0ce5febb353cb49f5fab14e7dc5..081786d176d097327d5e5fa54553087ae7eea92f 100644 (file)
@@ -69,7 +69,7 @@ static int uda1342_probe(struct i2c_client *client,
        dev_dbg(&client->dev, "initializing UDA1342 at address %d on %s\n",
                client->addr, adapter->name);
 
-       sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
+       sd = devm_kzalloc(&client->dev, sizeof(*sd), GFP_KERNEL);
        if (sd == NULL)
                return -ENOMEM;
 
@@ -89,7 +89,6 @@ static int uda1342_remove(struct i2c_client *client)
        struct v4l2_subdev *sd = i2c_get_clientdata(client);
 
        v4l2_device_unregister_subdev(sd);
-       kfree(sd);
        return 0;
 }
 
index f0a09214c519105bf4cbfea87f2ca6937dd88374..4283fc5f39ef2c30e62279915e8156e3adf356ad 100644 (file)
@@ -230,7 +230,7 @@ static int upd64031a_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       state = kzalloc(sizeof(struct upd64031a_state), GFP_KERNEL);
+       state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
        if (state == NULL)
                return -ENOMEM;
        sd = &state->sd;
@@ -249,7 +249,6 @@ static int upd64031a_remove(struct i2c_client *client)
        struct v4l2_subdev *sd = i2c_get_clientdata(client);
 
        v4l2_device_unregister_subdev(sd);
-       kfree(to_state(sd));
        return 0;
 }
 
index 343e0215f74ce6dedd095ad7300e64ec69e7a791..b2ac56ca22e6403c5a8cfc71c7f62123429a6b74 100644 (file)
@@ -202,7 +202,7 @@ static int upd64083_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       state = kzalloc(sizeof(struct upd64083_state), GFP_KERNEL);
+       state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
        if (state == NULL)
                return -ENOMEM;
        sd = &state->sd;
@@ -221,7 +221,6 @@ static int upd64083_remove(struct i2c_client *client)
        struct v4l2_subdev *sd = i2c_get_clientdata(client);
 
        v4l2_device_unregister_subdev(sd);
-       kfree(to_state(sd));
        return 0;
 }
 
index e71f139695afa1f23405f533d206583100574da8..208a095d7bcc96b8791c4f551f5fe87f08997a48 100644 (file)
@@ -169,7 +169,7 @@ static int vp27smpx_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       state = kzalloc(sizeof(struct vp27smpx_state), GFP_KERNEL);
+       state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
        if (state == NULL)
                return -ENOMEM;
        sd = &state->sd;
@@ -186,7 +186,6 @@ static int vp27smpx_remove(struct i2c_client *client)
        struct v4l2_subdev *sd = i2c_get_clientdata(client);
 
        v4l2_device_unregister_subdev(sd);
-       kfree(to_state(sd));
        return 0;
 }
 
index 2f67b4c5c823bf396a4a2d17ebdabde113eafe6f..f02e74b9b1ac83f56f13987f43faaddf48c610f4 100644 (file)
@@ -499,7 +499,7 @@ static int vpx3220_probe(struct i2c_client *client,
                I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA))
                return -ENODEV;
 
-       decoder = kzalloc(sizeof(struct vpx3220), GFP_KERNEL);
+       decoder = devm_kzalloc(&client->dev, sizeof(*decoder), GFP_KERNEL);
        if (decoder == NULL)
                return -ENOMEM;
        sd = &decoder->sd;
@@ -521,7 +521,6 @@ static int vpx3220_probe(struct i2c_client *client,
                int err = decoder->hdl.error;
 
                v4l2_ctrl_handler_free(&decoder->hdl);
-               kfree(decoder);
                return err;
        }
        v4l2_ctrl_handler_setup(&decoder->hdl);
@@ -566,7 +565,7 @@ static int vpx3220_remove(struct i2c_client *client)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&decoder->hdl);
-       kfree(decoder);
+
        return 0;
 }
 
index 6b8c0b7aa488fa16f87da2c47c92272d80946d49..94e284908f394a65d04465f5cf50987e4af4973a 100644 (file)
@@ -813,11 +813,9 @@ static int vs6624_probe(struct i2c_client *client,
        /* wait 100ms before any further i2c writes are performed */
        mdelay(100);
 
-       sensor = kzalloc(sizeof(*sensor), GFP_KERNEL);
-       if (sensor == NULL) {
-               gpio_free(*ce);
+       sensor = devm_kzalloc(&client->dev, sizeof(*sensor), GFP_KERNEL);
+       if (sensor == NULL)
                return -ENOMEM;
-       }
 
        sd = &sensor->sd;
        v4l2_i2c_subdev_init(sd, client, &vs6624_ops);
@@ -865,7 +863,6 @@ static int vs6624_probe(struct i2c_client *client,
                int err = hdl->error;
 
                v4l2_ctrl_handler_free(hdl);
-               kfree(sensor);
                gpio_free(*ce);
                return err;
        }
@@ -874,7 +871,6 @@ static int vs6624_probe(struct i2c_client *client,
        ret = v4l2_ctrl_handler_setup(hdl);
        if (ret) {
                v4l2_ctrl_handler_free(hdl);
-               kfree(sensor);
                gpio_free(*ce);
        }
        return ret;
@@ -888,7 +884,6 @@ static int vs6624_remove(struct i2c_client *client)
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(sd->ctrl_handler);
        gpio_free(sensor->ce_pin);
-       kfree(sensor);
        return 0;
 }
 
index 3bb99e93febedfa0b895e25c8eebf091b581b945..ac3faa7bab2d46c656b3e86417705ae382ba7e57 100644 (file)
@@ -220,7 +220,7 @@ static int wm8739_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       state = kzalloc(sizeof(struct wm8739_state), GFP_KERNEL);
+       state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
        if (state == NULL)
                return -ENOMEM;
        sd = &state->sd;
@@ -237,7 +237,6 @@ static int wm8739_probe(struct i2c_client *client,
                int err = state->hdl.error;
 
                v4l2_ctrl_handler_free(&state->hdl);
-               kfree(state);
                return err;
        }
        v4l2_ctrl_cluster(3, &state->volume);
@@ -271,7 +270,6 @@ static int wm8739_remove(struct i2c_client *client)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&state->hdl);
-       kfree(to_state(sd));
        return 0;
 }
 
index 27c27b4ae238516b89f49da8627b1fbd0568985d..75ded82d513ff63b22dff2751313dbbb9e3e639f 100644 (file)
@@ -241,7 +241,7 @@ static int wm8775_probe(struct i2c_client *client,
        v4l_info(client, "chip found @ 0x%02x (%s)\n",
                        client->addr << 1, client->adapter->name);
 
-       state = kzalloc(sizeof(struct wm8775_state), GFP_KERNEL);
+       state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
        if (state == NULL)
                return -ENOMEM;
        sd = &state->sd;
@@ -261,7 +261,6 @@ static int wm8775_probe(struct i2c_client *client,
        err = state->hdl.error;
        if (err) {
                v4l2_ctrl_handler_free(&state->hdl);
-               kfree(state);
                return err;
        }
 
@@ -319,7 +318,6 @@ static int wm8775_remove(struct i2c_client *client)
 
        v4l2_device_unregister_subdev(sd);
        v4l2_ctrl_handler_free(&state->hdl);
-       kfree(state);
        return 0;
 }