[media] radio-tea5764: embed struct video_device

This simplifies the code as it removes a memory allocation check.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Fabio Belavenuto <belavenuto@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
Hans Verkuil 2013-02-03 08:27:57 -03:00 committed by Mauro Carvalho Chehab
parent 099f88ee20
commit cf9033f9b5
1 changed files with 10 additions and 17 deletions

View File

@ -141,7 +141,7 @@ static int use_xtal = RADIO_TEA5764_XTAL;
struct tea5764_device { struct tea5764_device {
struct v4l2_device v4l2_dev; struct v4l2_device v4l2_dev;
struct i2c_client *i2c_client; struct i2c_client *i2c_client;
struct video_device *videodev; struct video_device vdev;
struct tea5764_regs regs; struct tea5764_regs regs;
struct mutex mutex; struct mutex mutex;
}; };
@ -303,7 +303,7 @@ static int vidioc_querycap(struct file *file, void *priv,
struct v4l2_capability *v) struct v4l2_capability *v)
{ {
struct tea5764_device *radio = video_drvdata(file); struct tea5764_device *radio = video_drvdata(file);
struct video_device *dev = radio->videodev; struct video_device *dev = &radio->vdev;
strlcpy(v->driver, dev->dev.driver->name, sizeof(v->driver)); strlcpy(v->driver, dev->dev.driver->name, sizeof(v->driver));
strlcpy(v->card, dev->name, sizeof(v->card)); strlcpy(v->card, dev->name, sizeof(v->card));
@ -491,7 +491,7 @@ static struct video_device tea5764_radio_template = {
.name = "TEA5764 FM-Radio", .name = "TEA5764 FM-Radio",
.fops = &tea5764_fops, .fops = &tea5764_fops,
.ioctl_ops = &tea5764_ioctl_ops, .ioctl_ops = &tea5764_ioctl_ops,
.release = video_device_release, .release = video_device_release_empty,
}; };
/* I2C probe: check if the device exists and register with v4l if it is */ /* I2C probe: check if the device exists and register with v4l if it is */
@ -528,17 +528,12 @@ static int tea5764_i2c_probe(struct i2c_client *client,
goto errunreg; goto errunreg;
} }
radio->videodev = video_device_alloc(); radio->vdev = tea5764_radio_template;
if (!(radio->videodev)) {
ret = -ENOMEM;
goto errunreg;
}
*radio->videodev = tea5764_radio_template;
i2c_set_clientdata(client, radio); i2c_set_clientdata(client, radio);
video_set_drvdata(radio->videodev, radio); video_set_drvdata(&radio->vdev, radio);
radio->videodev->lock = &radio->mutex; radio->vdev.lock = &radio->mutex;
radio->videodev->v4l2_dev = v4l2_dev; radio->vdev.v4l2_dev = v4l2_dev;
/* initialize and power off the chip */ /* initialize and power off the chip */
tea5764_i2c_read(radio); tea5764_i2c_read(radio);
@ -546,16 +541,14 @@ static int tea5764_i2c_probe(struct i2c_client *client,
tea5764_mute(radio, 1); tea5764_mute(radio, 1);
tea5764_power_down(radio); tea5764_power_down(radio);
ret = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr); ret = video_register_device(&radio->vdev, VFL_TYPE_RADIO, radio_nr);
if (ret < 0) { if (ret < 0) {
PWARN("Could not register video device!"); PWARN("Could not register video device!");
goto errrel; goto errunreg;
} }
PINFO("registered."); PINFO("registered.");
return 0; return 0;
errrel:
video_device_release(radio->videodev);
errunreg: errunreg:
v4l2_device_unregister(v4l2_dev); v4l2_device_unregister(v4l2_dev);
errfr: errfr:
@ -570,7 +563,7 @@ static int tea5764_i2c_remove(struct i2c_client *client)
PDEBUG("remove"); PDEBUG("remove");
if (radio) { if (radio) {
tea5764_power_down(radio); tea5764_power_down(radio);
video_unregister_device(radio->videodev); video_unregister_device(&radio->vdev);
v4l2_device_unregister(&radio->v4l2_dev); v4l2_device_unregister(&radio->v4l2_dev);
kfree(radio); kfree(radio);
} }