Changes in uspace/drv/usbmast/mast.c [5f0fe4e9:380e0364] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbmast/mast.c
r5f0fe4e9 r380e0364 40 40 #include <str_error.h> 41 41 #include <usb/debug.h> 42 #include <usb/request.h>43 42 44 43 bool usb_mast_verbose = true; … … 64 63 * @return Error code. 65 64 */ 66 int usb_massstor_data_in(usb_device_t *dev, 67 size_t bulk_in_pipe_index, size_t bulk_out_pipe_index, 65 int usb_massstor_data_in(usb_pipe_t *bulk_in_pipe, usb_pipe_t *bulk_out_pipe, 68 66 uint32_t tag, uint8_t lun, void *cmd, size_t cmd_size, 69 67 void *in_buffer, size_t in_buffer_size, size_t *received_size) … … 71 69 int rc; 72 70 size_t act_size; 73 usb_pipe_t *bulk_in_pipe = dev->pipes[bulk_in_pipe_index].pipe;74 usb_pipe_t *bulk_out_pipe = dev->pipes[bulk_out_pipe_index].pipe;75 71 76 72 /* Prepare CBW - command block wrapper */ … … 139 135 } 140 136 141 /** Perform bulk-only mass storage reset.142 *143 * @param dev Device to be reseted.144 * @return Error code.145 */146 int usb_massstor_reset(usb_device_t *dev)147 {148 return usb_control_request_set(&dev->ctrl_pipe,149 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,150 0xFF, 0, dev->interface_no, NULL, 0);151 }152 153 /** Perform complete reset recovery of bulk-only mass storage.154 *155 * Notice that no error is reported because if this fails, the error156 * would reappear on next transaction somehow.157 *158 * @param dev Device to be reseted.159 * @param bulk_in_idx Index of bulk in pipe.160 * @param bulk_out_idx Index of bulk out pipe.161 */162 void usb_massstor_reset_recovery(usb_device_t *dev,163 size_t bulk_in_idx, size_t bulk_out_idx)164 {165 /* We would ignore errors here because if this fails166 * we are doomed anyway and any following transaction would fail.167 */168 usb_massstor_reset(dev);169 usb_pipe_clear_halt(&dev->ctrl_pipe, dev->pipes[bulk_in_idx].pipe);170 usb_pipe_clear_halt(&dev->ctrl_pipe, dev->pipes[bulk_out_idx].pipe);171 }172 173 /** Get max LUN of a mass storage device.174 *175 * @see usb_masstor_get_lun_count176 *177 * @warning Error from this command does not necessarily indicate malfunction178 * of the device. Device does not need to support this request.179 * You shall rather use usb_masstor_get_lun_count.180 *181 * @param dev Mass storage device.182 * @return Error code of maximum LUN (index, not count).183 */184 int usb_massstor_get_max_lun(usb_device_t *dev)185 {186 uint8_t max_lun;187 size_t data_recv_len;188 int rc = usb_control_request_get(&dev->ctrl_pipe,189 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE,190 0xFE, 0, dev->interface_no, &max_lun, 1, &data_recv_len);191 if (rc != EOK) {192 return rc;193 }194 if (data_recv_len != 1) {195 return EEMPTY;196 }197 return (int) max_lun;198 }199 200 /** Get number of LUNs supported by mass storage device.201 *202 * @warning This function hides any error during the request203 * (typically that shall not be a problem).204 *205 * @param dev Mass storage device.206 * @return Number of LUNs.207 */208 size_t usb_masstor_get_lun_count(usb_device_t *dev)209 {210 int max_lun = usb_massstor_get_max_lun(dev);211 if (max_lun < 0) {212 max_lun = 1;213 } else {214 max_lun++;215 }216 217 return (size_t) max_lun;218 }219 220 137 /** 221 138 * @}
Note:
See TracChangeset
for help on using the changeset viewer.