Ignore:
File:
1 edited

Legend:

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

    r77223f8 r3954a63b  
    4949#include <assert.h>
    5050#include <usbhc_iface.h>
    51 #include "pipepriv.h"
    5251
    5352/** Request an in transfer, no checking of input parameters.
     
    7978        }
    8079
    81         /* Ensure serialization over the phone. */
    82         pipe_start_transaction(pipe);
    83 
    8480        /*
    8581         * Make call identifying target USB device and type of transfer.
    8682         */
    87         aid_t opening_request = async_send_3(pipe->hc_phone,
     83        aid_t opening_request = async_send_4(pipe->hc_phone,
    8884            DEV_IFACE_ID(USBHC_DEV_IFACE), ipc_method,
    8985            pipe->wire->address, pipe->endpoint_no,
     86            pipe->max_packet_size,
    9087            NULL);
    9188        if (opening_request == 0) {
    92                 pipe_end_transaction(pipe);
    9389                return ENOMEM;
    9490        }
     
    10096        aid_t data_request = async_data_read(pipe->hc_phone, buffer, size,
    10197            &data_request_call);
    102 
    103         /*
    104          * Since now on, someone else might access the backing phone
    105          * without breaking the transfer IPC protocol.
    106          */
    107         pipe_end_transaction(pipe);
    10898
    10999        if (data_request == 0) {
     
    156146
    157147        if (buffer == NULL) {
    158                 return EINVAL;
     148                        return EINVAL;
    159149        }
    160150
     
    163153        }
    164154
     155        if (!usb_pipe_is_session_started(pipe)) {
     156                return EBADF;
     157        }
     158
    165159        if (pipe->direction != USB_DIRECTION_IN) {
    166160                return EBADF;
     
    171165        }
    172166
     167        size_t act_size = 0;
    173168        int rc;
    174         rc = pipe_add_ref(pipe);
    175         if (rc != EOK) {
    176                 return rc;
    177         }
    178 
    179 
    180         size_t act_size = 0;
    181169
    182170        rc = usb_pipe_read_no_checks(pipe, buffer, size, &act_size);
    183 
    184         pipe_drop_ref(pipe);
    185 
    186171        if (rc != EOK) {
    187172                return rc;
     
    225210        }
    226211
    227         /* Ensure serialization over the phone. */
    228         pipe_start_transaction(pipe);
    229 
    230212        /*
    231213         * Make call identifying target USB device and type of transfer.
    232214         */
    233         aid_t opening_request = async_send_3(pipe->hc_phone,
     215        aid_t opening_request = async_send_4(pipe->hc_phone,
    234216            DEV_IFACE_ID(USBHC_DEV_IFACE), ipc_method,
    235217            pipe->wire->address, pipe->endpoint_no,
     218            pipe->max_packet_size,
    236219            NULL);
    237220        if (opening_request == 0) {
    238                 pipe_end_transaction(pipe);
    239221                return ENOMEM;
    240222        }
     
    244226         */
    245227        int rc = async_data_write_start(pipe->hc_phone, buffer, size);
    246 
    247         /*
    248          * Since now on, someone else might access the backing phone
    249          * without breaking the transfer IPC protocol.
    250          */
    251         pipe_end_transaction(pipe);
    252 
    253228        if (rc != EOK) {
    254229                async_wait_for(opening_request, NULL);
     
    285260        }
    286261
     262        if (!usb_pipe_is_session_started(pipe)) {
     263                return EBADF;
     264        }
     265
    287266        if (pipe->direction != USB_DIRECTION_OUT) {
    288267                return EBADF;
     
    293272        }
    294273
    295         int rc;
    296 
    297         rc = pipe_add_ref(pipe);
    298         if (rc != EOK) {
    299                 return rc;
    300         }
    301 
    302         rc = usb_pipe_write_no_check(pipe, buffer, size);
    303 
    304         pipe_drop_ref(pipe);
     274        int rc = usb_pipe_write_no_check(pipe, buffer, size);
    305275
    306276        return rc;
     
    323293    void *data_buffer, size_t data_buffer_size, size_t *data_transfered_size)
    324294{
    325         /* Ensure serialization over the phone. */
    326         pipe_start_transaction(pipe);
    327 
    328295        /*
    329296         * Make call identifying target USB device and control transfer type.
    330297         */
    331         aid_t opening_request = async_send_3(pipe->hc_phone,
     298        aid_t opening_request = async_send_4(pipe->hc_phone,
    332299            DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_CONTROL_READ,
    333300            pipe->wire->address, pipe->endpoint_no,
     301            pipe->max_packet_size,
    334302            NULL);
    335303        if (opening_request == 0) {
     
    343311            setup_buffer, setup_buffer_size);
    344312        if (rc != EOK) {
    345                 pipe_end_transaction(pipe);
    346313                async_wait_for(opening_request, NULL);
    347314                return rc;
     
    355322            data_buffer, data_buffer_size,
    356323            &data_request_call);
    357 
    358         /*
    359          * Since now on, someone else might access the backing phone
    360          * without breaking the transfer IPC protocol.
    361          */
    362         pipe_end_transaction(pipe);
    363 
    364 
    365324        if (data_request == 0) {
    366325                async_wait_for(opening_request, NULL);
     
    420379        }
    421380
     381        if (!usb_pipe_is_session_started(pipe)) {
     382                return EBADF;
     383        }
     384
    422385        if ((pipe->direction != USB_DIRECTION_BOTH)
    423386            || (pipe->transfer_type != USB_TRANSFER_CONTROL)) {
     
    425388        }
    426389
    427         int rc;
    428 
    429         rc = pipe_add_ref(pipe);
    430         if (rc != EOK) {
    431                 return rc;
    432         }
    433 
    434390        size_t act_size = 0;
    435         rc = usb_pipe_control_read_no_check(pipe,
     391        int rc = usb_pipe_control_read_no_check(pipe,
    436392            setup_buffer, setup_buffer_size,
    437393            data_buffer, data_buffer_size, &act_size);
    438 
    439         pipe_drop_ref(pipe);
    440394
    441395        if (rc != EOK) {
     
    464418    void *data_buffer, size_t data_buffer_size)
    465419{
    466         /* Ensure serialization over the phone. */
    467         pipe_start_transaction(pipe);
    468 
    469420        /*
    470421         * Make call identifying target USB device and control transfer type.
    471422         */
    472         aid_t opening_request = async_send_4(pipe->hc_phone,
     423        aid_t opening_request = async_send_5(pipe->hc_phone,
    473424            DEV_IFACE_ID(USBHC_DEV_IFACE), IPC_M_USBHC_CONTROL_WRITE,
    474425            pipe->wire->address, pipe->endpoint_no,
    475426            data_buffer_size,
     427            pipe->max_packet_size,
    476428            NULL);
    477429        if (opening_request == 0) {
    478                 pipe_end_transaction(pipe);
    479430                return ENOMEM;
    480431        }
     
    486437            setup_buffer, setup_buffer_size);
    487438        if (rc != EOK) {
    488                 pipe_end_transaction(pipe);
    489439                async_wait_for(opening_request, NULL);
    490440                return rc;
     
    497447                rc = async_data_write_start(pipe->hc_phone,
    498448                    data_buffer, data_buffer_size);
    499 
    500                 /* All data sent, pipe can be released. */
    501                 pipe_end_transaction(pipe);
    502 
    503449                if (rc != EOK) {
    504450                        async_wait_for(opening_request, NULL);
    505451                        return rc;
    506452                }
    507         } else {
    508                 /* No data to send, we can release the pipe for others. */
    509                 pipe_end_transaction(pipe);
    510453        }
    511454
     
    548491        }
    549492
     493        if (!usb_pipe_is_session_started(pipe)) {
     494                return EBADF;
     495        }
     496
    550497        if ((pipe->direction != USB_DIRECTION_BOTH)
    551498            || (pipe->transfer_type != USB_TRANSFER_CONTROL)) {
     
    553500        }
    554501
    555         int rc;
    556 
    557         rc = pipe_add_ref(pipe);
    558         if (rc != EOK) {
    559                 return rc;
    560         }
    561 
    562         rc = usb_pipe_control_write_no_check(pipe,
     502        int rc = usb_pipe_control_write_no_check(pipe,
    563503            setup_buffer, setup_buffer_size, data_buffer, data_buffer_size);
    564 
    565         pipe_drop_ref(pipe);
    566504
    567505        return rc;
Note: See TracChangeset for help on using the changeset viewer.