int            ahd_write_seeprom(struct ahd_softc *ahd, uint16_t *buf,
                                  u_int start_addr, u_int count);
-int            ahd_wait_seeprom(struct ahd_softc *ahd);
-int            ahd_verify_vpd_cksum(struct vpd_config *vpd);
 int            ahd_verify_cksum(struct seeprom_config *sc);
 int            ahd_acquire_seeprom(struct ahd_softc *ahd);
 void           ahd_release_seeprom(struct ahd_softc *ahd);
        char                    *name;
        ahd_device_setup_t      *setup;
 };
-extern struct ahd_pci_identity ahd_pci_ident_table [];
-extern const u_int ahd_num_pci_devs;
 
 /***************************** VL/EISA Declarations ***************************/
 struct aic7770_identity {
 /*************************** Function Declarations ****************************/
 /******************************************************************************/
 void                   ahd_reset_cmds_pending(struct ahd_softc *ahd);
-u_int                  ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl);
-void                   ahd_busy_tcl(struct ahd_softc *ahd,
-                                    u_int tcl, u_int busyid);
-static __inline void   ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl);
-static __inline void
-ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl)
-{
-       ahd_busy_tcl(ahd, tcl, SCB_LIST_NULL);
-}
 
 /***************************** PCI Front End *********************************/
 struct ahd_pci_identity *ahd_find_pci_device(ahd_dev_softc_t);
 int    ahd_pci_test_register_access(struct ahd_softc *);
 
 /************************** SCB and SCB queue management **********************/
-int            ahd_probe_scbs(struct ahd_softc *);
 void           ahd_qinfifo_requeue_tail(struct ahd_softc *ahd,
                                         struct scb *scb);
 int            ahd_match_scb(struct ahd_softc *ahd, struct scb *scb,
 int                     ahd_parse_cfgdata(struct ahd_softc *ahd,
                                           struct seeprom_config *sc);
 void                    ahd_intr_enable(struct ahd_softc *ahd, int enable);
-void                    ahd_update_coalescing_values(struct ahd_softc *ahd,
-                                                     u_int timer,
-                                                     u_int maxcmds,
-                                                     u_int mincmds);
-void                    ahd_enable_coalescing(struct ahd_softc *ahd,
-                                              int enable);
 void                    ahd_pause_and_flushwork(struct ahd_softc *ahd);
 int                     ahd_suspend(struct ahd_softc *ahd); 
-int                     ahd_resume(struct ahd_softc *ahd);
 void                    ahd_set_unit(struct ahd_softc *, int);
 void                    ahd_set_name(struct ahd_softc *, char *);
 struct scb             *ahd_get_scb(struct ahd_softc *ahd, u_int col_idx);
 void                    ahd_free_scb(struct ahd_softc *ahd, struct scb *scb);
-void                    ahd_alloc_scbs(struct ahd_softc *ahd);
 void                    ahd_free(struct ahd_softc *ahd);
 int                     ahd_reset(struct ahd_softc *ahd, int reinit);
-void                    ahd_shutdown(void *arg);
 int                     ahd_write_flexport(struct ahd_softc *ahd,
                                            u_int addr, u_int value);
 int                     ahd_read_flexport(struct ahd_softc *ahd, u_int addr,
                                           uint8_t *value);
-int                     ahd_wait_flexport(struct ahd_softc *ahd);
 
 /*************************** Interrupt Services *******************************/
-void                   ahd_pci_intr(struct ahd_softc *ahd);
-void                   ahd_clear_intstat(struct ahd_softc *ahd);
-void                   ahd_flush_qoutfifo(struct ahd_softc *ahd);
 void                   ahd_run_qoutfifo(struct ahd_softc *ahd);
 #ifdef AHD_TARGET_MODE
 void                   ahd_run_tqinfifo(struct ahd_softc *ahd, int paused);
 void                   ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat);
 void                   ahd_handle_scsiint(struct ahd_softc *ahd,
                                           u_int intstat);
-void                   ahd_clear_critical_section(struct ahd_softc *ahd);
 
 /***************************** Error Recovery *********************************/
 typedef enum {
                                             char channel, int lun, u_int tag,
                                             int stop_on_first, int remove,
                                             int save_state);
