linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / scsi / aic7xxx / aic7xxx_core.c
index 93e4e40..58ac461 100644 (file)
@@ -68,7 +68,7 @@ char *ahc_chip_names[] =
        "aic7892",
        "aic7899"
 };
-static const u_int num_chip_names = ARRAY_SIZE(ahc_chip_names);
+static const u_int num_chip_names = NUM_ELEMENTS(ahc_chip_names);
 
 /*
  * Hardware error codes.
@@ -88,7 +88,7 @@ static struct ahc_hard_error_entry ahc_hard_errors[] = {
        { PCIERRSTAT,   "PCI Error detected" },
        { CIOPARERR,    "CIOBUS Parity Error" },
 };
-static const u_int num_errors = ARRAY_SIZE(ahc_hard_errors);
+static const u_int num_errors = NUM_ELEMENTS(ahc_hard_errors);
 
 static struct ahc_phase_table_entry ahc_phase_table[] =
 {
@@ -108,7 +108,7 @@ static struct ahc_phase_table_entry ahc_phase_table[] =
  * In most cases we only wish to itterate over real phases, so
  * exclude the last element from the count.
  */
-static const u_int num_phases = ARRAY_SIZE(ahc_phase_table) - 1;
+static const u_int num_phases = NUM_ELEMENTS(ahc_phase_table) - 1;
 
 /*
  * Valid SCSIRATE values.  (p. 3-17)
@@ -2461,8 +2461,11 @@ ahc_construct_sdtr(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
 {
        if (offset == 0)
                period = AHC_ASYNC_XFER_PERIOD;
-       ahc->msgout_index += spi_populate_sync_msg(
-                       ahc->msgout_buf + ahc->msgout_index, period, offset);
+       ahc->msgout_buf[ahc->msgout_index++] = MSG_EXTENDED;
+       ahc->msgout_buf[ahc->msgout_index++] = MSG_EXT_SDTR_LEN;
+       ahc->msgout_buf[ahc->msgout_index++] = MSG_EXT_SDTR;
+       ahc->msgout_buf[ahc->msgout_index++] = period;
+       ahc->msgout_buf[ahc->msgout_index++] = offset;
        ahc->msgout_len += 5;
        if (bootverbose) {
                printf("(%s:%c:%d:%d): Sending SDTR period %x, offset %x\n",
@@ -2479,8 +2482,10 @@ static void
 ahc_construct_wdtr(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
                   u_int bus_width)
 {
-       ahc->msgout_index += spi_populate_width_msg(
-                       ahc->msgout_buf + ahc->msgout_index, bus_width);
+       ahc->msgout_buf[ahc->msgout_index++] = MSG_EXTENDED;
+       ahc->msgout_buf[ahc->msgout_index++] = MSG_EXT_WDTR_LEN;
+       ahc->msgout_buf[ahc->msgout_index++] = MSG_EXT_WDTR;
+       ahc->msgout_buf[ahc->msgout_index++] = bus_width;
        ahc->msgout_len += 4;
        if (bootverbose) {
                printf("(%s:%c:%d:%d): Sending WDTR %x\n",
@@ -2500,9 +2505,14 @@ ahc_construct_ppr(struct ahc_softc *ahc, struct ahc_devinfo *devinfo,
 {
        if (offset == 0)
                period = AHC_ASYNC_XFER_PERIOD;
-       ahc->msgout_index += spi_populate_ppr_msg(
-                       ahc->msgout_buf + ahc->msgout_index, period, offset,
-                       bus_width, ppr_options);
+       ahc->msgout_buf[ahc->msgout_index++] = MSG_EXTENDED;
+       ahc->msgout_buf[ahc->msgout_index++] = MSG_EXT_PPR_LEN;
+       ahc->msgout_buf[ahc->msgout_index++] = MSG_EXT_PPR;
+       ahc->msgout_buf[ahc->msgout_index++] = period;
+       ahc->msgout_buf[ahc->msgout_index++] = 0;
+       ahc->msgout_buf[ahc->msgout_index++] = offset;
+       ahc->msgout_buf[ahc->msgout_index++] = bus_width;
+       ahc->msgout_buf[ahc->msgout_index++] = ppr_options;
        ahc->msgout_len += 8;
        if (bootverbose) {
                printf("(%s:%c:%d:%d): Sending PPR bus_width %x, period %x, "
@@ -6367,7 +6377,7 @@ ahc_check_patch(struct ahc_softc *ahc, struct patch **start_patch,
        struct  patch *last_patch;
        u_int   num_patches;
 
-       num_patches = ARRAY_SIZE(patches);
+       num_patches = sizeof(patches)/sizeof(struct patch);
        last_patch = &patches[num_patches];
        cur_patch = *start_patch;
 
@@ -6774,8 +6784,8 @@ ahc_find_tmode_devs(struct ahc_softc *ahc, struct cam_sim *sim, union ccb *ccb,
        } else {
                u_int max_id;
 
-               max_id = (ahc->features & AHC_WIDE) ? 16 : 8;
-               if (ccb->ccb_h.target_id >= max_id)
+               max_id = (ahc->features & AHC_WIDE) ? 15 : 7;
+               if (ccb->ccb_h.target_id > max_id)
                        return (CAM_TID_INVALID);
 
                if (ccb->ccb_h.target_lun >= AHC_NUM_LUNS)