Changeset c53b58e in mainline
- Timestamp:
- 2014-09-12T05:25:57Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 83062ff
- Parents:
- 8e7c9fe
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbmast/bo_trans.c
r8e7c9fe rc53b58e 65 65 { 66 66 int rc; 67 int retval = EOK; 68 size_t act_size; 67 68 if (cmd->data_in && cmd->data_out) 69 return EINVAL; 70 69 71 usb_pipe_t *bulk_in_pipe = mfun->mdev->bulk_in_pipe; 70 72 usb_pipe_t *bulk_out_pipe = mfun->mdev->bulk_out_pipe; 71 usb_direction_t ddir; 72 void *dbuf; 73 size_t dbuf_size; 74 75 if (cmd->data_out != NULL && cmd->data_in == NULL) { 76 ddir = USB_DIRECTION_OUT; 77 dbuf = (void *)cmd->data_out; 78 dbuf_size = cmd->data_out_size; 79 } else if (cmd->data_out == NULL && cmd->data_in != NULL) { 73 74 usb_pipe_t *dpipe = bulk_out_pipe; 75 usb_direction_t ddir = USB_DIRECTION_OUT; 76 size_t dbuf_size = cmd->data_out_size; 77 78 if (cmd->data_in) { 80 79 ddir = USB_DIRECTION_IN; 81 dbuf = cmd->data_in;82 80 dbuf_size = cmd->data_in_size; 83 } else { 84 assert(false); 81 dpipe = bulk_in_pipe; 85 82 } 86 83 … … 100 97 101 98 MASTLOG("Transferring data.\n"); 102 if (ddir == USB_DIRECTION_IN) { 99 if (cmd->data_in) { 100 size_t act_size; 103 101 /* Recieve data from the device. */ 104 rc = usb_pipe_read(bulk_in_pipe, dbuf, dbuf_size, &act_size); 102 rc = usb_pipe_read(dpipe, cmd->data_in, cmd->data_in_size, 103 &act_size); 105 104 MASTLOG("Received %zu bytes (%s): %s.\n", act_size, 106 usb_debug_str_buffer( (uint8_t *) dbuf, act_size, 0),105 usb_debug_str_buffer(cmd->data_in, act_size, 0), 107 106 str_error(rc)); 108 } else { 107 } 108 if (cmd->data_out) { 109 109 /* Send data to the device. */ 110 rc = usb_pipe_write( bulk_out_pipe, dbuf, dbuf_size);111 MASTLOG("Sent %zu bytes (%s): %s.\n", act_size,112 usb_debug_str_buffer( (uint8_t *) dbuf, act_size, 0),110 rc = usb_pipe_write(dpipe, cmd->data_out, cmd->data_out_size); 111 MASTLOG("Sent %zu bytes (%s): %s.\n", cmd->data_out_size, 112 usb_debug_str_buffer(cmd->data_out, cmd->data_out_size, 0), 113 113 str_error(rc)); 114 114 } … … 116 116 if (rc == ESTALL) { 117 117 /* Clear stall condition and continue below to read CSW. */ 118 if (ddir == USB_DIRECTION_IN) { 119 usb_pipe_clear_halt( 120 usb_device_get_default_pipe(mfun->mdev->usb_dev), 121 bulk_in_pipe); 122 } else { 123 usb_pipe_clear_halt( 124 usb_device_get_default_pipe(mfun->mdev->usb_dev), 125 bulk_out_pipe); 126 } 118 usb_pipe_clear_halt( 119 usb_device_get_default_pipe(mfun->mdev->usb_dev), dpipe); 127 120 } else if (rc != EOK) { 128 121 return EIO; … … 165 158 case cbs_phase_error: 166 159 MASTLOG("Phase error\n"); 167 r etval= EIO;160 rc = EIO; 168 161 break; 169 162 default: 170 r etval= EIO;171 break; 172 } 173 174 size_t residue = (size_t)uint32_usb2host(csw.dCSWDataResidue);163 rc = EIO; 164 break; 165 } 166 167 const size_t residue = uint32_usb2host(csw.dCSWDataResidue); 175 168 if (residue > dbuf_size) { 176 169 MASTLOG("residue > dbuf_size\n"); … … 186 179 */ 187 180 188 if ( ddir == USB_DIRECTION_IN)181 if (cmd->data_in) 189 182 cmd->rcvd_size = dbuf_size - residue; 190 183 191 return r etval;184 return rc; 192 185 } 193 186
Note:
See TracChangeset
for help on using the changeset viewer.