Changeset 7b2c17c in mainline for uspace/drv/bus/usb/usbmast/inquiry.c
- Timestamp:
- 2011-07-02T20:42:14Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d2fac08c
- Parents:
- 239e7e10
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbmast/inquiry.c
r239e7e10 r7b2c17c 52 52 ((type)( (number) & (BITS_GET_MID_MASK(type, bitcount, offset)) ) >> (offset)) 53 53 54 #define INQUIRY_RESPONSE_LENGTH 3655 56 54 /** Get string representation for SCSI peripheral device type. 57 55 * … … 89 87 usb_massstor_inquiry_result_t *inquiry_result) 90 88 { 89 scsi_std_inquiry_data_t inq_data; 90 size_t response_len; 91 91 scsi_cdb_inquiry_t inquiry = { 92 92 .op_code = SCSI_CMD_INQUIRY, 93 93 .evpd = 0, 94 94 .page_code = 0, 95 .alloc_len = host2uint16_t_be( INQUIRY_RESPONSE_LENGTH),95 .alloc_len = host2uint16_t_be(sizeof(inq_data)), 96 96 .control = 0 97 97 }; 98 size_t response_len;99 uint8_t response[INQUIRY_RESPONSE_LENGTH];100 98 101 99 int rc; … … 103 101 rc = usb_massstor_data_in(dev, bulk_in_idx, bulk_out_idx, 104 102 0xDEADBEEF, 0, (uint8_t *) &inquiry, sizeof(inquiry), 105 response, INQUIRY_RESPONSE_LENGTH, &response_len);103 &inq_data, sizeof(inq_data), &response_len); 106 104 107 105 if (rc != EOK) { … … 111 109 } 112 110 113 if (response_len < 8) {114 usb_log_error("The SCSI response is too short.\n");115 return E RANGE;111 if (response_len < SCSI_STD_INQUIRY_DATA_MIN_SIZE) { 112 usb_log_error("The SCSI inquiry response is too short.\n"); 113 return EIO; 116 114 } 117 115 118 116 /* 119 * This is an ugly part of the code. We will parse the returned 120 * data by hand and try to get as many useful data as possible. 117 * Parse inquiry data and fill in the result structure. 121 118 */ 119 122 120 bzero(inquiry_result, sizeof(*inquiry_result)); 123 121 124 /* This shall be returned by all devices. */125 inquiry_result->peripheral_device_type126 = BITS_GET(uint8_t, response[0], 5, 0);127 inquiry_result->removable = BITS_GET(uint8_t, response[1], 1, 7);122 inquiry_result->device_type = 123 BITS_GET(uint8_t, inq_data.pqual_devtype, 5, 0); 124 inquiry_result->removable = 125 BITS_GET(uint8_t, inq_data.rmb, 1, 7); 128 126 129 if (response_len < 32) {130 return EOK;131 }127 str_ncpy(inquiry_result->vendor, 9, 128 (const char *) &inq_data.vendor, 8); 129 trim_trailing_spaces(inquiry_result->vendor); 132 130 133 str_ncpy(inquiry_result-> vendor_id, 9,134 (const char *) & response[8], 8);135 trim_trailing_spaces(inquiry_result-> vendor_id);131 str_ncpy(inquiry_result->product, 17, 132 (const char *) &inq_data.product, 16); 133 trim_trailing_spaces(inquiry_result->product); 136 134 137 str_ncpy(inquiry_result-> product_and_revision, 12,138 (const char *) & response[16], 11);139 trim_trailing_spaces(inquiry_result-> product_and_revision);135 str_ncpy(inquiry_result->revision, 5, 136 (const char *) &inq_data.revision, 4); 137 trim_trailing_spaces(inquiry_result->revision); 140 138 141 139 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.