Commit 8bb84227 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] cx231xx: Simplify interface checking logic at probe

Just a cleanup patch. Removes one indent level by moving
the return -ENODEV to happen before the device register
logic, if the interface is not the audio/video (int 1).
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent b8bc77db
...@@ -844,110 +844,110 @@ static int cx231xx_usb_probe(struct usb_interface *interface, ...@@ -844,110 +844,110 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
udev = usb_get_dev(interface_to_usbdev(interface)); udev = usb_get_dev(interface_to_usbdev(interface));
ifnum = interface->altsetting[0].desc.bInterfaceNumber; ifnum = interface->altsetting[0].desc.bInterfaceNumber;
if (ifnum == 1) { /*
/* * Interface number 0 - IR interface (handled by mceusb driver)
* Interface number 0 - IR interface * Interface number 1 - AV interface (handled by this driver)
*/ */
/* Check to see next free device and mark as used */ if (ifnum != 1)
nr = find_first_zero_bit(&cx231xx_devused, CX231XX_MAXBOARDS); return -ENODEV;
cx231xx_devused |= 1 << nr;
if (nr >= CX231XX_MAXBOARDS) {
cx231xx_err(DRIVER_NAME
": Supports only %i cx231xx boards.\n", CX231XX_MAXBOARDS);
cx231xx_devused &= ~(1 << nr);
return -ENOMEM;
}
/* allocate memory for our device state and initialize it */
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (dev == NULL) {
cx231xx_err(DRIVER_NAME ": out of memory!\n");
cx231xx_devused &= ~(1 << nr);
return -ENOMEM;
}
snprintf(dev->name, 29, "cx231xx #%d", nr);
dev->devno = nr;
dev->model = id->driver_info;
dev->video_mode.alt = -1;
dev->interface_count++;
/* reset gpio dir and value */
dev->gpio_dir = 0;
dev->gpio_val = 0;
dev->xc_fw_load_done = 0;
dev->has_alsa_audio = 1;
dev->power_mode = -1;
atomic_set(&dev->devlist_count, 0);
/* 0 - vbi ; 1 -sliced cc mode */
dev->vbi_or_sliced_cc_mode = 0;
/* get maximum no.of IAD interfaces */
assoc_desc = udev->actconfig->intf_assoc[0];
dev->max_iad_interface_count = assoc_desc->bInterfaceCount;
/* init CIR module TBD */
/* store the current interface */ /* Check to see next free device and mark as used */
lif = interface; nr = find_first_zero_bit(&cx231xx_devused, CX231XX_MAXBOARDS);
cx231xx_devused |= 1 << nr;
/*mode_tv: digital=1 or analog=0*/ if (nr >= CX231XX_MAXBOARDS) {
dev->mode_tv = 0; cx231xx_err(DRIVER_NAME
": Supports only %i cx231xx boards.\n", CX231XX_MAXBOARDS);
cx231xx_devused &= ~(1 << nr);
return -ENOMEM;
}
dev->USE_ISO = transfer_mode; /* allocate memory for our device state and initialize it */
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (dev == NULL) {
cx231xx_err(DRIVER_NAME ": out of memory!\n");
cx231xx_devused &= ~(1 << nr);
return -ENOMEM;
}
switch (udev->speed) { snprintf(dev->name, 29, "cx231xx #%d", nr);
case USB_SPEED_LOW: dev->devno = nr;
speed = "1.5"; dev->model = id->driver_info;
break; dev->video_mode.alt = -1;
case USB_SPEED_UNKNOWN:
case USB_SPEED_FULL: dev->interface_count++;
speed = "12"; /* reset gpio dir and value */
break; dev->gpio_dir = 0;
case USB_SPEED_HIGH: dev->gpio_val = 0;
speed = "480"; dev->xc_fw_load_done = 0;
break; dev->has_alsa_audio = 1;
default: dev->power_mode = -1;
speed = "unknown"; atomic_set(&dev->devlist_count, 0);
}
/* 0 - vbi ; 1 -sliced cc mode */
dev->vbi_or_sliced_cc_mode = 0;
/* get maximum no.of IAD interfaces */
assoc_desc = udev->actconfig->intf_assoc[0];
dev->max_iad_interface_count = assoc_desc->bInterfaceCount;
/* init CIR module TBD */
/* store the current interface */
lif = interface;
/*mode_tv: digital=1 or analog=0*/
dev->mode_tv = 0;
dev->USE_ISO = transfer_mode;
switch (udev->speed) {
case USB_SPEED_LOW:
speed = "1.5";
break;
case USB_SPEED_UNKNOWN:
case USB_SPEED_FULL:
speed = "12";
break;
case USB_SPEED_HIGH:
speed = "480";
break;
default:
speed = "unknown";
}
if (udev->manufacturer) if (udev->manufacturer)
strlcpy(descr, udev->manufacturer, sizeof(descr)); strlcpy(descr, udev->manufacturer, sizeof(descr));
if (udev->product) { if (udev->product) {
if (*descr)
strlcat(descr, " ", sizeof(descr));
strlcat(descr, udev->product, sizeof(descr));
}
if (*descr) if (*descr)
strlcat(descr, " ", sizeof(descr)); strlcat(descr, " ", sizeof(descr));
strlcat(descr, udev->product, sizeof(descr));
cx231xx_info("New device %s@ %s Mbps " }
"(%04x:%04x) with %d interfaces\n", if (*descr)
descr, strlcat(descr, " ", sizeof(descr));
speed,
le16_to_cpu(udev->descriptor.idVendor), cx231xx_info("New device %s@ %s Mbps "
le16_to_cpu(udev->descriptor.idProduct), "(%04x:%04x) with %d interfaces\n",
dev->max_iad_interface_count); descr,
speed,
/* store the interface 0 back */ le16_to_cpu(udev->descriptor.idVendor),
lif = udev->actconfig->interface[0]; le16_to_cpu(udev->descriptor.idProduct),
dev->max_iad_interface_count);
/* increment interface count */
dev->interface_count++; /* store the interface 0 back */
lif = udev->actconfig->interface[0];
/* get device number */
nr = dev->devno; /* increment interface count */
dev->interface_count++;
assoc_desc = udev->actconfig->intf_assoc[0];
if (assoc_desc->bFirstInterface != ifnum) { /* get device number */
cx231xx_err(DRIVER_NAME ": Not found " nr = dev->devno;
"matching IAD interface\n");
return -ENODEV; assoc_desc = udev->actconfig->intf_assoc[0];
} if (assoc_desc->bFirstInterface != ifnum) {
} else { cx231xx_err(DRIVER_NAME ": Not found "
"matching IAD interface\n");
return -ENODEV; return -ENODEV;
} }
......
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