aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/advansys.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/advansys.c')
-rw-r--r--drivers/scsi/advansys.c1164
1 files changed, 327 insertions, 837 deletions
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index dcfaee66a8b9..c67e401954c5 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -2178,22 +2178,6 @@ do { \
2178 2178
2179#define ASC_INFO_SIZE 128 /* advansys_info() line size */ 2179#define ASC_INFO_SIZE 128 /* advansys_info() line size */
2180 2180
2181#ifdef CONFIG_PROC_FS
2182/* /proc/scsi/advansys/[0...] related definitions */
2183#define ASC_PRTBUF_SIZE 2048
2184#define ASC_PRTLINE_SIZE 160
2185
2186#define ASC_PRT_NEXT() \
2187 if (cp) { \
2188 totlen += len; \
2189 leftlen -= len; \
2190 if (leftlen == 0) { \
2191 return totlen; \
2192 } \
2193 cp += len; \
2194 }
2195#endif /* CONFIG_PROC_FS */
2196
2197/* Asc Library return codes */ 2181/* Asc Library return codes */
2198#define ASC_TRUE 1 2182#define ASC_TRUE 1
2199#define ASC_FALSE 0 2183#define ASC_FALSE 0
@@ -2384,7 +2368,6 @@ struct asc_board {
2384 } eep_config; 2368 } eep_config;
2385 ulong last_reset; /* Saved last reset time */ 2369 ulong last_reset; /* Saved last reset time */
2386 /* /proc/scsi/advansys/[0...] */ 2370 /* /proc/scsi/advansys/[0...] */
2387 char *prtbuf; /* /proc print buffer */
2388#ifdef ADVANSYS_STATS 2371#ifdef ADVANSYS_STATS
2389 struct asc_stats asc_stats; /* Board statistics */ 2372 struct asc_stats asc_stats; /* Board statistics */
2390#endif /* ADVANSYS_STATS */ 2373#endif /* ADVANSYS_STATS */
@@ -2875,64 +2858,21 @@ static const char *advansys_info(struct Scsi_Host *shost)
2875} 2858}
2876 2859
2877#ifdef CONFIG_PROC_FS 2860#ifdef CONFIG_PROC_FS
2878/*
2879 * asc_prt_line()
2880 *
2881 * If 'cp' is NULL print to the console, otherwise print to a buffer.
2882 *
2883 * Return 0 if printing to the console, otherwise return the number of
2884 * bytes written to the buffer.
2885 *
2886 * Note: If any single line is greater than ASC_PRTLINE_SIZE bytes the stack
2887 * will be corrupted. 's[]' is defined to be ASC_PRTLINE_SIZE bytes.
2888 */
2889static int asc_prt_line(char *buf, int buflen, char *fmt, ...)
2890{
2891 va_list args;
2892 int ret;
2893 char s[ASC_PRTLINE_SIZE];
2894
2895 va_start(args, fmt);
2896 ret = vsprintf(s, fmt, args);
2897 BUG_ON(ret >= ASC_PRTLINE_SIZE);
2898 if (buf == NULL) {
2899 (void)printk(s);
2900 ret = 0;
2901 } else {
2902 ret = min(buflen, ret);
2903 memcpy(buf, s, ret);
2904 }
2905 va_end(args);
2906 return ret;
2907}
2908 2861
2909/* 2862/*
2910 * asc_prt_board_devices() 2863 * asc_prt_board_devices()
2911 * 2864 *
2912 * Print driver information for devices attached to the board. 2865 * Print driver information for devices attached to the board.
2913 *
2914 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
2915 * cf. asc_prt_line().
2916 *
2917 * Return the number of characters copied into 'cp'. No more than
2918 * 'cplen' characters will be copied to 'cp'.
2919 */ 2866 */
2920static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen) 2867static void asc_prt_board_devices(struct seq_file *m, struct Scsi_Host *shost)
2921{ 2868{
2922 struct asc_board *boardp = shost_priv(shost); 2869 struct asc_board *boardp = shost_priv(shost);
2923 int leftlen;
2924 int totlen;
2925 int len;
2926 int chip_scsi_id; 2870 int chip_scsi_id;
2927 int i; 2871 int i;
2928 2872
2929 leftlen = cplen; 2873 seq_printf(m,
2930 totlen = len = 0; 2874 "\nDevice Information for AdvanSys SCSI Host %d:\n",
2931 2875 shost->host_no);
2932 len = asc_prt_line(cp, leftlen,
2933 "\nDevice Information for AdvanSys SCSI Host %d:\n",
2934 shost->host_no);
2935 ASC_PRT_NEXT();
2936 2876
2937 if (ASC_NARROW_BOARD(boardp)) { 2877 if (ASC_NARROW_BOARD(boardp)) {
2938 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id; 2878 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
@@ -2940,60 +2880,42 @@ static int asc_prt_board_devices(struct Scsi_Host *shost, char *cp, int cplen)
2940 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id; 2880 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
2941 } 2881 }
2942 2882
2943 len = asc_prt_line(cp, leftlen, "Target IDs Detected:"); 2883 seq_printf(m, "Target IDs Detected:");
2944 ASC_PRT_NEXT();
2945 for (i = 0; i <= ADV_MAX_TID; i++) { 2884 for (i = 0; i <= ADV_MAX_TID; i++) {
2946 if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) { 2885 if (boardp->init_tidmask & ADV_TID_TO_TIDMASK(i))
2947 len = asc_prt_line(cp, leftlen, " %X,", i); 2886 seq_printf(m, " %X,", i);
2948 ASC_PRT_NEXT();
2949 }
2950 } 2887 }
2951 len = asc_prt_line(cp, leftlen, " (%X=Host Adapter)\n", chip_scsi_id); 2888 seq_printf(m, " (%X=Host Adapter)\n", chip_scsi_id);
2952 ASC_PRT_NEXT();
2953
2954 return totlen;
2955} 2889}
2956 2890
2957/* 2891/*
2958 * Display Wide Board BIOS Information. 2892 * Display Wide Board BIOS Information.
2959 */ 2893 */
2960static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen) 2894static void asc_prt_adv_bios(struct seq_file *m, struct Scsi_Host *shost)
2961{ 2895{
2962 struct asc_board *boardp = shost_priv(shost); 2896 struct asc_board *boardp = shost_priv(shost);
2963 int leftlen;
2964 int totlen;
2965 int len;
2966 ushort major, minor, letter; 2897 ushort major, minor, letter;
2967 2898
2968 leftlen = cplen; 2899 seq_printf(m, "\nROM BIOS Version: ");
2969 totlen = len = 0;
2970
2971 len = asc_prt_line(cp, leftlen, "\nROM BIOS Version: ");
2972 ASC_PRT_NEXT();
2973 2900
2974 /* 2901 /*
2975 * If the BIOS saved a valid signature, then fill in 2902 * If the BIOS saved a valid signature, then fill in
2976 * the BIOS code segment base address. 2903 * the BIOS code segment base address.
2977 */ 2904 */
2978 if (boardp->bios_signature != 0x55AA) { 2905 if (boardp->bios_signature != 0x55AA) {
2979 len = asc_prt_line(cp, leftlen, "Disabled or Pre-3.1\n"); 2906 seq_printf(m, "Disabled or Pre-3.1\n");
2980 ASC_PRT_NEXT(); 2907 seq_printf(m,
2981 len = asc_prt_line(cp, leftlen, 2908 "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n");
2982 "BIOS either disabled or Pre-3.1. If it is pre-3.1, then a newer version\n"); 2909 seq_printf(m,
2983 ASC_PRT_NEXT(); 2910 "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
2984 len = asc_prt_line(cp, leftlen,
2985 "can be found at the ConnectCom FTP site: ftp://ftp.connectcom.net/pub\n");
2986 ASC_PRT_NEXT();
2987 } else { 2911 } else {
2988 major = (boardp->bios_version >> 12) & 0xF; 2912 major = (boardp->bios_version >> 12) & 0xF;
2989 minor = (boardp->bios_version >> 8) & 0xF; 2913 minor = (boardp->bios_version >> 8) & 0xF;
2990 letter = (boardp->bios_version & 0xFF); 2914 letter = (boardp->bios_version & 0xFF);
2991 2915
2992 len = asc_prt_line(cp, leftlen, "%d.%d%c\n", 2916 seq_printf(m, "%d.%d%c\n",
2993 major, minor, 2917 major, minor,
2994 letter >= 26 ? '?' : letter + 'A'); 2918 letter >= 26 ? '?' : letter + 'A');
2995 ASC_PRT_NEXT();
2996
2997 /* 2919 /*
2998 * Current available ROM BIOS release is 3.1I for UW 2920 * Current available ROM BIOS release is 3.1I for UW
2999 * and 3.2I for U2W. This code doesn't differentiate 2921 * and 3.2I for U2W. This code doesn't differentiate
@@ -3001,16 +2923,12 @@ static int asc_prt_adv_bios(struct Scsi_Host *shost, char *cp, int cplen)
3001 */ 2923 */
3002 if (major < 3 || (major <= 3 && minor < 1) || 2924 if (major < 3 || (major <= 3 && minor < 1) ||
3003 (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) { 2925 (major <= 3 && minor <= 1 && letter < ('I' - 'A'))) {
3004 len = asc_prt_line(cp, leftlen, 2926 seq_printf(m,
3005 "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n"); 2927 "Newer version of ROM BIOS is available at the ConnectCom FTP site:\n");
3006 ASC_PRT_NEXT(); 2928 seq_printf(m,
3007 len = asc_prt_line(cp, leftlen, 2929 "ftp://ftp.connectcom.net/pub\n");
3008 "ftp://ftp.connectcom.net/pub\n");
3009 ASC_PRT_NEXT();
3010 } 2930 }
3011 } 2931 }
3012
3013 return totlen;
3014} 2932}
3015 2933
3016/* 2934/*
@@ -3115,20 +3033,11 @@ static int asc_get_eeprom_string(ushort *serialnum, uchar *cp)
3115 * asc_prt_asc_board_eeprom() 3033 * asc_prt_asc_board_eeprom()
3116 * 3034 *
3117 * Print board EEPROM configuration. 3035 * Print board EEPROM configuration.
3118 *
3119 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3120 * cf. asc_prt_line().
3121 *
3122 * Return the number of characters copied into 'cp'. No more than
3123 * 'cplen' characters will be copied to 'cp'.
3124 */ 3036 */
3125static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen) 3037static void asc_prt_asc_board_eeprom(struct seq_file *m, struct Scsi_Host *shost)
3126{ 3038{
3127 struct asc_board *boardp = shost_priv(shost); 3039 struct asc_board *boardp = shost_priv(shost);
3128 ASC_DVC_VAR *asc_dvc_varp; 3040 ASC_DVC_VAR *asc_dvc_varp;
3129 int leftlen;
3130 int totlen;
3131 int len;
3132 ASCEEP_CONFIG *ep; 3041 ASCEEP_CONFIG *ep;
3133 int i; 3042 int i;
3134#ifdef CONFIG_ISA 3043#ifdef CONFIG_ISA
@@ -3139,129 +3048,75 @@ static int asc_prt_asc_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
3139 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var; 3048 asc_dvc_varp = &boardp->dvc_var.asc_dvc_var;
3140 ep = &boardp->eep_config.asc_eep; 3049 ep = &boardp->eep_config.asc_eep;
3141 3050
3142 leftlen = cplen; 3051 seq_printf(m,
3143 totlen = len = 0; 3052 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
3144 3053 shost->host_no);
3145 len = asc_prt_line(cp, leftlen,
3146 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
3147 shost->host_no);
3148 ASC_PRT_NEXT();
3149 3054
3150 if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr) 3055 if (asc_get_eeprom_string((ushort *)&ep->adapter_info[0], serialstr)
3151 == ASC_TRUE) { 3056 == ASC_TRUE)
3152 len = 3057 seq_printf(m, " Serial Number: %s\n", serialstr);
3153 asc_prt_line(cp, leftlen, " Serial Number: %s\n", 3058 else if (ep->adapter_info[5] == 0xBB)
3154 serialstr); 3059 seq_printf(m,
3155 ASC_PRT_NEXT(); 3060 " Default Settings Used for EEPROM-less Adapter.\n");
3156 } else { 3061 else
3157 if (ep->adapter_info[5] == 0xBB) { 3062 seq_printf(m,
3158 len = asc_prt_line(cp, leftlen, 3063 " Serial Number Signature Not Present.\n");
3159 " Default Settings Used for EEPROM-less Adapter.\n"); 3064
3160 ASC_PRT_NEXT(); 3065 seq_printf(m,
3161 } else { 3066 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3162 len = asc_prt_line(cp, leftlen, 3067 ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng,
3163 " Serial Number Signature Not Present.\n"); 3068 ep->max_tag_qng);
3164 ASC_PRT_NEXT(); 3069
3165 } 3070 seq_printf(m,
3166 } 3071 " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam);
3167 3072
3168 len = asc_prt_line(cp, leftlen, 3073 seq_printf(m, " Target ID: ");
3169 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n", 3074 for (i = 0; i <= ASC_MAX_TID; i++)
3170 ASC_EEP_GET_CHIP_ID(ep), ep->max_total_qng, 3075 seq_printf(m, " %d", i);
3171 ep->max_tag_qng); 3076 seq_printf(m, "\n");
3172 ASC_PRT_NEXT(); 3077
3173 3078 seq_printf(m, " Disconnects: ");
3174 len = asc_prt_line(cp, leftlen, 3079 for (i = 0; i <= ASC_MAX_TID; i++)
3175 " cntl 0x%x, no_scam 0x%x\n", ep->cntl, ep->no_scam); 3080 seq_printf(m, " %c",
3176 ASC_PRT_NEXT(); 3081 (ep->disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3177 3082 seq_printf(m, "\n");
3178 len = asc_prt_line(cp, leftlen, " Target ID: "); 3083
3179 ASC_PRT_NEXT(); 3084 seq_printf(m, " Command Queuing: ");
3180 for (i = 0; i <= ASC_MAX_TID; i++) { 3085 for (i = 0; i <= ASC_MAX_TID; i++)
3181 len = asc_prt_line(cp, leftlen, " %d", i); 3086 seq_printf(m, " %c",
3182 ASC_PRT_NEXT(); 3087 (ep->use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3183 } 3088 seq_printf(m, "\n");
3184 len = asc_prt_line(cp, leftlen, "\n"); 3089
3185 ASC_PRT_NEXT(); 3090 seq_printf(m, " Start Motor: ");
3186 3091 for (i = 0; i <= ASC_MAX_TID; i++)
3187 len = asc_prt_line(cp, leftlen, " Disconnects: "); 3092 seq_printf(m, " %c",
3188 ASC_PRT_NEXT(); 3093 (ep->start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3189 for (i = 0; i <= ASC_MAX_TID; i++) { 3094 seq_printf(m, "\n");
3190 len = asc_prt_line(cp, leftlen, " %c", 3095
3191 (ep-> 3096 seq_printf(m, " Synchronous Transfer:");
3192 disc_enable & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 3097 for (i = 0; i <= ASC_MAX_TID; i++)
3193 'N'); 3098 seq_printf(m, " %c",
3194 ASC_PRT_NEXT(); 3099 (ep->init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3195 } 3100 seq_printf(m, "\n");
3196 len = asc_prt_line(cp, leftlen, "\n");
3197 ASC_PRT_NEXT();
3198
3199 len = asc_prt_line(cp, leftlen, " Command Queuing: ");
3200 ASC_PRT_NEXT();
3201 for (i = 0; i <= ASC_MAX_TID; i++) {
3202 len = asc_prt_line(cp, leftlen, " %c",
3203 (ep->
3204 use_cmd_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3205 'N');
3206 ASC_PRT_NEXT();
3207 }
3208 len = asc_prt_line(cp, leftlen, "\n");
3209 ASC_PRT_NEXT();
3210
3211 len = asc_prt_line(cp, leftlen, " Start Motor: ");
3212 ASC_PRT_NEXT();
3213 for (i = 0; i <= ASC_MAX_TID; i++) {
3214 len = asc_prt_line(cp, leftlen, " %c",
3215 (ep->
3216 start_motor & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3217 'N');
3218 ASC_PRT_NEXT();
3219 }
3220 len = asc_prt_line(cp, leftlen, "\n");
3221 ASC_PRT_NEXT();
3222
3223 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:");
3224 ASC_PRT_NEXT();
3225 for (i = 0; i <= ASC_MAX_TID; i++) {
3226 len = asc_prt_line(cp, leftlen, " %c",
3227 (ep->
3228 init_sdtr & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3229 'N');
3230 ASC_PRT_NEXT();
3231 }
3232 len = asc_prt_line(cp, leftlen, "\n");
3233 ASC_PRT_NEXT();
3234 3101
3235#ifdef CONFIG_ISA 3102#ifdef CONFIG_ISA
3236 if (asc_dvc_varp->bus_type & ASC_IS_ISA) { 3103 if (asc_dvc_varp->bus_type & ASC_IS_ISA) {
3237 len = asc_prt_line(cp, leftlen, 3104 seq_printf(m,
3238 " Host ISA DMA speed: %d MB/S\n", 3105 " Host ISA DMA speed: %d MB/S\n",
3239 isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]); 3106 isa_dma_speed[ASC_EEP_GET_DMA_SPD(ep)]);
3240 ASC_PRT_NEXT();
3241 } 3107 }
3242#endif /* CONFIG_ISA */ 3108#endif /* CONFIG_ISA */
3243
3244 return totlen;
3245} 3109}
3246 3110
3247/* 3111/*
3248 * asc_prt_adv_board_eeprom() 3112 * asc_prt_adv_board_eeprom()
3249 * 3113 *
3250 * Print board EEPROM configuration. 3114 * Print board EEPROM configuration.
3251 *
3252 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3253 * cf. asc_prt_line().
3254 *
3255 * Return the number of characters copied into 'cp'. No more than
3256 * 'cplen' characters will be copied to 'cp'.
3257 */ 3115 */
3258static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen) 3116static void asc_prt_adv_board_eeprom(struct seq_file *m, struct Scsi_Host *shost)
3259{ 3117{
3260 struct asc_board *boardp = shost_priv(shost); 3118 struct asc_board *boardp = shost_priv(shost);
3261 ADV_DVC_VAR *adv_dvc_varp; 3119 ADV_DVC_VAR *adv_dvc_varp;
3262 int leftlen;
3263 int totlen;
3264 int len;
3265 int i; 3120 int i;
3266 char *termstr; 3121 char *termstr;
3267 uchar serialstr[13]; 3122 uchar serialstr[13];
@@ -3281,13 +3136,9 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
3281 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep; 3136 ep_38C1600 = &boardp->eep_config.adv_38C1600_eep;
3282 } 3137 }
3283 3138
3284 leftlen = cplen; 3139 seq_printf(m,
3285 totlen = len = 0; 3140 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
3286 3141 shost->host_no);
3287 len = asc_prt_line(cp, leftlen,
3288 "\nEEPROM Settings for AdvanSys SCSI Host %d:\n",
3289 shost->host_no);
3290 ASC_PRT_NEXT();
3291 3142
3292 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3143 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3293 wordp = &ep_3550->serial_number_word1; 3144 wordp = &ep_3550->serial_number_word1;
@@ -3297,38 +3148,28 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
3297 wordp = &ep_38C1600->serial_number_word1; 3148 wordp = &ep_38C1600->serial_number_word1;
3298 } 3149 }
3299 3150
3300 if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE) { 3151 if (asc_get_eeprom_string(wordp, serialstr) == ASC_TRUE)
3301 len = 3152 seq_printf(m, " Serial Number: %s\n", serialstr);
3302 asc_prt_line(cp, leftlen, " Serial Number: %s\n", 3153 else
3303 serialstr); 3154 seq_printf(m, " Serial Number Signature Not Present.\n");
3304 ASC_PRT_NEXT();
3305 } else {
3306 len = asc_prt_line(cp, leftlen,
3307 " Serial Number Signature Not Present.\n");
3308 ASC_PRT_NEXT();
3309 }
3310 3155
3311 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3156 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
3312 len = asc_prt_line(cp, leftlen, 3157 seq_printf(m,
3313 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n", 3158 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3314 ep_3550->adapter_scsi_id, 3159 ep_3550->adapter_scsi_id,
3315 ep_3550->max_host_qng, ep_3550->max_dvc_qng); 3160 ep_3550->max_host_qng, ep_3550->max_dvc_qng);
3316 ASC_PRT_NEXT(); 3161 else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
3317 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) { 3162 seq_printf(m,
3318 len = asc_prt_line(cp, leftlen, 3163 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3319 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n", 3164 ep_38C0800->adapter_scsi_id,
3320 ep_38C0800->adapter_scsi_id, 3165 ep_38C0800->max_host_qng,
3321 ep_38C0800->max_host_qng, 3166 ep_38C0800->max_dvc_qng);
3322 ep_38C0800->max_dvc_qng); 3167 else
3323 ASC_PRT_NEXT(); 3168 seq_printf(m,
3324 } else { 3169 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n",
3325 len = asc_prt_line(cp, leftlen, 3170 ep_38C1600->adapter_scsi_id,
3326 " Host SCSI ID: %u, Host Queue Size: %u, Device Queue Size: %u\n", 3171 ep_38C1600->max_host_qng,
3327 ep_38C1600->adapter_scsi_id, 3172 ep_38C1600->max_dvc_qng);
3328 ep_38C1600->max_host_qng,
3329 ep_38C1600->max_dvc_qng);
3330 ASC_PRT_NEXT();
3331 }
3332 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3173 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3333 word = ep_3550->termination; 3174 word = ep_3550->termination;
3334 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) { 3175 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) {
@@ -3352,34 +3193,26 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
3352 break; 3193 break;
3353 } 3194 }
3354 3195
3355 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3196 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550)
3356 len = asc_prt_line(cp, leftlen, 3197 seq_printf(m,
3357 " termination: %u (%s), bios_ctrl: 0x%x\n", 3198 " termination: %u (%s), bios_ctrl: 0x%x\n",
3358 ep_3550->termination, termstr, 3199 ep_3550->termination, termstr,
3359 ep_3550->bios_ctrl); 3200 ep_3550->bios_ctrl);
3360 ASC_PRT_NEXT(); 3201 else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800)
3361 } else if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800) { 3202 seq_printf(m,
3362 len = asc_prt_line(cp, leftlen, 3203 " termination: %u (%s), bios_ctrl: 0x%x\n",
3363 " termination: %u (%s), bios_ctrl: 0x%x\n", 3204 ep_38C0800->termination_lvd, termstr,
3364 ep_38C0800->termination_lvd, termstr, 3205 ep_38C0800->bios_ctrl);
3365 ep_38C0800->bios_ctrl); 3206 else
3366 ASC_PRT_NEXT(); 3207 seq_printf(m,
3367 } else { 3208 " termination: %u (%s), bios_ctrl: 0x%x\n",
3368 len = asc_prt_line(cp, leftlen, 3209 ep_38C1600->termination_lvd, termstr,
3369 " termination: %u (%s), bios_ctrl: 0x%x\n", 3210 ep_38C1600->bios_ctrl);
3370 ep_38C1600->termination_lvd, termstr,
3371 ep_38C1600->bios_ctrl);
3372 ASC_PRT_NEXT();
3373 }
3374 3211
3375 len = asc_prt_line(cp, leftlen, " Target ID: "); 3212 seq_printf(m, " Target ID: ");
3376 ASC_PRT_NEXT(); 3213 for (i = 0; i <= ADV_MAX_TID; i++)
3377 for (i = 0; i <= ADV_MAX_TID; i++) { 3214 seq_printf(m, " %X", i);
3378 len = asc_prt_line(cp, leftlen, " %X", i); 3215 seq_printf(m, "\n");
3379 ASC_PRT_NEXT();
3380 }
3381 len = asc_prt_line(cp, leftlen, "\n");
3382 ASC_PRT_NEXT();
3383 3216
3384 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3217 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3385 word = ep_3550->disc_enable; 3218 word = ep_3550->disc_enable;
@@ -3388,15 +3221,11 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
3388 } else { 3221 } else {
3389 word = ep_38C1600->disc_enable; 3222 word = ep_38C1600->disc_enable;
3390 } 3223 }
3391 len = asc_prt_line(cp, leftlen, " Disconnects: "); 3224 seq_printf(m, " Disconnects: ");
3392 ASC_PRT_NEXT(); 3225 for (i = 0; i <= ADV_MAX_TID; i++)
3393 for (i = 0; i <= ADV_MAX_TID; i++) { 3226 seq_printf(m, " %c",
3394 len = asc_prt_line(cp, leftlen, " %c", 3227 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3395 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 3228 seq_printf(m, "\n");
3396 ASC_PRT_NEXT();
3397 }
3398 len = asc_prt_line(cp, leftlen, "\n");
3399 ASC_PRT_NEXT();
3400 3229
3401 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3230 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3402 word = ep_3550->tagqng_able; 3231 word = ep_3550->tagqng_able;
@@ -3405,15 +3234,11 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
3405 } else { 3234 } else {
3406 word = ep_38C1600->tagqng_able; 3235 word = ep_38C1600->tagqng_able;
3407 } 3236 }
3408 len = asc_prt_line(cp, leftlen, " Command Queuing: "); 3237 seq_printf(m, " Command Queuing: ");
3409 ASC_PRT_NEXT(); 3238 for (i = 0; i <= ADV_MAX_TID; i++)
3410 for (i = 0; i <= ADV_MAX_TID; i++) { 3239 seq_printf(m, " %c",
3411 len = asc_prt_line(cp, leftlen, " %c", 3240 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3412 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 3241 seq_printf(m, "\n");
3413 ASC_PRT_NEXT();
3414 }
3415 len = asc_prt_line(cp, leftlen, "\n");
3416 ASC_PRT_NEXT();
3417 3242
3418 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3243 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3419 word = ep_3550->start_motor; 3244 word = ep_3550->start_motor;
@@ -3422,42 +3247,28 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
3422 } else { 3247 } else {
3423 word = ep_38C1600->start_motor; 3248 word = ep_38C1600->start_motor;
3424 } 3249 }
3425 len = asc_prt_line(cp, leftlen, " Start Motor: "); 3250 seq_printf(m, " Start Motor: ");
3426 ASC_PRT_NEXT(); 3251 for (i = 0; i <= ADV_MAX_TID; i++)
3427 for (i = 0; i <= ADV_MAX_TID; i++) { 3252 seq_printf(m, " %c",
3428 len = asc_prt_line(cp, leftlen, " %c", 3253 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3429 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 3254 seq_printf(m, "\n");
3430 ASC_PRT_NEXT();
3431 }
3432 len = asc_prt_line(cp, leftlen, "\n");
3433 ASC_PRT_NEXT();
3434 3255
3435 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3256 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3436 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:"); 3257 seq_printf(m, " Synchronous Transfer:");
3437 ASC_PRT_NEXT(); 3258 for (i = 0; i <= ADV_MAX_TID; i++)
3438 for (i = 0; i <= ADV_MAX_TID; i++) { 3259 seq_printf(m, " %c",
3439 len = asc_prt_line(cp, leftlen, " %c", 3260 (ep_3550->sdtr_able & ADV_TID_TO_TIDMASK(i)) ?
3440 (ep_3550-> 3261 'Y' : 'N');
3441 sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 3262 seq_printf(m, "\n");
3442 'Y' : 'N');
3443 ASC_PRT_NEXT();
3444 }
3445 len = asc_prt_line(cp, leftlen, "\n");
3446 ASC_PRT_NEXT();
3447 } 3263 }
3448 3264
3449 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3265 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
3450 len = asc_prt_line(cp, leftlen, " Ultra Transfer: "); 3266 seq_printf(m, " Ultra Transfer: ");
3451 ASC_PRT_NEXT(); 3267 for (i = 0; i <= ADV_MAX_TID; i++)
3452 for (i = 0; i <= ADV_MAX_TID; i++) { 3268 seq_printf(m, " %c",
3453 len = asc_prt_line(cp, leftlen, " %c", 3269 (ep_3550->ultra_able & ADV_TID_TO_TIDMASK(i))
3454 (ep_3550-> 3270 ? 'Y' : 'N');
3455 ultra_able & ADV_TID_TO_TIDMASK(i)) 3271 seq_printf(m, "\n");
3456 ? 'Y' : 'N');
3457 ASC_PRT_NEXT();
3458 }
3459 len = asc_prt_line(cp, leftlen, "\n");
3460 ASC_PRT_NEXT();
3461 } 3272 }
3462 3273
3463 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) { 3274 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC3550) {
@@ -3467,21 +3278,16 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
3467 } else { 3278 } else {
3468 word = ep_38C1600->wdtr_able; 3279 word = ep_38C1600->wdtr_able;
3469 } 3280 }
3470 len = asc_prt_line(cp, leftlen, " Wide Transfer: "); 3281 seq_printf(m, " Wide Transfer: ");
3471 ASC_PRT_NEXT(); 3282 for (i = 0; i <= ADV_MAX_TID; i++)
3472 for (i = 0; i <= ADV_MAX_TID; i++) { 3283 seq_printf(m, " %c",
3473 len = asc_prt_line(cp, leftlen, " %c", 3284 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3474 (word & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N'); 3285 seq_printf(m, "\n");
3475 ASC_PRT_NEXT();
3476 }
3477 len = asc_prt_line(cp, leftlen, "\n");
3478 ASC_PRT_NEXT();
3479 3286
3480 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 || 3287 if (adv_dvc_varp->chip_type == ADV_CHIP_ASC38C0800 ||
3481 adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) { 3288 adv_dvc_varp->chip_type == ADV_CHIP_ASC38C1600) {
3482 len = asc_prt_line(cp, leftlen, 3289 seq_printf(m,
3483 " Synchronous Transfer Speed (Mhz):\n "); 3290 " Synchronous Transfer Speed (Mhz):\n ");
3484 ASC_PRT_NEXT();
3485 for (i = 0; i <= ADV_MAX_TID; i++) { 3291 for (i = 0; i <= ADV_MAX_TID; i++) {
3486 char *speed_str; 3292 char *speed_str;
3487 3293
@@ -3517,99 +3323,64 @@ static int asc_prt_adv_board_eeprom(struct Scsi_Host *shost, char *cp, int cplen
3517 speed_str = "Unk"; 3323 speed_str = "Unk";
3518 break; 3324 break;
3519 } 3325 }
3520 len = asc_prt_line(cp, leftlen, "%X:%s ", i, speed_str); 3326 seq_printf(m, "%X:%s ", i, speed_str);
3521 ASC_PRT_NEXT(); 3327 if (i == 7)
3522 if (i == 7) { 3328 seq_printf(m, "\n ");
3523 len = asc_prt_line(cp, leftlen, "\n ");
3524 ASC_PRT_NEXT();
3525 }
3526 sdtr_speed >>= 4; 3329 sdtr_speed >>= 4;
3527 } 3330 }
3528 len = asc_prt_line(cp, leftlen, "\n"); 3331 seq_printf(m, "\n");
3529 ASC_PRT_NEXT();
3530 } 3332 }
3531
3532 return totlen;
3533} 3333}
3534 3334
3535/* 3335/*
3536 * asc_prt_driver_conf() 3336 * asc_prt_driver_conf()
3537 *
3538 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3539 * cf. asc_prt_line().
3540 *
3541 * Return the number of characters copied into 'cp'. No more than
3542 * 'cplen' characters will be copied to 'cp'.
3543 */ 3337 */
3544static int asc_prt_driver_conf(struct Scsi_Host *shost, char *cp, int cplen) 3338static void asc_prt_driver_conf(struct seq_file *m, struct Scsi_Host *shost)
3545{ 3339{
3546 struct asc_board *boardp = shost_priv(shost); 3340 struct asc_board *boardp = shost_priv(shost);
3547 int leftlen;
3548 int totlen;
3549 int len;
3550 int chip_scsi_id; 3341 int chip_scsi_id;
3551 3342
3552 leftlen = cplen; 3343 seq_printf(m,
3553 totlen = len = 0; 3344 "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n",
3345 shost->host_no);
3554 3346
3555 len = asc_prt_line(cp, leftlen, 3347 seq_printf(m,
3556 "\nLinux Driver Configuration and Information for AdvanSys SCSI Host %d:\n", 3348 " host_busy %u, last_reset %lu, max_id %u, max_lun %u, max_channel %u\n",
3557 shost->host_no); 3349 shost->host_busy, shost->last_reset, shost->max_id,
3558 ASC_PRT_NEXT(); 3350 shost->max_lun, shost->max_channel);
3559 3351
3560 len = asc_prt_line(cp, leftlen, 3352 seq_printf(m,
3561 " host_busy %u, last_reset %u, max_id %u, max_lun %u, max_channel %u\n", 3353 " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n",
3562 shost->host_busy, shost->last_reset, shost->max_id, 3354 shost->unique_id, shost->can_queue, shost->this_id,
3563 shost->max_lun, shost->max_channel); 3355 shost->sg_tablesize, shost->cmd_per_lun);
3564 ASC_PRT_NEXT();
3565 3356
3566 len = asc_prt_line(cp, leftlen, 3357 seq_printf(m,
3567 " unique_id %d, can_queue %d, this_id %d, sg_tablesize %u, cmd_per_lun %u\n", 3358 " unchecked_isa_dma %d, use_clustering %d\n",
3568 shost->unique_id, shost->can_queue, shost->this_id, 3359 shost->unchecked_isa_dma, shost->use_clustering);
3569 shost->sg_tablesize, shost->cmd_per_lun);
3570 ASC_PRT_NEXT();
3571 3360
3572 len = asc_prt_line(cp, leftlen, 3361 seq_printf(m,
3573 " unchecked_isa_dma %d, use_clustering %d\n", 3362 " flags 0x%x, last_reset 0x%lx, jiffies 0x%lx, asc_n_io_port 0x%x\n",
3574 shost->unchecked_isa_dma, shost->use_clustering); 3363 boardp->flags, boardp->last_reset, jiffies,
3575 ASC_PRT_NEXT(); 3364 boardp->asc_n_io_port);
3576 3365
3577 len = asc_prt_line(cp, leftlen, 3366 seq_printf(m, " io_port 0x%lx\n", shost->io_port);
3578 " flags 0x%x, last_reset 0x%x, jiffies 0x%x, asc_n_io_port 0x%x\n",
3579 boardp->flags, boardp->last_reset, jiffies,
3580 boardp->asc_n_io_port);
3581 ASC_PRT_NEXT();
3582
3583 len = asc_prt_line(cp, leftlen, " io_port 0x%x\n", shost->io_port);
3584 ASC_PRT_NEXT();
3585 3367
3586 if (ASC_NARROW_BOARD(boardp)) { 3368 if (ASC_NARROW_BOARD(boardp)) {
3587 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id; 3369 chip_scsi_id = boardp->dvc_cfg.asc_dvc_cfg.chip_scsi_id;
3588 } else { 3370 } else {
3589 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id; 3371 chip_scsi_id = boardp->dvc_var.adv_dvc_var.chip_scsi_id;
3590 } 3372 }
3591
3592 return totlen;
3593} 3373}
3594 3374
3595/* 3375/*
3596 * asc_prt_asc_board_info() 3376 * asc_prt_asc_board_info()
3597 * 3377 *
3598 * Print dynamic board configuration information. 3378 * Print dynamic board configuration information.
3599 *
3600 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3601 * cf. asc_prt_line().
3602 *
3603 * Return the number of characters copied into 'cp'. No more than
3604 * 'cplen' characters will be copied to 'cp'.
3605 */ 3379 */
3606static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen) 3380static void asc_prt_asc_board_info(struct seq_file *m, struct Scsi_Host *shost)
3607{ 3381{
3608 struct asc_board *boardp = shost_priv(shost); 3382 struct asc_board *boardp = shost_priv(shost);
3609 int chip_scsi_id; 3383 int chip_scsi_id;
3610 int leftlen;
3611 int totlen;
3612 int len;
3613 ASC_DVC_VAR *v; 3384 ASC_DVC_VAR *v;
3614 ASC_DVC_CFG *c; 3385 ASC_DVC_CFG *c;
3615 int i; 3386 int i;
@@ -3619,105 +3390,79 @@ static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
3619 c = &boardp->dvc_cfg.asc_dvc_cfg; 3390 c = &boardp->dvc_cfg.asc_dvc_cfg;
3620 chip_scsi_id = c->chip_scsi_id; 3391 chip_scsi_id = c->chip_scsi_id;
3621 3392
3622 leftlen = cplen; 3393 seq_printf(m,
3623 totlen = len = 0; 3394 "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
3395 shost->host_no);
3624 3396
3625 len = asc_prt_line(cp, leftlen, 3397 seq_printf(m, " chip_version %u, mcode_date 0x%x, "
3626 "\nAsc Library Configuration and Statistics for AdvanSys SCSI Host %d:\n", 3398 "mcode_version 0x%x, err_code %u\n",
3627 shost->host_no); 3399 c->chip_version, c->mcode_date, c->mcode_version,
3628 ASC_PRT_NEXT(); 3400 v->err_code);
3629
3630 len = asc_prt_line(cp, leftlen, " chip_version %u, mcode_date 0x%x, "
3631 "mcode_version 0x%x, err_code %u\n",
3632 c->chip_version, c->mcode_date, c->mcode_version,
3633 v->err_code);
3634 ASC_PRT_NEXT();
3635 3401
3636 /* Current number of commands waiting for the host. */ 3402 /* Current number of commands waiting for the host. */
3637 len = asc_prt_line(cp, leftlen, 3403 seq_printf(m,
3638 " Total Command Pending: %d\n", v->cur_total_qng); 3404 " Total Command Pending: %d\n", v->cur_total_qng);
3639 ASC_PRT_NEXT();
3640 3405
3641 len = asc_prt_line(cp, leftlen, " Command Queuing:"); 3406 seq_printf(m, " Command Queuing:");
3642 ASC_PRT_NEXT();
3643 for (i = 0; i <= ASC_MAX_TID; i++) { 3407 for (i = 0; i <= ASC_MAX_TID; i++) {
3644 if ((chip_scsi_id == i) || 3408 if ((chip_scsi_id == i) ||
3645 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3409 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3646 continue; 3410 continue;
3647 } 3411 }
3648 len = asc_prt_line(cp, leftlen, " %X:%c", 3412 seq_printf(m, " %X:%c",
3649 i, 3413 i,
3650 (v-> 3414 (v->use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3651 use_tagged_qng & ADV_TID_TO_TIDMASK(i)) ?
3652 'Y' : 'N');
3653 ASC_PRT_NEXT();
3654 } 3415 }
3655 len = asc_prt_line(cp, leftlen, "\n"); 3416 seq_printf(m, "\n");
3656 ASC_PRT_NEXT();
3657 3417
3658 /* Current number of commands waiting for a device. */ 3418 /* Current number of commands waiting for a device. */
3659 len = asc_prt_line(cp, leftlen, " Command Queue Pending:"); 3419 seq_printf(m, " Command Queue Pending:");
3660 ASC_PRT_NEXT();
3661 for (i = 0; i <= ASC_MAX_TID; i++) { 3420 for (i = 0; i <= ASC_MAX_TID; i++) {
3662 if ((chip_scsi_id == i) || 3421 if ((chip_scsi_id == i) ||
3663 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3422 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3664 continue; 3423 continue;
3665 } 3424 }
3666 len = asc_prt_line(cp, leftlen, " %X:%u", i, v->cur_dvc_qng[i]); 3425 seq_printf(m, " %X:%u", i, v->cur_dvc_qng[i]);
3667 ASC_PRT_NEXT();
3668 } 3426 }
3669 len = asc_prt_line(cp, leftlen, "\n"); 3427 seq_printf(m, "\n");
3670 ASC_PRT_NEXT();
3671 3428
3672 /* Current limit on number of commands that can be sent to a device. */ 3429 /* Current limit on number of commands that can be sent to a device. */
3673 len = asc_prt_line(cp, leftlen, " Command Queue Limit:"); 3430 seq_printf(m, " Command Queue Limit:");
3674 ASC_PRT_NEXT();
3675 for (i = 0; i <= ASC_MAX_TID; i++) { 3431 for (i = 0; i <= ASC_MAX_TID; i++) {
3676 if ((chip_scsi_id == i) || 3432 if ((chip_scsi_id == i) ||
3677 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3433 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3678 continue; 3434 continue;
3679 } 3435 }
3680 len = asc_prt_line(cp, leftlen, " %X:%u", i, v->max_dvc_qng[i]); 3436 seq_printf(m, " %X:%u", i, v->max_dvc_qng[i]);
3681 ASC_PRT_NEXT();
3682 } 3437 }
3683 len = asc_prt_line(cp, leftlen, "\n"); 3438 seq_printf(m, "\n");
3684 ASC_PRT_NEXT();
3685 3439
3686 /* Indicate whether the device has returned queue full status. */ 3440 /* Indicate whether the device has returned queue full status. */
3687 len = asc_prt_line(cp, leftlen, " Command Queue Full:"); 3441 seq_printf(m, " Command Queue Full:");
3688 ASC_PRT_NEXT();
3689 for (i = 0; i <= ASC_MAX_TID; i++) { 3442 for (i = 0; i <= ASC_MAX_TID; i++) {
3690 if ((chip_scsi_id == i) || 3443 if ((chip_scsi_id == i) ||
3691 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3444 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3692 continue; 3445 continue;
3693 } 3446 }
3694 if (boardp->queue_full & ADV_TID_TO_TIDMASK(i)) { 3447 if (boardp->queue_full & ADV_TID_TO_TIDMASK(i))
3695 len = asc_prt_line(cp, leftlen, " %X:Y-%d", 3448 seq_printf(m, " %X:Y-%d",
3696 i, boardp->queue_full_cnt[i]); 3449 i, boardp->queue_full_cnt[i]);
3697 } else { 3450 else
3698 len = asc_prt_line(cp, leftlen, " %X:N", i); 3451 seq_printf(m, " %X:N", i);
3699 }
3700 ASC_PRT_NEXT();
3701 } 3452 }
3702 len = asc_prt_line(cp, leftlen, "\n"); 3453 seq_printf(m, "\n");
3703 ASC_PRT_NEXT();
3704 3454
3705 len = asc_prt_line(cp, leftlen, " Synchronous Transfer:"); 3455 seq_printf(m, " Synchronous Transfer:");
3706 ASC_PRT_NEXT();
3707 for (i = 0; i <= ASC_MAX_TID; i++) { 3456 for (i = 0; i <= ASC_MAX_TID; i++) {
3708 if ((chip_scsi_id == i) || 3457 if ((chip_scsi_id == i) ||
3709 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3458 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3710 continue; 3459 continue;
3711 } 3460 }
3712 len = asc_prt_line(cp, leftlen, " %X:%c", 3461 seq_printf(m, " %X:%c",
3713 i, 3462 i,
3714 (v-> 3463 (v->sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3715 sdtr_done & ADV_TID_TO_TIDMASK(i)) ? 'Y' :
3716 'N');
3717 ASC_PRT_NEXT();
3718 } 3464 }
3719 len = asc_prt_line(cp, leftlen, "\n"); 3465 seq_printf(m, "\n");
3720 ASC_PRT_NEXT();
3721 3466
3722 for (i = 0; i <= ASC_MAX_TID; i++) { 3467 for (i = 0; i <= ASC_MAX_TID; i++) {
3723 uchar syn_period_ix; 3468 uchar syn_period_ix;
@@ -3728,69 +3473,48 @@ static int asc_prt_asc_board_info(struct Scsi_Host *shost, char *cp, int cplen)
3728 continue; 3473 continue;
3729 } 3474 }
3730 3475
3731 len = asc_prt_line(cp, leftlen, " %X:", i); 3476 seq_printf(m, " %X:", i);
3732 ASC_PRT_NEXT();
3733 3477
3734 if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) { 3478 if ((boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET) == 0) {
3735 len = asc_prt_line(cp, leftlen, " Asynchronous"); 3479 seq_printf(m, " Asynchronous");
3736 ASC_PRT_NEXT();
3737 } else { 3480 } else {
3738 syn_period_ix = 3481 syn_period_ix =
3739 (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index - 3482 (boardp->sdtr_data[i] >> 4) & (v->max_sdtr_index -
3740 1); 3483 1);
3741 3484
3742 len = asc_prt_line(cp, leftlen, 3485 seq_printf(m,
3743 " Transfer Period Factor: %d (%d.%d Mhz),", 3486 " Transfer Period Factor: %d (%d.%d Mhz),",
3744 v->sdtr_period_tbl[syn_period_ix], 3487 v->sdtr_period_tbl[syn_period_ix],
3745 250 / 3488 250 / v->sdtr_period_tbl[syn_period_ix],
3746 v->sdtr_period_tbl[syn_period_ix], 3489 ASC_TENTHS(250,
3747 ASC_TENTHS(250, 3490 v->sdtr_period_tbl[syn_period_ix]));
3748 v->
3749 sdtr_period_tbl
3750 [syn_period_ix]));
3751 ASC_PRT_NEXT();
3752 3491
3753 len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d", 3492 seq_printf(m, " REQ/ACK Offset: %d",
3754 boardp-> 3493 boardp->sdtr_data[i] & ASC_SYN_MAX_OFFSET);
3755 sdtr_data[i] & ASC_SYN_MAX_OFFSET);
3756 ASC_PRT_NEXT();
3757 } 3494 }
3758 3495
3759 if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) { 3496 if ((v->sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
3760 len = asc_prt_line(cp, leftlen, "*\n"); 3497 seq_printf(m, "*\n");
3761 renegotiate = 1; 3498 renegotiate = 1;
3762 } else { 3499 } else {
3763 len = asc_prt_line(cp, leftlen, "\n"); 3500 seq_printf(m, "\n");
3764 } 3501 }
3765 ASC_PRT_NEXT();
3766 } 3502 }
3767 3503
3768 if (renegotiate) { 3504 if (renegotiate) {
3769 len = asc_prt_line(cp, leftlen, 3505 seq_printf(m,
3770 " * = Re-negotiation pending before next command.\n"); 3506 " * = Re-negotiation pending before next command.\n");
3771 ASC_PRT_NEXT();
3772 } 3507 }
3773
3774 return totlen;
3775} 3508}
3776 3509
3777/* 3510/*
3778 * asc_prt_adv_board_info() 3511 * asc_prt_adv_board_info()
3779 * 3512 *
3780 * Print dynamic board configuration information. 3513 * Print dynamic board configuration information.
3781 *
3782 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
3783 * cf. asc_prt_line().
3784 *
3785 * Return the number of characters copied into 'cp'. No more than
3786 * 'cplen' characters will be copied to 'cp'.
3787 */ 3514 */
3788static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen) 3515static void asc_prt_adv_board_info(struct seq_file *m, struct Scsi_Host *shost)
3789{ 3516{
3790 struct asc_board *boardp = shost_priv(shost); 3517 struct asc_board *boardp = shost_priv(shost);
3791 int leftlen;
3792 int totlen;
3793 int len;
3794 int i; 3518 int i;
3795 ADV_DVC_VAR *v; 3519 ADV_DVC_VAR *v;
3796 ADV_DVC_CFG *c; 3520 ADV_DVC_CFG *c;
@@ -3809,47 +3533,35 @@ static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
3809 iop_base = v->iop_base; 3533 iop_base = v->iop_base;
3810 chip_scsi_id = v->chip_scsi_id; 3534 chip_scsi_id = v->chip_scsi_id;
3811 3535
3812 leftlen = cplen; 3536 seq_printf(m,
3813 totlen = len = 0; 3537 "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
3814 3538 shost->host_no);
3815 len = asc_prt_line(cp, leftlen,
3816 "\nAdv Library Configuration and Statistics for AdvanSys SCSI Host %d:\n",
3817 shost->host_no);
3818 ASC_PRT_NEXT();
3819 3539
3820 len = asc_prt_line(cp, leftlen, 3540 seq_printf(m,
3821 " iop_base 0x%lx, cable_detect: %X, err_code %u\n", 3541 " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
3822 v->iop_base, 3542 (unsigned long)v->iop_base,
3823 AdvReadWordRegister(iop_base, 3543 AdvReadWordRegister(iop_base,IOPW_SCSI_CFG1) & CABLE_DETECT,
3824 IOPW_SCSI_CFG1) & CABLE_DETECT, 3544 v->err_code);
3825 v->err_code);
3826 ASC_PRT_NEXT();
3827 3545
3828 len = asc_prt_line(cp, leftlen, " chip_version %u, mcode_date 0x%x, " 3546 seq_printf(m, " chip_version %u, mcode_date 0x%x, "
3829 "mcode_version 0x%x\n", c->chip_version, 3547 "mcode_version 0x%x\n", c->chip_version,
3830 c->mcode_date, c->mcode_version); 3548 c->mcode_date, c->mcode_version);
3831 ASC_PRT_NEXT();
3832 3549
3833 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able); 3550 AdvReadWordLram(iop_base, ASC_MC_TAGQNG_ABLE, tagqng_able);
3834 len = asc_prt_line(cp, leftlen, " Queuing Enabled:"); 3551 seq_printf(m, " Queuing Enabled:");
3835 ASC_PRT_NEXT();
3836 for (i = 0; i <= ADV_MAX_TID; i++) { 3552 for (i = 0; i <= ADV_MAX_TID; i++) {
3837 if ((chip_scsi_id == i) || 3553 if ((chip_scsi_id == i) ||
3838 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3554 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3839 continue; 3555 continue;
3840 } 3556 }
3841 3557
3842 len = asc_prt_line(cp, leftlen, " %X:%c", 3558 seq_printf(m, " %X:%c",
3843 i, 3559 i,
3844 (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 3560 (tagqng_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3845 'N');
3846 ASC_PRT_NEXT();
3847 } 3561 }
3848 len = asc_prt_line(cp, leftlen, "\n"); 3562 seq_printf(m, "\n");
3849 ASC_PRT_NEXT();
3850 3563
3851 len = asc_prt_line(cp, leftlen, " Queue Limit:"); 3564 seq_printf(m, " Queue Limit:");
3852 ASC_PRT_NEXT();
3853 for (i = 0; i <= ADV_MAX_TID; i++) { 3565 for (i = 0; i <= ADV_MAX_TID; i++) {
3854 if ((chip_scsi_id == i) || 3566 if ((chip_scsi_id == i) ||
3855 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3567 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
@@ -3859,14 +3571,11 @@ static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
3859 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i, 3571 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_MAX_CMD + i,
3860 lrambyte); 3572 lrambyte);
3861 3573
3862 len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte); 3574 seq_printf(m, " %X:%d", i, lrambyte);
3863 ASC_PRT_NEXT();
3864 } 3575 }
3865 len = asc_prt_line(cp, leftlen, "\n"); 3576 seq_printf(m, "\n");
3866 ASC_PRT_NEXT();
3867 3577
3868 len = asc_prt_line(cp, leftlen, " Command Pending:"); 3578 seq_printf(m, " Command Pending:");
3869 ASC_PRT_NEXT();
3870 for (i = 0; i <= ADV_MAX_TID; i++) { 3579 for (i = 0; i <= ADV_MAX_TID; i++) {
3871 if ((chip_scsi_id == i) || 3580 if ((chip_scsi_id == i) ||
3872 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3581 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
@@ -3876,33 +3585,26 @@ static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
3876 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i, 3585 AdvReadByteLram(iop_base, ASC_MC_NUMBER_OF_QUEUED_CMD + i,
3877 lrambyte); 3586 lrambyte);
3878 3587
3879 len = asc_prt_line(cp, leftlen, " %X:%d", i, lrambyte); 3588 seq_printf(m, " %X:%d", i, lrambyte);
3880 ASC_PRT_NEXT();
3881 } 3589 }
3882 len = asc_prt_line(cp, leftlen, "\n"); 3590 seq_printf(m, "\n");
3883 ASC_PRT_NEXT();
3884 3591
3885 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able); 3592 AdvReadWordLram(iop_base, ASC_MC_WDTR_ABLE, wdtr_able);
3886 len = asc_prt_line(cp, leftlen, " Wide Enabled:"); 3593 seq_printf(m, " Wide Enabled:");
3887 ASC_PRT_NEXT();
3888 for (i = 0; i <= ADV_MAX_TID; i++) { 3594 for (i = 0; i <= ADV_MAX_TID; i++) {
3889 if ((chip_scsi_id == i) || 3595 if ((chip_scsi_id == i) ||
3890 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3596 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3891 continue; 3597 continue;
3892 } 3598 }
3893 3599
3894 len = asc_prt_line(cp, leftlen, " %X:%c", 3600 seq_printf(m, " %X:%c",
3895 i, 3601 i,
3896 (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 3602 (wdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3897 'N');
3898 ASC_PRT_NEXT();
3899 } 3603 }
3900 len = asc_prt_line(cp, leftlen, "\n"); 3604 seq_printf(m, "\n");
3901 ASC_PRT_NEXT();
3902 3605
3903 AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done); 3606 AdvReadWordLram(iop_base, ASC_MC_WDTR_DONE, wdtr_done);
3904 len = asc_prt_line(cp, leftlen, " Transfer Bit Width:"); 3607 seq_printf(m, " Transfer Bit Width:");
3905 ASC_PRT_NEXT();
3906 for (i = 0; i <= ADV_MAX_TID; i++) { 3608 for (i = 0; i <= ADV_MAX_TID; i++) {
3907 if ((chip_scsi_id == i) || 3609 if ((chip_scsi_id == i) ||
3908 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3610 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
@@ -3913,37 +3615,30 @@ static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
3913 ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i), 3615 ASC_MC_DEVICE_HSHK_CFG_TABLE + (2 * i),
3914 lramword); 3616 lramword);
3915 3617
3916 len = asc_prt_line(cp, leftlen, " %X:%d", 3618 seq_printf(m, " %X:%d",
3917 i, (lramword & 0x8000) ? 16 : 8); 3619 i, (lramword & 0x8000) ? 16 : 8);
3918 ASC_PRT_NEXT();
3919 3620
3920 if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) && 3621 if ((wdtr_able & ADV_TID_TO_TIDMASK(i)) &&
3921 (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) { 3622 (wdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
3922 len = asc_prt_line(cp, leftlen, "*"); 3623 seq_printf(m, "*");
3923 ASC_PRT_NEXT();
3924 renegotiate = 1; 3624 renegotiate = 1;
3925 } 3625 }
3926 } 3626 }
3927 len = asc_prt_line(cp, leftlen, "\n"); 3627 seq_printf(m, "\n");
3928 ASC_PRT_NEXT();
3929 3628
3930 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able); 3629 AdvReadWordLram(iop_base, ASC_MC_SDTR_ABLE, sdtr_able);
3931 len = asc_prt_line(cp, leftlen, " Synchronous Enabled:"); 3630 seq_printf(m, " Synchronous Enabled:");
3932 ASC_PRT_NEXT();
3933 for (i = 0; i <= ADV_MAX_TID; i++) { 3631 for (i = 0; i <= ADV_MAX_TID; i++) {
3934 if ((chip_scsi_id == i) || 3632 if ((chip_scsi_id == i) ||
3935 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) { 3633 ((boardp->init_tidmask & ADV_TID_TO_TIDMASK(i)) == 0)) {
3936 continue; 3634 continue;
3937 } 3635 }
3938 3636
3939 len = asc_prt_line(cp, leftlen, " %X:%c", 3637 seq_printf(m, " %X:%c",
3940 i, 3638 i,
3941 (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 3639 (sdtr_able & ADV_TID_TO_TIDMASK(i)) ? 'Y' : 'N');
3942 'N');
3943 ASC_PRT_NEXT();
3944 } 3640 }
3945 len = asc_prt_line(cp, leftlen, "\n"); 3641 seq_printf(m, "\n");
3946 ASC_PRT_NEXT();
3947 3642
3948 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done); 3643 AdvReadWordLram(iop_base, ASC_MC_SDTR_DONE, sdtr_done);
3949 for (i = 0; i <= ADV_MAX_TID; i++) { 3644 for (i = 0; i <= ADV_MAX_TID; i++) {
@@ -3959,358 +3654,170 @@ static int asc_prt_adv_board_info(struct Scsi_Host *shost, char *cp, int cplen)
3959 continue; 3654 continue;
3960 } 3655 }
3961 3656
3962 len = asc_prt_line(cp, leftlen, " %X:", i); 3657 seq_printf(m, " %X:", i);
3963 ASC_PRT_NEXT();
3964 3658
3965 if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */ 3659 if ((lramword & 0x1F) == 0) { /* Check for REQ/ACK Offset 0. */
3966 len = asc_prt_line(cp, leftlen, " Asynchronous"); 3660 seq_printf(m, " Asynchronous");
3967 ASC_PRT_NEXT();
3968 } else { 3661 } else {
3969 len = 3662 seq_printf(m, " Transfer Period Factor: ");
3970 asc_prt_line(cp, leftlen,
3971 " Transfer Period Factor: ");
3972 ASC_PRT_NEXT();
3973 3663
3974 if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */ 3664 if ((lramword & 0x1F00) == 0x1100) { /* 80 Mhz */
3975 len = 3665 seq_printf(m, "9 (80.0 Mhz),");
3976 asc_prt_line(cp, leftlen, "9 (80.0 Mhz),");
3977 ASC_PRT_NEXT();
3978 } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */ 3666 } else if ((lramword & 0x1F00) == 0x1000) { /* 40 Mhz */
3979 len = 3667 seq_printf(m, "10 (40.0 Mhz),");
3980 asc_prt_line(cp, leftlen, "10 (40.0 Mhz),");
3981 ASC_PRT_NEXT();
3982 } else { /* 20 Mhz or below. */ 3668 } else { /* 20 Mhz or below. */
3983 3669
3984 period = (((lramword >> 8) * 25) + 50) / 4; 3670 period = (((lramword >> 8) * 25) + 50) / 4;
3985 3671
3986 if (period == 0) { /* Should never happen. */ 3672 if (period == 0) { /* Should never happen. */
3987 len = 3673 seq_printf(m, "%d (? Mhz), ", period);
3988 asc_prt_line(cp, leftlen,
3989 "%d (? Mhz), ");
3990 ASC_PRT_NEXT();
3991 } else { 3674 } else {
3992 len = asc_prt_line(cp, leftlen, 3675 seq_printf(m,
3993 "%d (%d.%d Mhz),", 3676 "%d (%d.%d Mhz),",
3994 period, 250 / period, 3677 period, 250 / period,
3995 ASC_TENTHS(250, 3678 ASC_TENTHS(250, period));
3996 period));
3997 ASC_PRT_NEXT();
3998 } 3679 }
3999 } 3680 }
4000 3681
4001 len = asc_prt_line(cp, leftlen, " REQ/ACK Offset: %d", 3682 seq_printf(m, " REQ/ACK Offset: %d",
4002 lramword & 0x1F); 3683 lramword & 0x1F);
4003 ASC_PRT_NEXT();
4004 } 3684 }
4005 3685
4006 if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) { 3686 if ((sdtr_done & ADV_TID_TO_TIDMASK(i)) == 0) {
4007 len = asc_prt_line(cp, leftlen, "*\n"); 3687 seq_printf(m, "*\n");
4008 renegotiate = 1; 3688 renegotiate = 1;
4009 } else { 3689 } else {
4010 len = asc_prt_line(cp, leftlen, "\n"); 3690 seq_printf(m, "\n");
4011 } 3691 }
4012 ASC_PRT_NEXT();
4013 } 3692 }
4014 3693
4015 if (renegotiate) { 3694 if (renegotiate) {
4016 len = asc_prt_line(cp, leftlen, 3695 seq_printf(m,
4017 " * = Re-negotiation pending before next command.\n"); 3696 " * = Re-negotiation pending before next command.\n");
4018 ASC_PRT_NEXT();
4019 } 3697 }
4020
4021 return totlen;
4022}
4023
4024/*
4025 * asc_proc_copy()
4026 *
4027 * Copy proc information to a read buffer taking into account the current
4028 * read offset in the file and the remaining space in the read buffer.
4029 */
4030static int
4031asc_proc_copy(off_t advoffset, off_t offset, char *curbuf, int leftlen,
4032 char *cp, int cplen)
4033{
4034 int cnt = 0;
4035
4036 ASC_DBG(2, "offset %d, advoffset %d, cplen %d\n",
4037 (unsigned)offset, (unsigned)advoffset, cplen);
4038 if (offset <= advoffset) {
4039 /* Read offset below current offset, copy everything. */
4040 cnt = min(cplen, leftlen);
4041 ASC_DBG(2, "curbuf 0x%lx, cp 0x%lx, cnt %d\n",
4042 (ulong)curbuf, (ulong)cp, cnt);
4043 memcpy(curbuf, cp, cnt);
4044 } else if (offset < advoffset + cplen) {
4045 /* Read offset within current range, partial copy. */
4046 cnt = (advoffset + cplen) - offset;
4047 cp = (cp + cplen) - cnt;
4048 cnt = min(cnt, leftlen);
4049 ASC_DBG(2, "curbuf 0x%lx, cp 0x%lx, cnt %d\n",
4050 (ulong)curbuf, (ulong)cp, cnt);
4051 memcpy(curbuf, cp, cnt);
4052 }
4053 return cnt;
4054} 3698}
4055 3699
4056#ifdef ADVANSYS_STATS 3700#ifdef ADVANSYS_STATS
4057/* 3701/*
4058 * asc_prt_board_stats() 3702 * asc_prt_board_stats()
4059 *
4060 * Note: no single line should be greater than ASC_PRTLINE_SIZE,
4061 * cf. asc_prt_line().
4062 *
4063 * Return the number of characters copied into 'cp'. No more than
4064 * 'cplen' characters will be copied to 'cp'.
4065 */ 3703 */
4066static int asc_prt_board_stats(struct Scsi_Host *shost, char *cp, int cplen) 3704static void asc_prt_board_stats(struct seq_file *m, struct Scsi_Host *shost)
4067{ 3705{
4068 struct asc_board *boardp = shost_priv(shost); 3706 struct asc_board *boardp = shost_priv(shost);
4069 struct asc_stats *s = &boardp->asc_stats; 3707 struct asc_stats *s = &boardp->asc_stats;
4070 3708
4071 int leftlen = cplen; 3709 seq_printf(m,
4072 int len, totlen = 0; 3710 "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n",
3711 shost->host_no);
4073 3712
4074 len = asc_prt_line(cp, leftlen, 3713 seq_printf(m,
4075 "\nLinux Driver Statistics for AdvanSys SCSI Host %d:\n", 3714 " queuecommand %u, reset %u, biosparam %u, interrupt %u\n",
4076 shost->host_no); 3715 s->queuecommand, s->reset, s->biosparam,
4077 ASC_PRT_NEXT(); 3716 s->interrupt);
4078 3717
4079 len = asc_prt_line(cp, leftlen, 3718 seq_printf(m,
4080 " queuecommand %lu, reset %lu, biosparam %lu, interrupt %lu\n", 3719 " callback %u, done %u, build_error %u, build_noreq %u, build_nosg %u\n",
4081 s->queuecommand, s->reset, s->biosparam, 3720 s->callback, s->done, s->build_error,
4082 s->interrupt); 3721 s->adv_build_noreq, s->adv_build_nosg);
4083 ASC_PRT_NEXT();
4084 3722
4085 len = asc_prt_line(cp, leftlen, 3723 seq_printf(m,
4086 " callback %lu, done %lu, build_error %lu, build_noreq %lu, build_nosg %lu\n", 3724 " exe_noerror %u, exe_busy %u, exe_error %u, exe_unknown %u\n",
4087 s->callback, s->done, s->build_error, 3725 s->exe_noerror, s->exe_busy, s->exe_error,
4088 s->adv_build_noreq, s->adv_build_nosg); 3726 s->exe_unknown);
4089 ASC_PRT_NEXT();
4090
4091 len = asc_prt_line(cp, leftlen,
4092 " exe_noerror %lu, exe_busy %lu, exe_error %lu, exe_unknown %lu\n",
4093 s->exe_noerror, s->exe_busy, s->exe_error,
4094 s->exe_unknown);
4095 ASC_PRT_NEXT();
4096 3727
4097 /* 3728 /*
4098 * Display data transfer statistics. 3729 * Display data transfer statistics.
4099 */ 3730 */
4100 if (s->xfer_cnt > 0) { 3731 if (s->xfer_cnt > 0) {
4101 len = asc_prt_line(cp, leftlen, " xfer_cnt %lu, xfer_elem %lu, ", 3732 seq_printf(m, " xfer_cnt %u, xfer_elem %u, ",
4102 s->xfer_cnt, s->xfer_elem); 3733 s->xfer_cnt, s->xfer_elem);
4103 ASC_PRT_NEXT();
4104 3734
4105 len = asc_prt_line(cp, leftlen, "xfer_bytes %lu.%01lu kb\n", 3735 seq_printf(m, "xfer_bytes %u.%01u kb\n",
4106 s->xfer_sect / 2, ASC_TENTHS(s->xfer_sect, 2)); 3736 s->xfer_sect / 2, ASC_TENTHS(s->xfer_sect, 2));
4107 ASC_PRT_NEXT();
4108 3737
4109 /* Scatter gather transfer statistics */ 3738 /* Scatter gather transfer statistics */
4110 len = asc_prt_line(cp, leftlen, " avg_num_elem %lu.%01lu, ", 3739 seq_printf(m, " avg_num_elem %u.%01u, ",
4111 s->xfer_elem / s->xfer_cnt, 3740 s->xfer_elem / s->xfer_cnt,
4112 ASC_TENTHS(s->xfer_elem, s->xfer_cnt)); 3741 ASC_TENTHS(s->xfer_elem, s->xfer_cnt));
4113 ASC_PRT_NEXT();
4114 3742
4115 len = asc_prt_line(cp, leftlen, "avg_elem_size %lu.%01lu kb, ", 3743 seq_printf(m, "avg_elem_size %u.%01u kb, ",
4116 (s->xfer_sect / 2) / s->xfer_elem, 3744 (s->xfer_sect / 2) / s->xfer_elem,
4117 ASC_TENTHS((s->xfer_sect / 2), s->xfer_elem)); 3745 ASC_TENTHS((s->xfer_sect / 2), s->xfer_elem));
4118 ASC_PRT_NEXT();
4119 3746
4120 len = asc_prt_line(cp, leftlen, "avg_xfer_size %lu.%01lu kb\n", 3747 seq_printf(m, "avg_xfer_size %u.%01u kb\n",
4121 (s->xfer_sect / 2) / s->xfer_cnt, 3748 (s->xfer_sect / 2) / s->xfer_cnt,
4122 ASC_TENTHS((s->xfer_sect / 2), s->xfer_cnt)); 3749 ASC_TENTHS((s->xfer_sect / 2), s->xfer_cnt));
4123 ASC_PRT_NEXT();
4124 } 3750 }
4125
4126 return totlen;
4127} 3751}
4128#endif /* ADVANSYS_STATS */ 3752#endif /* ADVANSYS_STATS */
4129 3753
4130/* 3754/*
4131 * advansys_proc_info() - /proc/scsi/advansys/{0,1,2,3,...} 3755 * advansys_show_info() - /proc/scsi/advansys/{0,1,2,3,...}
4132 * 3756 *
4133 * *buffer: I/O buffer 3757 * m: seq_file to print into
4134 * **start: if inout == FALSE pointer into buffer where user read should start 3758 * shost: Scsi_Host
4135 * offset: current offset into a /proc/scsi/advansys/[0...] file
4136 * length: length of buffer
4137 * hostno: Scsi_Host host_no
4138 * inout: TRUE - user is writing; FALSE - user is reading
4139 * 3759 *
4140 * Return the number of bytes read from or written to a 3760 * Return the number of bytes read from or written to a
4141 * /proc/scsi/advansys/[0...] file. 3761 * /proc/scsi/advansys/[0...] file.
4142 *
4143 * Note: This function uses the per board buffer 'prtbuf' which is
4144 * allocated when the board is initialized in advansys_detect(). The
4145 * buffer is ASC_PRTBUF_SIZE bytes. The function asc_proc_copy() is
4146 * used to write to the buffer. The way asc_proc_copy() is written
4147 * if 'prtbuf' is too small it will not be overwritten. Instead the
4148 * user just won't get all the available statistics.
4149 */ 3762 */
4150static int 3763static int
4151advansys_proc_info(struct Scsi_Host *shost, char *buffer, char **start, 3764advansys_show_info(struct seq_file *m, struct Scsi_Host *shost)
4152 off_t offset, int length, int inout)
4153{ 3765{
4154 struct asc_board *boardp = shost_priv(shost); 3766 struct asc_board *boardp = shost_priv(shost);
4155 char *cp;
4156 int cplen;
4157 int cnt;
4158 int totcnt;
4159 int leftlen;
4160 char *curbuf;
4161 off_t advoffset;
4162 3767
4163 ASC_DBG(1, "begin\n"); 3768 ASC_DBG(1, "begin\n");
4164 3769
4165 /* 3770 /*
4166 * User write not supported.
4167 */
4168 if (inout == TRUE)
4169 return -ENOSYS;
4170
4171 /*
4172 * User read of /proc/scsi/advansys/[0...] file. 3771 * User read of /proc/scsi/advansys/[0...] file.
4173 */ 3772 */
4174 3773
4175 /* Copy read data starting at the beginning of the buffer. */
4176 *start = buffer;
4177 curbuf = buffer;
4178 advoffset = 0;
4179 totcnt = 0;
4180 leftlen = length;
4181
4182 /* 3774 /*
4183 * Get board configuration information. 3775 * Get board configuration information.
4184 * 3776 *
4185 * advansys_info() returns the board string from its own static buffer. 3777 * advansys_info() returns the board string from its own static buffer.
4186 */ 3778 */
4187 cp = (char *)advansys_info(shost);
4188 strcat(cp, "\n");
4189 cplen = strlen(cp);
4190 /* Copy board information. */ 3779 /* Copy board information. */
4191 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen); 3780 seq_printf(m, "%s\n", (char *)advansys_info(shost));
4192 totcnt += cnt;
4193 leftlen -= cnt;
4194 if (leftlen == 0) {
4195 ASC_DBG(1, "totcnt %d\n", totcnt);
4196 return totcnt;
4197 }
4198 advoffset += cplen;
4199 curbuf += cnt;
4200
4201 /* 3781 /*
4202 * Display Wide Board BIOS Information. 3782 * Display Wide Board BIOS Information.
4203 */ 3783 */
4204 if (!ASC_NARROW_BOARD(boardp)) { 3784 if (!ASC_NARROW_BOARD(boardp))
4205 cp = boardp->prtbuf; 3785 asc_prt_adv_bios(m, shost);
4206 cplen = asc_prt_adv_bios(shost, cp, ASC_PRTBUF_SIZE);
4207 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4208 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp,
4209 cplen);
4210 totcnt += cnt;
4211 leftlen -= cnt;
4212 if (leftlen == 0) {
4213 ASC_DBG(1, "totcnt %d\n", totcnt);
4214 return totcnt;
4215 }
4216 advoffset += cplen;
4217 curbuf += cnt;
4218 }
4219 3786
4220 /* 3787 /*
4221 * Display driver information for each device attached to the board. 3788 * Display driver information for each device attached to the board.
4222 */ 3789 */
4223 cp = boardp->prtbuf; 3790 asc_prt_board_devices(m, shost);
4224 cplen = asc_prt_board_devices(shost, cp, ASC_PRTBUF_SIZE);
4225 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4226 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4227 totcnt += cnt;
4228 leftlen -= cnt;
4229 if (leftlen == 0) {
4230 ASC_DBG(1, "totcnt %d\n", totcnt);
4231 return totcnt;
4232 }
4233 advoffset += cplen;
4234 curbuf += cnt;
4235 3791
4236 /* 3792 /*
4237 * Display EEPROM configuration for the board. 3793 * Display EEPROM configuration for the board.
4238 */ 3794 */
4239 cp = boardp->prtbuf; 3795 if (ASC_NARROW_BOARD(boardp))
4240 if (ASC_NARROW_BOARD(boardp)) { 3796 asc_prt_asc_board_eeprom(m, shost);
4241 cplen = asc_prt_asc_board_eeprom(shost, cp, ASC_PRTBUF_SIZE); 3797 else
4242 } else { 3798 asc_prt_adv_board_eeprom(m, shost);
4243 cplen = asc_prt_adv_board_eeprom(shost, cp, ASC_PRTBUF_SIZE);
4244 }
4245 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4246 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4247 totcnt += cnt;
4248 leftlen -= cnt;
4249 if (leftlen == 0) {
4250 ASC_DBG(1, "totcnt %d\n", totcnt);
4251 return totcnt;
4252 }
4253 advoffset += cplen;
4254 curbuf += cnt;
4255 3799
4256 /* 3800 /*
4257 * Display driver configuration and information for the board. 3801 * Display driver configuration and information for the board.
4258 */ 3802 */
4259 cp = boardp->prtbuf; 3803 asc_prt_driver_conf(m, shost);
4260 cplen = asc_prt_driver_conf(shost, cp, ASC_PRTBUF_SIZE);
4261 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4262 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4263 totcnt += cnt;
4264 leftlen -= cnt;
4265 if (leftlen == 0) {
4266 ASC_DBG(1, "totcnt %d\n", totcnt);
4267 return totcnt;
4268 }
4269 advoffset += cplen;
4270 curbuf += cnt;
4271 3804
4272#ifdef ADVANSYS_STATS 3805#ifdef ADVANSYS_STATS
4273 /* 3806 /*
4274 * Display driver statistics for the board. 3807 * Display driver statistics for the board.
4275 */ 3808 */
4276 cp = boardp->prtbuf; 3809 asc_prt_board_stats(m, shost);
4277 cplen = asc_prt_board_stats(shost, cp, ASC_PRTBUF_SIZE);
4278 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4279 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4280 totcnt += cnt;
4281 leftlen -= cnt;
4282 if (leftlen == 0) {
4283 ASC_DBG(1, "totcnt %d\n", totcnt);
4284 return totcnt;
4285 }
4286 advoffset += cplen;
4287 curbuf += cnt;
4288#endif /* ADVANSYS_STATS */ 3810#endif /* ADVANSYS_STATS */
4289 3811
4290 /* 3812 /*
4291 * Display Asc Library dynamic configuration information 3813 * Display Asc Library dynamic configuration information
4292 * for the board. 3814 * for the board.
4293 */ 3815 */
4294 cp = boardp->prtbuf; 3816 if (ASC_NARROW_BOARD(boardp))
4295 if (ASC_NARROW_BOARD(boardp)) { 3817 asc_prt_asc_board_info(m, shost);
4296 cplen = asc_prt_asc_board_info(shost, cp, ASC_PRTBUF_SIZE); 3818 else
4297 } else { 3819 asc_prt_adv_board_info(m, shost);
4298 cplen = asc_prt_adv_board_info(shost, cp, ASC_PRTBUF_SIZE); 3820 return 0;
4299 }
4300 BUG_ON(cplen >= ASC_PRTBUF_SIZE);
4301 cnt = asc_proc_copy(advoffset, offset, curbuf, leftlen, cp, cplen);
4302 totcnt += cnt;
4303 leftlen -= cnt;
4304 if (leftlen == 0) {
4305 ASC_DBG(1, "totcnt %d\n", totcnt);
4306 return totcnt;
4307 }
4308 advoffset += cplen;
4309 curbuf += cnt;
4310
4311 ASC_DBG(1, "totcnt %d\n", totcnt);
4312
4313 return totcnt;
4314} 3821}
4315#endif /* CONFIG_PROC_FS */ 3822#endif /* CONFIG_PROC_FS */
4316 3823
@@ -11743,7 +11250,7 @@ static int AdvInitGetConfig(struct pci_dev *pdev, struct Scsi_Host *shost)
11743static struct scsi_host_template advansys_template = { 11250static struct scsi_host_template advansys_template = {
11744 .proc_name = DRV_NAME, 11251 .proc_name = DRV_NAME,
11745#ifdef CONFIG_PROC_FS 11252#ifdef CONFIG_PROC_FS
11746 .proc_info = advansys_proc_info, 11253 .show_info = advansys_show_info,
11747#endif 11254#endif
11748 .name = DRV_NAME, 11255 .name = DRV_NAME,
11749 .info = advansys_info, 11256 .info = advansys_info,
@@ -11939,20 +11446,6 @@ static int advansys_board_found(struct Scsi_Host *shost, unsigned int iop,
11939#endif /* CONFIG_PCI */ 11446#endif /* CONFIG_PCI */
11940 } 11447 }
11941 11448
11942#ifdef CONFIG_PROC_FS
11943 /*
11944 * Allocate buffer for printing information from
11945 * /proc/scsi/advansys/[0...].
11946 */
11947 boardp->prtbuf = kmalloc(ASC_PRTBUF_SIZE, GFP_KERNEL);
11948 if (!boardp->prtbuf) {
11949 shost_printk(KERN_ERR, shost, "kmalloc(%d) returned NULL\n",
11950 ASC_PRTBUF_SIZE);
11951 ret = -ENOMEM;
11952 goto err_unmap;
11953 }
11954#endif /* CONFIG_PROC_FS */
11955
11956 if (ASC_NARROW_BOARD(boardp)) { 11449 if (ASC_NARROW_BOARD(boardp)) {
11957 /* 11450 /*
11958 * Set the board bus type and PCI IRQ before 11451 * Set the board bus type and PCI IRQ before
@@ -12010,7 +11503,7 @@ static int advansys_board_found(struct Scsi_Host *shost, unsigned int iop,
12010 } 11503 }
12011 11504
12012 if (ret) 11505 if (ret)
12013 goto err_free_proc; 11506 goto err_unmap;
12014 11507
12015 /* 11508 /*
12016 * Save the EEPROM configuration so that it can be displayed 11509 * Save the EEPROM configuration so that it can be displayed
@@ -12055,7 +11548,7 @@ static int advansys_board_found(struct Scsi_Host *shost, unsigned int iop,
12055 ASC_DBG(2, "AscInitSetConfig()\n"); 11548 ASC_DBG(2, "AscInitSetConfig()\n");
12056 ret = AscInitSetConfig(pdev, shost) ? -ENODEV : 0; 11549 ret = AscInitSetConfig(pdev, shost) ? -ENODEV : 0;
12057 if (ret) 11550 if (ret)
12058 goto err_free_proc; 11551 goto err_unmap;
12059 } else { 11552 } else {
12060 ADVEEP_3550_CONFIG *ep_3550; 11553 ADVEEP_3550_CONFIG *ep_3550;
12061 ADVEEP_38C0800_CONFIG *ep_38C0800; 11554 ADVEEP_38C0800_CONFIG *ep_38C0800;
@@ -12290,7 +11783,7 @@ static int advansys_board_found(struct Scsi_Host *shost, unsigned int iop,
12290 shost_printk(KERN_ERR, shost, "request_dma() " 11783 shost_printk(KERN_ERR, shost, "request_dma() "
12291 "%d failed %d\n", 11784 "%d failed %d\n",
12292 shost->dma_channel, ret); 11785 shost->dma_channel, ret);
12293 goto err_free_proc; 11786 goto err_unmap;
12294 } 11787 }
12295 AscEnableIsaDma(shost->dma_channel); 11788 AscEnableIsaDma(shost->dma_channel);
12296 } 11789 }
@@ -12371,8 +11864,6 @@ static int advansys_board_found(struct Scsi_Host *shost, unsigned int iop,
12371 if (shost->dma_channel != NO_ISA_DMA) 11864 if (shost->dma_channel != NO_ISA_DMA)
12372 free_dma(shost->dma_channel); 11865 free_dma(shost->dma_channel);
12373#endif 11866#endif
12374 err_free_proc:
12375 kfree(boardp->prtbuf);
12376 err_unmap: 11867 err_unmap:
12377 if (boardp->ioremap_addr) 11868 if (boardp->ioremap_addr)
12378 iounmap(boardp->ioremap_addr); 11869 iounmap(boardp->ioremap_addr);
@@ -12406,7 +11897,6 @@ static int advansys_release(struct Scsi_Host *shost)
12406 iounmap(board->ioremap_addr); 11897 iounmap(board->ioremap_addr);
12407 advansys_wide_free_mem(board); 11898 advansys_wide_free_mem(board);
12408 } 11899 }
12409 kfree(board->prtbuf);
12410 scsi_host_put(shost); 11900 scsi_host_put(shost);
12411 ASC_DBG(1, "end\n"); 11901 ASC_DBG(1, "end\n");
12412 return 0; 11902 return 0;