Changeset 747ef72 in mainline for uspace/lib/usbdev/src/pipesinit.c


Ignore:
Timestamp:
2011-11-10T11:29:10Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
54464f6a, c2245a3, c6f189f7
Parents:
2e1b9dc (diff), 2d1ba51 (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.

Interface changes:

  • GET_ADDRESS has been renamed to GET_MY_ADDRESS and the handle parameter was dropped. Tis call no longer cascades up to the root hub, but it is answered in the first place the information is available (nearest hub)
  • Reintroduced address reservation for USB_DEFAULT_ADDRESS. The interface now enables device drivers to request specific address on initialization and either insists on that address or accept any other if the address is not available. Note that it is not possible to get the default address if the driver does not insist.
  • Any endpoint registered is removed when address is released and a warning is produced if there were any such endpoints.
  • It is no longer necessary or possible to pass device speed information when registering endpoints.

Driver fixes: memory leaks and crashes (not only) in error paths.
Fixes or removes flaky device_remove implementation in device drivers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/src/pipesinit.c

    r2e1b9dc r747ef72  
    192192        }
    193193
    194         if (ep_mapping->pipe == NULL) {
    195                 return EBADMEM;
    196         }
    197194        if (ep_mapping->present) {
    198195                return EEXISTS;
    199196        }
    200197
    201         int rc = usb_pipe_initialize(ep_mapping->pipe, wire,
     198        int rc = usb_pipe_initialize(&ep_mapping->pipe, wire,
    202199            ep_no, description.transfer_type, endpoint->max_packet_size,
    203200            description.direction);
     
    254251 *
    255252 * The mapping array is expected to conform to following rules:
    256  * - @c pipe must point to already allocated structure with uninitialized pipe
     253 * - @c pipe must be uninitialized pipe
    257254 * - @c description must point to prepared endpoint description
    258255 * - @c descriptor does not need to be initialized (will be overwritten)
     
    297294        }
    298295
    299         /*
    300          * Go through the mapping and set all endpoints to not present.
    301          */
    302         size_t i;
    303         for (i = 0; i < mapping_count; i++) {
     296        /* Go through the mapping and set all endpoints to not present. */
     297        for (size_t i = 0; i < mapping_count; i++) {
    304298                mapping[i].present = false;
    305299                mapping[i].descriptor = NULL;
     
    307301        }
    308302
    309         /*
    310          * Prepare the descriptor parser.
    311          */
     303        /* Prepare the descriptor parser. */
    312304        const usb_dp_parser_t dp_parser = {
    313305                .nesting = descriptor_nesting
     
    454446 * @return Error code.
    455447 */
    456 int usb_pipe_register(usb_pipe_t *pipe,
    457     unsigned int interval,
    458     usb_hc_connection_t *hc_connection)
    459 {
    460         return usb_pipe_register_with_speed(pipe, USB_SPEED_MAX + 1,
    461             interval, hc_connection);
    462 }
    463 
    464 /** Register endpoint with a speed at the host controller.
    465  *
    466  * You will rarely need to use this function because it is needed only
    467  * if the registered endpoint is of address 0 and there is no other way
    468  * to tell speed of the device at address 0.
    469  *
    470  * @param pipe Pipe to be registered.
    471  * @param speed Speed of the device
    472  *      (invalid speed means use previously specified one).
    473  * @param interval Polling interval.
    474  * @param hc_connection Connection to the host controller (must be opened).
    475  * @return Error code.
    476  */
    477 int usb_pipe_register_with_speed(usb_pipe_t *pipe, usb_speed_t speed,
    478     unsigned int interval,
     448int usb_pipe_register(usb_pipe_t *pipe, unsigned interval,
    479449    usb_hc_connection_t *hc_connection)
    480450{
    481451        assert(pipe);
    482452        assert(hc_connection);
    483        
     453
    484454        if (!usb_hc_connection_is_opened(hc_connection))
    485455                return EBADF;
    486        
     456
    487457        const usb_target_t target =
    488458            {{ .address = pipe->wire->address, .endpoint = pipe->endpoint_no }};
    489 #define _PACK2(high, low) (((high) << 16) + (low))
    490 #define _PACK3(high, middle, low) (((((high) << 8) + (middle)) << 8) + (low))
    491        
     459#define _PACK2(high, low) (((high & 0xffff) << 16) | (low & 0xffff))
     460
    492461        async_exch_t *exch = async_exchange_begin(hc_connection->hc_sess);
    493462        int rc = async_req_4_0(exch, DEV_IFACE_ID(USBHC_DEV_IFACE),
    494463            IPC_M_USBHC_REGISTER_ENDPOINT, target.packed,
    495             _PACK3(speed, pipe->transfer_type, pipe->direction),
     464            _PACK2(pipe->transfer_type, pipe->direction),
    496465            _PACK2(pipe->max_packet_size, interval));
    497466        async_exchange_end(exch);
    498        
     467
    499468#undef _PACK2
    500 #undef _PACK3
    501        
    502469        return rc;
    503470}
Note: See TracChangeset for help on using the changeset viewer.