aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sym53c8xx_2/sym_hipd.c
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2006-02-07 09:54:46 -0500
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>2006-02-27 23:55:09 -0500
commit6ea3c0b2dac0d6a857d6bc010e544f4c901fff78 (patch)
tree0650d6e8b5be747eb192e558dd90e875ca7a13fb /drivers/scsi/sym53c8xx_2/sym_hipd.c
parentb0dc1db15225d5801bf3105966c9ce12c5142013 (diff)
[SCSI] Add spi_populate_*_msg functions
Introduce new helpers: - spi_populate_width_msg() - spi_populate_sync_msg() - spi_populate_ppr_msg() and use them in drivers which already enable the SPI transport. Signed-off-by: Matthew Wilcox <matthew@wil.cx> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/sym53c8xx_2/sym_hipd.c')
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.c53
1 files changed, 12 insertions, 41 deletions
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c
index f4854c33f48..620b4726fbd 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.c
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c
@@ -40,7 +40,6 @@
40 40
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <asm/param.h> /* for timeouts in units of HZ */ 42#include <asm/param.h> /* for timeouts in units of HZ */
43#include <scsi/scsi_dbg.h>
44 43
45#include "sym_glue.h" 44#include "sym_glue.h"
46#include "sym_nvram.h" 45#include "sym_nvram.h"
@@ -1430,29 +1429,18 @@ static int sym_prepare_nego(struct sym_hcb *np, struct sym_ccb *cp, u_char *msgp
1430 1429
1431 switch (nego) { 1430 switch (nego) {
1432 case NS_SYNC: 1431 case NS_SYNC:
1433 msgptr[msglen++] = M_EXTENDED; 1432 msglen += spi_populate_sync_msg(msgptr + msglen, goal->period,
1434 msgptr[msglen++] = 3; 1433 goal->offset);
1435 msgptr[msglen++] = M_X_SYNC_REQ;
1436 msgptr[msglen++] = goal->period;
1437 msgptr[msglen++] = goal->offset;
1438 break; 1434 break;
1439 case NS_WIDE: 1435 case NS_WIDE:
1440 msgptr[msglen++] = M_EXTENDED; 1436 msglen += spi_populate_width_msg(msgptr + msglen, goal->width);
1441 msgptr[msglen++] = 2;
1442 msgptr[msglen++] = M_X_WIDE_REQ;
1443 msgptr[msglen++] = goal->width;
1444 break; 1437 break;
1445 case NS_PPR: 1438 case NS_PPR:
1446 msgptr[msglen++] = M_EXTENDED; 1439 msglen += spi_populate_ppr_msg(msgptr + msglen, goal->period,
1447 msgptr[msglen++] = 6; 1440 goal->offset, goal->width,
1448 msgptr[msglen++] = M_X_PPR_REQ; 1441 (goal->iu ? PPR_OPT_IU : 0) |
1449 msgptr[msglen++] = goal->period;
1450 msgptr[msglen++] = 0;
1451 msgptr[msglen++] = goal->offset;
1452 msgptr[msglen++] = goal->width;
1453 msgptr[msglen++] = (goal->iu ? PPR_OPT_IU : 0) |
1454 (goal->dt ? PPR_OPT_DT : 0) | 1442 (goal->dt ? PPR_OPT_DT : 0) |
1455 (goal->qas ? PPR_OPT_QAS : 0); 1443 (goal->qas ? PPR_OPT_QAS : 0));
1456 break; 1444 break;
1457 } 1445 }
1458 1446
@@ -3948,11 +3936,7 @@ sym_sync_nego_check(struct sym_hcb *np, int req, struct sym_ccb *cp)
3948 /* 3936 /*
3949 * It was a request. Prepare an answer message. 3937 * It was a request. Prepare an answer message.
3950 */ 3938 */
3951 np->msgout[0] = M_EXTENDED; 3939 spi_populate_sync_msg(np->msgout, per, ofs);
3952 np->msgout[1] = 3;
3953 np->msgout[2] = M_X_SYNC_REQ;
3954 np->msgout[3] = per;
3955 np->msgout[4] = ofs;
3956 3940
3957 if (DEBUG_FLAGS & DEBUG_NEGO) { 3941 if (DEBUG_FLAGS & DEBUG_NEGO) {
3958 sym_print_nego_msg(np, target, "sync msgout", np->msgout); 3942 sym_print_nego_msg(np, target, "sync msgout", np->msgout);
@@ -4078,14 +4062,7 @@ sym_ppr_nego_check(struct sym_hcb *np, int req, int target)
4078 /* 4062 /*
4079 * It was a request. Prepare an answer message. 4063 * It was a request. Prepare an answer message.
4080 */ 4064 */
4081 np->msgout[0] = M_EXTENDED; 4065 spi_populate_ppr_msg(np->msgout, per, ofs, wide, opts);
4082 np->msgout[1] = 6;
4083 np->msgout[2] = M_X_PPR_REQ;
4084 np->msgout[3] = per;
4085 np->msgout[4] = 0;
4086 np->msgout[5] = ofs;
4087 np->msgout[6] = wide;
4088 np->msgout[7] = opts;
4089 4066
4090 if (DEBUG_FLAGS & DEBUG_NEGO) { 4067 if (DEBUG_FLAGS & DEBUG_NEGO) {
4091 sym_print_nego_msg(np, target, "ppr msgout", np->msgout); 4068 sym_print_nego_msg(np, target, "ppr msgout", np->msgout);
@@ -4197,10 +4174,7 @@ sym_wide_nego_check(struct sym_hcb *np, int req, struct sym_ccb *cp)
4197 /* 4174 /*
4198 * It was a request. Prepare an answer message. 4175 * It was a request. Prepare an answer message.
4199 */ 4176 */
4200 np->msgout[0] = M_EXTENDED; 4177 spi_populate_width_msg(np->msgout, wide);
4201 np->msgout[1] = 2;
4202 np->msgout[2] = M_X_WIDE_REQ;
4203 np->msgout[3] = wide;
4204 4178
4205 np->msgin [0] = M_NOOP; 4179 np->msgin [0] = M_NOOP;
4206 4180
@@ -4245,11 +4219,8 @@ static void sym_wide_nego(struct sym_hcb *np, struct sym_tcb *tp, struct sym_ccb
4245 * a single SCSI command (Suggested by Justin Gibbs). 4219 * a single SCSI command (Suggested by Justin Gibbs).
4246 */ 4220 */
4247 if (tp->tgoal.offset) { 4221 if (tp->tgoal.offset) {
4248 np->msgout[0] = M_EXTENDED; 4222 spi_populate_sync_msg(np->msgout, tp->tgoal.period,
4249 np->msgout[1] = 3; 4223 tp->tgoal.offset);
4250 np->msgout[2] = M_X_SYNC_REQ;
4251 np->msgout[3] = tp->tgoal.period;
4252 np->msgout[4] = tp->tgoal.offset;
4253 4224
4254 if (DEBUG_FLAGS & DEBUG_NEGO) { 4225 if (DEBUG_FLAGS & DEBUG_NEGO) {
4255 sym_print_nego_msg(np, cp->target, 4226 sym_print_nego_msg(np, cp->target,