Ignore:
File:
1 edited

Legend:

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

    rd48fcc0 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.
     
    9187            NULL);
    9288        if (opening_request == 0) {
    93                 pipe_end_transaction(pipe);
    9489                return ENOMEM;
    9590        }
     
    10196        aid_t data_request = async_data_read(pipe->hc_phone, buffer, size,
    10297            &data_request_call);
    103 
    104         /*
    105          * Since now on, someone else might access the backing phone
    106          * without breaking the transfer IPC protocol.
    107          */
    108         pipe_end_transaction(pipe);
    10998
    11099        if (data_request == 0) {
     
    157146
    158147        if (buffer == NULL) {
    159                 return EINVAL;
     148                        return EINVAL;
    160149        }
    161150
     
    164153        }
    165154
     155        if (!usb_pipe_is_session_started(pipe)) {
     156                return EBADF;
     157        }
     158
    166159        if (pipe->direction != USB_DIRECTION_IN) {
    167160                return EBADF;
     
    172165        }
    173166
     167        size_t act_size = 0;
    174168        int rc;
    175         rc = pipe_add_ref(pipe);
    176         if (rc != EOK) {
    177                 return rc;
    178         }
    179 
    180 
    181         size_t act_size = 0;
    182169
    183170        rc = usb_pipe_read_no_checks(pipe, buffer, size, &act_size);
    184 
    185         pipe_drop_ref(pipe);
    186 
    187171        if (rc != EOK) {
    188172                return rc;
     
    226210        }
    227211
    228         /* Ensure serialization over the phone. */
    229         pipe_start_transaction(pipe);
    230 
    231212        /*
    232213         * Make call identifying target USB device and type of transfer.
     
    238219            NULL);
    239220        if (opening_request == 0) {
    240                 pipe_end_transaction(pipe);
    241221                return ENOMEM;
    242222        }
     
    246226         */
    247227        int rc = async_data_write_start(pipe->hc_phone, buffer, size);
    248 
    249         /*
    250          * Since now on, someone else might access the backing phone
    251          * without breaking the transfer IPC protocol.
    252          */
    253         pipe_end_transaction(pipe);
    254 
    255228        if (rc != EOK) {
    256229                async_wait_for(opening_request, NULL);
     
    287260        }
    288261
     262        if (!usb_pipe_is_session_started(pipe)) {
     263                return EBADF;
     264        }
     265
    289266        if (pipe->direction != USB_DIRECTION_OUT) {
    290267                return EBADF;
     
    295272        }
    296273
    297         int rc;
    298 
    299         rc = pipe_add_ref(pipe);
    300         if (rc != EOK) {
    301                 return rc;
    302         }
    303 
    304         rc = usb_pipe_write_no_check(pipe, buffer, size);
    305 
    306         pipe_drop_ref(pipe);
     274        int rc = usb_pipe_write_no_check(pipe, buffer, size);
    307275
    308276        return rc;
     
    325293    void *data_buffer, size_t data_buffer_size, size_t *data_transfered_size)
    326294{
    327         /* Ensure serialization over the phone. */
    328         pipe_start_transaction(pipe);
    329 
    330295        /*
    331296         * Make call identifying target USB device and control transfer type.
     
    346311            setup_buffer, setup_buffer_size);
    347312        if (rc != EOK) {
    348                 pipe_end_transaction(pipe);
    349313                async_wait_for(opening_request, NULL);
    350314                return rc;
     
    358322            data_buffer, data_buffer_size,
    359323            &data_request_call);
    360 
    361         /*
    362          * Since now on, someone else might access the backing phone
    363          * without breaking the transfer IPC protocol.
    364          */
    365         pipe_end_transaction(pipe);
    366 
    367 
    368324        if (data_request == 0) {
    369325                async_wait_for(opening_request, NULL);
     
    423379        }
    424380
     381        if (!usb_pipe_is_session_started(pipe)) {
     382                return EBADF;
     383        }
     384
    425385        if ((pipe->direction != USB_DIRECTION_BOTH)
    426386            || (pipe->transfer_type != USB_TRANSFER_CONTROL)) {
     
    428388        }
    429389
    430         int rc;
    431 
    432         rc = pipe_add_ref(pipe);
    433         if (rc != EOK) {
    434                 return rc;
    435         }
    436 
    437390        size_t act_size = 0;
    438         rc = usb_pipe_control_read_no_check(pipe,
     391        int rc = usb_pipe_control_read_no_check(pipe,
    439392            setup_buffer, setup_buffer_size,
    440393            data_buffer, data_buffer_size, &act_size);
    441 
    442         pipe_drop_ref(pipe);
    443394
    444395        if (rc != EOK) {
     
    467418    void *data_buffer, size_t data_buffer_size)
    468419{
    469         /* Ensure serialization over the phone. */
    470         pipe_start_transaction(pipe);
    471 
    472420        /*
    473421         * Make call identifying target USB device and control transfer type.
     
    480428            NULL);
    481429        if (opening_request == 0) {
    482                 pipe_end_transaction(pipe);
    483430                return ENOMEM;
    484431        }
     
    490437            setup_buffer, setup_buffer_size);
    491438        if (rc != EOK) {
    492                 pipe_end_transaction(pipe);
    493439                async_wait_for(opening_request, NULL);
    494440                return rc;
     
    501447                rc = async_data_write_start(pipe->hc_phone,
    502448                    data_buffer, data_buffer_size);
    503 
    504                 /* All data sent, pipe can be released. */
    505                 pipe_end_transaction(pipe);
    506 
    507449                if (rc != EOK) {
    508450                        async_wait_for(opening_request, NULL);
    509451                        return rc;
    510452                }
    511         } else {
    512                 /* No data to send, we can release the pipe for others. */
    513                 pipe_end_transaction(pipe);
    514453        }
    515454
     
    552491        }
    553492
     493        if (!usb_pipe_is_session_started(pipe)) {
     494                return EBADF;
     495        }
     496
    554497        if ((pipe->direction != USB_DIRECTION_BOTH)
    555498            || (pipe->transfer_type != USB_TRANSFER_CONTROL)) {
     
    557500        }
    558501
    559         int rc;
    560 
    561         rc = pipe_add_ref(pipe);
    562         if (rc != EOK) {
    563                 return rc;
    564         }
    565 
    566         rc = usb_pipe_control_write_no_check(pipe,
     502        int rc = usb_pipe_control_write_no_check(pipe,
    567503            setup_buffer, setup_buffer_size, data_buffer, data_buffer_size);
    568 
    569         pipe_drop_ref(pipe);
    570504
    571505        return rc;
Note: See TracChangeset for help on using the changeset viewer.