summaryrefslogtreecommitdiff
path: root/drivers/media/radio
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-02-03 08:25:32 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-06-17 09:26:11 -0300
commit099f88ee20c4d387a7bd76e0a5765533b1f5b6b0 (patch)
tree68362f22c31088f9cf40e0aa765356a2b39c3020 /drivers/media/radio
parentbb732ccca29123850ffcacefe51cf2bc7d16e88c (diff)
[media] radio-tea5764: add support for struct v4l2_device
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Cc: Fabio Belavenuto <belavenuto@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/radio')
-rw-r--r--drivers/media/radio/radio-tea5764.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c
index 38d563d62595..f6a5471e51aa 100644
--- a/drivers/media/radio/radio-tea5764.c
+++ b/drivers/media/radio/radio-tea5764.c
@@ -39,6 +39,7 @@
#include <linux/i2c.h> /* I2C */
#include <media/v4l2-common.h>
#include <media/v4l2-ioctl.h>
+#include <media/v4l2-device.h>
#define DRIVER_VERSION "0.0.2"
@@ -138,6 +139,7 @@ static int radio_nr = -1;
static int use_xtal = RADIO_TEA5764_XTAL;
struct tea5764_device {
+ struct v4l2_device v4l2_dev;
struct i2c_client *i2c_client;
struct video_device *videodev;
struct tea5764_regs regs;
@@ -497,6 +499,7 @@ static int tea5764_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct tea5764_device *radio;
+ struct v4l2_device *v4l2_dev;
struct tea5764_regs *r;
int ret;
@@ -505,31 +508,37 @@ static int tea5764_i2c_probe(struct i2c_client *client,
if (!radio)
return -ENOMEM;
+ v4l2_dev = &radio->v4l2_dev;
+ ret = v4l2_device_register(&client->dev, v4l2_dev);
+ if (ret < 0) {
+ v4l2_err(v4l2_dev, "could not register v4l2_device\n");
+ goto errfr;
+ }
mutex_init(&radio->mutex);
radio->i2c_client = client;
ret = tea5764_i2c_read(radio);
if (ret)
- goto errfr;
+ goto errunreg;
r = &radio->regs;
PDEBUG("chipid = %04X, manid = %04X", r->chipid, r->manid);
if (r->chipid != TEA5764_CHIPID ||
(r->manid & 0x0fff) != TEA5764_MANID) {
PWARN("This chip is not a TEA5764!");
ret = -EINVAL;
- goto errfr;
+ goto errunreg;
}
radio->videodev = video_device_alloc();
if (!(radio->videodev)) {
ret = -ENOMEM;
- goto errfr;
+ goto errunreg;
}
- memcpy(radio->videodev, &tea5764_radio_template,
- sizeof(tea5764_radio_template));
+ *radio->videodev = tea5764_radio_template;
i2c_set_clientdata(client, radio);
video_set_drvdata(radio->videodev, radio);
radio->videodev->lock = &radio->mutex;
+ radio->videodev->v4l2_dev = v4l2_dev;
/* initialize and power off the chip */
tea5764_i2c_read(radio);
@@ -547,6 +556,8 @@ static int tea5764_i2c_probe(struct i2c_client *client,
return 0;
errrel:
video_device_release(radio->videodev);
+errunreg:
+ v4l2_device_unregister(v4l2_dev);
errfr:
kfree(radio);
return ret;
@@ -560,6 +571,7 @@ static int tea5764_i2c_remove(struct i2c_client *client)
if (radio) {
tea5764_power_down(radio);
video_unregister_device(radio->videodev);
+ v4l2_device_unregister(&radio->v4l2_dev);
kfree(radio);
}
return 0;