diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-22 06:52:02 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-04-06 20:44:09 -0400 |
commit | 90960744a1ea83b70ace7983c80173220c9451c3 (patch) | |
tree | aa886bfe688c4a0e48d97c6f28348c7ca2d3bb6c | |
parent | b905de30e300b959ea89c3af9d436e7f73e9e628 (diff) |
V4L/DVB (11132): cx231xx: usb probe cleanups
Simplifies the usb probe logic, cleaning the printed messages during the probing
phase.
Cc: Srinivasa Deevi <srinivasa.deevi@conexant.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/cx231xx/cx231xx-cards.c | 412 |
1 files changed, 189 insertions, 223 deletions
diff --git a/drivers/media/video/cx231xx/cx231xx-cards.c b/drivers/media/video/cx231xx/cx231xx-cards.c index 1416101672a8..8971f35a73e7 100644 --- a/drivers/media/video/cx231xx/cx231xx-cards.c +++ b/drivers/media/video/cx231xx/cx231xx-cards.c | |||
@@ -558,10 +558,10 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
558 | udev = usb_get_dev(interface_to_usbdev(interface)); | 558 | udev = usb_get_dev(interface_to_usbdev(interface)); |
559 | ifnum = interface->altsetting[0].desc.bInterfaceNumber; | 559 | ifnum = interface->altsetting[0].desc.bInterfaceNumber; |
560 | 560 | ||
561 | printk(DRIVER_NAME ": Interface Number %d\n", ifnum); | 561 | if (!ifnum) { |
562 | 562 | /* | |
563 | /* Interface number 0 - IR interface */ | 563 | * Interface number 0 - IR interface |
564 | if (ifnum == 0) { | 564 | */ |
565 | /* Check to see next free device and mark as used */ | 565 | /* Check to see next free device and mark as used */ |
566 | nr = find_first_zero_bit(&cx231xx_devused, CX231XX_MAXBOARDS); | 566 | nr = find_first_zero_bit(&cx231xx_devused, CX231XX_MAXBOARDS); |
567 | cx231xx_devused |= 1 << nr; | 567 | cx231xx_devused |= 1 << nr; |
@@ -600,42 +600,46 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
600 | /* get maximum no.of IAD interfaces */ | 600 | /* get maximum no.of IAD interfaces */ |
601 | assoc_desc = udev->actconfig->intf_assoc[0]; | 601 | assoc_desc = udev->actconfig->intf_assoc[0]; |
602 | dev->max_iad_interface_count = assoc_desc->bInterfaceCount; | 602 | dev->max_iad_interface_count = assoc_desc->bInterfaceCount; |
603 | cx231xx_info("Found IAD interface count %d\n", | ||
604 | dev->max_iad_interface_count); | ||
605 | 603 | ||
606 | /* init CIR module TBD */ | 604 | /* init CIR module TBD */ |
607 | 605 | ||
608 | /* store the current interface */ | 606 | /* store the current interface */ |
609 | lif = interface; | 607 | lif = interface; |
610 | 608 | ||
611 | } else if (ifnum == 1) { | 609 | switch (udev->speed) { |
612 | 610 | case USB_SPEED_LOW: | |
613 | /* Get dev structure first */ | 611 | speed = "1.5"; |
614 | dev = usb_get_intfdata(udev->actconfig->interface[0]); | 612 | break; |
615 | if (dev == NULL) { | 613 | case USB_SPEED_UNKNOWN: |
616 | cx231xx_err(DRIVER_NAME ": out of first interface!\n"); | 614 | case USB_SPEED_FULL: |
617 | return -ENODEV; | 615 | speed = "12"; |
616 | break; | ||
617 | case USB_SPEED_HIGH: | ||
618 | speed = "480"; | ||
619 | break; | ||
620 | default: | ||
621 | speed = "unknown"; | ||
618 | } | 622 | } |
619 | 623 | ||
620 | /* store the interface 0 back */ | 624 | if (udev->manufacturer) |
621 | lif = udev->actconfig->interface[0]; | 625 | strlcpy(descr, udev->manufacturer, sizeof(descr)); |
622 | |||
623 | /* increment interface count */ | ||
624 | dev->interface_count++; | ||
625 | |||
626 | /* get device number */ | ||
627 | nr = dev->devno; | ||
628 | 626 | ||
629 | assoc_desc = udev->actconfig->intf_assoc[0]; | 627 | if (udev->product) { |
630 | if (assoc_desc->bFirstInterface == ifnum) { | 628 | if (*descr) |
631 | cx231xx_info | 629 | strlcat(descr, " ", sizeof(descr)); |
632 | ("Found IAD interface match: AV Desc Start!! \n"); | 630 | strlcat(descr, udev->product, sizeof(descr)); |
633 | } else { | ||
634 | cx231xx_err(" Not found matching interface\n"); | ||
635 | return -ENODEV; | ||
636 | } | 631 | } |
632 | if (*descr) | ||
633 | strlcat(descr, " ", sizeof(descr)); | ||
637 | 634 | ||
638 | } else if (ifnum >= 2) { | 635 | cx231xx_info("New device %s@ %s Mbps " |
636 | "(%04x:%04x) with %d interfaces\n", | ||
637 | descr, | ||
638 | speed, | ||
639 | le16_to_cpu(udev->descriptor.idVendor), | ||
640 | le16_to_cpu(udev->descriptor.idProduct), | ||
641 | dev->max_iad_interface_count); | ||
642 | } else { | ||
639 | /* Get dev structure first */ | 643 | /* Get dev structure first */ |
640 | dev = usb_get_intfdata(udev->actconfig->interface[0]); | 644 | dev = usb_get_intfdata(udev->actconfig->interface[0]); |
641 | if (dev == NULL) { | 645 | if (dev == NULL) { |
@@ -652,162 +656,176 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
652 | /* get device number */ | 656 | /* get device number */ |
653 | nr = dev->devno; | 657 | nr = dev->devno; |
654 | 658 | ||
655 | /* set skip interface */ | 659 | /* |
656 | if ((dev->interface_count - 1) != dev->max_iad_interface_count) | 660 | * set skip interface, for all interfaces but |
657 | skip_interface = 1; /* set skipping */ | 661 | * interface 1 and the last one |
658 | else { | 662 | */ |
659 | cx231xx_info | 663 | if ((ifnum != 1) && ((dev->interface_count - 1) |
660 | ("Found IAD interface no. match with AV Device no.!\n"); | 664 | != dev->max_iad_interface_count)) |
665 | skip_interface = 1; | ||
666 | |||
667 | if (ifnum == 1) { | ||
668 | assoc_desc = udev->actconfig->intf_assoc[0]; | ||
669 | if (assoc_desc->bFirstInterface != ifnum) { | ||
670 | cx231xx_err(DRIVER_NAME ": Not found " | ||
671 | "matching IAD interface\n"); | ||
672 | return -ENODEV; | ||
673 | } | ||
661 | } | 674 | } |
662 | } | 675 | } |
663 | 676 | ||
664 | switch (udev->speed) { | 677 | if (skip_interface) |
665 | case USB_SPEED_LOW: | 678 | return -ENODEV; |
666 | speed = "1.5"; | ||
667 | break; | ||
668 | case USB_SPEED_UNKNOWN: | ||
669 | case USB_SPEED_FULL: | ||
670 | speed = "12"; | ||
671 | break; | ||
672 | case USB_SPEED_HIGH: | ||
673 | speed = "480"; | ||
674 | break; | ||
675 | default: | ||
676 | speed = "unknown"; | ||
677 | } | ||
678 | 679 | ||
679 | if (udev->manufacturer) | 680 | cx231xx_info("registering interface %d\n", ifnum); |
680 | strlcpy(descr, udev->manufacturer, sizeof(descr)); | ||
681 | 681 | ||
682 | if (udev->product) { | 682 | /* save our data pointer in this interface device */ |
683 | if (*descr) | 683 | usb_set_intfdata(lif, dev); |
684 | strlcat(descr, " ", sizeof(descr)); | ||
685 | strlcat(descr, udev->product, sizeof(descr)); | ||
686 | } | ||
687 | if (*descr) | ||
688 | strlcat(descr, " ", sizeof(descr)); | ||
689 | 684 | ||
690 | cx231xx_info("New device %s@ %s Mbps " | 685 | if ((dev->interface_count - 1) != dev->max_iad_interface_count) |
691 | "(%04x:%04x, interface %d, class %d)\n", | 686 | return 0; |
692 | descr, | ||
693 | speed, | ||
694 | le16_to_cpu(udev->descriptor.idVendor), | ||
695 | le16_to_cpu(udev->descriptor.idProduct), | ||
696 | ifnum, interface->altsetting->desc.bInterfaceNumber); | ||
697 | 687 | ||
698 | /* AV device initialization */ | 688 | /* |
699 | if ((dev->interface_count - 1) == dev->max_iad_interface_count) { | 689 | * AV device initialization - only done at the last interface |
700 | cx231xx_info(" Calling init_dev\n"); | 690 | */ |
701 | 691 | ||
702 | /* Create v4l2 device */ | 692 | /* Create v4l2 device */ |
703 | snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), | 693 | snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), |
704 | "%s-%03d", "cx231xx", nr); | 694 | "%s-%03d", "cx231xx", nr); |
705 | retval = v4l2_device_register(&udev->dev, &dev->v4l2_dev); | 695 | retval = v4l2_device_register(&udev->dev, &dev->v4l2_dev); |
706 | if (retval) { | 696 | if (retval) { |
707 | printk(KERN_ERR "%s() v4l2_device_register failed\n", | 697 | cx231xx_errdev("v4l2_device_register failed\n"); |
708 | __func__); | 698 | cx231xx_devused &= ~(1 << nr); |
709 | cx231xx_devused &= ~(1 << nr); | 699 | kfree(dev); |
710 | kfree(dev); | 700 | return -EIO; |
711 | return -EIO; | 701 | } |
712 | } | ||
713 | |||
714 | /* allocate device struct */ | ||
715 | retval = cx231xx_init_dev(&dev, udev, nr); | ||
716 | if (retval) { | ||
717 | cx231xx_devused &= ~(1 << dev->devno); | ||
718 | v4l2_device_unregister(&dev->v4l2_dev); | ||
719 | kfree(dev); | ||
720 | return retval; | ||
721 | } | ||
722 | 702 | ||
723 | /* compute alternate max packet sizes for video */ | 703 | /* allocate device struct */ |
724 | uif = | 704 | retval = cx231xx_init_dev(&dev, udev, nr); |
725 | udev->actconfig->interface[dev->current_pcb_config. | 705 | if (retval) { |
726 | hs_config_info[0].interface_info. | 706 | cx231xx_devused &= ~(1 << dev->devno); |
727 | video_index + 1]; | 707 | v4l2_device_unregister(&dev->v4l2_dev); |
708 | kfree(dev); | ||
709 | return retval; | ||
710 | } | ||
728 | 711 | ||
729 | dev->video_mode.end_point_addr = | 712 | /* compute alternate max packet sizes for video */ |
730 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc. | 713 | uif = udev->actconfig->interface[dev->current_pcb_config. |
731 | bEndpointAddress); | 714 | hs_config_info[0].interface_info.video_index + 1]; |
732 | 715 | ||
733 | dev->video_mode.num_alt = uif->num_altsetting; | 716 | dev->video_mode.end_point_addr = le16_to_cpu(uif->altsetting[0]. |
734 | cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n", | 717 | endpoint[isoc_pipe].desc.bEndpointAddress); |
735 | dev->video_mode.end_point_addr, | ||
736 | dev->video_mode.num_alt); | ||
737 | dev->video_mode.alt_max_pkt_size = | ||
738 | kmalloc(32 * dev->video_mode.num_alt, GFP_KERNEL); | ||
739 | 718 | ||
740 | if (dev->video_mode.alt_max_pkt_size == NULL) { | 719 | dev->video_mode.num_alt = uif->num_altsetting; |
741 | cx231xx_errdev("out of memory!\n"); | 720 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", |
742 | cx231xx_devused &= ~(1 << nr); | 721 | dev->video_mode.end_point_addr, |
743 | v4l2_device_unregister(&dev->v4l2_dev); | 722 | dev->video_mode.num_alt); |
744 | kfree(dev); | 723 | dev->video_mode.alt_max_pkt_size = |
745 | return -ENOMEM; | 724 | kmalloc(32 * dev->video_mode.num_alt, GFP_KERNEL); |
746 | } | ||
747 | 725 | ||
748 | for (i = 0; i < dev->video_mode.num_alt; i++) { | 726 | if (dev->video_mode.alt_max_pkt_size == NULL) { |
749 | u16 tmp = | 727 | cx231xx_errdev("out of memory!\n"); |
750 | le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. | 728 | cx231xx_devused &= ~(1 << nr); |
751 | desc.wMaxPacketSize); | 729 | v4l2_device_unregister(&dev->v4l2_dev); |
752 | dev->video_mode.alt_max_pkt_size[i] = | 730 | kfree(dev); |
753 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | 731 | return -ENOMEM; |
754 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | 732 | } |
755 | dev->video_mode.alt_max_pkt_size[i]); | ||
756 | } | ||
757 | 733 | ||
758 | /* compute alternate max packet sizes for vbi */ | 734 | for (i = 0; i < dev->video_mode.num_alt; i++) { |
759 | uif = | 735 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. |
760 | udev->actconfig->interface[dev->current_pcb_config. | 736 | desc.wMaxPacketSize); |
761 | hs_config_info[0].interface_info. | 737 | dev->video_mode.alt_max_pkt_size[i] = |
762 | vanc_index + 1]; | 738 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
739 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | ||
740 | dev->video_mode.alt_max_pkt_size[i]); | ||
741 | } | ||
763 | 742 | ||
764 | dev->vbi_mode.end_point_addr = | 743 | /* compute alternate max packet sizes for vbi */ |
765 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc. | 744 | uif = udev->actconfig->interface[dev->current_pcb_config. |
766 | bEndpointAddress); | 745 | hs_config_info[0].interface_info. |
746 | vanc_index + 1]; | ||
747 | |||
748 | dev->vbi_mode.end_point_addr = | ||
749 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc. | ||
750 | bEndpointAddress); | ||
751 | |||
752 | dev->vbi_mode.num_alt = uif->num_altsetting; | ||
753 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", | ||
754 | dev->vbi_mode.end_point_addr, | ||
755 | dev->vbi_mode.num_alt); | ||
756 | dev->vbi_mode.alt_max_pkt_size = | ||
757 | kmalloc(32 * dev->vbi_mode.num_alt, GFP_KERNEL); | ||
758 | |||
759 | if (dev->vbi_mode.alt_max_pkt_size == NULL) { | ||
760 | cx231xx_errdev("out of memory!\n"); | ||
761 | cx231xx_devused &= ~(1 << nr); | ||
762 | v4l2_device_unregister(&dev->v4l2_dev); | ||
763 | kfree(dev); | ||
764 | return -ENOMEM; | ||
765 | } | ||
767 | 766 | ||
768 | dev->vbi_mode.num_alt = uif->num_altsetting; | 767 | for (i = 0; i < dev->vbi_mode.num_alt; i++) { |
769 | cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n", | 768 | u16 tmp = |
770 | dev->vbi_mode.end_point_addr, | 769 | le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. |
771 | dev->vbi_mode.num_alt); | 770 | desc.wMaxPacketSize); |
772 | dev->vbi_mode.alt_max_pkt_size = | 771 | dev->vbi_mode.alt_max_pkt_size[i] = |
773 | kmalloc(32 * dev->vbi_mode.num_alt, GFP_KERNEL); | 772 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
773 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | ||
774 | dev->vbi_mode.alt_max_pkt_size[i]); | ||
775 | } | ||
774 | 776 | ||
775 | if (dev->vbi_mode.alt_max_pkt_size == NULL) { | 777 | /* compute alternate max packet sizes for sliced CC */ |
776 | cx231xx_errdev("out of memory!\n"); | 778 | uif = udev->actconfig->interface[dev->current_pcb_config. |
777 | cx231xx_devused &= ~(1 << nr); | 779 | hs_config_info[0].interface_info. |
778 | v4l2_device_unregister(&dev->v4l2_dev); | 780 | hanc_index + 1]; |
779 | kfree(dev); | 781 | |
780 | return -ENOMEM; | 782 | dev->sliced_cc_mode.end_point_addr = |
781 | } | 783 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc. |
784 | bEndpointAddress); | ||
785 | |||
786 | dev->sliced_cc_mode.num_alt = uif->num_altsetting; | ||
787 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", | ||
788 | dev->sliced_cc_mode.end_point_addr, | ||
789 | dev->sliced_cc_mode.num_alt); | ||
790 | dev->sliced_cc_mode.alt_max_pkt_size = | ||
791 | kmalloc(32 * dev->sliced_cc_mode.num_alt, GFP_KERNEL); | ||
792 | |||
793 | if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) { | ||
794 | cx231xx_errdev("out of memory!\n"); | ||
795 | cx231xx_devused &= ~(1 << nr); | ||
796 | v4l2_device_unregister(&dev->v4l2_dev); | ||
797 | kfree(dev); | ||
798 | return -ENOMEM; | ||
799 | } | ||
782 | 800 | ||
783 | for (i = 0; i < dev->vbi_mode.num_alt; i++) { | 801 | for (i = 0; i < dev->sliced_cc_mode.num_alt; i++) { |
784 | u16 tmp = | 802 | u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. |
785 | le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. | 803 | desc.wMaxPacketSize); |
786 | desc.wMaxPacketSize); | 804 | dev->sliced_cc_mode.alt_max_pkt_size[i] = |
787 | dev->vbi_mode.alt_max_pkt_size[i] = | 805 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
788 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | 806 | cx231xx_info("Alternate setting %i, max size= %i\n", i, |
789 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | 807 | dev->sliced_cc_mode.alt_max_pkt_size[i]); |
790 | dev->vbi_mode.alt_max_pkt_size[i]); | 808 | } |
791 | } | ||
792 | 809 | ||
793 | /* compute alternate max packet sizes for sliced CC */ | 810 | if (dev->current_pcb_config.ts1_source != 0xff) { |
794 | uif = | 811 | /* compute alternate max packet sizes for TS1 */ |
795 | udev->actconfig->interface[dev->current_pcb_config. | 812 | uif = udev->actconfig->interface[dev->current_pcb_config. |
796 | hs_config_info[0].interface_info. | 813 | hs_config_info[0]. |
797 | hanc_index + 1]; | 814 | interface_info. |
815 | ts1_index + 1]; | ||
798 | 816 | ||
799 | dev->sliced_cc_mode.end_point_addr = | 817 | dev->ts1_mode.end_point_addr = |
800 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc. | 818 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe]. |
801 | bEndpointAddress); | 819 | desc.bEndpointAddress); |
802 | 820 | ||
803 | dev->sliced_cc_mode.num_alt = uif->num_altsetting; | 821 | dev->ts1_mode.num_alt = uif->num_altsetting; |
804 | cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n", | 822 | cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n", |
805 | dev->sliced_cc_mode.end_point_addr, | 823 | dev->ts1_mode.end_point_addr, |
806 | dev->sliced_cc_mode.num_alt); | 824 | dev->ts1_mode.num_alt); |
807 | dev->sliced_cc_mode.alt_max_pkt_size = | 825 | dev->ts1_mode.alt_max_pkt_size = |
808 | kmalloc(32 * dev->sliced_cc_mode.num_alt, GFP_KERNEL); | 826 | kmalloc(32 * dev->ts1_mode.num_alt, GFP_KERNEL); |
809 | 827 | ||
810 | if (dev->sliced_cc_mode.alt_max_pkt_size == NULL) { | 828 | if (dev->ts1_mode.alt_max_pkt_size == NULL) { |
811 | cx231xx_errdev("out of memory!\n"); | 829 | cx231xx_errdev("out of memory!\n"); |
812 | cx231xx_devused &= ~(1 << nr); | 830 | cx231xx_devused &= ~(1 << nr); |
813 | v4l2_device_unregister(&dev->v4l2_dev); | 831 | v4l2_device_unregister(&dev->v4l2_dev); |
@@ -815,74 +833,19 @@ static int cx231xx_usb_probe(struct usb_interface *interface, | |||
815 | return -ENOMEM; | 833 | return -ENOMEM; |
816 | } | 834 | } |
817 | 835 | ||
818 | for (i = 0; i < dev->sliced_cc_mode.num_alt; i++) { | 836 | for (i = 0; i < dev->ts1_mode.num_alt; i++) { |
819 | u16 tmp = | 837 | u16 tmp = le16_to_cpu(uif->altsetting[i]. |
820 | le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe]. | ||
821 | desc.wMaxPacketSize); | ||
822 | dev->sliced_cc_mode.alt_max_pkt_size[i] = | ||
823 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); | ||
824 | cx231xx_info("Alternate setting %i, max size= %i\n", i, | ||
825 | dev->sliced_cc_mode.alt_max_pkt_size[i]); | ||
826 | } | ||
827 | |||
828 | if (dev->current_pcb_config.ts1_source != 0xff) { | ||
829 | |||
830 | /* compute alternate max packet sizes for TS1 */ | ||
831 | uif = | ||
832 | udev->actconfig->interface[dev->current_pcb_config. | ||
833 | hs_config_info[0]. | ||
834 | interface_info. | ||
835 | ts1_index + 1]; | ||
836 | |||
837 | dev->ts1_mode.end_point_addr = | ||
838 | le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe]. | ||
839 | desc.bEndpointAddress); | ||
840 | |||
841 | dev->ts1_mode.num_alt = uif->num_altsetting; | ||
842 | cx231xx_info | ||
843 | (": EndPoint Addr 0x%x, Alternate settings: %i\n", | ||
844 | dev->ts1_mode.end_point_addr, | ||
845 | dev->ts1_mode.num_alt); | ||
846 | dev->ts1_mode.alt_max_pkt_size = | ||
847 | kmalloc(32 * dev->ts1_mode.num_alt, GFP_KERNEL); | ||
848 | |||
849 | if (dev->ts1_mode.alt_max_pkt_size == NULL) { | ||
850 | cx231xx_errdev("out of memory!\n"); | ||
851 | cx231xx_devused &= ~(1 << nr); | ||
852 | v4l2_device_unregister(&dev->v4l2_dev); | ||
853 | kfree(dev); | ||
854 | return -ENOMEM; | ||
855 | } | ||
856 | |||
857 | for (i = 0; i < dev->ts1_mode.num_alt; i++) { | ||
858 | u16 tmp = | ||
859 | le16_to_cpu(uif->altsetting[i]. | ||
860 | endpoint[isoc_pipe].desc. | 838 | endpoint[isoc_pipe].desc. |
861 | wMaxPacketSize); | 839 | wMaxPacketSize); |
862 | dev->ts1_mode.alt_max_pkt_size[i] = | 840 | dev->ts1_mode.alt_max_pkt_size[i] = |
863 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + | 841 | (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1); |
864 | 1); | 842 | cx231xx_info("Alternate setting %i, max size= %i\n", i, |
865 | cx231xx_info | ||
866 | ("Alternate setting %i, max size= %i\n", i, | ||
867 | dev->ts1_mode.alt_max_pkt_size[i]); | 843 | dev->ts1_mode.alt_max_pkt_size[i]); |
868 | } | ||
869 | } | 844 | } |
870 | |||
871 | } | 845 | } |
872 | 846 | ||
873 | /* save our data pointer in this interface device */ | ||
874 | usb_set_intfdata(lif, dev); | ||
875 | |||
876 | /* load other modules required */ | 847 | /* load other modules required */ |
877 | if ((dev->interface_count - 1) == dev->max_iad_interface_count) { | 848 | request_modules(dev); |
878 | cx231xx_info("Calling request modules\n"); | ||
879 | request_modules(dev); | ||
880 | } | ||
881 | |||
882 | if (skip_interface) { | ||
883 | cx231xx_info("Skipping the interface\n"); | ||
884 | return -ENODEV; | ||
885 | } | ||
886 | 849 | ||
887 | return 0; | 850 | return 0; |
888 | } | 851 | } |
@@ -902,6 +865,9 @@ static void cx231xx_usb_disconnect(struct usb_interface *interface) | |||
902 | if (!dev) | 865 | if (!dev) |
903 | return; | 866 | return; |
904 | 867 | ||
868 | if (!dev->udev) | ||
869 | return; | ||
870 | |||
905 | /* delete v4l2 device */ | 871 | /* delete v4l2 device */ |
906 | v4l2_device_unregister(&dev->v4l2_dev); | 872 | v4l2_device_unregister(&dev->v4l2_dev); |
907 | 873 | ||