Changeset 62f4212 in mainline for uspace/lib/usb/src/pipes.c


Ignore:
Timestamp:
2011-03-22T10:07:53Z (13 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f8e4cb6
Parents:
18b3cfd (diff), b01995b (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:

Merged changes from development

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/src/pipes.c

    r18b3cfd r62f4212  
    4242#include <assert.h>
    4343
     44#define IPC_AGAIN_DELAY (1000 * 2) /* 2ms */
     45
    4446/** Tell USB address assigned to given device.
    4547 *
     
    150152        }
    151153
    152         my_address = get_my_address(parent_phone, dev);
    153         if (my_address < 0) {
    154                 rc = my_address;
    155                 goto leave;
    156         }
     154        /*
     155         * Asking for "my" address may require several attempts.
     156         * That is because following scenario may happen:
     157         *  - parent driver (i.e. driver of parent device) announces new device
     158         *    and devman launches current driver
     159         *  - parent driver is preempted and thus does not send address-handle
     160         *    binding to HC driver
     161         *  - this driver gets here and wants the binding
     162         *  - the HC does not know the binding yet and thus it answers ENOENT
     163         *  So, we need to wait for the HC to learn the binding.
     164         */
     165        do {
     166                my_address = get_my_address(parent_phone, dev);
     167
     168                if (my_address == ENOENT) {
     169                        /* Be nice, let other fibrils run and try again. */
     170                        async_usleep(IPC_AGAIN_DELAY);
     171                } else if (my_address < 0) {
     172                        /* Some other problem, no sense trying again. */
     173                        rc = my_address;
     174                        goto leave;
     175                }
     176
     177        } while (my_address < 0);
    157178
    158179        rc = usb_device_connection_initialize(connection,
     
    212233 * A session is something inside what any communication occurs.
    213234 * It is expected that sessions would be started right before the transfer
    214  * and ended - see usb_endpoint_pipe_end_session() - after the last
     235 * and ended - see usb_pipe_end_session() - after the last
    215236 * transfer.
    216237 * The reason for this is that session actually opens some communication
     
    223244 * @return Error code.
    224245 */
    225 int usb_endpoint_pipe_start_session(usb_endpoint_pipe_t *pipe)
     246int usb_pipe_start_session(usb_pipe_t *pipe)
    226247{
    227248        assert(pipe);
    228249
    229         if (usb_endpoint_pipe_is_session_started(pipe)) {
     250        if (usb_pipe_is_session_started(pipe)) {
    230251                return EBUSY;
    231252        }
     
    244265/** Ends a session on the endpoint pipe.
    245266 *
    246  * @see usb_endpoint_pipe_start_session
     267 * @see usb_pipe_start_session
    247268 *
    248269 * @param pipe Endpoint pipe to end the session on.
    249270 * @return Error code.
    250271 */
    251 int usb_endpoint_pipe_end_session(usb_endpoint_pipe_t *pipe)
     272int usb_pipe_end_session(usb_pipe_t *pipe)
    252273{
    253274        assert(pipe);
    254275
    255         if (!usb_endpoint_pipe_is_session_started(pipe)) {
     276        if (!usb_pipe_is_session_started(pipe)) {
    256277                return ENOENT;
    257278        }
     
    275296 * @return Whether @p pipe has opened a session.
    276297 */
    277 bool usb_endpoint_pipe_is_session_started(usb_endpoint_pipe_t *pipe)
     298bool usb_pipe_is_session_started(usb_pipe_t *pipe)
    278299{
    279300        return (pipe->hc_phone >= 0);
Note: See TracChangeset for help on using the changeset viewer.