Commit 90960744 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

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: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent b905de30
......@@ -558,10 +558,10 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
udev = usb_get_dev(interface_to_usbdev(interface));
ifnum = interface->altsetting[0].desc.bInterfaceNumber;
printk(DRIVER_NAME ": Interface Number %d\n", ifnum);
/* Interface number 0 - IR interface */
if (ifnum == 0) {
if (!ifnum) {
/*
* Interface number 0 - IR interface
*/
/* Check to see next free device and mark as used */
nr = find_first_zero_bit(&cx231xx_devused, CX231XX_MAXBOARDS);
cx231xx_devused |= 1 << nr;
......@@ -600,67 +600,12 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
/* get maximum no.of IAD interfaces */
assoc_desc = udev->actconfig->intf_assoc[0];
dev->max_iad_interface_count = assoc_desc->bInterfaceCount;
cx231xx_info("Found IAD interface count %d\n",
dev->max_iad_interface_count);
/* init CIR module TBD */
/* store the current interface */
lif = interface;
} else if (ifnum == 1) {
/* Get dev structure first */
dev = usb_get_intfdata(udev->actconfig->interface[0]);
if (dev == NULL) {
cx231xx_err(DRIVER_NAME ": out of first interface!\n");
return -ENODEV;
}
/* store the interface 0 back */
lif = udev->actconfig->interface[0];
/* increment interface count */
dev->interface_count++;
/* get device number */
nr = dev->devno;
assoc_desc = udev->actconfig->intf_assoc[0];
if (assoc_desc->bFirstInterface == ifnum) {
cx231xx_info
("Found IAD interface match: AV Desc Start!! \n");
} else {
cx231xx_err(" Not found matching interface\n");
return -ENODEV;
}
} else if (ifnum >= 2) {
/* Get dev structure first */
dev = usb_get_intfdata(udev->actconfig->interface[0]);
if (dev == NULL) {
cx231xx_err(DRIVER_NAME ": out of first interface!\n");
return -ENODEV;
}
/* store the interface 0 back */
lif = udev->actconfig->interface[0];
/* increment interface count */
dev->interface_count++;
/* get device number */
nr = dev->devno;
/* set skip interface */
if ((dev->interface_count - 1) != dev->max_iad_interface_count)
skip_interface = 1; /* set skipping */
else {
cx231xx_info
("Found IAD interface no. match with AV Device no.!\n");
}
}
switch (udev->speed) {
case USB_SPEED_LOW:
speed = "1.5";
......@@ -688,24 +633,68 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
strlcat(descr, " ", sizeof(descr));
cx231xx_info("New device %s@ %s Mbps "
"(%04x:%04x, interface %d, class %d)\n",
"(%04x:%04x) with %d interfaces\n",
descr,
speed,
le16_to_cpu(udev->descriptor.idVendor),
le16_to_cpu(udev->descriptor.idProduct),
ifnum, interface->altsetting->desc.bInterfaceNumber);
dev->max_iad_interface_count);
} else {
/* Get dev structure first */
dev = usb_get_intfdata(udev->actconfig->interface[0]);
if (dev == NULL) {
cx231xx_err(DRIVER_NAME ": out of first interface!\n");
return -ENODEV;
}
/* store the interface 0 back */
lif = udev->actconfig->interface[0];
/* increment interface count */
dev->interface_count++;
/* AV device initialization */
if ((dev->interface_count - 1) == dev->max_iad_interface_count) {
cx231xx_info(" Calling init_dev\n");
/* get device number */
nr = dev->devno;
/*
* set skip interface, for all interfaces but
* interface 1 and the last one
*/
if ((ifnum != 1) && ((dev->interface_count - 1)
!= dev->max_iad_interface_count))
skip_interface = 1;
if (ifnum == 1) {
assoc_desc = udev->actconfig->intf_assoc[0];
if (assoc_desc->bFirstInterface != ifnum) {
cx231xx_err(DRIVER_NAME ": Not found "
"matching IAD interface\n");
return -ENODEV;
}
}
}
if (skip_interface)
return -ENODEV;
cx231xx_info("registering interface %d\n", ifnum);
/* save our data pointer in this interface device */
usb_set_intfdata(lif, dev);
if ((dev->interface_count - 1) != dev->max_iad_interface_count)
return 0;
/*
* AV device initialization - only done at the last interface
*/
/* Create v4l2 device */
snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name),
"%s-%03d", "cx231xx", nr);
retval = v4l2_device_register(&udev->dev, &dev->v4l2_dev);
if (retval) {
printk(KERN_ERR "%s() v4l2_device_register failed\n",
__func__);
cx231xx_errdev("v4l2_device_register failed\n");
cx231xx_devused &= ~(1 << nr);
kfree(dev);
return -EIO;
......@@ -721,17 +710,14 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
}
/* compute alternate max packet sizes for video */
uif =
udev->actconfig->interface[dev->current_pcb_config.
hs_config_info[0].interface_info.
video_index + 1];
uif = udev->actconfig->interface[dev->current_pcb_config.
hs_config_info[0].interface_info.video_index + 1];
dev->video_mode.end_point_addr =
le16_to_cpu(uif->altsetting[0].endpoint[isoc_pipe].desc.
bEndpointAddress);
dev->video_mode.end_point_addr = le16_to_cpu(uif->altsetting[0].
endpoint[isoc_pipe].desc.bEndpointAddress);
dev->video_mode.num_alt = uif->num_altsetting;
cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n",
cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
dev->video_mode.end_point_addr,
dev->video_mode.num_alt);
dev->video_mode.alt_max_pkt_size =
......@@ -746,8 +732,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
}
for (i = 0; i < dev->video_mode.num_alt; i++) {
u16 tmp =
le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].
u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].
desc.wMaxPacketSize);
dev->video_mode.alt_max_pkt_size[i] =
(tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
......@@ -756,8 +741,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
}
/* compute alternate max packet sizes for vbi */
uif =
udev->actconfig->interface[dev->current_pcb_config.
uif = udev->actconfig->interface[dev->current_pcb_config.
hs_config_info[0].interface_info.
vanc_index + 1];
......@@ -766,7 +750,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
bEndpointAddress);
dev->vbi_mode.num_alt = uif->num_altsetting;
cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n",
cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
dev->vbi_mode.end_point_addr,
dev->vbi_mode.num_alt);
dev->vbi_mode.alt_max_pkt_size =
......@@ -791,8 +775,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
}
/* compute alternate max packet sizes for sliced CC */
uif =
udev->actconfig->interface[dev->current_pcb_config.
uif = udev->actconfig->interface[dev->current_pcb_config.
hs_config_info[0].interface_info.
hanc_index + 1];
......@@ -801,7 +784,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
bEndpointAddress);
dev->sliced_cc_mode.num_alt = uif->num_altsetting;
cx231xx_info(": EndPoint Addr 0x%x, Alternate settings: %i\n",
cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
dev->sliced_cc_mode.end_point_addr,
dev->sliced_cc_mode.num_alt);
dev->sliced_cc_mode.alt_max_pkt_size =
......@@ -816,8 +799,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
}
for (i = 0; i < dev->sliced_cc_mode.num_alt; i++) {
u16 tmp =
le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].
u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].
desc.wMaxPacketSize);
dev->sliced_cc_mode.alt_max_pkt_size[i] =
(tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
......@@ -826,10 +808,8 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
}
if (dev->current_pcb_config.ts1_source != 0xff) {
/* compute alternate max packet sizes for TS1 */
uif =
udev->actconfig->interface[dev->current_pcb_config.
uif = udev->actconfig->interface[dev->current_pcb_config.
hs_config_info[0].
interface_info.
ts1_index + 1];
......@@ -839,8 +819,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
desc.bEndpointAddress);
dev->ts1_mode.num_alt = uif->num_altsetting;
cx231xx_info
(": EndPoint Addr 0x%x, Alternate settings: %i\n",
cx231xx_info("EndPoint Addr 0x%x, Alternate settings: %i\n",
dev->ts1_mode.end_point_addr,
dev->ts1_mode.num_alt);
dev->ts1_mode.alt_max_pkt_size =
......@@ -855,34 +834,18 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
}
for (i = 0; i < dev->ts1_mode.num_alt; i++) {
u16 tmp =
le16_to_cpu(uif->altsetting[i].
u16 tmp = le16_to_cpu(uif->altsetting[i].
endpoint[isoc_pipe].desc.
wMaxPacketSize);
dev->ts1_mode.alt_max_pkt_size[i] =
(tmp & 0x07ff) * (((tmp & 0x1800) >> 11) +
1);
cx231xx_info
("Alternate setting %i, max size= %i\n", i,
(tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
cx231xx_info("Alternate setting %i, max size= %i\n", i,
dev->ts1_mode.alt_max_pkt_size[i]);
}
}
}
/* save our data pointer in this interface device */
usb_set_intfdata(lif, dev);
/* load other modules required */
if ((dev->interface_count - 1) == dev->max_iad_interface_count) {
cx231xx_info("Calling request modules\n");
request_modules(dev);
}
if (skip_interface) {
cx231xx_info("Skipping the interface\n");
return -ENODEV;
}
return 0;
}
......@@ -902,6 +865,9 @@ static void cx231xx_usb_disconnect(struct usb_interface *interface)
if (!dev)
return;
if (!dev->udev)
return;
/* delete v4l2 device */
v4l2_device_unregister(&dev->v4l2_dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment