+ /* Many devices have trouble transfering more than 32KB at a time,
+ * while others have trouble with more than 64K. At this time we
+ * are limiting both to 32K (64 sectores).
+ */
+ if ((us->flags & US_FL_MAX_SECTORS_64) &&
+ sdev->request_queue->max_sectors > 64)
+ blk_queue_max_sectors(sdev->request_queue, 64);
+
+ /* We can't put these settings in slave_alloc() because that gets
+ * called before the device type is known. Consequently these
+ * settings can't be overridden via the scsi devinfo mechanism. */
+ if (sdev->type == TYPE_DISK) {
+
+ /* Disk-type devices use MODE SENSE(6) if the protocol
+ * (SubClass) is Transparent SCSI, otherwise they use
+ * MODE SENSE(10). */
+ if (us->subclass != US_SC_SCSI)
+ sdev->use_10_for_ms = 1;
+
+ /* Many disks only accept MODE SENSE transfer lengths of
+ * 192 bytes (that's what Windows uses). */
+ sdev->use_192_bytes_for_3f = 1;
+
+ /* Some devices don't like MODE SENSE with page=0x3f,
+ * which is the command used for checking if a device
+ * is write-protected. Now that we tell the sd driver
+ * to do a 192-byte transfer with this command the
+ * majority of devices work fine, but a few still can't
+ * handle it. The sd driver will simply assume those
+ * devices are write-enabled. */
+ if (us->flags & US_FL_NO_WP_DETECT)
+ sdev->skip_ms_page_3f = 1;
+
+ /* A number of devices have problems with MODE SENSE for
+ * page x08, so we will skip it. */
+ sdev->skip_ms_page_8 = 1;
+
+ /* Some disks return the total number of blocks in response
+ * to READ CAPACITY rather than the highest block number.
+ * If this device makes that mistake, tell the sd driver. */
+ if (us->flags & US_FL_FIX_CAPACITY)
+ sdev->fix_capacity = 1;
+
+ /* Some devices report a SCSI revision level above 2 but are
+ * unable to handle the REPORT LUNS command (for which
+ * support is mandatory at level 3). Since we already have
+ * a Get-Max-LUN request, we won't lose much by setting the
+ * revision level down to 2. The only devices that would be
+ * affected are those with sparse LUNs. */
+ sdev->scsi_level = sdev->sdev_target->scsi_level = SCSI_2;
+
+ /* USB-IDE bridges tend to report SK = 0x04 (Non-recoverable
+ * Hardware Error) when any low-level error occurs,
+ * recoverable or not. Setting this flag tells the SCSI
+ * midlayer to retry such commands, which frequently will
+ * succeed and fix the error. The worst this can lead to
+ * is an occasional series of retries that will all fail. */
+ sdev->retry_hwerror = 1;
+
+ } else {