]> err.no Git - linux-2.6/blobdiff - drivers/scsi/scsi_transport_spi.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/tmlind/linux-omap-upstream
[linux-2.6] / drivers / scsi / scsi_transport_spi.c
index 380e1671eb18abb82eba53dfdc1c93e5d5785d60..7ee95eb83ddaa52c5fe1aa50a52642b150293eba 100644 (file)
@@ -24,7 +24,7 @@
 #include <linux/module.h>
 #include <linux/workqueue.h>
 #include <linux/blkdev.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
 #include <scsi/scsi.h>
 #include "scsi_priv.h"
 #include <scsi/scsi_device.h>
@@ -48,7 +48,7 @@
 
 /* Private data accessors (keep these out of the header file) */
 #define spi_dv_pending(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_pending)
-#define spi_dv_sem(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_sem)
+#define spi_dv_mutex(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_mutex)
 
 struct spi_internal {
        struct scsi_transport_template t;
@@ -242,7 +242,7 @@ static int spi_setup_transport_attrs(struct transport_container *tc,
        spi_hold_mcs(starget) = 0;
        spi_dv_pending(starget) = 0;
        spi_initial_dv(starget) = 0;
-       init_MUTEX(&spi_dv_sem(starget));
+       mutex_init(&spi_dv_mutex(starget));
 
        return 0;
 }
@@ -379,9 +379,7 @@ static CLASS_DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate);
 
 /* Translate the period into ns according to the current spec
  * for SDTR/PPR messages */
-static ssize_t
-show_spi_transport_period_helper(struct class_device *cdev, char *buf,
-                                int period)
+static int period_to_str(char *buf, int period)
 {
        int len, picosec;
 
@@ -399,6 +397,14 @@ show_spi_transport_period_helper(struct class_device *cdev, char *buf,
                len = sprint_frac(buf, picosec, 1000);
        }
 
+       return len;
+}
+
+static ssize_t
+show_spi_transport_period_helper(struct class_device *cdev, char *buf,
+                                int period)
+{
+       int len = period_to_str(buf, period);
        buf[len++] = '\n';
        buf[len] = '\0';
        return len;
@@ -909,7 +915,7 @@ spi_dv_device(struct scsi_device *sdev)
        scsi_target_quiesce(starget);
 
        spi_dv_pending(starget) = 1;
-       down(&spi_dv_sem(starget));
+       mutex_lock(&spi_dv_mutex(starget));
 
        starget_printk(KERN_INFO, starget, "Beginning Domain Validation\n");
 
@@ -917,7 +923,7 @@ spi_dv_device(struct scsi_device *sdev)
 
        starget_printk(KERN_INFO, starget, "Ending Domain Validation\n");
 
-       up(&spi_dv_sem(starget));
+       mutex_unlock(&spi_dv_mutex(starget));
        spi_dv_pending(starget) = 0;
 
        scsi_target_resume(starget);
@@ -1065,9 +1071,23 @@ static const char * const two_byte_msgs[] = {
 
 static const char * const extended_msgs[] = {
 /* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request",
-/* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request"
+/* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request",
+/* 0x04 */ "Parallel Protocol Request"
 };
 
+static void print_nego(const unsigned char *msg, int per, int off, int width)
+{
+       if (per) {
+               char buf[20];
+               period_to_str(buf, msg[per]);
+               printk("period = %s ns ", buf);
+       }
+
+       if (off)
+               printk("offset = %d ", msg[off]);
+       if (width)
+               printk("width = %d ", 8 << msg[width]);
+}
 
 int spi_print_msg(const unsigned char *msg)
 {
@@ -1085,11 +1105,13 @@ int spi_print_msg(const unsigned char *msg)
                                (msg[4] << 16) | (msg[5] << 8) | msg[6]);
                        break;
                case EXTENDED_SDTR:
-                       printk("period = %d ns, offset = %d",
-                               (int) msg[3] * 4, (int) msg[4]);
+                       print_nego(msg, 3, 4, 0);
                        break;
                case EXTENDED_WDTR:
-                       printk("width = 2^%d bytes", msg[3]);
+                       print_nego(msg, 0, 0, 3);
+                       break;
+               case EXTENDED_PPR:
+                       print_nego(msg, 3, 5, 6);
                        break;
                default:
                for (i = 2; i < len; ++i)