Commit 060b54e2 authored by James Bottomley's avatar James Bottomley

Merge

parents 49ccf84d 2e4420fa
......@@ -333,7 +333,7 @@ int scsi_get_device_flags(struct scsi_device *sdev, unsigned char *vendor,
struct scsi_dev_info_list *devinfo;
unsigned int bflags;
bflags = sdev->host->hostt->flags;
bflags = sdev->sdev_bflags;
if (!bflags)
bflags = scsi_default_dev_flags;
......
......@@ -646,6 +646,9 @@ static int scsi_add_lun(struct scsi_device *sdev, char *inq_result, int *bflags)
* may do I/O */
scsi_device_set_state(sdev, SDEV_RUNNING);
if (*bflags & BLIST_MS_192_BYTES_FOR_3F)
sdev->use_192_bytes_for_3f = 1;
if(sdev->host->hostt->slave_configure)
sdev->host->hostt->slave_configure(sdev);
......
......@@ -1122,26 +1122,32 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, char *diskname,
return;
}
/*
* First attempt: ask for all pages (0x3F), but only 4 bytes.
* We have to start carefully: some devices hang if we ask
* for more than is available.
*/
res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 4, &data);
if (sdkp->device->use_192_bytes_for_3f) {
res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 192, &data);
} else {
/*
* First attempt: ask for all pages (0x3F), but only 4 bytes.
* We have to start carefully: some devices hang if we ask
* for more than is available.
*/
res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 4, &data);
/*
* Second attempt: ask for page 0
* When only page 0 is implemented, a request for page 3F may return
* Sense Key 5: Illegal Request, Sense Code 24: Invalid field in CDB.
*/
if (!scsi_status_is_good(res))
res = sd_do_mode_sense(SRpnt, 0, 0, buffer, 4, &data);
/*
* Second attempt: ask for page 0 When only page 0 is
* implemented, a request for page 3F may return Sense Key
* 5: Illegal Request, Sense Code 24: Invalid field in
* CDB.
*/
if (!scsi_status_is_good(res))
res = sd_do_mode_sense(SRpnt, 0, 0, buffer, 4, &data);
/*
* Third attempt: ask 255 bytes, as we did earlier.
*/
if (!scsi_status_is_good(res))
res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 255, &data);
/*
* Third attempt: ask 255 bytes, as we did earlier.
*/
if (!scsi_status_is_good(res))
res = sd_do_mode_sense(SRpnt, 0, 0x3F, buffer, 255,
&data);
}
if (!scsi_status_is_good(res)) {
printk(KERN_WARNING
......
......@@ -64,6 +64,17 @@ static const char* host_info(struct Scsi_Host *host)
return "SCSI emulation for USB Mass Storage devices";
}
static int slave_alloc (struct scsi_device *sdev)
{
/*
* Set default bflags. These can be overridden for individual
* models and vendors via the scsi devinfo mechanism.
*/
sdev->sdev_bflags = (BLIST_MS_SKIP_PAGE_08 | BLIST_MS_SKIP_PAGE_3F |
BLIST_USE_10_BYTE_MS);
return 0;
}
static int slave_configure (struct scsi_device *sdev)
{
/* Scatter-gather buffers (all but the last) must have a length
......@@ -365,6 +376,7 @@ struct scsi_host_template usb_stor_host_template = {
/* unknown initiator id */
.this_id = -1,
.slave_alloc = slave_alloc,
.slave_configure = slave_configure,
/* lots of sg segments can be handled */
......@@ -385,10 +397,6 @@ struct scsi_host_template usb_stor_host_template = {
/* sysfs device attributes */
.sdev_attrs = sysfs_device_attr_list,
/* modify scsi_device bits on probe */
.flags = (BLIST_MS_SKIP_PAGE_08 | BLIST_MS_SKIP_PAGE_3F |
BLIST_USE_10_BYTE_MS),
/* module management */
.module = THIS_MODULE
};
......
......@@ -71,6 +71,10 @@ struct scsi_device {
unsigned char current_tag; /* current tag */
struct scsi_target *sdev_target; /* used only for single_lun */
unsigned int sdev_bflags; /* black/white flags as also found in
* scsi_devinfo.[hc]. For now used only to
* pass settings from slave_alloc to scsi
* core. */
unsigned writeable:1;
unsigned removable:1;
unsigned changed:1; /* Data invalid due to media change */
......@@ -98,6 +102,7 @@ struct scsi_device {
unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */
unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */
unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */
unsigned use_192_bytes_for_3f:1; /* ask for 192 bytes from page 0x3f */
unsigned no_start_on_add:1; /* do not issue start on add */
unsigned allow_restart:1; /* issue START_UNIT in error handler */
......
......@@ -19,4 +19,5 @@
#define BLIST_MS_SKIP_PAGE_08 0x2000 /* do not send ms page 0x08 */
#define BLIST_MS_SKIP_PAGE_3F 0x4000 /* do not send ms page 0x3f */
#define BLIST_USE_10_BYTE_MS 0x8000 /* use 10 byte ms before 6 byte ms */
#define BLIST_MS_192_BYTES_FOR_3F 0x10000 /* 192 byte ms page 0x3f request */
#endif
......@@ -345,12 +345,6 @@ struct scsi_host_template {
* module_init/module_exit.
*/
struct list_head legacy_hosts;
/*
* Default flags settings, these modify the setting of scsi_device
* bits.
*/
unsigned int flags;
};
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment