/* No driver, we shouldn't be enabled ... */ if (!d->driver || !d->enabled) {
EPDBG(ep, "Device is wrong state driver=%p enabled=%d\n",
d->driver, d->enabled); return std_req_stall;
}
/* * Note: we used to reject/stall requests while suspended, * we don't do that anymore as we seem to have cases of * mass storage getting very upset.
*/
/* First packet, grab speed */ if (d->gadget.speed == USB_SPEED_UNKNOWN) {
d->gadget.speed = ep->vhub->speed; if (d->gadget.speed > d->driver->max_speed)
d->gadget.speed = d->driver->max_speed;
DDBG(d, "fist packet, captured speed %d\n",
d->gadget.speed);
}
/* Mark disconnected in the hub */
ast_vhub_device_connect(d->vhub, d->index, on);
/* * If enabled, nuke all requests if any (there shouldn't be) * and disable the port. This will clear the address too.
*/ if (d->enabled) {
ast_vhub_dev_nuke(d);
ast_vhub_dev_disable(d);
}
DDBG(d, "Match EP type %d\n", usb_endpoint_type(desc));
/* * First we need to look for an existing unclaimed EP as another * configuration may have already associated a bunch of EPs with * this gadget. This duplicates the code in usb_ep_autoconfig_ss() * unfortunately.
*/
list_for_each_entry(u_ep, &gadget->ep_list, ep_list) { if (usb_gadget_ep_match_desc(gadget, u_ep, desc, ss)) {
DDBG(d, " -> using existing EP%d\n",
to_ast_ep(u_ep)->d_idx); return u_ep;
}
}
/* * We didn't find one, we need to grab one from the pool. * * First let's do some sanity checking
*/ switch(usb_endpoint_type(desc)) { case USB_ENDPOINT_XFER_CONTROL: /* Only EP0 can be a control endpoint */ return NULL; case USB_ENDPOINT_XFER_ISOC: /* ISO: limit 1023 bytes full speed, 1024 high/super speed */ if (gadget_is_dualspeed(gadget))
max = 1024; else
max = 1023; break; case USB_ENDPOINT_XFER_BULK: if (gadget_is_dualspeed(gadget))
max = 512; else
max = 64; break; case USB_ENDPOINT_XFER_INT: if (gadget_is_dualspeed(gadget))
max = 1024; else
max = 64; break;
} if (usb_endpoint_maxp(desc) > max) return NULL;
/* * Find a free EP address for that device. We can't * let the generic code assign these as it would * create overlapping numbers for IN and OUT which * we don't support, so also create a suitable name * that will allow the generic code to use our * assigned address.
*/ for (i = 0; i < d->max_epns; i++) if (d->epns[i] == NULL) break; if (i >= d->max_epns) return NULL;
addr = i + 1;
/* * Now grab an EP from the shared pool and associate * it with our device
*/
ep = ast_vhub_alloc_epn(d, addr); if (!ep) return NULL;
DDBG(d, "Allocated epn#%d for port EP%d\n",
ep->epn.g_idx, addr);
void ast_vhub_dev_reset(struct ast_vhub_dev *d)
{ /* No driver, just disable the device and return */ if (!d->driver) {
ast_vhub_dev_disable(d); return;
}
/* If the port isn't enabled, just enable it */ if (!d->enabled) {
DDBG(d, "Reset of disabled device, enabling...\n");
ast_vhub_dev_enable(d);
} else {
DDBG(d, "Reset of enabled device, resetting...\n");
spin_unlock(&d->vhub->lock);
usb_gadget_udc_reset(&d->gadget, d->driver);
spin_lock(&d->vhub->lock);
/* * Disable and maybe re-enable HW, this will clear the address * and speed setting.
*/
ast_vhub_dev_disable(d);
ast_vhub_dev_enable(d);
}
}
/* * A USB device can have up to 30 endpoints besides control * endpoint 0.
*/
d->max_epns = min_t(u32, vhub->max_epns, 30);
d->epns = kcalloc(d->max_epns, sizeof(*d->epns), GFP_KERNEL); if (!d->epns) return -ENOMEM;
/* * The UDC core really needs us to have separate and uniquely * named "parent" devices for each port so we create a sub device * here for that purpose
*/
d->port_dev = kzalloc(sizeof(struct device), GFP_KERNEL); if (!d->port_dev) {
rc = -ENOMEM; goto fail_alloc;
}
device_initialize(d->port_dev);
d->port_dev->release = ast_vhub_dev_release;
d->port_dev->parent = parent;
dev_set_name(d->port_dev, "%s:p%d", dev_name(parent), idx + 1);
rc = device_add(d->port_dev); if (rc) goto fail_add;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.