/* * Function irda_usb_find_class_desc(dev, ifnum) * * Returns instance of IrDA class descriptor, or NULL if not found * * The class descriptor is some extra info that IrDA USB devices will * offer to us, describing their IrDA characteristics. We will use that in * irda_usb_init_qos() * * Based on the same function in drivers/net/irda/irda-usb.c */ static struct usb_irda_cs_descriptor * irda_usb_find_class_desc(struct usb_device *dev, unsigned int ifnum) { struct usb_irda_cs_descriptor *desc; int ret; desc = kzalloc(sizeof(*desc), GFP_KERNEL); if (!desc) return NULL; ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), USB_REQ_CS_IRDA_GET_CLASS_DESC, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0, ifnum, desc, sizeof(*desc), 1000); dbg("%s - ret=%d", __func__, ret); if (ret < sizeof(*desc)) { dbg("%s - class descriptor read %s (%d)", __func__, (ret < 0) ? "failed" : "too short", ret); goto error; } if (desc->bDescriptorType != USB_DT_CS_IRDA) { dbg("%s - bad class descriptor type", __func__); goto error; } irda_usb_dump_class_desc(desc); return desc; error: kfree(desc); return NULL; }
/* * Function irda_usb_find_class_desc(dev, ifnum) * * Returns instance of IrDA class descriptor, or NULL if not found * * The class descriptor is some extra info that IrDA USB devices will * offer to us, describing their IrDA characteristics. We will use that in * irda_usb_init_qos() * * Based on the same function in drivers/net/irda/irda-usb.c */ static struct irda_class_desc *irda_usb_find_class_desc(struct usb_device *dev, unsigned int ifnum) { struct irda_class_desc *desc; int ret; desc = kmalloc(sizeof (struct irda_class_desc), GFP_KERNEL); if (desc == NULL) return NULL; memset(desc, 0, sizeof(struct irda_class_desc)); ret = usb_control_msg(dev, usb_rcvctrlpipe(dev,0), IU_REQ_GET_CLASS_DESC, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0, ifnum, desc, sizeof(*desc), MSECS_TO_JIFFIES(500)); dbg("%s - ret=%d", __FUNCTION__, ret); if (ret < sizeof(*desc)) { dbg("%s - class descriptor read %s (%d)", __FUNCTION__, (ret<0) ? "failed" : "too short", ret); goto error; } if (desc->bDescriptorType != USB_DT_IRDA) { dbg("%s - bad class descriptor type", __FUNCTION__); goto error; } irda_usb_dump_class_desc(desc); return desc; error: kfree(desc); return NULL; }