Changeset 48ae3ef in mainline for uspace/drv/bus


Ignore:
Timestamp:
2011-10-28T21:52:15Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
57e06ef
Parents:
7265558
Message:

libusbhost: Make interfaces more symmetric.

Make usb_endpoint_manager interface easier to use and understand.
Move ep removal hook pointer from endpoint_t to hcd_t.

Location:
uspace/drv/bus/usb
Files:
4 edited

Legend:

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

    r7265558 r48ae3ef  
    142142if (ret != EOK) { \
    143143        usb_log_error(message); \
    144         usb_endpoint_manager_unregister_ep( \
    145             &instance->generic.ep_manager, hub_address, 0, USB_DIRECTION_BOTH);\
     144        usb_endpoint_manager_remove_ep( \
     145            &instance->generic.ep_manager, hub_address, 0, USB_DIRECTION_BOTH, \
     146            NULL, NULL);\
    146147        usb_device_manager_release( \
    147148            &instance->generic.dev_manager, hub_address); \
     
    150151        int ret = usb_endpoint_manager_add_ep(
    151152            &instance->generic.ep_manager, hub_address, 0, USB_DIRECTION_BOTH,
    152             USB_TRANSFER_CONTROL, USB_SPEED_FULL, 64, 0);
     153            USB_TRANSFER_CONTROL, USB_SPEED_FULL, 64, 0, NULL, NULL);
    153154        CHECK_RET_UNREG_RETURN(ret,
    154155            "Failed to register root hub control endpoint: %s.\n",
     
    197198        instance->generic.schedule = hc_schedule;
    198199        instance->generic.ep_add_hook = ohci_endpoint_init;
     200        instance->generic.ep_remove_hook = ohci_endpoint_fini;
    199201
    200202        ret = hc_init_memory(instance);
  • uspace/drv/bus/usb/ohci/ohci_endpoint.c

    r7265558 r48ae3ef  
    6262}
    6363/*----------------------------------------------------------------------------*/
    64 /** Disposes hcd endpoint structure
    65  *
    66  * @param[in] hcd_ep endpoint structure
    67  */
    68 static 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         }
    77 }
    78 /*----------------------------------------------------------------------------*/
    7964/** Creates new hcd endpoint representation.
    8065 *
     
    10489        ed_init(ohci_ep->ed, ep, ohci_ep->td);
    10590        endpoint_set_hc_data(
    106             ep, ohci_ep, ohci_endpoint_fini, ohci_ep_toggle_get, ohci_ep_toggle_set);
     91            ep, ohci_ep, ohci_ep_toggle_get, ohci_ep_toggle_set);
    10792        ohci_ep->hcd = hcd;
    10893        hc_enqueue_endpoint(hcd->private_data, ep);
    10994        return EOK;
    11095}
     96/*----------------------------------------------------------------------------*/
     97/** Disposes hcd endpoint structure
     98 *
     99 * @param[in] hcd_ep endpoint structure
     100 */
     101void ohci_endpoint_fini(hcd_t *hcd, endpoint_t *ep)
     102{
     103        assert(hcd);
     104        assert(ep);
     105        ohci_endpoint_t *instance = ohci_endpoint_get(ep);
     106        hc_dequeue_endpoint(hcd->private_data, ep);
     107        if (instance) {
     108                free32(instance->ed);
     109                free32(instance->td);
     110                free(instance);
     111        }
     112        endpoint_clear_hc_data(ep);
     113}
    111114/**
    112115 * @}
  • uspace/drv/bus/usb/ohci/ohci_endpoint.h

    r7265558 r48ae3ef  
    5656
    5757int ohci_endpoint_init(hcd_t *hcd, endpoint_t *ep);
     58void ohci_endpoint_fini(hcd_t *hcd, endpoint_t *ep);
    5859
    5960/** Get and convert assigned ohci_endpoint_t structure
  • uspace/drv/bus/usb/vhc/connhost.c

    r7265558 r48ae3ef  
    140140    size_t max_packet_size, unsigned int interval)
    141141{
    142         /* TODO: Use usb_endpoint_manager_add_ep */
    143         VHC_DATA(vhc, fun);
    144 
    145         endpoint_t *ep = endpoint_create(
    146             address, endpoint, direction, transfer_type, USB_SPEED_FULL, 1, 0);
    147         if (ep == NULL) {
    148                 return ENOMEM;
    149         }
    150 
    151         int rc = usb_endpoint_manager_register_ep(&vhc->ep_manager, ep, 1);
    152         if (rc != EOK) {
    153                 endpoint_destroy(ep);
    154                 return rc;
    155         }
    156 
    157         return EOK;
     142        VHC_DATA(vhc, fun);
     143
     144        return usb_endpoint_manager_add_ep(&vhc->ep_manager,
     145            address, endpoint, direction, transfer_type, USB_SPEED_FULL, 1, 0,
     146            NULL, NULL);
     147
    158148}
    159149
     
    171161        VHC_DATA(vhc, fun);
    172162
    173         int rc = usb_endpoint_manager_unregister_ep(&vhc->ep_manager,
    174             address, endpoint, direction);
     163        int rc = usb_endpoint_manager_remove_ep(&vhc->ep_manager,
     164            address, endpoint, direction, NULL, NULL);
    175165
    176166        return rc;
     
    413403        VHC_DATA(vhc, fun);
    414404
    415         endpoint_t *ep = usb_endpoint_manager_get_ep(&vhc->ep_manager,
     405        endpoint_t *ep = usb_endpoint_manager_find_ep(&vhc->ep_manager,
    416406            target.address, target.endpoint, USB_DIRECTION_IN);
    417407        if (ep == NULL) {
     
    455445        VHC_DATA(vhc, fun);
    456446
    457         endpoint_t *ep = usb_endpoint_manager_get_ep(&vhc->ep_manager,
     447        endpoint_t *ep = usb_endpoint_manager_find_ep(&vhc->ep_manager,
    458448            target.address, target.endpoint, USB_DIRECTION_OUT);
    459449        if (ep == NULL) {
Note: See TracChangeset for help on using the changeset viewer.