Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[powerpc.git] / drivers / scsi / scsi_scan.c
index 7d31a4b..1341608 100644 (file)
@@ -25,7 +25,6 @@
  *             or a LUN is seen that cannot have a device attached to it.
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/init.h>
 #include <asm/semaphore.h>
 
 #include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_driver.h>
 #include <scsi/scsi_devinfo.h>
 #include <scsi/scsi_host.h>
-#include <scsi/scsi_request.h>
 #include <scsi/scsi_transport.h>
 #include <scsi/scsi_eh.h>
 
@@ -673,6 +672,7 @@ static int scsi_add_lun(struct scsi_device *sdev, char *inq_result, int *bflags)
        case TYPE_MEDIUM_CHANGER:
        case TYPE_ENCLOSURE:
        case TYPE_COMM:
+       case TYPE_RAID:
        case TYPE_RBC:
                sdev->writeable = 1;
                break;
@@ -737,6 +737,13 @@ static int scsi_add_lun(struct scsi_device *sdev, char *inq_result, int *bflags)
        if (*bflags & BLIST_SELECT_NO_ATN)
                sdev->select_no_atn = 1;
 
+       /*
+        * Maximum 512 sector transfer length
+        * broken RA4x00 Compaq Disk Array
+        */
+       if (*bflags & BLIST_MAX_512)
+               blk_queue_max_sectors(sdev->request_queue, 512);
+
        /*
         * Some devices may not want to have a start command automatically
         * issued when a device is added.
@@ -808,6 +815,7 @@ static inline void scsi_destroy_sdev(struct scsi_device *sdev)
        put_device(&sdev->sdev_gendev);
 }
 
+#ifdef CONFIG_SCSI_LOGGING
 /** 
  * scsi_inq_str - print INQUIRY data from min to max index,
  * strip trailing whitespace
@@ -816,12 +824,13 @@ static inline void scsi_destroy_sdev(struct scsi_device *sdev)
  * @first: Offset of string into inq
  * @end:   Index after last character in inq
  */
-static unsigned char* scsi_inq_str(unsigned char* buf, unsigned char *inq,
+static unsigned char *scsi_inq_str(unsigned char *buf, unsigned char *inq,
                                   unsigned first, unsigned end)
 {
        unsigned term = 0, idx;
-       for (idx = 0; idx+first < end && idx+first < inq[4]+5; ++idx) {
-               if (inq[idx+first] > 0x20) {
+
+       for (idx = 0; idx + first < end && idx + first < inq[4] + 5; idx++) {
+               if (inq[idx+first] > ' ') {
                        buf[idx] = inq[idx+first];
                        term = idx+1;
                } else {
@@ -831,6 +840,7 @@ static unsigned char* scsi_inq_str(unsigned char* buf, unsigned char *inq,
        buf[term] = 0;
        return buf;
 }
+#endif
 
 /**
  * scsi_probe_and_add_lun - probe a LUN, if a LUN is found add it
@@ -915,12 +925,16 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
                                   " peripheral qualifier of 3, device not"
                                   " added\n"))
                if (lun == 0) {
-                       unsigned char vend[9], mod[17];
-                       SCSI_LOG_SCAN_BUS(1, sdev_printk(KERN_INFO, sdev,
+                       SCSI_LOG_SCAN_BUS(1, {
+                               unsigned char vend[9];
+                               unsigned char mod[17];
+
+                               sdev_printk(KERN_INFO, sdev,
                                        "scsi scan: consider passing scsi_mod."
                                        "dev_flags=%s:%s:0x240 or 0x800240\n",
                                        scsi_inq_str(vend, result, 8, 16),
-                                       scsi_inq_str(mod, result, 16, 32)));
+                                       scsi_inq_str(mod, result, 16, 32));
+                       });
                }
                
                res = SCSI_SCAN_TARGET_PRESENT;
@@ -1146,10 +1160,13 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
         * Also allow SCSI-2 if BLIST_REPORTLUN2 is set and host adapter does
         * support more than 8 LUNs.
         */
-       if ((bflags & BLIST_NOREPORTLUN) || 
-            starget->scsi_level < SCSI_2 ||
-           (starget->scsi_level < SCSI_3 && 
-            (!(bflags & BLIST_REPORTLUN2) || shost->max_lun <= 8)) )
+       if (bflags & BLIST_NOREPORTLUN)
+               return 1;
+       if (starget->scsi_level < SCSI_2 &&
+           starget->scsi_level != SCSI_UNKNOWN)
+               return 1;
+       if (starget->scsi_level < SCSI_3 &&
+           (!(bflags & BLIST_REPORTLUN2) || shost->max_lun <= 8))
                return 1;
        if (bflags & BLIST_NOLUN)
                return 0;
@@ -1485,7 +1502,7 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
                __FUNCTION__, channel, id, lun));
 
        if (((channel != SCAN_WILD_CARD) && (channel > shost->max_channel)) ||
-           ((id != SCAN_WILD_CARD) && (id > shost->max_id)) ||
+           ((id != SCAN_WILD_CARD) && (id >= shost->max_id)) ||
            ((lun != SCAN_WILD_CARD) && (lun > shost->max_lun)))
                return -EINVAL;