[media] cx25821: embed video_device, clean up some kernel log spam

Embed the video_device struct instead of allocating it.
Remove some of the annoying and ugly kernel messages shown during
loading and unloading of the module.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
Hans Verkuil 2013-04-13 08:18:00 -03:00 committed by Mauro Carvalho Chehab
parent 89c21389f2
commit 467870ca26
3 changed files with 16 additions and 55 deletions

View file

@ -845,8 +845,7 @@ static void cx25821_dev_checkrevision(struct cx25821_dev *dev)
{ {
dev->hwrevision = cx_read(RDR_CFG2) & 0xff; dev->hwrevision = cx_read(RDR_CFG2) & 0xff;
pr_info("%s(): Hardware revision = 0x%02x\n", pr_info("Hardware revision = 0x%02x\n", dev->hwrevision);
__func__, dev->hwrevision);
} }
static void cx25821_iounmap(struct cx25821_dev *dev) static void cx25821_iounmap(struct cx25821_dev *dev)
@ -856,7 +855,6 @@ static void cx25821_iounmap(struct cx25821_dev *dev)
/* Releasing IO memory */ /* Releasing IO memory */
if (dev->lmmio != NULL) { if (dev->lmmio != NULL) {
CX25821_INFO("Releasing lmmio.\n");
iounmap(dev->lmmio); iounmap(dev->lmmio);
dev->lmmio = NULL; dev->lmmio = NULL;
} }
@ -867,10 +865,6 @@ static int cx25821_dev_setup(struct cx25821_dev *dev)
static unsigned int cx25821_devcount; static unsigned int cx25821_devcount;
int i; int i;
pr_info("\n***********************************\n");
pr_info("cx25821 set up\n");
pr_info("***********************************\n\n");
mutex_init(&dev->lock); mutex_init(&dev->lock);
dev->nr = ++cx25821_devcount; dev->nr = ++cx25821_devcount;
@ -950,17 +944,12 @@ static int cx25821_dev_setup(struct cx25821_dev *dev)
/* cx25821_i2c_register(&dev->i2c_bus[1]); /* cx25821_i2c_register(&dev->i2c_bus[1]);
* cx25821_i2c_register(&dev->i2c_bus[2]); */ * cx25821_i2c_register(&dev->i2c_bus[2]); */
CX25821_INFO("i2c register! bus->i2c_rc = %d\n",
dev->i2c_bus[0].i2c_rc);
if (medusa_video_init(dev) < 0) if (medusa_video_init(dev) < 0)
CX25821_ERR("%s(): Failed to initialize medusa!\n", __func__); CX25821_ERR("%s(): Failed to initialize medusa!\n", __func__);
cx25821_video_register(dev); cx25821_video_register(dev);
cx25821_dev_checkrevision(dev); cx25821_dev_checkrevision(dev);
CX25821_INFO("setup done!\n");
return 0; return 0;
} }
@ -1337,8 +1326,6 @@ static int cx25821_initdev(struct pci_dev *pci_dev,
goto fail_unregister_device; goto fail_unregister_device;
} }
pr_info("Athena pci enable !\n");
err = cx25821_dev_setup(dev); err = cx25821_dev_setup(dev);
if (err) { if (err) {
if (err == -EBUSY) if (err == -EBUSY)

View file

@ -144,26 +144,6 @@ static int cx25821_set_tvnorm(struct cx25821_dev *dev, v4l2_std_id norm)
return 0; return 0;
} }
static struct video_device *cx25821_vdev_init(struct cx25821_dev *dev,
struct pci_dev *pci,
const struct video_device *template,
char *type)
{
struct video_device *vfd;
dprintk(1, "%s()\n", __func__);
vfd = video_device_alloc();
if (NULL == vfd)
return NULL;
*vfd = *template;
vfd->v4l2_dev = &dev->v4l2_dev;
vfd->release = video_device_release;
snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", dev->name, type,
cx25821_boards[dev->board].name);
video_set_drvdata(vfd, dev);
return vfd;
}
/* /*
static int cx25821_ctrl_query(struct v4l2_queryctrl *qctrl) static int cx25821_ctrl_query(struct v4l2_queryctrl *qctrl)
{ {
@ -657,7 +637,7 @@ static int video_open(struct file *file)
v4l2_type_names[type]); v4l2_type_names[type]);
for (ch_id = 0; ch_id < MAX_VID_CHANNEL_NUM - 1; ch_id++) for (ch_id = 0; ch_id < MAX_VID_CHANNEL_NUM - 1; ch_id++)
if (dev->channels[ch_id].video_dev == vdev) if (&dev->channels[ch_id].vdev == vdev)
break; break;
/* Can't happen */ /* Can't happen */
@ -1692,6 +1672,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
static const struct video_device cx25821_video_device = { static const struct video_device cx25821_video_device = {
.name = "cx25821-video", .name = "cx25821-video",
.fops = &video_fops, .fops = &video_fops,
.release = video_device_release_empty,
.minor = -1, .minor = -1,
.ioctl_ops = &video_ioctl_ops, .ioctl_ops = &video_ioctl_ops,
.tvnorms = CX25821_NORMS, .tvnorms = CX25821_NORMS,
@ -1701,22 +1682,12 @@ void cx25821_video_unregister(struct cx25821_dev *dev, int chan_num)
{ {
cx_clear(PCI_INT_MSK, 1); cx_clear(PCI_INT_MSK, 1);
if (dev->channels[chan_num].video_dev) { if (video_is_registered(&dev->channels[chan_num].vdev)) {
if (video_is_registered(dev->channels[chan_num].video_dev)) video_unregister_device(&dev->channels[chan_num].vdev);
video_unregister_device(
dev->channels[chan_num].video_dev);
else
video_device_release(
dev->channels[chan_num].video_dev);
dev->channels[chan_num].video_dev = NULL;
btcx_riscmem_free(dev->pci, btcx_riscmem_free(dev->pci,
&dev->channels[chan_num].vidq.stopper); &dev->channels[chan_num].vidq.stopper);
pr_warn("device %d released!\n", chan_num);
} }
} }
int cx25821_video_register(struct cx25821_dev *dev) int cx25821_video_register(struct cx25821_dev *dev)
@ -1727,6 +1698,8 @@ int cx25821_video_register(struct cx25821_dev *dev)
spin_lock_init(&dev->slock); spin_lock_init(&dev->slock);
for (i = 0; i < VID_CHANNEL_NUM; ++i) { for (i = 0; i < VID_CHANNEL_NUM; ++i) {
struct video_device *vdev = &dev->channels[i].vdev;
if (i == SRAM_CH08) /* audio channel */ if (i == SRAM_CH08) /* audio channel */
continue; continue;
@ -1736,7 +1709,6 @@ int cx25821_video_register(struct cx25821_dev *dev)
dev->channels[i].sram_channels->dma_ctl, 0x11, 0); dev->channels[i].sram_channels->dma_ctl, 0x11, 0);
dev->channels[i].sram_channels = &cx25821_sram_channels[i]; dev->channels[i].sram_channels = &cx25821_sram_channels[i];
dev->channels[i].video_dev = NULL;
dev->channels[i].resources = 0; dev->channels[i].resources = 0;
cx_write(dev->channels[i].sram_channels->int_stat, 0xffffffff); cx_write(dev->channels[i].sram_channels->int_stat, 0xffffffff);
@ -1753,15 +1725,16 @@ int cx25821_video_register(struct cx25821_dev *dev)
init_timer(&dev->channels[i].vidq.timeout); init_timer(&dev->channels[i].vidq.timeout);
/* register v4l devices */ /* register v4l devices */
dev->channels[i].video_dev = cx25821_vdev_init(dev, dev->pci, *vdev = cx25821_video_device;
&cx25821_video_device, "video"); vdev->v4l2_dev = &dev->v4l2_dev;
snprintf(vdev->name, sizeof(vdev->name), "%s #%d", dev->name, i);
video_set_drvdata(vdev, dev);
err = video_register_device(dev->channels[i].video_dev, err = video_register_device(vdev, VFL_TYPE_GRABBER,
VFL_TYPE_GRABBER, video_nr[dev->nr]); video_nr[dev->nr]);
if (err < 0) if (err < 0)
goto fail_unreg; goto fail_unreg;
} }
/* set PCI interrupt */ /* set PCI interrupt */
@ -1776,6 +1749,7 @@ int cx25821_video_register(struct cx25821_dev *dev)
return 0; return 0;
fail_unreg: fail_unreg:
cx25821_video_unregister(dev, i); while (i >= 0)
cx25821_video_unregister(dev, i--);
return err; return err;
} }

View file

@ -217,7 +217,7 @@ struct cx25821_channel {
int ctl_saturation; int ctl_saturation;
struct cx25821_data timeout_data; struct cx25821_data timeout_data;
struct video_device *video_dev; struct video_device vdev;
struct cx25821_dmaqueue vidq; struct cx25821_dmaqueue vidq;
const struct sram_channel *sram_channels; const struct sram_channel *sram_channels;