AmendHub

Download:

jcs

/

wifi_da

/

amendments

/

3

scsi: Look for blue variant


jcs made amendment 3 about 1 year ago
--- scsi.c Fri Jan 1 06:29:17 1904 +++ scsi.c Thu Sep 21 13:41:22 2023 @@ -69,19 +69,21 @@ scsi_find_wifi(void) for (scsi_id = 0; scsi_id <= 7; scsi_id++) { for (i = 0; i <= 1; i++) { if (SCSIGet() != noErr) - return -1; + goto scan_failed; if (SCSISelect(scsi_id) != noErr) break; if (SCSICmd((Ptr)&cdb, 6) != noErr) { SCSIComplete(&stat, &msg, 300); - return -1; + goto scan_failed; } + memset(&inq, 0, sizeof(inq)); + if (SCSIRead((Ptr)&tib) != noErr) { SCSIComplete(&stat, &msg, 300); - return -1; + goto scan_failed; } if (i == 0) { @@ -90,18 +92,19 @@ scsi_find_wifi(void) } if (SCSIComplete(&stat, &msg, 300) != noErr) - return -1; + goto scan_failed; if (memcmp(inq.vendorID, "Dayna", 5) == 0 && - memcmp(inq.productID, "SCSI/Link", 9) == 0) + memcmp(inq.productID, "SCSI/Link/Blue", 14) == 0) return scsi_id; } } - - return -1; + +scan_failed: + return WIFI_SCSI_ID_NONE; } -short +bool scsi_wifi_scan(short scsi_id) { unsigned char cdb[6]; @@ -113,9 +116,7 @@ scsi_wifi_scan(short scsi_id) cdb[2] = BLUESCSI_NETWORK_WIFI_CMD_SCAN; cdb[4] = 0x01; - scsi_io(scsi_id, cdb, sizeof(cdb), SCSI_READ, 1); - - return 1; + return (scsi_io(scsi_id, cdb, sizeof(cdb), SCSI_READ, 1) != -1); } bool @@ -128,7 +129,8 @@ scsi_wifi_scan_finished(short scsi_id) cdb[2] = BLUESCSI_NETWORK_WIFI_CMD_COMPLETE; cdb[4] = 0x01; - scsi_io(scsi_id, cdb, sizeof(cdb), SCSI_READ, 1); + if (scsi_io(scsi_id, cdb, sizeof(cdb), SCSI_READ, 1) == -1) + return true; if (scsi_data[0] == 1) return true; @@ -149,7 +151,9 @@ scsi_wifi_scan_results(short scsi_id, struct wifi_netw cdb[3] = (sizeof(scsi_data) >> 8) & 0xff; cdb[4] = sizeof(scsi_data) & 0xff; - scsi_io(scsi_id, cdb, sizeof(cdb), SCSI_READ, sizeof(scsi_data)); + if (scsi_io(scsi_id, cdb, sizeof(cdb), SCSI_READ, + sizeof(scsi_data)) == -1) + return 0; size = (scsi_data[0] << 8) | scsi_data[1]; net_count = size / sizeof(struct wifi_network_entry); @@ -162,7 +166,7 @@ scsi_wifi_scan_results(short scsi_id, struct wifi_netw return net_count; } -short +bool scsi_wifi_info(short scsi_id, struct wifi_network_entry *resp) { static struct wifi_network_entry wifi_info; @@ -177,16 +181,17 @@ scsi_wifi_info(short scsi_id, struct wifi_network_entr cdb[3] = (size >> 8) & 0xff; cdb[4] = size & 0xff; - scsi_io(scsi_id, cdb, sizeof(cdb), SCSI_READ, size); + if (scsi_io(scsi_id, cdb, sizeof(cdb), SCSI_READ, size) == -1) + return false; memset(resp, 0, sizeof(struct wifi_network_entry)); /* skip returned size */ memcpy(resp, scsi_data + 2, sizeof(struct wifi_network_entry)); - return 1; + return true; } -short +bool scsi_wifi_join(short scsi_id, struct wifi_join_request *wjr) { unsigned char cdb[6]; @@ -203,9 +208,7 @@ scsi_wifi_join(short scsi_id, struct wifi_join_request memcpy(scsi_data, wjr, sizeof(struct wifi_join_request)); - scsi_io(scsi_id, cdb, sizeof(cdb), SCSI_WRITE, size); - - return 1; + return (scsi_io(scsi_id, cdb, sizeof(cdb), SCSI_WRITE, size) != -1); } short