Commit c0714f6c authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

V4L/DVB (11295): cx23885: convert to v4l2_device.

Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 8bbd90ce
...@@ -1739,16 +1739,20 @@ static int __devinit cx23885_initdev(struct pci_dev *pci_dev, ...@@ -1739,16 +1739,20 @@ static int __devinit cx23885_initdev(struct pci_dev *pci_dev,
if (NULL == dev) if (NULL == dev)
return -ENOMEM; return -ENOMEM;
err = v4l2_device_register(&pci_dev->dev, &dev->v4l2_dev);
if (err < 0)
goto fail_free;
/* pci init */ /* pci init */
dev->pci = pci_dev; dev->pci = pci_dev;
if (pci_enable_device(pci_dev)) { if (pci_enable_device(pci_dev)) {
err = -EIO; err = -EIO;
goto fail_free; goto fail_unreg;
} }
if (cx23885_dev_setup(dev) < 0) { if (cx23885_dev_setup(dev) < 0) {
err = -EINVAL; err = -EINVAL;
goto fail_free; goto fail_unreg;
} }
/* print pci info */ /* print pci info */
...@@ -1775,8 +1779,6 @@ static int __devinit cx23885_initdev(struct pci_dev *pci_dev, ...@@ -1775,8 +1779,6 @@ static int __devinit cx23885_initdev(struct pci_dev *pci_dev,
goto fail_irq; goto fail_irq;
} }
pci_set_drvdata(pci_dev, dev);
switch (dev->board) { switch (dev->board) {
case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
cx_set(PCI_INT_MSK, 0x01800000); /* for NetUP */ cx_set(PCI_INT_MSK, 0x01800000); /* for NetUP */
...@@ -1787,6 +1789,8 @@ static int __devinit cx23885_initdev(struct pci_dev *pci_dev, ...@@ -1787,6 +1789,8 @@ static int __devinit cx23885_initdev(struct pci_dev *pci_dev,
fail_irq: fail_irq:
cx23885_dev_unregister(dev); cx23885_dev_unregister(dev);
fail_unreg:
v4l2_device_unregister(&dev->v4l2_dev);
fail_free: fail_free:
kfree(dev); kfree(dev);
return err; return err;
...@@ -1794,7 +1798,8 @@ static int __devinit cx23885_initdev(struct pci_dev *pci_dev, ...@@ -1794,7 +1798,8 @@ static int __devinit cx23885_initdev(struct pci_dev *pci_dev,
static void __devexit cx23885_finidev(struct pci_dev *pci_dev) static void __devexit cx23885_finidev(struct pci_dev *pci_dev)
{ {
struct cx23885_dev *dev = pci_get_drvdata(pci_dev); struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
struct cx23885_dev *dev = to_cx23885(v4l2_dev);
cx23885_shutdown(dev); cx23885_shutdown(dev);
...@@ -1802,13 +1807,13 @@ static void __devexit cx23885_finidev(struct pci_dev *pci_dev) ...@@ -1802,13 +1807,13 @@ static void __devexit cx23885_finidev(struct pci_dev *pci_dev)
/* unregister stuff */ /* unregister stuff */
free_irq(pci_dev->irq, dev); free_irq(pci_dev->irq, dev);
pci_set_drvdata(pci_dev, NULL);
mutex_lock(&devlist); mutex_lock(&devlist);
list_del(&dev->devlist); list_del(&dev->devlist);
mutex_unlock(&devlist); mutex_unlock(&devlist);
cx23885_dev_unregister(dev); cx23885_dev_unregister(dev);
v4l2_device_unregister(v4l2_dev);
kfree(dev); kfree(dev);
} }
......
...@@ -270,8 +270,8 @@ static int i2c_xfer(struct i2c_adapter *i2c_adap, ...@@ -270,8 +270,8 @@ static int i2c_xfer(struct i2c_adapter *i2c_adap,
static int attach_inform(struct i2c_client *client) static int attach_inform(struct i2c_client *client)
{ {
struct cx23885_i2c *bus = i2c_get_adapdata(client->adapter); struct v4l2_device *v4l2_dev = i2c_get_adapdata(client->adapter);
struct cx23885_dev *dev = bus->dev; struct cx23885_dev *dev = to_cx23885(v4l2_dev);
struct tuner_setup tun_setup; struct tuner_setup tun_setup;
dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n", dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n",
...@@ -310,7 +310,8 @@ static int attach_inform(struct i2c_client *client) ...@@ -310,7 +310,8 @@ static int attach_inform(struct i2c_client *client)
static int detach_inform(struct i2c_client *client) static int detach_inform(struct i2c_client *client)
{ {
struct cx23885_dev *dev = i2c_get_adapdata(client->adapter); struct v4l2_device *v4l2_dev = i2c_get_adapdata(client->adapter);
struct cx23885_dev *dev = to_cx23885(v4l2_dev);
dprintk(1, "i2c detach [client=%s]\n", client->name); dprintk(1, "i2c detach [client=%s]\n", client->name);
...@@ -402,7 +403,7 @@ int cx23885_i2c_register(struct cx23885_i2c *bus) ...@@ -402,7 +403,7 @@ int cx23885_i2c_register(struct cx23885_i2c *bus)
bus->i2c_algo.data = bus; bus->i2c_algo.data = bus;
bus->i2c_adap.algo_data = bus; bus->i2c_adap.algo_data = bus;
i2c_set_adapdata(&bus->i2c_adap, bus); i2c_set_adapdata(&bus->i2c_adap, &dev->v4l2_dev);
i2c_add_adapter(&bus->i2c_adap); i2c_add_adapter(&bus->i2c_adap);
bus->i2c_client.adapter = &bus->i2c_adap; bus->i2c_client.adapter = &bus->i2c_adap;
......
...@@ -321,7 +321,7 @@ static struct video_device *cx23885_vdev_init(struct cx23885_dev *dev, ...@@ -321,7 +321,7 @@ static struct video_device *cx23885_vdev_init(struct cx23885_dev *dev,
return NULL; return NULL;
*vfd = *template; *vfd = *template;
vfd->minor = -1; vfd->minor = -1;
vfd->parent = &pci->dev; vfd->v4l2_dev = &dev->v4l2_dev;
vfd->release = video_device_release; vfd->release = video_device_release;
snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
dev->name, type, cx23885_boards[dev->board].name); dev->name, type, cx23885_boards[dev->board].name);
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <linux/i2c-algo-bit.h> #include <linux/i2c-algo-bit.h>
#include <linux/kdev_t.h> #include <linux/kdev_t.h>
#include <media/v4l2-common.h> #include <media/v4l2-device.h>
#include <media/tuner.h> #include <media/tuner.h>
#include <media/tveeprom.h> #include <media/tveeprom.h>
#include <media/videobuf-dma-sg.h> #include <media/videobuf-dma-sg.h>
...@@ -277,6 +277,7 @@ struct cx23885_tsport { ...@@ -277,6 +277,7 @@ struct cx23885_tsport {
struct cx23885_dev { struct cx23885_dev {
struct list_head devlist; struct list_head devlist;
atomic_t refcount; atomic_t refcount;
struct v4l2_device v4l2_dev;
/* pci stuff */ /* pci stuff */
struct pci_dev *pci; struct pci_dev *pci;
...@@ -342,6 +343,11 @@ struct cx23885_dev { ...@@ -342,6 +343,11 @@ struct cx23885_dev {
}; };
static inline struct cx23885_dev *to_cx23885(struct v4l2_device *v4l2_dev)
{
return container_of(v4l2_dev, struct cx23885_dev, v4l2_dev);
}
extern struct list_head cx23885_devlist; extern struct list_head cx23885_devlist;
#define SRAM_CH01 0 /* Video A */ #define SRAM_CH01 0 /* Video A */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment