Changeset 41924f30 in mainline for uspace/drv/bus/usb/xhci/endpoint.c


Ignore:
Timestamp:
2017-10-12T14:07:27Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a5976973
Parents:
7e74911
Message:

WIP usbhost refactoring

This commit replaces callbacks with more systematic virtual-like inheritance-like solution. Currently breaks build of HelenOS, but both xhci and usbhost are buildable. More refactoring follows…

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/endpoint.c

    r7e74911 r41924f30  
    3434 */
    3535
     36#include <usb/host/endpoint.h>
     37
    3638#include <errno.h>
    3739
     40#include "bus.h"
    3841#include "endpoint.h"
    3942
    40 int endpoint_init(hcd_t *hcd, endpoint_t *ep)
     43int xhci_endpoint_init(xhci_endpoint_t *xhci_ep, xhci_bus_t *xhci_bus)
    4144{
    42         assert(ep);
    43         xhci_endpoint_t *xhci_ep = malloc(sizeof(xhci_endpoint_t));
    44         if (xhci_ep == NULL)
    45                 return ENOMEM;
     45        assert(xhci_ep);
     46        assert(xhci_bus);
     47
     48        bus_t *bus = &xhci_bus->base;
     49        endpoint_t *ep = &xhci_ep->base;
     50
     51        endpoint_init(ep, bus);
    4652
    4753        /* FIXME: Set xhci_ep->slot_id */
    4854
    49         fibril_mutex_lock(&ep->guard);
    50         ep->hc_data.data = xhci_ep;
    51         /* FIXME: The two handlers below should be implemented. */
    52         ep->hc_data.toggle_get = NULL;
    53         ep->hc_data.toggle_set = NULL;
    54         fibril_mutex_unlock(&ep->guard);
    55 
    56         usb_log_debug("Endpoint %d:%d initialized.", ep->address, ep->endpoint);
     55        usb_log_debug("XHCI Endpoint %d:%d initialized.", ep->target.address, ep->target.endpoint);
    5756
    5857        return EOK;
    5958}
    6059
    61 void endpoint_fini(hcd_t *hcd, endpoint_t *ep)
     60void xhci_endpoint_fini(xhci_endpoint_t *xhci_ep)
    6261{
    63         assert(hcd);
    64         assert(ep);
    65         xhci_endpoint_t *xhci_ep = endpoint_get(ep);
     62        assert(xhci_ep);
     63
    6664        /* FIXME: Tear down TR's? */
    67         if (xhci_ep) {
    68                 free(xhci_ep);
    69         }
    7065
    71         fibril_mutex_lock(&ep->guard);
    72         ep->hc_data.data = NULL;
    73         ep->hc_data.toggle_get = NULL;
    74         ep->hc_data.toggle_set = NULL;
    75         fibril_mutex_unlock(&ep->guard);
     66        endpoint_t *ep = &xhci_ep->base;
    7667
    77         usb_log_debug("Endpoint %d:%d destroyed.", ep->address, ep->endpoint);
     68        usb_log_debug("XHCI Endpoint %d:%d destroyed.", ep->target.address, ep->target.endpoint);
    7869}
    7970
Note: See TracChangeset for help on using the changeset viewer.