Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq
[pandora-kernel.git] / drivers / scsi / scsi_transport_spi.c
index c87ae46..7670919 100644 (file)
@@ -348,17 +348,21 @@ spi_transport_rd_attr(rd_strm, "%d\n");
 spi_transport_rd_attr(rti, "%d\n");
 spi_transport_rd_attr(pcomp_en, "%d\n");
 
+/* we only care about the first child device so we return 1 */
+static int child_iter(struct device *dev, void *data)
+{
+       struct scsi_device *sdev = to_scsi_device(dev);
+
+       spi_dv_device(sdev);
+       return 1;
+}
+
 static ssize_t
 store_spi_revalidate(struct class_device *cdev, const char *buf, size_t count)
 {
        struct scsi_target *starget = transport_class_to_starget(cdev);
 
-       /* FIXME: we're relying on an awful lot of device internals
-        * here.  We really need a function to get the first available
-        * child */
-       struct device *dev = container_of(starget->dev.children.next, struct device, node);
-       struct scsi_device *sdev = to_scsi_device(dev);
-       spi_dv_device(sdev);
+       device_for_each_child(&starget->dev, NULL, child_iter);
        return count;
 }
 static CLASS_DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate);
@@ -791,7 +795,8 @@ spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer)
        }
 
        /* test width */
-       if (i->f->set_width && spi_max_width(starget) && sdev->wdtr) {
+       if (i->f->set_width && spi_max_width(starget) &&
+           scsi_device_wide(sdev)) {
                i->f->set_width(starget, 1);
 
                if (spi_dv_device_compare_inquiry(sreq, buffer,
@@ -807,14 +812,14 @@ spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer)
                return;
 
        /* device can't handle synchronous */
-       if (!sdev->ppr && !sdev->sdtr)
+       if (!scsi_device_sync(sdev) && !scsi_device_dt(sdev))
                return;
 
        /* see if the device has an echo buffer.  If it does we can
         * do the SPI pattern write tests */
 
        len = 0;
-       if (sdev->ppr)
+       if (scsi_device_dt(sdev))
                len = spi_dv_device_get_echo_buffer(sreq, buffer);
 
  retry:
@@ -824,9 +829,11 @@ spi_dv_device_internal(struct scsi_request *sreq, u8 *buffer)
        DV_SET(period, spi_min_period(starget));
        /* try QAS requests; this should be harmless to set if the
         * target supports it */
-       DV_SET(qas, 1);
+       if (scsi_device_qas(sdev))
+               DV_SET(qas, 1);
        /* Also try IU transfers */
-       DV_SET(iu, 1);
+       if (scsi_device_ius(sdev))
+               DV_SET(iu, 1);
        if (spi_min_period(starget) < 9) {
                /* This u320 (or u640). Ignore the coupled parameters
                 * like DT and IU, but set the optional ones */