diff options
author | Jarod Wilson <jarod@redhat.com> | 2011-04-28 17:20:58 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-05-20 14:56:41 -0400 |
commit | 76a2d21d96fba4d0e94cf191eb3716ea7c4916e8 (patch) | |
tree | 8b9edeed09b1b43939059997f868a78e0b619ef3 /drivers/media | |
parent | 46872d27dadb9d7401d8edc20393e443c573526f (diff) |
[media] imon: clean up disconnect routine
- Eliminate a possible circular locking lockdep warning
- Make sure we don't try to unregister a vfd on a device w/a vga screen
- Always free imon context after devices are removed (display_close can
just error out w/no context)
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/rc/imon.c | 34 |
1 files changed, 7 insertions, 27 deletions
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c index 8fc0f081b470..2d2476d68a1a 100644 --- a/drivers/media/rc/imon.c +++ b/drivers/media/rc/imon.c | |||
@@ -443,16 +443,6 @@ static int display_close(struct inode *inode, struct file *file) | |||
443 | } else { | 443 | } else { |
444 | ictx->display_isopen = false; | 444 | ictx->display_isopen = false; |
445 | dev_dbg(ictx->dev, "display port closed\n"); | 445 | dev_dbg(ictx->dev, "display port closed\n"); |
446 | if (!ictx->dev_present_intf0) { | ||
447 | /* | ||
448 | * Device disconnected before close and IR port is not | ||
449 | * open. If IR port is open, context will be deleted by | ||
450 | * ir_close. | ||
451 | */ | ||
452 | mutex_unlock(&ictx->lock); | ||
453 | free_imon_context(ictx); | ||
454 | return retval; | ||
455 | } | ||
456 | } | 446 | } |
457 | 447 | ||
458 | mutex_unlock(&ictx->lock); | 448 | mutex_unlock(&ictx->lock); |
@@ -1492,7 +1482,6 @@ static void imon_incoming_packet(struct imon_context *ictx, | |||
1492 | struct device *dev = ictx->dev; | 1482 | struct device *dev = ictx->dev; |
1493 | unsigned long flags; | 1483 | unsigned long flags; |
1494 | u32 kc; | 1484 | u32 kc; |
1495 | bool norelease = false; | ||
1496 | int i; | 1485 | int i; |
1497 | u64 scancode; | 1486 | u64 scancode; |
1498 | int press_type = 0; | 1487 | int press_type = 0; |
@@ -1560,7 +1549,6 @@ static void imon_incoming_packet(struct imon_context *ictx, | |||
1560 | !(buf[1] & 0x1 || buf[1] >> 2 & 0x1))) { | 1549 | !(buf[1] & 0x1 || buf[1] >> 2 & 0x1))) { |
1561 | len = 8; | 1550 | len = 8; |
1562 | imon_pad_to_keys(ictx, buf); | 1551 | imon_pad_to_keys(ictx, buf); |
1563 | norelease = true; | ||
1564 | } | 1552 | } |
1565 | 1553 | ||
1566 | if (debug) { | 1554 | if (debug) { |
@@ -2274,14 +2262,12 @@ static int __devinit imon_probe(struct usb_interface *interface, | |||
2274 | struct usb_host_interface *iface_desc = NULL; | 2262 | struct usb_host_interface *iface_desc = NULL; |
2275 | struct usb_interface *first_if; | 2263 | struct usb_interface *first_if; |
2276 | struct device *dev = &interface->dev; | 2264 | struct device *dev = &interface->dev; |
2277 | int ifnum, code_length, sysfs_err; | 2265 | int ifnum, sysfs_err; |
2278 | int ret = 0; | 2266 | int ret = 0; |
2279 | struct imon_context *ictx = NULL; | 2267 | struct imon_context *ictx = NULL; |
2280 | struct imon_context *first_if_ctx = NULL; | 2268 | struct imon_context *first_if_ctx = NULL; |
2281 | u16 vendor, product; | 2269 | u16 vendor, product; |
2282 | 2270 | ||
2283 | code_length = BUF_CHUNK_SIZE * 8; | ||
2284 | |||
2285 | usbdev = usb_get_dev(interface_to_usbdev(interface)); | 2271 | usbdev = usb_get_dev(interface_to_usbdev(interface)); |
2286 | iface_desc = interface->cur_altsetting; | 2272 | iface_desc = interface->cur_altsetting; |
2287 | ifnum = iface_desc->desc.bInterfaceNumber; | 2273 | ifnum = iface_desc->desc.bInterfaceNumber; |
@@ -2366,8 +2352,6 @@ static void __devexit imon_disconnect(struct usb_interface *interface) | |||
2366 | dev = ictx->dev; | 2352 | dev = ictx->dev; |
2367 | ifnum = interface->cur_altsetting->desc.bInterfaceNumber; | 2353 | ifnum = interface->cur_altsetting->desc.bInterfaceNumber; |
2368 | 2354 | ||
2369 | mutex_lock(&ictx->lock); | ||
2370 | |||
2371 | /* | 2355 | /* |
2372 | * sysfs_remove_group is safe to call even if sysfs_create_group | 2356 | * sysfs_remove_group is safe to call even if sysfs_create_group |
2373 | * hasn't been called | 2357 | * hasn't been called |
@@ -2391,24 +2375,20 @@ static void __devexit imon_disconnect(struct usb_interface *interface) | |||
2391 | if (ictx->display_supported) { | 2375 | if (ictx->display_supported) { |
2392 | if (ictx->display_type == IMON_DISPLAY_TYPE_LCD) | 2376 | if (ictx->display_type == IMON_DISPLAY_TYPE_LCD) |
2393 | usb_deregister_dev(interface, &imon_lcd_class); | 2377 | usb_deregister_dev(interface, &imon_lcd_class); |
2394 | else | 2378 | else if (ictx->display_type == IMON_DISPLAY_TYPE_VFD) |
2395 | usb_deregister_dev(interface, &imon_vfd_class); | 2379 | usb_deregister_dev(interface, &imon_vfd_class); |
2396 | } | 2380 | } |
2397 | } else { | 2381 | } else { |
2398 | ictx->dev_present_intf1 = false; | 2382 | ictx->dev_present_intf1 = false; |
2399 | usb_kill_urb(ictx->rx_urb_intf1); | 2383 | usb_kill_urb(ictx->rx_urb_intf1); |
2400 | if (ictx->display_type == IMON_DISPLAY_TYPE_VGA) | 2384 | if (ictx->display_type == IMON_DISPLAY_TYPE_VGA) { |
2401 | input_unregister_device(ictx->touch); | 2385 | input_unregister_device(ictx->touch); |
2386 | del_timer_sync(&ictx->ttimer); | ||
2387 | } | ||
2402 | } | 2388 | } |
2403 | 2389 | ||
2404 | if (!ictx->dev_present_intf0 && !ictx->dev_present_intf1) { | 2390 | if (!ictx->dev_present_intf0 && !ictx->dev_present_intf1) |
2405 | if (ictx->display_type == IMON_DISPLAY_TYPE_VGA) | 2391 | free_imon_context(ictx); |
2406 | del_timer_sync(&ictx->ttimer); | ||
2407 | mutex_unlock(&ictx->lock); | ||
2408 | if (!ictx->display_isopen) | ||
2409 | free_imon_context(ictx); | ||
2410 | } else | ||
2411 | mutex_unlock(&ictx->lock); | ||
2412 | 2392 | ||
2413 | mutex_unlock(&driver_lock); | 2393 | mutex_unlock(&driver_lock); |
2414 | 2394 | ||