int option_ms_init(struct us_data *us) { int result; US_DEBUGP("Option MS: option_ms_init called\n"); /* Additional test for vendor information via INQUIRY, * because some vendor/product IDs are ambiguous */ result = option_inquiry(us); if (result != 0) { US_DEBUGP("Option MS: vendor is not Option or not determinable," " no action taken\n"); return 0; } else US_DEBUGP("Option MS: this is a genuine Option device," " proceeding\n"); /* Force Modem mode */ if (option_zero_cd == ZCD_FORCE_MODEM) { US_DEBUGP("Option MS: %s", "Forcing Modem Mode\n"); result = option_rezero(us); if (result != USB_STOR_XFER_GOOD) US_DEBUGP("Option MS: Failed to switch to modem mode.\n"); return -EIO; } else if (option_zero_cd == ZCD_ALLOW_MS) { /* Allow Mass Storage mode (keep CD-Rom) */ US_DEBUGP("Option MS: %s", "Allowing Mass Storage Mode if device" " requests it\n"); } return 0; }
int option_ms_init(struct us_data *us) { struct usb_device *udev; struct usb_interface *intf; struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint = NULL; u8 ep_in = 0, ep_out = 0; int ep_in_size = 0, ep_out_size = 0; int i, result; udev = us->pusb_dev; intf = us->pusb_intf; /* Ensure it's really a ZeroCD device; devices that are already * in modem mode return 0xFF for class, subclass, and protocol. */ if (udev->descriptor.bDeviceClass != 0 || udev->descriptor.bDeviceSubClass != 0 || udev->descriptor.bDeviceProtocol != 0) return USB_STOR_TRANSPORT_GOOD; US_DEBUGP("Option MS: option_ms_init called\n"); /* Find the right mass storage interface */ iface_desc = intf->cur_altsetting; if (iface_desc->desc.bInterfaceClass != 0x8 || iface_desc->desc.bInterfaceSubClass != 0x6 || iface_desc->desc.bInterfaceProtocol != 0x50) { US_DEBUGP("Option MS: mass storage interface not found, no action " "required\n"); return USB_STOR_TRANSPORT_GOOD; } /* Find the mass storage bulk endpoints */ for (i = 0; i < iface_desc->desc.bNumEndpoints && (!ep_in_size || !ep_out_size); ++i) { endpoint = &iface_desc->endpoint[i].desc; if (usb_endpoint_is_bulk_in(endpoint)) { ep_in = usb_pipeendpoint(urb->pipe); ep_in_size = le16_to_cpu(endpoint->wMaxPacketSize); } else if (usb_endpoint_is_bulk_out(endpoint)) { ep_out = usb_pipeendpoint(urb->pipe); ep_out_size = le16_to_cpu(endpoint->wMaxPacketSize); } } /* Can't find the mass storage endpoints */ if (!ep_in_size || !ep_out_size) { US_DEBUGP("Option MS: mass storage endpoints not found, no action " "required\n"); return USB_STOR_TRANSPORT_GOOD; } /* Force Modem mode */ if (option_zero_cd == ZCD_FORCE_MODEM) { US_DEBUGP("Option MS: %s", "Forcing Modem Mode\n"); result = option_rezero(us, ep_in, ep_out); if (result != USB_STOR_XFER_GOOD) US_DEBUGP("Option MS: Failed to switch to modem mode.\n"); return -EIO; } else if (option_zero_cd == ZCD_ALLOW_MS) { /* Allow Mass Storage mode (keep CD-Rom) */ US_DEBUGP("Option MS: %s", "Allowing Mass Storage Mode if device" " requests it\n"); } return USB_STOR_TRANSPORT_GOOD; }