diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-15 15:49:56 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-15 15:49:56 -0500 |
commit | 122804ecb59493fbb4d31b3ba9ac59faaf45276f (patch) | |
tree | cff4d8a158c412e4a8d3abc8d91bb0eb52b01c9a /drivers/media/video/cx231xx/cx231xx-cards.c | |
parent | 16008d641670571ff4cd750b416c7caf2d89f467 (diff) | |
parent | 126400033940afb658123517a2e80eb68259fbd7 (diff) |
Merge branch 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
* 'v4l_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (655 commits)
[media] revert patch: HDIC HD29L2 DMB-TH USB2.0 reference design driver
mb86a20s: Add a few more register settings at the init seq
mb86a20s: Group registers into the same line
[media] [PATCH] don't reset the delivery system on DTV_CLEAR
[media] [BUG] it913x-fe fix typo error making SNR levels unstable
[media] cx23885: Query the CX25840 during enum_input for status
[media] cx25840: Add support for g_input_status
[media] rc-videomate-m1f.c Rename to match remote controler name
[media] drivers: media: au0828: Fix dependency for VIDEO_AU0828
[media] convert drivers/media/* to use module_platform_driver()
[media] drivers: video: cx231xx: Fix dependency for VIDEO_CX231XX_DVB
[media] Exynos4 JPEG codec v4l2 driver
[media] doc: v4l: selection: choose pixels as units for selection rectangles
[media] v4l: s5p-tv: mixer: fix setup of VP scaling
[media] v4l: s5p-tv: mixer: add support for selection API
[media] v4l: emulate old crop API using extended crop/compose API
[media] doc: v4l: add documentation for selection API
[media] doc: v4l: add binary images for selection API
[media] v4l: add support for selection api
[media] hd29l2: fix review findings
...
Diffstat (limited to 'drivers/media/video/cx231xx/cx231xx-cards.c')
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-cards.c | 86 |
1 files changed, 40 insertions, 46 deletions
diff --git a/drivers/media/video/cx231xx/cx231xx-cards.c b/drivers/media/video/cx231xx/cx231xx-cards.c index 60b021e79864..919ed77b32f2 100644 --- a/drivers/media/video/cx231xx/cx231xx-cards.c +++ b/drivers/media/video/cx231xx/cx231xx-cards.c | |||
@@ -843,25 +843,34 @@ void cx231xx_release_resources(struct cx231xx *dev) | |||
843 | 843 | ||
844 | cx231xx_remove_from_devlist(dev); | 844 | cx231xx_remove_from_devlist(dev); |
845 | 845 | ||
846 | cx231xx_ir_exit(dev); | ||
847 | |||
846 | /* Release I2C buses */ | 848 | /* Release I2C buses */ |
847 | cx231xx_dev_uninit(dev); | 849 | cx231xx_dev_uninit(dev); |
848 | 850 | ||
849 | cx231xx_ir_exit(dev); | 851 | /* delete v4l2 device */ |
852 | v4l2_device_unregister(&dev->v4l2_dev); | ||
850 | 853 | ||
851 | usb_put_dev(dev->udev); | 854 | usb_put_dev(dev->udev); |
852 | 855 | ||
853 | /* Mark device as unused */ | 856 | /* Mark device as unused */ |
854 | cx231xx_devused &= ~(1 << dev->devno); | 857 | clear_bit(dev->devno, &cx231xx_devused); |
858 | |||
859 | kfree(dev->video_mode.alt_max_pkt_size); | ||
860 | kfree(dev->vbi_mode.alt_max_pkt_size); | ||
861 | kfree(dev->sliced_cc_mode.alt_max_pkt_size); | ||
862 | kfree(dev->ts1_mode.alt_max_pkt_size); | ||
863 | kfree(dev); | ||
864 | dev = NULL; | ||
855 | } | 865 | } |
856 | 866 | ||
857 | /* | 867 | /* |
858 | * cx231xx_init_dev() | 868 | * cx231xx_init_dev() |
859 | * allocates and inits the device structs, registers i2c bus and v4l device | 869 | * allocates and inits the device structs, registers i2c bus and v4l device |
860 | */ | 870 | */ |
861 | static int cx231xx_init_dev(struct cx231xx **devhandle, struct usb_device *udev, | 871 | static int cx231xx_init_dev(struct cx231xx *dev, struct usb_device *udev, |
862 | int minor) | 872 | int minor) |
863 | { | 873 | { |
864 | struct cx231xx *dev = *devhandle; | ||
865 | int retval = -ENOMEM; | 874 | int retval = -ENOMEM; |
866 | int errCode; | 875 | int errCode; |
867 | unsigned int maxh, maxw; | 876 | unsigned int maxh, maxw; |
@@ -1016,7 +1025,6 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1016 | int i, isoc_pipe = 0; | 1025 | int i, isoc_pipe = 0; |
1017 | char *speed; | 1026 | char *speed; |
1018 | char descr[255] = ""; | 1027 | char descr[255] = ""; |
1019 | struct usb_interface *lif = NULL; | ||
1020 | struct usb_interface_assoc_descriptor *assoc_desc; | 1028 | struct usb_interface_assoc_descriptor *assoc_desc; |
1021 | 1029 | ||
1022 | udev = usb_get_dev(interface_to_usbdev(interface)); | 1030 | udev = usb_get_dev(interface_to_usbdev(interface)); |
@@ -1030,21 +1038,21 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1030 | return -ENODEV; | 1038 | return -ENODEV; |
1031 | 1039 | ||
1032 | /* Check to see next free device and mark as used */ | 1040 | /* Check to see next free device and mark as used */ |
1033 | nr = find_first_zero_bit(&cx231xx_devused, CX231XX_MAXBOARDS); | 1041 | do { |
1034 | cx231xx_devused |= 1 << nr; | 1042 | nr = find_first_zero_bit(&cx231xx_devused, CX231XX_MAXBOARDS); |
1035 | 1043 | if (nr >= CX231XX_MAXBOARDS) { | |
1036 | if (nr >= CX231XX_MAXBOARDS) { | 1044 | /* No free device slots */ |
1037 | cx231xx_err(DRIVER_NAME | 1045 | cx231xx_err(DRIVER_NAME ": Supports only %i devices.\n", |
1038 | ": Supports only %i cx231xx boards.\n", CX231XX_MAXBOARDS); | 1046 | CX231XX_MAXBOARDS); |
1039 | cx231xx_devused &= ~(1 << nr); | 1047 | return -ENOMEM; |
1040 | return -ENOMEM; | 1048 | } |
1041 | } | 1049 | } while (test_and_set_bit(nr, &cx231xx_devused)); |
1042 | 1050 | ||
1043 | /* allocate memory for our device state and initialize it */ | 1051 | /* allocate memory for our device state and initialize it */ |
1044 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | 1052 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
1045 | if (dev == NULL) { | 1053 | if (dev == NULL) { |
1046 | cx231xx_err(DRIVER_NAME ": out of memory!\n"); | 1054 | cx231xx_err(DRIVER_NAME ": out of memory!\n"); |
1047 | cx231xx_devused &= ~(1 << nr); | 1055 | clear_bit(dev->devno, &cx231xx_devused); |
1048 | return -ENOMEM; | 1056 | return -ENOMEM; |
1049 | } | 1057 | } |
1050 | 1058 | ||
@@ -1071,9 +1079,6 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1071 | 1079 | ||
1072 | /* init CIR module TBD */ | 1080 | /* init CIR module TBD */ |
1073 | 1081 | ||
1074 | /* store the current interface */ | ||
1075 | lif = interface; | ||
1076 | |||
1077 | /*mode_tv: digital=1 or analog=0*/ | 1082 | /*mode_tv: digital=1 or analog=0*/ |
1078 | dev->mode_tv = 0; | 1083 | dev->mode_tv = 0; |
1079 | 1084 | ||
@@ -1113,9 +1118,6 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1113 | le16_to_cpu(udev->descriptor.idProduct), | 1118 | le16_to_cpu(udev->descriptor.idProduct), |
1114 | dev->max_iad_interface_count); | 1119 | dev->max_iad_interface_count); |
1115 | 1120 | ||
1116 | /* store the interface 0 back */ | ||
1117 | lif = udev->actconfig->interface[0]; | ||
1118 | |||
1119 | /* increment interface count */ | 1121 | /* increment interface count */ |
1120 | dev->interface_count++; | 1122 | dev->interface_count++; |
1121 | 1123 | ||
@@ -1126,7 +1128,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1126 | if (assoc_desc->bFirstInterface != ifnum) { | 1128 | if (assoc_desc->bFirstInterface != ifnum) { |
1127 | cx231xx_err(DRIVER_NAME ": Not found " | 1129 | cx231xx_err(DRIVER_NAME ": Not found " |
1128 | "matching IAD interface\n"); | 1130 | "matching IAD interface\n"); |
1129 | cx231xx_devused &= ~(1 << nr); | 1131 | clear_bit(dev->devno, &cx231xx_devused); |
1130 | kfree(dev); | 1132 | kfree(dev); |
1131 | dev = NULL; | 1133 | dev = NULL; |
1132 | return -ENODEV; | 1134 | return -ENODEV; |
@@ -1135,7 +1137,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1135 | cx231xx_info("registering interface %d\n", ifnum); | 1137 | cx231xx_info("registering interface %d\n", ifnum); |
1136 | 1138 | ||
1137 | /* save our data pointer in this interface device */ | 1139 | /* save our data pointer in this interface device */ |
1138 | usb_set_intfdata(lif, dev); | 1140 | usb_set_intfdata(interface, dev); |
1139 | 1141 | ||
1140 | /* | 1142 | /* |
1141 | * AV device initialization - only done at the last interface | 1143 | * AV device initialization - only done at the last interface |
@@ -1145,19 +1147,19 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1145 | retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev); | 1147 | retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev); |
1146 | if (retval) { | 1148 | if (retval) { |
1147 | cx231xx_errdev("v4l2_device_register failed\n"); | 1149 | cx231xx_errdev("v4l2_device_register failed\n"); |
1148 | cx231xx_devused &= ~(1 << nr); | 1150 | clear_bit(dev->devno, &cx231xx_devused); |
1149 | kfree(dev); | 1151 | kfree(dev); |
1150 | dev = NULL; | 1152 | dev = NULL; |
1151 | return -EIO; | 1153 | return -EIO; |
1152 | } | 1154 | } |
1153 | /* allocate device struct */ | 1155 | /* allocate device struct */ |
1154 | retval = cx231xx_init_dev(&dev, udev, nr); | 1156 | retval = cx231xx_init_dev(dev, udev, nr); |
1155 | if (retval) { | 1157 | if (retval) { |
1156 | cx231xx_devused &= ~(1 << dev->devno); | 1158 | clear_bit(dev->devno, &cx231xx_devused); |
1157 | v4l2_device_unregister(&dev->v4l2_dev); | 1159 | v4l2_device_unregister(&dev->v4l2_dev); |
1158 | kfree(dev); | 1160 | kfree(dev); |
1159 | dev = NULL; | 1161 | dev = NULL; |
1160 | usb_set_intfdata(lif, NULL); | 1162 | usb_set_intfdata(interface, NULL); |
1161 | 1163 | ||
1162 | return retval; | 1164 | return retval; |
1163 | } | 1165 | } |
@@ -1178,7 +1180,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1178 | 1180 | ||
1179 | if (dev->video_mode.alt_max_pkt_size == NULL) { | 1181 | if (dev->video_mode.alt_max_pkt_size == NULL) { |
1180 | cx231xx_errdev("out of memory!\n"); | 1182 | cx231xx_errdev("out of memory!\n"); |
1181 | cx231xx_devused &= ~(1 << nr); | 1183 | clear_bit(dev->devno, &cx231xx_devused); |
1182 | v4l2_device_unregister(&dev->v4l2_dev); | 1184 | v4l2_device_unregister(&dev->v4l2_dev); |
1183 | kfree(dev); | 1185 | kfree(dev); |
1184 | dev = NULL; | 1186 | dev = NULL; |
@@ -1212,7 +1214,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1212 | 1214 | ||
1213 | if (dev->vbi_mode.alt_max_pkt_size == NULL) { | 1215 | if (dev->vbi_mode.alt_max_pkt_size == NULL) { |
1214 | cx231xx_errdev("out of memory!\n"); | 1216 | cx231xx_errdev("out of memory!\n"); |
1215 | cx231xx_devused &= ~(1 << nr); | 1217 | clear_bit(dev->devno, &cx231xx_devused); |
1216 | v4l2_device_unregister(&dev->v4l2_dev); | 1218 | v4l2_device_unregister(&dev->v4l2_dev); |
1217 | kfree(dev); | 1219 | kfree(dev); |
1218 | dev = NULL; | 1220 | dev = NULL; |
@@ -1247,7 +1249,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1247 | 1249 | ||
1248 | if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) { | 1250 | if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) { |
1249 | cx231xx_errdev("out of memory!\n"); | 1251 | cx231xx_errdev("out of memory!\n"); |
1250 | cx231xx_devused &= ~(1 << nr); | 1252 | clear_bit(dev->devno, &cx231xx_devused); |
1251 | v4l2_device_unregister(&dev->v4l2_dev); | 1253 | v4l2_device_unregister(&dev->v4l2_dev); |
1252 | kfree(dev); | 1254 | kfree(dev); |
1253 | dev = NULL; | 1255 | dev = NULL; |
@@ -1283,7 +1285,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
1283 | 1285 | ||
1284 | if (dev->ts1_mode.alt_max_pkt_size == NULL) { | 1286 | if (dev->ts1_mode.alt_max_pkt_size == NULL) { |
1285 | cx231xx_errdev("out of memory!\n"); | 1287 | cx231xx_errdev("out of memory!\n"); |
1286 | cx231xx_devused &= ~(1 << nr); | 1288 | clear_bit(dev->devno, &cx231xx_devused); |
1287 | v4l2_device_unregister(&dev->v4l2_dev); | 1289 | v4l2_device_unregister(&dev->v4l2_dev); |
1288 | kfree(dev); | 1290 | kfree(dev); |
1289 | dev = NULL; | 1291 | dev = NULL; |
@@ -1334,10 +1336,9 @@ static void cx231xx_usb_disconnect(struct usb_interface *interface) | |||
1334 | if (!dev->udev) | 1336 | if (!dev->udev) |
1335 | return; | 1337 | return; |
1336 | 1338 | ||
1337 | flush_request_modules(dev); | 1339 | dev->state |= DEV_DISCONNECTED; |
1338 | 1340 | ||
1339 | /* delete v4l2 device */ | 1341 | flush_request_modules(dev); |
1340 | v4l2_device_unregister(&dev->v4l2_dev); | ||
1341 | 1342 | ||
1342 | /* wait until all current v4l2 io is finished then deallocate | 1343 | /* wait until all current v4l2 io is finished then deallocate |
1343 | resources */ | 1344 | resources */ |
@@ -1351,31 +1352,24 @@ static void cx231xx_usb_disconnect(struct usb_interface *interface) | |||
1351 | "deallocation are deferred on close.\n", | 1352 | "deallocation are deferred on close.\n", |
1352 | video_device_node_name(dev->vdev)); | 1353 | video_device_node_name(dev->vdev)); |
1353 | 1354 | ||
1354 | dev->state |= DEV_MISCONFIGURED; | 1355 | /* Even having users, it is safe to remove the RC i2c driver */ |
1356 | cx231xx_ir_exit(dev); | ||
1357 | |||
1355 | if (dev->USE_ISO) | 1358 | if (dev->USE_ISO) |
1356 | cx231xx_uninit_isoc(dev); | 1359 | cx231xx_uninit_isoc(dev); |
1357 | else | 1360 | else |
1358 | cx231xx_uninit_bulk(dev); | 1361 | cx231xx_uninit_bulk(dev); |
1359 | dev->state |= DEV_DISCONNECTED; | ||
1360 | wake_up_interruptible(&dev->wait_frame); | 1362 | wake_up_interruptible(&dev->wait_frame); |
1361 | wake_up_interruptible(&dev->wait_stream); | 1363 | wake_up_interruptible(&dev->wait_stream); |
1362 | } else { | 1364 | } else { |
1363 | dev->state |= DEV_DISCONNECTED; | ||
1364 | cx231xx_release_resources(dev); | ||
1365 | } | 1365 | } |
1366 | 1366 | ||
1367 | cx231xx_close_extension(dev); | 1367 | cx231xx_close_extension(dev); |
1368 | 1368 | ||
1369 | mutex_unlock(&dev->lock); | 1369 | mutex_unlock(&dev->lock); |
1370 | 1370 | ||
1371 | if (!dev->users) { | 1371 | if (!dev->users) |
1372 | kfree(dev->video_mode.alt_max_pkt_size); | 1372 | cx231xx_release_resources(dev); |
1373 | kfree(dev->vbi_mode.alt_max_pkt_size); | ||
1374 | kfree(dev->sliced_cc_mode.alt_max_pkt_size); | ||
1375 | kfree(dev->ts1_mode.alt_max_pkt_size); | ||
1376 | kfree(dev); | ||
1377 | dev = NULL; | ||
1378 | } | ||
1379 | } | 1373 | } |
1380 | 1374 | ||
1381 | static struct usb_driver cx231xx_usb_driver = { | 1375 | static struct usb_driver cx231xx_usb_driver = { |