Skip to content

Commit 60f075d

Browse files
authored
Merge pull request #3195 from hathach/update-inquiry2
add bufsize to tud_msc_inquiry2_cb()
2 parents dce5880 + f66f98f commit 60f075d

File tree

7 files changed

+15
-10
lines changed

7 files changed

+15
-10
lines changed

examples/device/cdc_msc/src/msc_disk.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] = {
119119
// Invoked when received SCSI_CMD_INQUIRY, v2 with full inquiry response
120120
// Some inquiry_resp's fields are already filled with default values, application can update them
121121
// Return length of inquiry response, typically sizeof(scsi_inquiry_resp_t) (36 bytes), can be longer if included vendor data.
122-
uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t* inquiry_resp) {
122+
uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t *inquiry_resp, uint32_t bufsize) {
123123
(void) lun;
124+
(void) bufsize;
124125
const char vid[] = "TinyUSB";
125126
const char pid[] = "Mass Storage";
126127
const char rev[] = "1.0";

examples/device/cdc_msc_freertos/src/msc_disk.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static void io_task(void *params) {
166166
io_ops_t io_ops;
167167
while (1) {
168168
if (xQueueReceive(io_queue, &io_ops, portMAX_DELAY)) {
169-
const uint8_t* addr = msc_disk[io_ops.lba] + io_ops.offset;
169+
uint8_t* addr = (uint8_t*) (uintptr_t) (msc_disk[io_ops.lba] + io_ops.offset);
170170
int32_t nbytes = io_ops.bufsize;
171171
if (io_ops.is_read) {
172172
memcpy(io_ops.buffer, addr, io_ops.bufsize);
@@ -191,8 +191,9 @@ void msc_disk_init() {}
191191
// Invoked when received SCSI_CMD_INQUIRY, v2 with full inquiry response
192192
// Some inquiry_resp's fields are already filled with default values, application can update them
193193
// Return length of inquiry response, typically sizeof(scsi_inquiry_resp_t) (36 bytes), can be longer if included vendor data.
194-
uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t* inquiry_resp) {
194+
uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t* inquiry_resp, uint32_t bufsize) {
195195
(void) lun;
196+
(void) bufsize;
196197
const char vid[] = "TinyUSB";
197198
const char pid[] = "Mass Storage";
198199
const char rev[] = "1.0";

examples/device/dynamic_configuration/src/msc_disk.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
119119
// Invoked when received SCSI_CMD_INQUIRY, v2 with full inquiry response
120120
// Some inquiry_resp's fields are already filled with default values, application can update them
121121
// Return length of inquiry response, typically sizeof(scsi_inquiry_resp_t) (36 bytes), can be longer if included vendor data.
122-
uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t* inquiry_resp) {
122+
uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t *inquiry_resp, uint32_t bufsize) {
123123
(void) lun;
124+
(void) bufsize;
124125
const char vid[] = "TinyUSB";
125126
const char pid[] = "Mass Storage";
126127
const char rev[] = "1.0";

examples/device/msc_dual_lun/src/msc_disk_dual.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,9 @@ uint8_t tud_msc_get_maxlun_cb(void) {
210210
// Invoked when received SCSI_CMD_INQUIRY, v2 with full inquiry response
211211
// Some inquiry_resp's fields are already filled with default values, application can update them
212212
// Return length of inquiry response, typically sizeof(scsi_inquiry_resp_t) (36 bytes), can be longer if included vendor data.
213-
uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t* inquiry_resp) {
213+
uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t *inquiry_resp, uint32_t bufsize) {
214214
(void) lun;
215+
(void) bufsize;
215216
const char vid[] = "TinyUSB";
216217
const char pid[] = "Mass Storage";
217218
const char rev[] = "1.0";

src/class/msc/msc_device.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
TU_ATTR_WEAK void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16], uint8_t product_rev[4]) {
4848
(void) lun; (void) vendor_id; (void) product_id; (void) product_rev;
4949
}
50-
TU_ATTR_WEAK uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t* inquiry_resp) {
51-
(void) lun; (void) inquiry_resp;
50+
TU_ATTR_WEAK uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t *inquiry_resp, uint32_t bufsize) {
51+
(void) lun; (void) inquiry_resp; (void) bufsize;
5252
return 0;
5353
}
5454

@@ -749,7 +749,7 @@ static int32_t proc_builtin_scsi(uint8_t lun, uint8_t const scsi_cmd[16], uint8_
749749
inquiry_rsp->response_data_format = 2;
750750
inquiry_rsp->additional_length = sizeof(scsi_inquiry_resp_t) - 5;
751751

752-
resplen = (int32_t) tud_msc_inquiry2_cb(lun, inquiry_rsp);
752+
resplen = (int32_t) tud_msc_inquiry2_cb(lun, inquiry_rsp, bufsize);
753753
if (resplen == 0) {
754754
// stub callback with no response, use v1 callback
755755
tud_msc_inquiry_cb(lun, inquiry_rsp->vendor_id, inquiry_rsp->product_id, inquiry_rsp->product_rev);

src/class/msc/msc_device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16
9797
// Invoked when received SCSI_CMD_INQUIRY, v2 with full inquiry response
9898
// Some inquiry_resp's fields are already filled with default values, application can update them
9999
// Return length of inquiry response, typically sizeof(scsi_inquiry_resp_t) (36 bytes), can be longer if included vendor data.
100-
uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t* inquiry_resp);
100+
uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t *inquiry_resp, uint32_t bufsize);
101101

102102
// Invoked when received Test Unit Ready command.
103103
// return true allowing host to read/write this LUN e.g SD card inserted

test/unit-test/test/device/msc/test_msc_device.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE];
9797
// Invoked when received SCSI_CMD_INQUIRY, v2 with full inquiry response
9898
// Some inquiry_resp's fields are already filled with default values, application can update them
9999
// Return length of inquiry response, typically sizeof(scsi_inquiry_resp_t) (36 bytes), can be longer if included vendor data.
100-
uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t* inquiry_resp) {
100+
uint32_t tud_msc_inquiry2_cb(uint8_t lun, scsi_inquiry_resp_t* inquiry_resp, uint32_t bufsize) {
101101
(void) lun;
102+
(void) bufsize;
102103
const char vid[] = "TinyUSB";
103104
const char pid[] = "Mass Storage";
104105
const char rev[] = "1.0";

0 commit comments

Comments
 (0)