Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c02b211d authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab
Browse files

[media] media: i2c: Convert to devm_kzalloc()



Using the managed function the kfree() calls can be removed from the
probe error path and the remove handler.

Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Acked-by: default avatarLad, Prabhakar <prabhakar.csengg@gmail.com>
Acked-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarBenoît Thébaudeau <benoit.thebaudeau@advansee.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 95323361
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -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;
}

+2 −3
Original line number Diff line number Diff line
@@ -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;
}

+1 −2
Original line number Diff line number Diff line
@@ -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;
}

+1 −2
Original line number Diff line number Diff line
@@ -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;
}

+1 −3
Original line number Diff line number Diff line
@@ -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;
}

Loading