]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/scsi/aic7xxx/aic79xx_proc.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/jejb/scsi-rc-fixes-2.6
[linux-2.6-omap-h63xx.git] / drivers / scsi / aic7xxx / aic79xx_proc.c
index 2058aa9b5c8006f7a77ee6aeda533249be90b88b..39a27840fce66220935fba62116ff44072c92f94 100644 (file)
@@ -53,6 +53,49 @@ static void  ahd_dump_device_state(struct info_str *info,
 static int     ahd_proc_write_seeprom(struct ahd_softc *ahd,
                                       char *buffer, int length);
 
+/*
+ * Table of syncrates that don't follow the "divisible by 4"
+ * rule. This table will be expanded in future SCSI specs.
+ */
+static struct {
+       u_int period_factor;
+       u_int period;   /* in 100ths of ns */
+} scsi_syncrates[] = {
+       { 0x08, 625 },  /* FAST-160 */
+       { 0x09, 1250 }, /* FAST-80 */
+       { 0x0a, 2500 }, /* FAST-40 40MHz */
+       { 0x0b, 3030 }, /* FAST-40 33MHz */
+       { 0x0c, 5000 }  /* FAST-20 */
+};
+
+/*
+ * Return the frequency in kHz corresponding to the given
+ * sync period factor.
+ */
+static u_int
+ahd_calc_syncsrate(u_int period_factor)
+{
+       int i;
+       int num_syncrates;
+
+       num_syncrates = sizeof(scsi_syncrates) / sizeof(scsi_syncrates[0]);
+       /* See if the period is in the "exception" table */
+       for (i = 0; i < num_syncrates; i++) {
+
+               if (period_factor == scsi_syncrates[i].period_factor) {
+                       /* Period in kHz */
+                       return (100000000 / scsi_syncrates[i].period);
+               }
+       }
+
+       /*
+        * Wasn't in the table, so use the standard
+        * 4 times conversion.
+        */
+       return (10000000 / (period_factor * 4 * 10));
+}
+
+
 static void
 copy_mem_info(struct info_str *info, char *data, int len)
 {
@@ -109,7 +152,7 @@ ahd_format_transinfo(struct info_str *info, struct ahd_transinfo *tinfo)
         speed = 3300;
         freq = 0;
        if (tinfo->offset != 0) {
-               freq = aic_calc_syncsrate(tinfo->period);
+               freq = ahd_calc_syncsrate(tinfo->period);
                speed = freq;
        }
        speed *= (0x01 << tinfo->width);
@@ -178,9 +221,9 @@ ahd_dump_target_state(struct ahd_softc *ahd, struct info_str *info,
        copy_info(info, "\tUser: ");
        ahd_format_transinfo(info, &tinfo->user);
        starget = ahd->platform_data->starget[target_offset];
-       targ = scsi_transport_target_data(starget);
-       if (targ == NULL)
+       if (starget == NULL)
                return;
+       targ = scsi_transport_target_data(starget);
 
        copy_info(info, "\tGoal: ");
        ahd_format_transinfo(info, &tinfo->goal);
@@ -285,21 +328,13 @@ int
 ahd_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
                    off_t offset, int length, int inout)
 {
-       struct  ahd_softc *ahd;
+       struct  ahd_softc *ahd = *(struct ahd_softc **)shost->hostdata;
        struct  info_str info;
        char    ahd_info[256];
-       u_long  l;
        u_int   max_targ;
        u_int   i;
        int     retval;
 
-       retval = -EINVAL;
-       ahd_list_lock(&l);
-       ahd = ahd_find_softc(*(struct ahd_softc **)shost->hostdata);
-
-       if (ahd == NULL)
-               goto done;
-
         /* Has data been written to the file? */ 
        if (inout == TRUE) {
                retval = ahd_proc_write_seeprom(ahd, buffer, length);
@@ -349,6 +384,5 @@ ahd_linux_proc_info(struct Scsi_Host *shost, char *buffer, char **start,
        }
        retval = info.pos > info.offset ? info.pos - info.offset : 0;
 done:
-       ahd_list_unlock(&l);
        return (retval);
 }