Ignore:
Timestamp:
2011-09-16T14:50:20Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
432a269, d1e18573
Parents:
47fecbb (diff), 82a31261 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge USB changes from bzr://krabicka.net/orome/helenos/usb/

  • Move common HC code from uhci/ohci drivers to libusbhost
  • Rewrite USB HC interface to have common read/write functions for all transfer types.
  • Restructure hc drivers to avoid some hooks and void* casts
  • Cleanup the code and remove unnecessary mallocs.
File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/ohci_endpoint.c

    r47fecbb rfd07e526  
    3333 */
    3434#include "utils/malloc32.h"
    35 #include "hcd_endpoint.h"
     35#include "ohci_endpoint.h"
     36#include "hc.h"
    3637
    3738/** Callback to set toggle on ED.
     
    4041 * @param[in] toggle new value of toggle bit
    4142 */
    42 static void hcd_ep_toggle_set(void *hcd_ep, int toggle)
     43static void ohci_ep_toggle_set(void *ohci_ep, int toggle)
    4344{
    44         hcd_endpoint_t *instance = hcd_ep;
     45        ohci_endpoint_t *instance = ohci_ep;
    4546        assert(instance);
    4647        assert(instance->ed);
     
    5354 * @return Current value of toggle bit.
    5455 */
    55 static int hcd_ep_toggle_get(void *hcd_ep)
     56static int ohci_ep_toggle_get(void *ohci_ep)
    5657{
    57         hcd_endpoint_t *instance = hcd_ep;
     58        ohci_endpoint_t *instance = ohci_ep;
    5859        assert(instance);
    5960        assert(instance->ed);
    6061        return ed_toggle_get(instance->ed);
     62}
     63/*----------------------------------------------------------------------------*/
     64/** Disposes hcd endpoint structure
     65 *
     66 * @param[in] hcd_ep endpoint structure
     67 */
     68static void ohci_endpoint_fini(endpoint_t *ep)
     69{
     70        ohci_endpoint_t *instance = ep->hc_data.data;
     71        hc_dequeue_endpoint(instance->hcd->private_data, ep);
     72        if (instance) {
     73                free32(instance->ed);
     74                free32(instance->td);
     75                free(instance);
     76        }
    6177}
    6278/*----------------------------------------------------------------------------*/
     
    6682 * @return pointer to a new hcd endpoint structure, NULL on failure.
    6783 */
    68 hcd_endpoint_t * hcd_endpoint_assign(endpoint_t *ep)
     84int ohci_endpoint_init(hcd_t *hcd, endpoint_t *ep)
    6985{
    7086        assert(ep);
    71         hcd_endpoint_t *hcd_ep = malloc(sizeof(hcd_endpoint_t));
    72         if (hcd_ep == NULL)
    73                 return NULL;
     87        ohci_endpoint_t *ohci_ep = malloc(sizeof(ohci_endpoint_t));
     88        if (ohci_ep == NULL)
     89                return ENOMEM;
    7490
    75         hcd_ep->ed = malloc32(sizeof(ed_t));
    76         if (hcd_ep->ed == NULL) {
    77                 free(hcd_ep);
    78                 return NULL;
     91        ohci_ep->ed = malloc32(sizeof(ed_t));
     92        if (ohci_ep->ed == NULL) {
     93                free(ohci_ep);
     94                return ENOMEM;
    7995        }
    8096
    81         hcd_ep->td = malloc32(sizeof(td_t));
    82         if (hcd_ep->td == NULL) {
    83                 free32(hcd_ep->ed);
    84                 free(hcd_ep);
    85                 return NULL;
     97        ohci_ep->td = malloc32(sizeof(td_t));
     98        if (ohci_ep->td == NULL) {
     99                free32(ohci_ep->ed);
     100                free(ohci_ep);
     101                return ENOMEM;
    86102        }
    87103
    88         ed_init(hcd_ep->ed, ep);
    89         ed_set_td(hcd_ep->ed, hcd_ep->td);
    90         endpoint_set_hc_data(ep, hcd_ep, hcd_ep_toggle_get, hcd_ep_toggle_set);
    91 
    92         return hcd_ep;
    93 }
    94 /*----------------------------------------------------------------------------*/
    95 /** Disposes assigned hcd endpoint structure
    96  *
    97  * @param[in] ep USBD endpoint structure
    98  */
    99 void hcd_endpoint_clear(endpoint_t *ep)
    100 {
    101         assert(ep);
    102         hcd_endpoint_t *hcd_ep = ep->hc_data.data;
    103         assert(hcd_ep);
    104         free32(hcd_ep->ed);
    105         free32(hcd_ep->td);
    106         free(hcd_ep);
     104        ed_init(ohci_ep->ed, ep);
     105        ed_set_td(ohci_ep->ed, ohci_ep->td);
     106        endpoint_set_hc_data(
     107            ep, ohci_ep, ohci_endpoint_fini, ohci_ep_toggle_get, ohci_ep_toggle_set);
     108        ohci_ep->hcd = hcd;
     109        hc_enqueue_endpoint(hcd->private_data, ep);
     110        return EOK;
    107111}
    108112/**
Note: See TracChangeset for help on using the changeset viewer.