diff options
author | Andy Walls <awalls@radix.net> | 2009-01-11 13:08:53 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:42:25 -0400 |
commit | 888cdb07741ab0098ccb8d9feff3f98cad048c26 (patch) | |
tree | 942168c99f00def299ce83eae6c3c1fffb8151ef /drivers | |
parent | 3d05913d894a460b7dc8e5d93415fde21b986411 (diff) |
V4L/DVB (10281): cx18: Conversion to new V4L2 framework: use v4l2_device object
First step in conversion to the new V4L2 framework. Added per cx18 device
instance of the v4l2_device and its registration.
Signed-off-by: Andy Walls <awalls@radix.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/cx18/cx18-driver.c | 23 | ||||
-rw-r--r-- | drivers/media/video/cx18/cx18-driver.h | 3 |
2 files changed, 19 insertions, 7 deletions
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c index 52d04f640b73..450c48dd995a 100644 --- a/drivers/media/video/cx18/cx18-driver.c +++ b/drivers/media/video/cx18/cx18-driver.c | |||
@@ -797,21 +797,28 @@ static int __devinit cx18_probe(struct pci_dev *pci_dev, | |||
797 | return -ENOMEM; | 797 | return -ENOMEM; |
798 | } | 798 | } |
799 | cx18_cards[cx18_cards_active] = cx; | 799 | cx18_cards[cx18_cards_active] = cx; |
800 | cx->pci_dev = pci_dev; | ||
801 | cx->num = cx18_cards_active++; | 800 | cx->num = cx18_cards_active++; |
802 | snprintf(cx->name, sizeof(cx->name), "cx18-%d", cx->num); | 801 | snprintf(cx->name, sizeof(cx->name), "cx18-%d", cx->num); |
803 | CX18_INFO("Initializing card #%d\n", cx->num); | 802 | CX18_INFO("Initializing card #%d\n", cx->num); |
804 | 803 | ||
805 | spin_unlock(&cx18_cards_lock); | 804 | spin_unlock(&cx18_cards_lock); |
806 | 805 | ||
806 | cx->pci_dev = pci_dev; | ||
807 | retval = v4l2_device_register(&pci_dev->dev, &cx->v4l2_dev); | ||
808 | if (retval) { | ||
809 | CX18_ERR("Call to v4l2_device_register() failed\n"); | ||
810 | goto err; | ||
811 | } | ||
812 | CX18_DEBUG_INFO("registered v4l2_device name: %s\n", cx->v4l2_dev.name); | ||
813 | |||
807 | cx18_process_options(cx); | 814 | cx18_process_options(cx); |
808 | if (cx->options.cardtype == -1) { | 815 | if (cx->options.cardtype == -1) { |
809 | retval = -ENODEV; | 816 | retval = -ENODEV; |
810 | goto err; | 817 | goto unregister_v4l2; |
811 | } | 818 | } |
812 | if (cx18_init_struct1(cx)) { | 819 | if (cx18_init_struct1(cx)) { |
813 | retval = -ENOMEM; | 820 | retval = -ENOMEM; |
814 | goto err; | 821 | goto unregister_v4l2; |
815 | } | 822 | } |
816 | 823 | ||
817 | CX18_DEBUG_INFO("base addr: 0x%08x\n", cx->base_addr); | 824 | CX18_DEBUG_INFO("base addr: 0x%08x\n", cx->base_addr); |
@@ -821,9 +828,6 @@ static int __devinit cx18_probe(struct pci_dev *pci_dev, | |||
821 | if (retval != 0) | 828 | if (retval != 0) |
822 | goto free_workqueue; | 829 | goto free_workqueue; |
823 | 830 | ||
824 | /* save cx in the pci struct for later use */ | ||
825 | pci_set_drvdata(pci_dev, cx); | ||
826 | |||
827 | /* map io memory */ | 831 | /* map io memory */ |
828 | CX18_DEBUG_INFO("attempting ioremap at 0x%08x len 0x%08x\n", | 832 | CX18_DEBUG_INFO("attempting ioremap at 0x%08x len 0x%08x\n", |
829 | cx->base_addr + CX18_MEM_OFFSET, CX18_MEM_SIZE); | 833 | cx->base_addr + CX18_MEM_OFFSET, CX18_MEM_SIZE); |
@@ -1002,6 +1006,8 @@ free_mem: | |||
1002 | release_mem_region(cx->base_addr, CX18_MEM_SIZE); | 1006 | release_mem_region(cx->base_addr, CX18_MEM_SIZE); |
1003 | free_workqueue: | 1007 | free_workqueue: |
1004 | destroy_workqueue(cx->work_queue); | 1008 | destroy_workqueue(cx->work_queue); |
1009 | unregister_v4l2: | ||
1010 | v4l2_device_unregister(&cx->v4l2_dev); | ||
1005 | err: | 1011 | err: |
1006 | if (retval == 0) | 1012 | if (retval == 0) |
1007 | retval = -ENODEV; | 1013 | retval = -ENODEV; |
@@ -1106,7 +1112,8 @@ static void cx18_cancel_epu_work_orders(struct cx18 *cx) | |||
1106 | 1112 | ||
1107 | static void cx18_remove(struct pci_dev *pci_dev) | 1113 | static void cx18_remove(struct pci_dev *pci_dev) |
1108 | { | 1114 | { |
1109 | struct cx18 *cx = pci_get_drvdata(pci_dev); | 1115 | struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev); |
1116 | struct cx18 *cx = container_of(v4l2_dev, struct cx18, v4l2_dev); | ||
1110 | 1117 | ||
1111 | CX18_DEBUG_INFO("Removing Card #%d\n", cx->num); | 1118 | CX18_DEBUG_INFO("Removing Card #%d\n", cx->num); |
1112 | 1119 | ||
@@ -1137,6 +1144,8 @@ static void cx18_remove(struct pci_dev *pci_dev) | |||
1137 | 1144 | ||
1138 | pci_disable_device(cx->pci_dev); | 1145 | pci_disable_device(cx->pci_dev); |
1139 | 1146 | ||
1147 | v4l2_device_unregister(v4l2_dev); | ||
1148 | |||
1140 | CX18_INFO("Removed %s, card #%d\n", cx->card_name, cx->num); | 1149 | CX18_INFO("Removed %s, card #%d\n", cx->card_name, cx->num); |
1141 | } | 1150 | } |
1142 | 1151 | ||
diff --git a/drivers/media/video/cx18/cx18-driver.h b/drivers/media/video/cx18/cx18-driver.h index 316ff333d4a5..2d5bcbf1b236 100644 --- a/drivers/media/video/cx18/cx18-driver.h +++ b/drivers/media/video/cx18/cx18-driver.h | |||
@@ -48,6 +48,7 @@ | |||
48 | #include <linux/dvb/audio.h> | 48 | #include <linux/dvb/audio.h> |
49 | #include <media/v4l2-common.h> | 49 | #include <media/v4l2-common.h> |
50 | #include <media/v4l2-ioctl.h> | 50 | #include <media/v4l2-ioctl.h> |
51 | #include <media/v4l2-device.h> | ||
51 | #include <media/tuner.h> | 52 | #include <media/tuner.h> |
52 | #include "cx18-mailbox.h" | 53 | #include "cx18-mailbox.h" |
53 | #include "cx18-av-core.h" | 54 | #include "cx18-av-core.h" |
@@ -386,6 +387,8 @@ struct cx18 { | |||
386 | int num; /* board number, -1 during init! */ | 387 | int num; /* board number, -1 during init! */ |
387 | char name[8]; /* board name for printk and interrupts (e.g. 'cx180') */ | 388 | char name[8]; /* board name for printk and interrupts (e.g. 'cx180') */ |
388 | struct pci_dev *pci_dev; | 389 | struct pci_dev *pci_dev; |
390 | struct v4l2_device v4l2_dev; | ||
391 | |||
389 | const struct cx18_card *card; /* card information */ | 392 | const struct cx18_card *card; /* card information */ |
390 | const char *card_name; /* full name of the card */ | 393 | const char *card_name; /* full name of the card */ |
391 | const struct cx18_card_tuner_i2c *card_i2c; /* i2c addresses to probe for tuner */ | 394 | const struct cx18_card_tuner_i2c *card_i2c; /* i2c addresses to probe for tuner */ |