Changeset 5a6cc679 in mainline for uspace/drv/block/usbmast
- Timestamp:
- 2018-01-31T02:21:24Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a0a9cc2
- Parents:
- 132ab5d1
- Location:
- uspace/drv/block/usbmast
- Files:
-
- 5 edited
-
bo_trans.c (modified) (3 diffs)
-
bo_trans.h (modified) (1 diff)
-
main.c (modified) (14 diffs)
-
scsi_ms.c (modified) (10 diffs)
-
scsi_ms.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/block/usbmast/bo_trans.c
r132ab5d1 r5a6cc679 58 58 * @return Error code 59 59 */ 60 int usb_massstor_cmd(usbmast_fun_t *mfun, uint32_t tag, scsi_cmd_t *cmd)61 { 62 int rc;60 errno_t usb_massstor_cmd(usbmast_fun_t *mfun, uint32_t tag, scsi_cmd_t *cmd) 61 { 62 errno_t rc; 63 63 64 64 if (cmd->data_in && cmd->data_out) … … 192 192 * @return Error code 193 193 */ 194 int usb_massstor_reset(usbmast_dev_t *mdev)194 errno_t usb_massstor_reset(usbmast_dev_t *mdev) 195 195 { 196 196 return usb_control_request_set( … … 234 234 uint8_t max_lun; 235 235 size_t data_recv_len; 236 int rc = usb_control_request_get(236 errno_t rc = usb_control_request_get( 237 237 usb_device_get_default_pipe(mdev->usb_dev), 238 238 USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_INTERFACE, -
uspace/drv/block/usbmast/bo_trans.h
r132ab5d1 r5a6cc679 86 86 } scsi_cmd_t; 87 87 88 extern int usb_massstor_cmd(usbmast_fun_t *, uint32_t, scsi_cmd_t *);89 extern int usb_massstor_reset(usbmast_dev_t *);88 extern errno_t usb_massstor_cmd(usbmast_fun_t *, uint32_t, scsi_cmd_t *); 89 extern errno_t usb_massstor_reset(usbmast_dev_t *); 90 90 extern void usb_massstor_reset_recovery(usbmast_dev_t *); 91 91 extern int usb_massstor_get_max_lun(usbmast_dev_t *); -
uspace/drv/block/usbmast/main.c
r132ab5d1 r5a6cc679 77 77 }; 78 78 79 static int usbmast_fun_create(usbmast_dev_t *mdev, unsigned lun);79 static errno_t usbmast_fun_create(usbmast_dev_t *mdev, unsigned lun); 80 80 static void usbmast_bd_connection(ipc_callid_t iid, ipc_call_t *icall, 81 81 void *arg); 82 82 83 static int usbmast_bd_open(bd_srvs_t *, bd_srv_t *);84 static int usbmast_bd_close(bd_srv_t *);85 static int usbmast_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);86 static int usbmast_bd_sync_cache(bd_srv_t *, aoff64_t, size_t);87 static int usbmast_bd_write_blocks(bd_srv_t *, aoff64_t, size_t, const void *, size_t);88 static int usbmast_bd_get_block_size(bd_srv_t *, size_t *);89 static int usbmast_bd_get_num_blocks(bd_srv_t *, aoff64_t *);83 static errno_t usbmast_bd_open(bd_srvs_t *, bd_srv_t *); 84 static errno_t usbmast_bd_close(bd_srv_t *); 85 static errno_t usbmast_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t); 86 static errno_t usbmast_bd_sync_cache(bd_srv_t *, aoff64_t, size_t); 87 static errno_t usbmast_bd_write_blocks(bd_srv_t *, aoff64_t, size_t, const void *, size_t); 88 static errno_t usbmast_bd_get_block_size(bd_srv_t *, size_t *); 89 static errno_t usbmast_bd_get_num_blocks(bd_srv_t *, aoff64_t *); 90 90 91 91 static bd_ops_t usbmast_bd_ops = { … … 109 109 * @return Error code. 110 110 */ 111 static int usbmast_device_gone(usb_device_t *dev)111 static errno_t usbmast_device_gone(usb_device_t *dev) 112 112 { 113 113 usbmast_dev_t *mdev = usb_device_data_get(dev); … … 115 115 116 116 for (size_t i = 0; i < mdev->lun_count; ++i) { 117 const int rc = ddf_fun_unbind(mdev->luns[i]);117 const errno_t rc = ddf_fun_unbind(mdev->luns[i]); 118 118 if (rc != EOK) { 119 119 usb_log_error("Failed to unbind LUN function %zu: " … … 133 133 * @return Error code. 134 134 */ 135 static int usbmast_device_remove(usb_device_t *dev)135 static errno_t usbmast_device_remove(usb_device_t *dev) 136 136 { 137 137 //TODO: flush buffers, or whatever. … … 145 145 * @return Error code. 146 146 */ 147 static int usbmast_device_add(usb_device_t *dev)148 { 149 int rc;147 static errno_t usbmast_device_add(usb_device_t *dev) 148 { 149 errno_t rc; 150 150 usbmast_dev_t *mdev = NULL; 151 151 unsigned i; … … 198 198 if (mdev->luns[i] == NULL) 199 199 continue; 200 const int rc = ddf_fun_unbind(mdev->luns[i]);200 const errno_t rc = ddf_fun_unbind(mdev->luns[i]); 201 201 if (rc != EOK) { 202 202 usb_log_warning("Failed to unbind LUN function %zu: " … … 217 217 * @return EOK on success or an error code. 218 218 */ 219 static int usbmast_fun_create(usbmast_dev_t *mdev, unsigned lun)220 { 221 int rc;219 static errno_t usbmast_fun_create(usbmast_dev_t *mdev, unsigned lun) 220 { 221 errno_t rc; 222 222 char *fun_name = NULL; 223 223 ddf_fun_t *fun = NULL; … … 326 326 327 327 /** Open device. */ 328 static int usbmast_bd_open(bd_srvs_t *bds, bd_srv_t *bd)328 static errno_t usbmast_bd_open(bd_srvs_t *bds, bd_srv_t *bd) 329 329 { 330 330 return EOK; … … 332 332 333 333 /** Close device. */ 334 static int usbmast_bd_close(bd_srv_t *bd)334 static errno_t usbmast_bd_close(bd_srv_t *bd) 335 335 { 336 336 return EOK; … … 338 338 339 339 /** Read blocks from the device. */ 340 static int usbmast_bd_read_blocks(bd_srv_t *bd, uint64_t ba, size_t cnt, void *buf,340 static errno_t usbmast_bd_read_blocks(bd_srv_t *bd, uint64_t ba, size_t cnt, void *buf, 341 341 size_t size) 342 342 { … … 350 350 351 351 /** Synchronize blocks to nonvolatile storage. */ 352 static int usbmast_bd_sync_cache(bd_srv_t *bd, uint64_t ba, size_t cnt)352 static errno_t usbmast_bd_sync_cache(bd_srv_t *bd, uint64_t ba, size_t cnt) 353 353 { 354 354 usbmast_fun_t *mfun = bd_srv_usbmast(bd); … … 358 358 359 359 /** Write blocks to the device. */ 360 static int usbmast_bd_write_blocks(bd_srv_t *bd, uint64_t ba, size_t cnt,360 static errno_t usbmast_bd_write_blocks(bd_srv_t *bd, uint64_t ba, size_t cnt, 361 361 const void *buf, size_t size) 362 362 { … … 370 370 371 371 /** Get device block size. */ 372 static int usbmast_bd_get_block_size(bd_srv_t *bd, size_t *rsize)372 static errno_t usbmast_bd_get_block_size(bd_srv_t *bd, size_t *rsize) 373 373 { 374 374 usbmast_fun_t *mfun = bd_srv_usbmast(bd); … … 378 378 379 379 /** Get number of blocks on device. */ 380 static int usbmast_bd_get_num_blocks(bd_srv_t *bd, aoff64_t *rnb)380 static errno_t usbmast_bd_get_num_blocks(bd_srv_t *bd, aoff64_t *rnb) 381 381 { 382 382 usbmast_fun_t *mfun = bd_srv_usbmast(bd); -
uspace/drv/block/usbmast/scsi_ms.c
r132ab5d1 r5a6cc679 72 72 } 73 73 74 static int usb_massstor_unit_ready(usbmast_fun_t *mfun)74 static errno_t usb_massstor_unit_ready(usbmast_fun_t *mfun) 75 75 { 76 76 scsi_cmd_t cmd; 77 77 scsi_cdb_test_unit_ready_t cdb; 78 int rc;78 errno_t rc; 79 79 80 80 memset(&cdb, 0, sizeof(cdb)); … … 107 107 * XXX This is too simplified. 108 108 */ 109 static int usbmast_run_cmd(usbmast_fun_t *mfun, scsi_cmd_t *cmd)109 static errno_t usbmast_run_cmd(usbmast_fun_t *mfun, scsi_cmd_t *cmd) 110 110 { 111 111 uint8_t sense_key; 112 112 scsi_sense_data_t sense_buf; 113 int rc;113 errno_t rc; 114 114 115 115 do { … … 162 162 * @return Error code 163 163 */ 164 int usbmast_inquiry(usbmast_fun_t *mfun, usbmast_inquiry_data_t *inq_res)164 errno_t usbmast_inquiry(usbmast_fun_t *mfun, usbmast_inquiry_data_t *inq_res) 165 165 { 166 166 scsi_std_inquiry_data_t inq_data; 167 167 scsi_cmd_t cmd; 168 168 scsi_cdb_inquiry_t cdb; 169 int rc;169 errno_t rc; 170 170 171 171 memset(&cdb, 0, sizeof(cdb)); … … 231 231 * @return Error code. 232 232 */ 233 int usbmast_request_sense(usbmast_fun_t *mfun, void *buf, size_t size)233 errno_t usbmast_request_sense(usbmast_fun_t *mfun, void *buf, size_t size) 234 234 { 235 235 scsi_cmd_t cmd; 236 236 scsi_cdb_request_sense_t cdb; 237 int rc;237 errno_t rc; 238 238 239 239 memset(&cdb, 0, sizeof(cdb)); … … 272 272 * @return Error code. 273 273 */ 274 int usbmast_read_capacity(usbmast_fun_t *mfun, uint32_t *nblocks,274 errno_t usbmast_read_capacity(usbmast_fun_t *mfun, uint32_t *nblocks, 275 275 uint32_t *block_size) 276 276 { … … 278 278 scsi_cdb_read_capacity_10_t cdb; 279 279 scsi_read_capacity_10_data_t data; 280 int rc;280 errno_t rc; 281 281 282 282 memset(&cdb, 0, sizeof(cdb)); … … 323 323 * @return Error code 324 324 */ 325 int usbmast_read(usbmast_fun_t *mfun, uint64_t ba, size_t nblocks, void *buf)325 errno_t usbmast_read(usbmast_fun_t *mfun, uint64_t ba, size_t nblocks, void *buf) 326 326 { 327 327 scsi_cmd_t cmd; 328 328 scsi_cdb_read_10_t cdb; 329 int rc;329 errno_t rc; 330 330 331 331 if (ba > UINT32_MAX) … … 378 378 * @return Error code 379 379 */ 380 int usbmast_write(usbmast_fun_t *mfun, uint64_t ba, size_t nblocks,380 errno_t usbmast_write(usbmast_fun_t *mfun, uint64_t ba, size_t nblocks, 381 381 const void *data) 382 382 { 383 383 scsi_cmd_t cmd; 384 384 scsi_cdb_write_10_t cdb; 385 int rc;385 errno_t rc; 386 386 387 387 if (ba > UINT32_MAX) … … 428 428 * @return Error code 429 429 */ 430 int usbmast_sync_cache(usbmast_fun_t *mfun, uint64_t ba, size_t nblocks)430 errno_t usbmast_sync_cache(usbmast_fun_t *mfun, uint64_t ba, size_t nblocks) 431 431 { 432 432 if (ba > UINT32_MAX) … … 447 447 }; 448 448 449 const int rc = usbmast_run_cmd(mfun, &cmd);449 const errno_t rc = usbmast_run_cmd(mfun, &cmd); 450 450 451 451 if (rc != EOK) { -
uspace/drv/block/usbmast/scsi_ms.h
r132ab5d1 r5a6cc679 60 60 } usbmast_inquiry_data_t; 61 61 62 extern int usbmast_inquiry(usbmast_fun_t *, usbmast_inquiry_data_t *);63 extern int usbmast_request_sense(usbmast_fun_t *, void *, size_t);64 extern int usbmast_read_capacity(usbmast_fun_t *, uint32_t *, uint32_t *);65 extern int usbmast_read(usbmast_fun_t *, uint64_t, size_t, void *);66 extern int usbmast_write(usbmast_fun_t *, uint64_t, size_t, const void *);67 extern int usbmast_sync_cache(usbmast_fun_t *, uint64_t, size_t);62 extern errno_t usbmast_inquiry(usbmast_fun_t *, usbmast_inquiry_data_t *); 63 extern errno_t usbmast_request_sense(usbmast_fun_t *, void *, size_t); 64 extern errno_t usbmast_read_capacity(usbmast_fun_t *, uint32_t *, uint32_t *); 65 extern errno_t usbmast_read(usbmast_fun_t *, uint64_t, size_t, void *); 66 extern errno_t usbmast_write(usbmast_fun_t *, uint64_t, size_t, const void *); 67 extern errno_t usbmast_sync_cache(usbmast_fun_t *, uint64_t, size_t); 68 68 extern const char *usbmast_scsi_dev_type_str(unsigned); 69 69
Note:
See TracChangeset
for help on using the changeset viewer.
