Ignore:
Timestamp:
2011-10-29T13:35:40Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4dfc905
Parents:
2fd1f0c6
Message:

libusbhost: Fixes and improvements for usb_endpoint_manager.

Add doxygen comments.
Add asserts and input checks.
Fix bandwidth count (bits vs. bytes).
Refactor usb_endpoint_manager_add_ep to avoid crash/leak in error path.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/include/usb/host/usb_endpoint_manager.h

    r2fd1f0c6 r5400606  
    4646#include <usb/host/endpoint.h>
    4747
    48 #define BANDWIDTH_TOTAL_USB11 12000000
     48/** Bytes per second in FULL SPEED */
     49#define BANDWIDTH_TOTAL_USB11 (12000000 / 8)
     50/** 90% of total bandwidth is available for periodic transfers */
    4951#define BANDWIDTH_AVAILABLE_USB11 ((BANDWIDTH_TOTAL_USB11 / 10) * 9)
     52/** 16 addresses per list */
    5053#define ENDPOINT_LIST_COUNT 8
    5154
     55/** Endpoint management structure */
    5256typedef struct usb_endpoint_manager {
     57        /** Store endpoint_t instances */
    5358        list_t endpoint_lists[ENDPOINT_LIST_COUNT];
     59        /** Prevents races accessing lists */
    5460        fibril_mutex_t guard;
     61        /** Size of the bandwidth pool */
    5562        size_t free_bw;
     63        /** Use this function to count bw required by EP */
    5664        size_t (*bw_count)(usb_speed_t, usb_transfer_type_t, size_t, size_t);
    5765} usb_endpoint_manager_t;
     
    6472    size_t (*bw_count)(usb_speed_t, usb_transfer_type_t, size_t, size_t));
    6573
    66 void usb_endpoint_manager_reset_eps_if_need(
    67     usb_endpoint_manager_t *instance, usb_target_t target, const uint8_t *data);
     74void usb_endpoint_manager_reset_eps_if_need(usb_endpoint_manager_t *instance,
     75    usb_target_t target, const uint8_t data[8]);
    6876
    6977int usb_endpoint_manager_register_ep(
Note: See TracChangeset for help on using the changeset viewer.