Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 25251bb in mainline


Ignore:
Timestamp:
2017-10-26T08:38:53Z (3 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
master
Children:
928afc8d
Parents:
62558202
Message:

xhci: move pointer to hc from device to bus

Also, fixes the bug of hc ptr not set on tier 2+ device.

Location:
uspace/drv/bus/usb/xhci
Files:
5 edited

Legend:

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

    r62558202 r25251bb  
    266266
    267267        usb_log_info("Endpoint(%d:%d) registered to XHCI bus.", ep->device->address, ep->endpoint);
    268         return xhci_device_add_endpoint(xhci_dev, xhci_ep);
     268        return xhci_device_add_endpoint(bus->hc, xhci_dev, xhci_ep);
    269269}
    270270
     
    278278        xhci_device_t *xhci_dev = xhci_device_get(ep->device);
    279279        xhci_endpoint_t *xhci_ep = xhci_endpoint_get(ep);
    280         const int res = xhci_device_remove_endpoint(xhci_dev, xhci_ep);
     280        const int res = xhci_device_remove_endpoint(bus->hc, xhci_dev, xhci_ep);
    281281        if (res != EOK)
    282282                return res;
     
    396396                return ENOMEM;
    397397
     398        bus->hc = hc;
    398399        bus->base.ops = xhci_bus_ops;
    399400        bus->default_address_speed = USB_SPEED_MAX;
  • uspace/drv/bus/usb/xhci/bus.h

    r62558202 r25251bb  
    4848        bus_t base;             /**< Inheritance. Keep this first. */
    4949
     50        xhci_hc_t *hc;                          /**< Pointer to managing HC (to issue commands) */
     51
    5052        xhci_device_t **devices_by_slot;        /**< Devices by Slot ID */
    5153
  • uspace/drv/bus/usb/xhci/endpoint.c

    r62558202 r25251bb  
    269269}
    270270
    271 int xhci_device_add_endpoint(xhci_device_t *dev, xhci_endpoint_t *ep)
     271int xhci_device_add_endpoint(xhci_hc_t *hc, xhci_device_t *dev, xhci_endpoint_t *ep)
    272272{
    273273        assert(dev);
     
    299299        xhci_setup_endpoint_context(ep, &ep_ctx);
    300300
    301         return hc_add_endpoint(dev->hc, dev->slot_id, xhci_endpoint_index(ep), &ep_ctx);
    302 }
    303 
    304 int xhci_device_remove_endpoint(xhci_device_t *dev, xhci_endpoint_t *ep)
     301        return hc_add_endpoint(hc, dev->slot_id, xhci_endpoint_index(ep), &ep_ctx);
     302}
     303
     304int xhci_device_remove_endpoint(xhci_hc_t *hc, xhci_device_t *dev, xhci_endpoint_t *ep)
    305305{
    306306        assert(&dev->base == ep->base.device);
     
    320320
    321321        /* Drop the endpoint. */
    322         if ((err = hc_drop_endpoint(dev->hc, dev->slot_id, xhci_endpoint_index(ep)))) {
     322        if ((err = hc_drop_endpoint(hc, dev->slot_id, xhci_endpoint_index(ep)))) {
    323323                goto err;
    324324        }
  • uspace/drv/bus/usb/xhci/endpoint.h

    r62558202 r25251bb  
    117117        uint8_t active_endpoint_count;
    118118
    119         /** Need HC to schedule commands from bus callbacks. TODO: Move this elsewhere. */
    120         xhci_hc_t *hc;
    121 
    122119        /** Flag indicating whether the device is USB3 (it's USB2 otherwise). */
    123120        bool usb3;
     
    137134void xhci_setup_endpoint_context(xhci_endpoint_t *, xhci_ep_ctx_t *);
    138135
    139 int xhci_device_add_endpoint(xhci_device_t *, xhci_endpoint_t *);
    140 int xhci_device_remove_endpoint(xhci_device_t *, xhci_endpoint_t *);
     136int xhci_device_add_endpoint(xhci_hc_t *, xhci_device_t *, xhci_endpoint_t *);
     137int xhci_device_remove_endpoint(xhci_hc_t *, xhci_device_t *, xhci_endpoint_t *);
    141138xhci_endpoint_t * xhci_device_get_endpoint(xhci_device_t *, usb_endpoint_t);
    142139
  • uspace/drv/bus/usb/xhci/rh.c

    r62558202 r25251bb  
    102102        const xhci_port_speed_t *port_speed = xhci_rh_get_port_speed(rh, port_id);
    103103        xhci_device_t *xhci_dev = xhci_device_get(dev);
    104         xhci_dev->hc = rh->hc;
    105104        xhci_dev->usb3 = port_speed->major == 3;
    106105        xhci_dev->rh_port = port_id;
     
    363362}
    364363
    365 static inline int get_hub_available_bandwidth(xhci_device_t* dev, uint8_t speed, xhci_port_bandwidth_ctx_t *ctx) {
     364static inline int get_hub_available_bandwidth(xhci_hc_t *hc, xhci_device_t* dev, uint8_t speed, xhci_port_bandwidth_ctx_t *ctx) {
    366365        // TODO: find a correct place for this function + API
    367366        // We need speed, because a root hub device has both USB 2 and USB 3 speeds
     
    383382
    384383        int err;
    385         if ((err = xhci_cmd_sync(dev->hc, &cmd))) {
     384        if ((err = xhci_cmd_sync(hc, &cmd))) {
    386385                goto end;
    387386        }
Note: See TracChangeset for help on using the changeset viewer.