-void                   ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb);
 int                    ahd_reset_channel(struct ahd_softc *ahd, char channel,
                                          int initiate_reset);
-int                    ahd_abort_scbs(struct ahd_softc *ahd, int target,
-                                      char channel, int lun, u_int tag,
-                                      role_t role, uint32_t status);
-void                   ahd_restart(struct ahd_softc *ahd);
-void                   ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo);
-void                   ahd_handle_scb_status(struct ahd_softc *ahd,
-                                             struct scb *scb);
-void                   ahd_handle_scsi_status(struct ahd_softc *ahd,
-                                              struct scb *scb);
-void                   ahd_calc_residual(struct ahd_softc *ahd,
-                                         struct scb *scb);
 /*************************** Utility Functions ********************************/
-struct ahd_phase_table_entry*
-                       ahd_lookup_phase_entry(int phase);
 void                   ahd_compile_devinfo(struct ahd_devinfo *devinfo,
                                            u_int our_id, u_int target,
                                            u_int lun, char channel,
 /************************** Transfer Negotiation ******************************/
 void                   ahd_find_syncrate(struct ahd_softc *ahd, u_int *period,
                                          u_int *ppr_options, u_int maxsync);
-void                   ahd_validate_offset(struct ahd_softc *ahd,
-                                           struct ahd_initiator_tinfo *tinfo,
-                                           u_int period, u_int *offset,
-                                           int wide, role_t role);
-void                   ahd_validate_width(struct ahd_softc *ahd,
-                                          struct ahd_initiator_tinfo *tinfo,
-                                          u_int *bus_width,
-                                          role_t role);
 /*
  * Negotiation types.  These are used to qualify if we should renegotiate
  * even if our goal and current transport parameters are identical.
 #define AHD_SHOW_INT_COALESCING        0x10000
 #define AHD_DEBUG_SEQUENCER    0x20000
 #endif
-void                   ahd_print_scb(struct scb *scb);
 void                   ahd_print_devinfo(struct ahd_softc *ahd,
                                          struct ahd_devinfo *devinfo);
-void                   ahd_dump_sglist(struct scb *scb);
 void                   ahd_dump_card_state(struct ahd_softc *ahd);
 int                    ahd_print_register(ahd_reg_parse_entry_t *table,
                                           u_int num_entries,
                                           u_int value,
                                           u_int *cur_column,
                                           u_int wrap_point);
-void                   ahd_dump_scbs(struct ahd_softc *ahd);
 #endif /* _AIC79XX_H_ */
 
 
 
 /***************************** Lookup Tables **********************************/
-char *ahd_chip_names[] =
+static char *ahd_chip_names[] =
 {
        "NONE",
        "aic7901",
                                              struct target_cmd *cmd);
 #endif
 
+static int             ahd_abort_scbs(struct ahd_softc *ahd, int target,
+                                      char channel, int lun, u_int tag,
+                                      role_t role, uint32_t status);
+static void            ahd_alloc_scbs(struct ahd_softc *ahd);
+static void            ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl,
+                                    u_int scbid);
+static void            ahd_calc_residual(struct ahd_softc *ahd,
+                                         struct scb *scb);
+static void            ahd_clear_critical_section(struct ahd_softc *ahd);
+static void            ahd_clear_intstat(struct ahd_softc *ahd);
+static void            ahd_enable_coalescing(struct ahd_softc *ahd,
+                                             int enable);
+static u_int           ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl);
+static void            ahd_freeze_devq(struct ahd_softc *ahd,
+                                       struct scb *scb);
+static void            ahd_handle_scb_status(struct ahd_softc *ahd,
+                                             struct scb *scb);
+static struct ahd_phase_table_entry* ahd_lookup_phase_entry(int phase);
+static void            ahd_shutdown(void *arg);
+static void            ahd_update_coalescing_values(struct ahd_softc *ahd,
+                                                    u_int timer,
+                                                    u_int maxcmds,
+                                                    u_int mincmds);
+static int             ahd_verify_vpd_cksum(struct vpd_config *vpd);
+static int             ahd_wait_seeprom(struct ahd_softc *ahd);
+
 /******************************** Private Inlines *****************************/
-static __inline void   ahd_assert_atn(struct ahd_softc *ahd);
-static __inline int    ahd_currently_packetized(struct ahd_softc *ahd);
-static __inline int    ahd_set_active_fifo(struct ahd_softc *ahd);
 
 static __inline void
 ahd_assert_atn(struct ahd_softc *ahd)
        }
 }
 
+static __inline void
+ahd_unbusy_tcl(struct ahd_softc *ahd, u_int tcl)
+{
+       ahd_busy_tcl(ahd, tcl, SCB_LIST_NULL);
+}
+
+/*
+ * Determine whether the sequencer reported a residual
+ * for this SCB/transaction.
+ */
+static __inline void
+ahd_update_residual(struct ahd_softc *ahd, struct scb *scb)
+{
+       uint32_t sgptr;
+
+       sgptr = ahd_le32toh(scb->hscb->sgptr);
+       if ((sgptr & SG_STATUS_VALID) != 0)
+               ahd_calc_residual(ahd, scb);
+}
+
+static __inline void
+ahd_complete_scb(struct ahd_softc *ahd, struct scb *scb)
+{
+       uint32_t sgptr;
+
+       sgptr = ahd_le32toh(scb->hscb->sgptr);
+       if ((sgptr & SG_STATUS_VALID) != 0)
+               ahd_handle_scb_status(ahd, scb);
+       else
+               ahd_done(ahd, scb);
+}
+
+
 /************************* Sequencer Execution Control ************************/
 /*
  * Restart the sequencer program from address zero
  */
-void
+static void
 ahd_restart(struct ahd_softc *ahd)
 {
 
        ahd_unpause(ahd);
 }
 
-void
+static void
 ahd_clear_fifo(struct ahd_softc *ahd, u_int fifo)
 {
        ahd_mode_state   saved_modes;
  * Flush and completed commands that are sitting in the command
  * complete queues down on the chip but have yet to be dma'ed back up.
  */
-void
+static void
 ahd_flush_qoutfifo(struct ahd_softc *ahd)
 {
        struct          scb *scb;
        ahd_free(ahd);
 }
 
+#ifdef AHD_DEBUG
+static void
+ahd_dump_sglist(struct scb *scb)
+{
+       int i;
+
+       if (scb->sg_count > 0) {
+               if ((scb->ahd_softc->flags & AHD_64BIT_ADDRESSING) != 0) {
+                       struct ahd_dma64_seg *sg_list;
+
+                       sg_list = (struct ahd_dma64_seg*)scb->sg_list;
+                       for (i = 0; i < scb->sg_count; i++) {
+                               uint64_t addr;
+                               uint32_t len;
+
+                               addr = ahd_le64toh(sg_list[i].addr);
+                               len = ahd_le32toh(sg_list[i].len);
+                               printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
+                                      i,
+                                      (uint32_t)((addr >> 32) & 0xFFFFFFFF),
+                                      (uint32_t)(addr & 0xFFFFFFFF),
+                                      sg_list[i].len & AHD_SG_LEN_MASK,
+                                      (sg_list[i].len & AHD_DMA_LAST_SEG)
+                                    ? " Last" : "");
+                       }
+               } else {
+                       struct ahd_dma_seg *sg_list;
+
+                       sg_list = (struct ahd_dma_seg*)scb->sg_list;
+                       for (i = 0; i < scb->sg_count; i++) {
+                               uint32_t len;
+
+                               len = ahd_le32toh(sg_list[i].len);
+                               printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
+                                      i,
+                                      (len & AHD_SG_HIGH_ADDR_MASK) >> 24,
+                                      ahd_le32toh(sg_list[i].addr),
+                                      len & AHD_SG_LEN_MASK,
+                                      len & AHD_DMA_LAST_SEG ? " Last" : "");
+                       }
+               }
+       }
+}
+#endif  /*  AHD_DEBUG  */
+
 void
 ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
 {
 }
 
 #define AHD_MAX_STEPS 2000
-void
+static void
 ahd_clear_critical_section(struct ahd_softc *ahd)
 {
        ahd_mode_state  saved_modes;
 /*
  * Clear any pending interrupt status.
  */
-void
+static void
 ahd_clear_intstat(struct ahd_softc *ahd)
 {
        AHD_ASSERT_MODES(ahd, ~(AHD_MODE_UNKNOWN_MSK|AHD_MODE_CFG_MSK),
 #ifdef AHD_DEBUG
 uint32_t ahd_debug = AHD_DEBUG_OPTS;
 #endif
+
+#if 0
 void
 ahd_print_scb(struct scb *scb)
 {
               SCB_GET_TAG(scb));
        ahd_dump_sglist(scb);
 }
-
-void
-ahd_dump_sglist(struct scb *scb)
-{
-       int i;
-
-       if (scb->sg_count > 0) {
-               if ((scb->ahd_softc->flags & AHD_64BIT_ADDRESSING) != 0) {
-                       struct ahd_dma64_seg *sg_list;
-
-                       sg_list = (struct ahd_dma64_seg*)scb->sg_list;
-                       for (i = 0; i < scb->sg_count; i++) {
-                               uint64_t addr;
-                               uint32_t len;
-
-                               addr = ahd_le64toh(sg_list[i].addr);
-                               len = ahd_le32toh(sg_list[i].len);
-                               printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
-                                      i,
-                                      (uint32_t)((addr >> 32) & 0xFFFFFFFF),
-                                      (uint32_t)(addr & 0xFFFFFFFF),
-                                      sg_list[i].len & AHD_SG_LEN_MASK,
-                                      (sg_list[i].len & AHD_DMA_LAST_SEG)
-                                    ? " Last" : "");
-                       }
-               } else {
-                       struct ahd_dma_seg *sg_list;
-
-                       sg_list = (struct ahd_dma_seg*)scb->sg_list;
-                       for (i = 0; i < scb->sg_count; i++) {
-                               uint32_t len;
-
-                               len = ahd_le32toh(sg_list[i].len);
-                               printf("sg[%d] - Addr 0x%x%x : Length %d%s\n",
-                                      i,
-                                      (len & AHD_SG_HIGH_ADDR_MASK) >> 24,
-                                      ahd_le32toh(sg_list[i].addr),
-                                      len & AHD_SG_LEN_MASK,
-                                      len & AHD_DMA_LAST_SEG ? " Last" : "");
-                       }
-               }
-       }
-}
+#endif  /*  0  */
 
 /************************* Transfer Negotiation *******************************/
 /*
  * Truncate the given synchronous offset to a value the
  * current adapter type and syncrate are capable of.
  */
-void
+static void
 ahd_validate_offset(struct ahd_softc *ahd,
                    struct ahd_initiator_tinfo *tinfo,
                    u_int period, u_int *offset, int wide,
  * Truncate the given transfer width parameter to a value the
  * current adapter type is capable of.
  */
-void
+static void
 ahd_validate_width(struct ahd_softc *ahd, struct ahd_initiator_tinfo *tinfo,
                   u_int *bus_width, role_t role)
 {
               devinfo->target, devinfo->lun);
 }
 
-struct ahd_phase_table_entry*
+static struct ahd_phase_table_entry*
 ahd_lookup_phase_entry(int phase)
 {
        struct ahd_phase_table_entry *entry;
        return;
 }
 
-void
+static void
 ahd_shutdown(void *arg)
 {
        struct  ahd_softc *ahd;
 /*
  * Determine the number of SCBs available on the controller
  */
-int
+static int
 ahd_probe_scbs(struct ahd_softc *ahd) {
        int i;
 
        ahd_platform_scb_free(ahd, scb);
 }
 
-void
+static void
 ahd_alloc_scbs(struct ahd_softc *ahd)
 {
        struct scb_data *scb_data;
        ahd_outb(ahd, HCNTRL, hcntrl);
 }
 
-void
+static void
 ahd_update_coalescing_values(struct ahd_softc *ahd, u_int timer, u_int maxcmds,
                             u_int mincmds)
 {
        ahd_outb(ahd, INT_COALESCING_MINCMDS, -mincmds);
 }
 
-void
+static void
 ahd_enable_coalescing(struct ahd_softc *ahd, int enable)
 {
 
        ahd->flags &= ~AHD_ALL_INTERRUPTS;
 }
 
+#if 0
 int
 ahd_suspend(struct ahd_softc *ahd)
 {
        ahd_shutdown(ahd);
        return (0);
 }
+#endif  /*  0  */
 
+#if 0
 int
 ahd_resume(struct ahd_softc *ahd)
 {
        ahd_restart(ahd);
        return (0);
 }
+#endif  /*  0  */
 
 /************************** Busy Target Table *********************************/
 /*
 /*
  * Return the untagged transaction id for a given target/channel lun.
  */
-u_int
+static u_int
 ahd_find_busy_tcl(struct ahd_softc *ahd, u_int tcl)
 {
        u_int scbid;
        return (scbid);
 }
 
-void
+static void
 ahd_busy_tcl(struct ahd_softc *ahd, u_int tcl, u_int scbid)
 {
        u_int scb_offset;
        return match;
 }
 
-void
+static void
 ahd_freeze_devq(struct ahd_softc *ahd, struct scb *scb)
 {
        int     target;
  * been modified from CAM_REQ_INPROG.  This routine assumes that the sequencer
  * is paused before it is called.
  */
-int
+static int
 ahd_abort_scbs(struct ahd_softc *ahd, int target, char channel,
               int lun, u_int tag, role_t role, uint32_t status)
 {
 }
 
 /****************************** Status Processing *****************************/
-void
-ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb)
-{
-       if (scb->hscb->shared_data.istatus.scsi_status != 0) {
-               ahd_handle_scsi_status(ahd, scb);
-       } else {
-               ahd_calc_residual(ahd, scb);
-               ahd_done(ahd, scb);
-       }
-}
 
-void
+static void
 ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)
 {
        struct  hardware_scb *hscb;
        }
 }
 
+static void
+ahd_handle_scb_status(struct ahd_softc *ahd, struct scb *scb)
+{
+       if (scb->hscb->shared_data.istatus.scsi_status != 0) {
+               ahd_handle_scsi_status(ahd, scb);
+       } else {
+               ahd_calc_residual(ahd, scb);
+               ahd_done(ahd, scb);
+       }
+}
+
 /*
  * Calculate the residual for a just completed SCB.
  */
-void
+static void
 ahd_calc_residual(struct ahd_softc *ahd, struct scb *scb)
 {
        struct hardware_scb *hscb;
                ahd_unpause(ahd);
 }
 
+#if 0
 void
 ahd_dump_scbs(struct ahd_softc *ahd)
 {
        ahd_set_scbptr(ahd, saved_scb_index);
        ahd_restore_modes(ahd, saved_modes);
 }
+#endif  /*  0  */
 
 /**************************** Flexport Logic **********************************/
 /*
 /*
  * Wait ~100us for the serial eeprom to satisfy our request.
  */
-int
+static int
 ahd_wait_seeprom(struct ahd_softc *ahd)
 {
        int cnt;
  * Validate the two checksums in the per_channel
  * vital product data struct.
  */
-int
+static int
 ahd_verify_vpd_cksum(struct vpd_config *vpd)
 {
        int i;
        /* Currently a no-op */
 }
 
+/*
+ * Wait at most 2 seconds for flexport arbitration to succeed.
+ */
+static int
+ahd_wait_flexport(struct ahd_softc *ahd)
+{
+       int cnt;
+
+       AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
+       cnt = 1000000 * 2 / 5;
+       while ((ahd_inb(ahd, BRDCTL) & FLXARBACK) == 0 && --cnt)
+               ahd_delay(5);
+
+       if (cnt == 0)
+               return (ETIMEDOUT);
+       return (0);
+}
+
 int
 ahd_write_flexport(struct ahd_softc *ahd, u_int addr, u_int value)
 {
        return (0);
 }
 
-/*
- * Wait at most 2 seconds for flexport arbitration to succeed.
- */
-int
-ahd_wait_flexport(struct ahd_softc *ahd)
-{
-       int cnt;
-
-       AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
-       cnt = 1000000 * 2 / 5;
-       while ((ahd_inb(ahd, BRDCTL) & FLXARBACK) == 0 && --cnt)
-               ahd_delay(5);
-
-       if (cnt == 0)
-               return (ETIMEDOUT);
-       return (0);
-}
-
 /************************* Target Mode ****************************************/
 #ifdef AHD_TARGET_MODE
 cam_status