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

Changeset 6bb0f43 in mainline


Ignore:
Timestamp:
2011-04-13T10:36:09Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
2759c52
Parents:
3d932af6
Message:

Move endpoint registration to hc.c

Location:
uspace/drv/ohci
Files:
3 edited

Legend:

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

    r3d932af6 r6bb0f43  
    130130                fibril_add_ready(instance->interrupt_emulator);
    131131        }
    132 
     132#undef CHECK_RET_RETURN
    133133        return EOK;
     134}
     135/*----------------------------------------------------------------------------*/
     136int hc_add_endpoint(
     137    hc_t *instance, usb_address_t address, usb_endpoint_t endpoint,
     138    usb_speed_t speed, usb_transfer_type_t type, usb_direction_t direction,
     139    size_t mps, size_t size, unsigned interval)
     140{
     141        endpoint_t *ep = malloc(sizeof(endpoint_t));
     142        if (ep == NULL)
     143                return ENOMEM;
     144        int ret =
     145            endpoint_init(ep, address, endpoint, direction, type, speed, mps);
     146        if (ret != EOK) {
     147                free(ep);
     148                return ret;
     149        }
     150
     151        ret = usb_endpoint_manager_register_ep(&instance->ep_manager, ep, size);
     152        if (ret != EOK) {
     153                endpoint_destroy(ep);
     154        }
     155        return ret;
     156}
     157/*----------------------------------------------------------------------------*/
     158int hc_remove_endpoint(hc_t *instance, usb_address_t address,
     159    usb_endpoint_t endpoint, usb_direction_t direction)
     160{
     161        return usb_endpoint_manager_unregister_ep(&instance->ep_manager,
     162            address, endpoint, direction);
    134163}
    135164/*----------------------------------------------------------------------------*/
  • uspace/drv/ohci/hc.h

    r3d932af6 r6bb0f43  
    7777     uintptr_t regs, size_t reg_size, bool interrupts);
    7878
    79 int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch);
    80 
    81 void hc_interrupt(hc_t *instance, uint32_t status);
    82 
    8379/** Safely dispose host controller internal structures
    8480 *
     
    8682 */
    8783static inline void hc_fini(hc_t *instance) { /* TODO: implement*/ };
     84
     85int hc_add_endpoint(hc_t *instance, usb_address_t address, usb_endpoint_t ep,
     86    usb_speed_t speed, usb_transfer_type_t type, usb_direction_t direction,
     87                size_t max_packet_size, size_t size, unsigned interval);
     88
     89int hc_remove_endpoint(hc_t *instance, usb_address_t address,
     90    usb_endpoint_t endpoint, usb_direction_t direction);
     91
     92int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch);
     93
     94void hc_interrupt(hc_t *instance, uint32_t status);
    8895
    8996/** Get and cast pointer to the driver data
  • uspace/drv/ohci/iface.c

    r3d932af6 r6bb0f43  
    164164        }
    165165        const size_t size = max_packet_size;
    166         int ret;
    167166
    168167        usb_log_debug("Register endpoint %d:%d %s %s(%d) %zu(%zu) %u.\n",
     
    170169            usb_str_speed(speed), direction, size, max_packet_size, interval);
    171170
    172         endpoint_t *ep = malloc(sizeof(endpoint_t));
    173         if (ep == NULL)
    174                 return ENOMEM;
    175         ret = endpoint_init(ep, address, endpoint, direction,
    176             transfer_type, speed, max_packet_size);
    177         if (ret != EOK) {
    178                 free(ep);
    179                 return ret;
    180         }
    181 
    182         ret = usb_endpoint_manager_register_ep(&hc->ep_manager, ep, size);
    183         if (ret != EOK) {
    184                 endpoint_destroy(ep);
    185         }
    186         return ret;
     171        return hc_add_endpoint(hc, address, endpoint, speed, transfer_type,
     172            direction, max_packet_size, size, interval);
    187173}
    188174/*----------------------------------------------------------------------------*/
     
    195181        usb_log_debug("Unregister endpoint %d:%d %d.\n",
    196182            address, endpoint, direction);
    197         return usb_endpoint_manager_unregister_ep(&hc->ep_manager, address,
    198             endpoint, direction);
     183        return hc_remove_endpoint(hc, address, endpoint, direction);
    199184}
    200185/*----------------------------------------------------------------------------*/
     
    346331 * @param[in] setup_packet Setup packet buffer (in USB endianess, allocated
    347332 *      and deallocated by the caller).
    348  * @param[in] setup_packet_size Size of @p setup_packet buffer in bytes.
     333 * @param[in] setup_size Size of @p setup_packet buffer in bytes.
    349334 * @param[in] data_buffer Data buffer (in USB endianess, allocated and
    350335 *      deallocated by the caller).
    351  * @param[in] data_buffer_size Size of @p data_buffer buffer in bytes.
     336 * @param[in] size Size of @p data_buffer buffer in bytes.
    352337 * @param[in] callback Callback to be issued once the transfer is complete.
    353338 * @param[in] arg Pass-through argument to the callback.
     
    386371 * @param[in] setup_packet Setup packet buffer (in USB endianess, allocated
    387372 *      and deallocated by the caller).
    388  * @param[in] setup_packet_size Size of @p setup_packet buffer in bytes.
     373 * @param[in] setup_size Size of @p setup_packet buffer in bytes.
    389374 * @param[in] data_buffer Buffer where to store the data (in USB endianess,
    390375 *      allocated and deallocated by the caller).
    391  * @param[in] data_buffer_size Size of @p data_buffer buffer in bytes.
     376 * @param[in] size Size of @p data_buffer buffer in bytes.
    392377 * @param[in] callback Callback to be issued once the transfer is complete.
    393378 * @param[in] arg Pass-through argument to the callback.
Note: See TracChangeset for help on using the changeset viewer.