Changeset 1e70157 in mainline


Ignore:
Timestamp:
2011-04-06T19:52:17Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8dc762e0
Parents:
fb8927d
Message:

Header fixes, add qh to endpoint structure, add endpoint toggle reset

Location:
uspace/drv/uhci-hcd
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/endpoint.c

    rfb8927d r1e70157  
    3434 */
    3535
     36#include <errno.h>
     37
    3638#include "endpoint.h"
     39#include "utils/malloc32.h"
    3740
    38 void endpoint_init(endpoint_t *instance, usb_transfer_type_t transfer_type,
     41int endpoint_init(endpoint_t *instance, usb_transfer_type_t transfer_type,
    3942    usb_speed_t speed, size_t max_packet_size)
    4043{
     
    4548        instance->max_packet_size = max_packet_size;
    4649        instance->toggle = 0;
     50        instance->qh = malloc32(sizeof(qh_t));
     51        if (instance->qh == NULL)
     52                return ENOMEM;
     53        return EOK;
    4754}
    4855/*----------------------------------------------------------------------------*/
    49 void endpoint_destroy(void *instance)
     56void endpoint_destroy(void *ep)
    5057{
     58        endpoint_t *instance = ep;
    5159        assert(instance);
     60        list_remove(&instance->same_device_eps);
     61        free32(instance->qh);
    5262        free(instance);
     63}
     64/*----------------------------------------------------------------------------*/
     65void endpoint_toggle_reset(link_t *ep)
     66{
     67        endpoint_t *instance =
     68            list_get_instance(ep, endpoint_t, same_device_eps);
     69        assert(instance);
     70        instance->toggle = 0;
    5371}
    5472/**
  • uspace/drv/uhci-hcd/endpoint.h

    rfb8927d r1e70157  
    4141#include <usb/usb.h>
    4242
     43#include "hw_struct/queue_head.h"
     44
    4345typedef struct endpoint {
    4446        link_t same_device_eps;
     
    4850        bool active;
    4951        int toggle:1;
     52        qh_t *qh;
    5053} endpoint_t;
    5154
    52 void endpoint_init(endpoint_t *instance, usb_transfer_type_t transfer_type,
     55int endpoint_init(endpoint_t *instance, usb_transfer_type_t transfer_type,
    5356    usb_speed_t speed, size_t max_packet_size);
    5457
    55 void endpoint_destroy(void *instance);
     58void endpoint_destroy(void *ep);
     59
     60void endpoint_toggle_reset(link_t *ep);
    5661
    5762#endif
  • uspace/drv/uhci-hcd/hw_struct/queue_head.h

    rfb8927d r1e70157  
    3939
    4040#include "link_pointer.h"
    41 #include "utils/malloc32.h"
    4241
    4342typedef struct queue_head {
  • uspace/drv/uhci-hcd/iface.c

    rfb8927d r1e70157  
    160160            usb_device_keeper_get_speed(&hc->manager, address);
    161161        const size_t size = max_packet_size;
     162        int ret;
    162163
    163164        endpoint_t *ep = malloc(sizeof(endpoint_t));
    164165        if (ep == NULL)
    165166                return ENOMEM;
    166         endpoint_init(ep, transfer_type, speed, max_packet_size);
     167        ret = endpoint_init(ep, transfer_type, speed, max_packet_size);
     168        if (ret != EOK) {
     169                free(ep);
     170                return ret;
     171        }
    167172
    168173        usb_log_debug("Register endpoint %d:%d %s %s(%d) %zu(%zu) %u.\n",
     
    176181            0;
    177182
    178         int ret = usb_endpoint_manager_register_ep(&hc->ep_manager,
     183        ret = usb_endpoint_manager_register_ep(&hc->ep_manager,
    179184            address, endpoint, direction, ep, endpoint_destroy, bw);
    180185        if (ret != EOK) {
    181186                endpoint_destroy(ep);
     187        } else {
     188                usb_device_keeper_add_ep(&hc->manager, address, &ep->same_device_eps);
    182189        }
    183190        return ret;
     
    345352        assert(ep->transfer_type == USB_TRANSFER_BULK);
    346353
    347 
    348354        usb_transfer_batch_t *batch =
    349355            batch_get(fun, target, ep->transfer_type, ep->max_packet_size,
     
    394400
    395401        usb_transfer_batch_t *batch =
    396             batch_get(fun, target, ep->transfer_type, ep->max_packet_size, ep->speed,
    397                 data, size, NULL, 0, callback, NULL, arg, &hc->manager);
     402            batch_get(fun, target, ep->transfer_type, ep->max_packet_size,
     403                ep->speed, data, size, NULL, 0, callback, NULL, arg,
     404                &hc->manager);
    398405        if (!batch)
    399406                return ENOMEM;
  • uspace/drv/uhci-hcd/transfer_list.h

    rfb8927d r1e70157  
    3939#include "batch.h"
    4040#include "hw_struct/queue_head.h"
     41#include "utils/malloc32.h"
    4142
    4243typedef struct transfer_list
  • uspace/drv/uhci-hcd/utils/malloc32.h

    rfb8927d r1e70157  
    3636
    3737#include <assert.h>
     38#include <errno.h>
    3839#include <malloc.h>
    3940#include <mem.h>
Note: See TracChangeset for help on using the changeset viewer.