From 31a804eb65e0673ac26f6ddb483f9bfe4bc8c854 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= <jerome.duval@gmail.com>
Date: Mon, 7 Oct 2013 19:25:55 +0200
Subject: [PATCH] usb_disk: accept B_DEV_MEDIA_CHANGED as a ready unit.
* revert 0x2800 sense action change.
---
headers/private/drivers/scsi_sense.h | 6 ++----
src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp | 7 ++++---
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/headers/private/drivers/scsi_sense.h b/headers/private/drivers/scsi_sense.h
index 7e9bf4e..fa1204e 100644
a
|
b
|
|
4 | 4 | * |
5 | 5 | * Authors: |
6 | 6 | * Jérôme Duval |
7 | | * |
| 7 | * |
8 | 8 | * Generated based on http://www.t10.org/lists/asc-num.txt 20130919 |
9 | 9 | * and http://www.t10.org/lists/2sensekey.htm |
10 | 10 | */ |
… |
… |
scsi_sense_asc_table sSCSISenseAscTable[] =
|
315 | 315 | { 0x2705, "Permanent write protect", err_act_fail, B_READ_ONLY_DEVICE }, // T R |
316 | 316 | { 0x2706, "Conditional write protect", err_act_fail, B_READ_ONLY_DEVICE }, // R F |
317 | 317 | { 0x2707, "Space allocation failed write protect", err_act_fail, B_READ_ONLY_DEVICE }, // D B |
318 | | { 0x2800, "Not ready to ready change, medium may have changed", err_act_retry, B_DEV_MEDIA_CHANGED }, // DTLPWROMAEBKVF |
| 318 | { 0x2800, "Not ready to ready change, medium may have changed", err_act_fail, B_DEV_MEDIA_CHANGED }, // DTLPWROMAEBKVF |
319 | 319 | { 0x2801, "Import or export element accessed", err_act_fail, ENXIO }, // DT WROM B |
320 | 320 | { 0x2802, "Format-layer may have changed", err_act_fail, B_DEV_MEDIA_CHANGED }, // R |
321 | 321 | { 0x2803, "Import/export element accessed, medium changed", err_act_fail, B_ERROR }, // M |
… |
… |
scsi_get_sense_asc_info(uint16 asc_asq, const char **label, err_act *action, sta
|
792 | 792 | *label = NULL; |
793 | 793 | return B_BAD_VALUE; |
794 | 794 | } |
795 | | |
796 | | |
diff --git a/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp b/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp
index 6c874f3..5da2965 100644
a
|
b
|
usb_disk_request_sense(device_lun *lun, err_act *_action)
|
481 | 481 | lun->media_present = false; |
482 | 482 | usb_disk_reset_capacity(lun); |
483 | 483 | } |
484 | | |
| 484 | |
485 | 485 | if (_action != NULL) |
486 | 486 | *_action = action; |
487 | 487 | |
… |
… |
usb_disk_device_added(usb_device newDevice, void **cookie)
|
799 | 799 | TRACE("usb lun %"B_PRIu8" inquiry attempt %"B_PRIu32" begin\n", |
800 | 800 | i, tries); |
801 | 801 | status_t ready = usb_disk_test_unit_ready(lun, &action); |
802 | | if (ready == B_OK || ready == B_DEV_NO_MEDIA) { |
| 802 | if (ready == B_OK || ready == B_DEV_NO_MEDIA |
| 803 | || ready == B_DEV_MEDIA_CHANGED) { |
803 | 804 | if (lun->device_type == B_CD) |
804 | 805 | lun->write_protected = true; |
805 | 806 | // TODO: check for write protection; disabled since some |
… |
… |
usb_disk_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
|
1100 | 1101 | break; |
1101 | 1102 | } |
1102 | 1103 | snooze(500000); |
1103 | | } |
| 1104 | } |
1104 | 1105 | TRACE("B_GET_MEDIA_STATUS: 0x%08" B_PRIx32 "\n", |
1105 | 1106 | *(status_t *)buffer); |
1106 | 1107 | result = B_OK; |