public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <matthew@wil.cx>
To: linux-scsi@vger.kernel.org
Cc: "Subject:[PATCH 5/5]"@wil.cx, "[SCSI]"@wil.cx, Add@wil.cx,
	PPR@wil.cx, support@wil.cx, to@wil.cx, spi_print_msg@wil.cx,
	Matthew Wilcox <matthew@wil.cx>
Subject: From: Matthew Wilcox <matthew@wil.cx>
Date: Thu, 15 Dec 2005 16:07:32 -0500	[thread overview]
Message-ID: <11346808523044-git-send-email-matthew@wil.cx> (raw)
In-Reply-To: <11346808521924-git-send-email-matthew@wil.cx>

Introduce a new helper, print_nego() to handle SDTR/WDTR/PPR.
Split out the guts of show_spi_transport_period_helper() into period_to_str()
and use it in print_nego to get the period factor conversion right.

Signed-off-by: Matthew Wilcox <matthew@wil.cx>

---

 drivers/scsi/scsi_transport_spi.c |   36 +++++++++++++++++++++++++++++-------
 1 files changed, 29 insertions(+), 7 deletions(-)

550d3fc8c8d8c8d4f660d95fd480c2ab028138a8
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index 380e167..46da6fe 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -379,9 +379,7 @@ static CLASS_DEVICE_ATTR(revalidate, S_I
 
 /* 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 
 		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;
@@ -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"
 };
 
+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 *m
 				(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) 
-- 
0.99.9.GIT


  reply	other threads:[~2005-12-15 21:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-13 16:53 [PATCH] Move scsi_print_msg to SPI code Matthew Wilcox
2005-12-13 18:32 ` Jeff Garzik
2005-12-15 20:58   ` Matthew Wilcox
2005-12-15 21:07     ` From: Matthew Wilcox <matthew@wil.cx> Matthew Wilcox
2005-12-15 21:07       ` Matthew Wilcox
2005-12-15 21:07         ` Matthew Wilcox
2005-12-15 21:07           ` Matthew Wilcox
2005-12-15 21:07             ` Matthew Wilcox [this message]
2005-12-15 21:22     ` [PATCH 4/5] [SCSI] Use ARRAY_SIZE in spi_print_msg Matthew Wilcox
2005-12-15 21:22     ` [PATCH 5/5] [SCSI] Add PPR support to spi_print_msg Matthew Wilcox
2005-12-15 21:22     ` [PATCH 3/5] [SCSI] Fix printing of two-byte messages Matthew Wilcox
2005-12-15 21:22     ` [PATCH 1/5] [SCSI] Move scsi_print_msg to SPI class Matthew Wilcox
2005-12-15 21:22     ` [PATCH 2/5] [SCSI] Rename scsi_print_msg to spi_print_msg Matthew Wilcox
2005-12-15 21:22     ` [PATCH] Move scsi_print_msg to SPI code Matthew Wilcox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11346808523044-git-send-email-matthew@wil.cx \
    --to=matthew@wil.cx \
    --cc="Subject:[PATCH 5/5]"@wil.cx \
    --cc="[SCSI]"@wil.cx \
    --cc=Add@wil.cx \
    --cc=PPR@wil.cx \
    --cc=linux-scsi@vger.kernel.org \
    --cc=spi_print_msg@wil.cx \
    --cc=support@wil.cx \
    --cc=to@wil.cx \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox