]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/aic7xxx/aic79xx_core.c
[SCSI] aic79xx: user visible misuse wrong SI units (not disk size!)
[linux-2.6-omap-h63xx.git] / drivers / scsi / aic7xxx / aic79xx_core.c
index 336f4bea251b11763d2822bc8125cda3c45f7571..bdad54ec088cc8d0dd6970c7f1cd9618859c6f6a 100644 (file)
@@ -52,7 +52,7 @@
 
 
 /***************************** Lookup Tables **********************************/
-static char *ahd_chip_names[] =
+static const char *const ahd_chip_names[] =
 {
        "NONE",
        "aic7901",
@@ -66,10 +66,10 @@ static const u_int num_chip_names = ARRAY_SIZE(ahd_chip_names);
  */
 struct ahd_hard_error_entry {
         uint8_t errno;
-       char *errmesg;
+       const char *errmesg;
 };
 
-static struct ahd_hard_error_entry ahd_hard_errors[] = {
+static const struct ahd_hard_error_entry ahd_hard_errors[] = {
        { DSCTMOUT,     "Discard Timer has timed out" },
        { ILLOPCODE,    "Illegal Opcode in sequencer program" },
        { SQPARERR,     "Sequencer Parity Error" },
@@ -79,7 +79,7 @@ static struct ahd_hard_error_entry ahd_hard_errors[] = {
 };
 static const u_int num_errors = ARRAY_SIZE(ahd_hard_errors);
 
-static struct ahd_phase_table_entry ahd_phase_table[] =
+static const struct ahd_phase_table_entry ahd_phase_table[] =
 {
        { P_DATAOUT,    MSG_NOOP,               "in Data-out phase"     },
        { P_DATAIN,     MSG_INITIATOR_DET_ERR,  "in Data-in phase"      },
@@ -213,7 +213,7 @@ static void         ahd_dumpseq(struct ahd_softc *ahd);
 #endif
 static void            ahd_loadseq(struct ahd_softc *ahd);
 static int             ahd_check_patch(struct ahd_softc *ahd,
-                                       struct patch **start_patch,
+                                       const struct patch **start_patch,
                                        u_int start_instr, u_int *skip_addr);
 static u_int           ahd_resolve_seqaddr(struct ahd_softc *ahd,
                                            u_int address);
@@ -254,7 +254,7 @@ 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 const 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,
@@ -266,6 +266,18 @@ static int         ahd_match_scb(struct ahd_softc *ahd, struct scb *scb,
                                      int target, char channel, int lun,
                                      u_int tag, role_t role);
 
+static void            ahd_reset_cmds_pending(struct ahd_softc *ahd);
+
+/*************************** Interrupt Services *******************************/
+static void            ahd_run_qoutfifo(struct ahd_softc *ahd);
+#ifdef AHD_TARGET_MODE
+static void            ahd_run_tqinfifo(struct ahd_softc *ahd, int paused);
+#endif
+static void            ahd_handle_hwerrint(struct ahd_softc *ahd);
+static void            ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat);
+static void            ahd_handle_scsiint(struct ahd_softc *ahd,
+                                          u_int intstat);
+
 /************************ Sequencer Execution Control *************************/
 void
 ahd_set_modes(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
@@ -285,7 +297,7 @@ ahd_set_modes(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
        ahd->dst_mode = dst;
 }
 
-void
+static void
 ahd_update_modes(struct ahd_softc *ahd)
 {
        ahd_mode_state mode_ptr;
@@ -301,7 +313,7 @@ ahd_update_modes(struct ahd_softc *ahd)
        ahd_known_modes(ahd, src, dst);
 }
 
-void
+static void
 ahd_assert_modes(struct ahd_softc *ahd, ahd_mode srcmode,
                 ahd_mode dstmode, const char *file, int line)
 {
@@ -422,7 +434,7 @@ ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb,
        }
 }
 
-void
+static void
 ahd_setup_scb_common(struct ahd_softc *ahd, struct scb *scb)
 {
        /* XXX Handle target mode SCBs. */
@@ -443,7 +455,7 @@ ahd_setup_scb_common(struct ahd_softc *ahd, struct scb *scb)
                    ahd_htole32(scb->sense_busaddr);
 }
 
-void
+static void
 ahd_setup_data_scb(struct ahd_softc *ahd, struct scb *scb)
 {
        /*
@@ -480,7 +492,7 @@ ahd_setup_data_scb(struct ahd_softc *ahd, struct scb *scb)
        scb->hscb->sgptr = ahd_htole32(scb->sg_list_busaddr|SG_FULL_RESID);
 }
 
-void
+static void
 ahd_setup_noxfer_scb(struct ahd_softc *ahd, struct scb *scb)
 {
        scb->hscb->sgptr = ahd_htole32(SG_LIST_NULL);
@@ -489,7 +501,7 @@ ahd_setup_noxfer_scb(struct ahd_softc *ahd, struct scb *scb)
 }
 
 /************************** Memory mapping routines ***************************/
-void *
+static void *
 ahd_sg_bus_to_virt(struct ahd_softc *ahd, struct scb *scb, uint32_t sg_busaddr)
 {
        dma_addr_t sg_offset;
@@ -499,7 +511,7 @@ ahd_sg_bus_to_virt(struct ahd_softc *ahd, struct scb *scb, uint32_t sg_busaddr)
        return ((uint8_t *)scb->sg_list + sg_offset);
 }
 
-uint32_t
+static uint32_t
 ahd_sg_virt_to_bus(struct ahd_softc *ahd, struct scb *scb, void *sg)
 {
        dma_addr_t sg_offset;
@@ -511,7 +523,7 @@ ahd_sg_virt_to_bus(struct ahd_softc *ahd, struct scb *scb, void *sg)
        return (scb->sg_list_busaddr + sg_offset);
 }
 
-void
+static void
 ahd_sync_scb(struct ahd_softc *ahd, struct scb *scb, int op)
 {
        ahd_dmamap_sync(ahd, ahd->scb_data.hscb_dmat,
@@ -532,7 +544,7 @@ ahd_sync_sglist(struct ahd_softc *ahd, struct scb *scb, int op)
                        /*len*/ahd_sg_size(ahd) * scb->sg_count, op);
 }
 
-void
+static void
 ahd_sync_sense(struct ahd_softc *ahd, struct scb *scb, int op)
 {
        ahd_dmamap_sync(ahd, ahd->scb_data.sense_dmat,
@@ -541,12 +553,14 @@ ahd_sync_sense(struct ahd_softc *ahd, struct scb *scb, int op)
                        /*len*/AHD_SENSE_BUFSIZE, op);
 }
 
-uint32_t
+#ifdef AHD_TARGET_MODE
+static uint32_t
 ahd_targetcmd_offset(struct ahd_softc *ahd, u_int index)
 {
        return (((uint8_t *)&ahd->targetcmds[index])
               - (uint8_t *)ahd->qoutfifo);
 }
+#endif
 
 /*********************** Miscelaneous Support Functions ***********************/
 /*
@@ -653,31 +667,35 @@ ahd_set_scbptr(struct ahd_softc *ahd, u_int scbptr)
        ahd_outb(ahd, SCBPTR+1, (scbptr >> 8) & 0xFF);
 }
 
-u_int
+#if 0 /* unused */
+static u_int
 ahd_get_hnscb_qoff(struct ahd_softc *ahd)
 {
        return (ahd_inw_atomic(ahd, HNSCB_QOFF));
 }
+#endif
 
-void
+static void
 ahd_set_hnscb_qoff(struct ahd_softc *ahd, u_int value)
 {
        ahd_outw_atomic(ahd, HNSCB_QOFF, value);
 }
 
-u_int
+#if 0 /* unused */
+static u_int
 ahd_get_hescb_qoff(struct ahd_softc *ahd)
 {
        return (ahd_inb(ahd, HESCB_QOFF));
 }
+#endif
 
-void
+static void
 ahd_set_hescb_qoff(struct ahd_softc *ahd, u_int value)
 {
        ahd_outb(ahd, HESCB_QOFF, value);
 }
 
-u_int
+static u_int
 ahd_get_snscb_qoff(struct ahd_softc *ahd)
 {
        u_int oldvalue;
@@ -688,35 +706,39 @@ ahd_get_snscb_qoff(struct ahd_softc *ahd)
        return (oldvalue);
 }
 
-void
+static void
 ahd_set_snscb_qoff(struct ahd_softc *ahd, u_int value)
 {
        AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
        ahd_outw(ahd, SNSCB_QOFF, value);
 }
 
-u_int
+#if 0 /* unused */
+static u_int
 ahd_get_sescb_qoff(struct ahd_softc *ahd)
 {
        AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
        return (ahd_inb(ahd, SESCB_QOFF));
 }
+#endif
 
-void
+static void
 ahd_set_sescb_qoff(struct ahd_softc *ahd, u_int value)
 {
        AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
        ahd_outb(ahd, SESCB_QOFF, value);
 }
 
-u_int
+#if 0 /* unused */
+static u_int
 ahd_get_sdscb_qoff(struct ahd_softc *ahd)
 {
        AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
        return (ahd_inb(ahd, SDSCB_QOFF) | (ahd_inb(ahd, SDSCB_QOFF + 1) << 8));
 }
+#endif
 
-void
+static void
 ahd_set_sdscb_qoff(struct ahd_softc *ahd, u_int value)
 {
        AHD_ASSERT_MODES(ahd, AHD_MODE_CCHAN_MSK, AHD_MODE_CCHAN_MSK);
@@ -756,14 +778,14 @@ ahd_inw_scbram(struct ahd_softc *ahd, u_int offset)
              | (ahd_inb_scbram(ahd, offset+1) << 8));
 }
 
-uint32_t
+static uint32_t
 ahd_inl_scbram(struct ahd_softc *ahd, u_int offset)
 {
        return (ahd_inw_scbram(ahd, offset)
              | (ahd_inw_scbram(ahd, offset+2) << 16));
 }
 
-uint64_t
+static uint64_t
 ahd_inq_scbram(struct ahd_softc *ahd, u_int offset)
 {
        return (ahd_inl_scbram(ahd, offset)
@@ -784,7 +806,7 @@ ahd_lookup_scb(struct ahd_softc *ahd, u_int tag)
        return (scb);
 }
 
-void
+static void
 ahd_swap_with_next_hscb(struct ahd_softc *ahd, struct scb *scb)
 {
        struct   hardware_scb *q_hscb;
@@ -869,7 +891,7 @@ ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb)
 }
 
 /************************** Interrupt Processing ******************************/
-void
+static void
 ahd_sync_qoutfifo(struct ahd_softc *ahd, int op)
 {
        ahd_dmamap_sync(ahd, ahd->shared_data_dmat, ahd->shared_data_map.dmamap,
@@ -877,7 +899,7 @@ ahd_sync_qoutfifo(struct ahd_softc *ahd, int op)
                        /*len*/AHD_SCB_MAX * sizeof(struct ahd_completion), op);
 }
 
-void
+static void
 ahd_sync_tqinfifo(struct ahd_softc *ahd, int op)
 {
 #ifdef AHD_TARGET_MODE
@@ -897,7 +919,7 @@ ahd_sync_tqinfifo(struct ahd_softc *ahd, int op)
  */
 #define AHD_RUN_QOUTFIFO 0x1
 #define AHD_RUN_TQINFIFO 0x2
-u_int
+static u_int
 ahd_check_cmdcmpltqueues(struct ahd_softc *ahd)
 {
        u_int retval;
@@ -1640,7 +1662,7 @@ clrchn:
  * a copy of the first byte (little endian) of the sgptr
  * hscb field.
  */
-void
+static void
 ahd_run_qoutfifo(struct ahd_softc *ahd)
 {
        struct ahd_completion *completion;
@@ -1679,7 +1701,7 @@ ahd_run_qoutfifo(struct ahd_softc *ahd)
 }
 
 /************************* Interrupt Handling *********************************/
-void
+static void
 ahd_handle_hwerrint(struct ahd_softc *ahd)
 {
        /*
@@ -1753,7 +1775,7 @@ ahd_dump_sglist(struct scb *scb)
 }
 #endif  /*  AHD_DEBUG  */
 
-void
+static void
 ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
 {
        u_int seqintcode;
@@ -2365,7 +2387,7 @@ ahd_handle_seqint(struct ahd_softc *ahd, u_int intstat)
        ahd_unpause(ahd);
 }
 
-void
+static void
 ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat)
 {
        struct scb      *scb;
@@ -2450,8 +2472,6 @@ ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat)
                if ((ahd->bugs & AHD_CLRLQO_AUTOCLR_BUG) != 0)
                        ahd_outb(ahd, CLRLQOINT1, 0);
        } else if ((status & SELTO) != 0) {
-               u_int  scbid;
-
                /* Stop the selection */
                ahd_outb(ahd, SCSISEQ0, 0);
 
@@ -2561,9 +2581,6 @@ ahd_handle_scsiint(struct ahd_softc *ahd, u_int intstat)
                case BUSFREE_DFF0:
                case BUSFREE_DFF1:
                {
-                       u_int   scbid;
-                       struct  scb *scb;
-
                        mode = busfreetime == BUSFREE_DFF0
                             ? AHD_MODE_DFF0 : AHD_MODE_DFF1;
                        ahd_set_modes(ahd, mode, mode);
@@ -3667,7 +3684,7 @@ ahd_free_tstate(struct ahd_softc *ahd, u_int scsi_id, char channel, int force)
  * by the capabilities of the bus connectivity of and sync settings for
  * the target.
  */
-void
+static void
 ahd_devlimited_syncrate(struct ahd_softc *ahd,
                        struct ahd_initiator_tinfo *tinfo,
                        u_int *period, u_int *ppr_options, role_t role)
@@ -4114,7 +4131,7 @@ ahd_update_neg_table(struct ahd_softc *ahd, struct ahd_devinfo *devinfo,
 
                        /*
                         * Harpoon2A assumed that there would be a
-                        * fallback rate between 160MHz and 80Mhz,
+                        * fallback rate between 160MHz and 80MHz,
                         * so 7 is used as the period factor rather
                         * than 8 for 160MHz.
                         */
@@ -4315,11 +4332,11 @@ ahd_print_devinfo(struct ahd_softc *ahd, struct ahd_devinfo *devinfo)
               devinfo->target, devinfo->lun);
 }
 
-static struct ahd_phase_table_entry*
+static const struct ahd_phase_table_entry*
 ahd_lookup_phase_entry(int phase)
 {
-       struct ahd_phase_table_entry *entry;
-       struct ahd_phase_table_entry *last_entry;
+       const struct ahd_phase_table_entry *entry;
+       const struct ahd_phase_table_entry *last_entry;
 
        /*
         * num_phases doesn't include the default entry which
@@ -8131,7 +8148,7 @@ ahd_qinfifo_count(struct ahd_softc *ahd)
                      + ARRAY_SIZE(ahd->qinfifo) - wrap_qinpos);
 }
 
-void
+static void
 ahd_reset_cmds_pending(struct ahd_softc *ahd)
 {
        struct          scb *scb;
@@ -8686,7 +8703,7 @@ ahd_reset_current_bus(struct ahd_softc *ahd)
 int
 ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset)
 {
-       struct  ahd_devinfo devinfo;
+       struct  ahd_devinfo caminfo;
        u_int   initiator;
        u_int   target;
        u_int   max_scsiid;
@@ -8707,7 +8724,7 @@ ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset)
 
        ahd->pending_device = NULL;
 
-       ahd_compile_devinfo(&devinfo,
+       ahd_compile_devinfo(&caminfo,
                            CAM_TARGET_WILDCARD,
                            CAM_TARGET_WILDCARD,
                            CAM_LUN_WILDCARD,
@@ -8846,7 +8863,7 @@ ahd_reset_channel(struct ahd_softc *ahd, char channel, int initiate_reset)
        }
 
        /* Notify the XPT that a bus reset occurred */
-       ahd_send_async(ahd, devinfo.channel, CAM_TARGET_WILDCARD,
+       ahd_send_async(ahd, caminfo.channel, CAM_TARGET_WILDCARD,
                       CAM_LUN_WILDCARD, AC_BUS_RESET);
 
        ahd_restart(ahd);
@@ -9332,7 +9349,7 @@ ahd_loadseq(struct ahd_softc *ahd)
        struct  cs cs_table[num_critical_sections];
        u_int   begin_set[num_critical_sections];
        u_int   end_set[num_critical_sections];
-       struct  patch *cur_patch;
+       const struct patch *cur_patch;
        u_int   cs_count;
        u_int   cur_cs;
        u_int   i;
@@ -9487,11 +9504,11 @@ ahd_loadseq(struct ahd_softc *ahd)
 }
 
 static int
-ahd_check_patch(struct ahd_softc *ahd, struct patch **start_patch,
+ahd_check_patch(struct ahd_softc *ahd, const struct patch **start_patch,
                u_int start_instr, u_int *skip_addr)
 {
-       struct  patch *cur_patch;
-       struct  patch *last_patch;
+       const struct patch *cur_patch;
+       const struct patch *last_patch;
        u_int   num_patches;
 
        num_patches = ARRAY_SIZE(patches);
@@ -9525,7 +9542,7 @@ ahd_check_patch(struct ahd_softc *ahd, struct patch **start_patch,
 static u_int
 ahd_resolve_seqaddr(struct ahd_softc *ahd, u_int address)
 {
-       struct patch *cur_patch;
+       const struct patch *cur_patch;
        int address_offset;
        u_int skip_addr;
        u_int i;
@@ -9656,7 +9673,7 @@ sized:
 }
 
 int
-ahd_print_register(ahd_reg_parse_entry_t *table, u_int num_entries,
+ahd_print_register(const ahd_reg_parse_entry_t *table, u_int num_entries,
                   const char *name, u_int address, u_int value,
                   u_int *cur_column, u_int wrap_point)
 {
@@ -10647,7 +10664,7 @@ ahd_update_scsiid(struct ahd_softc *ahd, u_int targid_mask)
 #endif
 }
 
-void
+static void
 ahd_run_tqinfifo(struct ahd_softc *ahd, int paused)
 {
        struct target_cmd *cmd;