static inline int usbhost_classbind(FAR struct usbhost_hubport_s *hport, const uint8_t *configdesc, int desclen, struct usbhost_id_s *id, FAR struct usbhost_class_s **usbclass) { FAR struct usbhost_class_s *devclass; FAR const struct usbhost_registry_s *reg; int ret = -EINVAL; /* Is there is a class implementation registered to support this device. */ reg = usbhost_findclass(id); uvdbg("usbhost_findclass: %p\n", reg); if (reg != NULL) { /* Yes.. there is a class for this device. Get an instance of * its interface. */ ret = -ENOMEM; devclass = CLASS_CREATE(reg, hport, id); uvdbg("CLASS_CREATE: %p\n", devclass); if (devclass != NULL) { /* Then bind the newly instantiated class instance */ ret = CLASS_CONNECT(devclass, configdesc, desclen); if (ret < 0) { /* On failures, call the class disconnect method which * should then free the allocated devclass instance. */ udbg("CLASS_CONNECT failed: %d\n", ret); CLASS_DISCONNECTED(devclass); } else { *usbclass = devclass; } } } uvdbg("Returning: %d\n", ret); return ret; }
* bind this configuration descriptor with a supported class. * *******************************************************************************/ static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr, const uint8_t *configdesc, int desclen, struct usbhost_id_s *id, uint8_t funcaddr, FAR struct usbhost_class_s **class) { FAR struct usbhost_class_s *devclass; const struct usbhost_registry_s *reg; int ret = -EINVAL; /* Is there is a class implementation registered to support this device. */ reg = usbhost_findclass(id); uvdbg("usbhost_findclass: %p\n", reg); if (reg) { /* Yes.. there is a class for this device. Get an instance of * its interface. */ ret = -ENOMEM; devclass = CLASS_CREATE(reg, drvr, id); uvdbg("CLASS_CREATE: %p\n", devclass); if (devclass) { /* Then bind the newly instantiated class instance */ ret = CLASS_CONNECT(devclass, configdesc, desclen, funcaddr);