gdth: switch to ->show_info()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2013-03-31 00:52:08 -04:00
parent 408bb25ba5
commit 3e0552eebd
4 changed files with 52 additions and 170 deletions

View File

@ -4676,7 +4676,8 @@ static struct scsi_host_template gdth_template = {
.eh_bus_reset_handler = gdth_eh_bus_reset, .eh_bus_reset_handler = gdth_eh_bus_reset,
.slave_configure = gdth_slave_configure, .slave_configure = gdth_slave_configure,
.bios_param = gdth_bios_param, .bios_param = gdth_bios_param,
.proc_info = gdth_proc_info, .show_info = gdth_show_info,
.write_info = gdth_set_info,
.eh_timed_out = gdth_timed_out, .eh_timed_out = gdth_timed_out,
.proc_name = "gdth", .proc_name = "gdth",
.can_queue = GDTH_MAXCMDS, .can_queue = GDTH_MAXCMDS,

View File

@ -1007,6 +1007,7 @@ typedef struct {
/* function prototyping */ /* function prototyping */
int gdth_proc_info(struct Scsi_Host *, char *,char **,off_t,int,int); int gdth_show_info(struct seq_file *, struct Scsi_Host *);
int gdth_set_info(struct Scsi_Host *, char *, int);
#endif #endif

View File

@ -5,23 +5,9 @@
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/slab.h> #include <linux/slab.h>
int gdth_proc_info(struct Scsi_Host *host, char *buffer,char **start,off_t offset,int length, int gdth_set_info(struct Scsi_Host *host, char *buffer, int length)
int inout)
{ {
gdth_ha_str *ha = shost_priv(host); gdth_ha_str *ha = shost_priv(host);
TRACE2(("gdth_proc_info() length %d offs %d inout %d\n",
length,(int)offset,inout));
if (inout)
return(gdth_set_info(buffer,length,host,ha));
else
return(gdth_get_info(buffer,start,offset,length,host,ha));
}
static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host,
gdth_ha_str *ha)
{
int ret_val = -EINVAL; int ret_val = -EINVAL;
TRACE2(("gdth_set_info() ha %d\n",ha->hanum,)); TRACE2(("gdth_set_info() ha %d\n",ha->hanum,));
@ -149,12 +135,10 @@ static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
return(-EINVAL); return(-EINVAL);
} }
static int gdth_get_info(char *buffer,char **start,off_t offset,int length, int gdth_show_info(struct seq_file *m, struct Scsi_Host *host)
struct Scsi_Host *host, gdth_ha_str *ha)
{ {
int size = 0,len = 0; gdth_ha_str *ha = shost_priv(host);
int hlen; int hlen;
off_t begin = 0,pos = 0;
int id, i, j, k, sec, flag; int id, i, j, k, sec, flag;
int no_mdrv = 0, drv_no, is_mirr; int no_mdrv = 0, drv_no, is_mirr;
u32 cnt; u32 cnt;
@ -189,8 +173,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
/* request is i.e. "cat /proc/scsi/gdth/0" */ /* request is i.e. "cat /proc/scsi/gdth/0" */
/* format: %-15s\t%-10s\t%-15s\t%s */ /* format: %-15s\t%-10s\t%-15s\t%s */
/* driver parameters */ /* driver parameters */
size = sprintf(buffer+len,"Driver Parameters:\n"); seq_printf(m, "Driver Parameters:\n");
len += size; pos = begin + len;
if (reserve_list[0] == 0xff) if (reserve_list[0] == 0xff)
strcpy(hrec, "--"); strcpy(hrec, "--");
else { else {
@ -201,69 +184,50 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
hlen += snprintf(hrec + hlen , 161 - hlen, ",%d", reserve_list[i]); hlen += snprintf(hrec + hlen , 161 - hlen, ",%d", reserve_list[i]);
} }
} }
size = sprintf(buffer+len, seq_printf(m,
" reserve_mode: \t%d \treserve_list: \t%s\n", " reserve_mode: \t%d \treserve_list: \t%s\n",
reserve_mode, hrec); reserve_mode, hrec);
len += size; pos = begin + len; seq_printf(m,
size = sprintf(buffer+len,
" max_ids: \t%-3d \thdr_channel: \t%d\n", " max_ids: \t%-3d \thdr_channel: \t%d\n",
max_ids, hdr_channel); max_ids, hdr_channel);
len += size; pos = begin + len;
/* controller information */ /* controller information */
size = sprintf(buffer+len,"\nDisk Array Controller Information:\n"); seq_printf(m,"\nDisk Array Controller Information:\n");
len += size; pos = begin + len; seq_printf(m,
strcpy(hrec, ha->binfo.type_string);
size = sprintf(buffer+len,
" Number: \t%d \tName: \t%s\n", " Number: \t%d \tName: \t%s\n",
ha->hanum, hrec); ha->hanum, ha->binfo.type_string);
len += size; pos = begin + len;
seq_printf(m,
" Driver Ver.: \t%-10s\tFirmware Ver.: \t",
GDTH_VERSION_STR);
if (ha->more_proc) if (ha->more_proc)
sprintf(hrec, "%d.%02d.%02d-%c%03X", seq_printf(m, "%d.%02d.%02d-%c%03X\n",
(u8)(ha->binfo.upd_fw_ver>>24), (u8)(ha->binfo.upd_fw_ver>>24),
(u8)(ha->binfo.upd_fw_ver>>16), (u8)(ha->binfo.upd_fw_ver>>16),
(u8)(ha->binfo.upd_fw_ver), (u8)(ha->binfo.upd_fw_ver),
ha->bfeat.raid ? 'R':'N', ha->bfeat.raid ? 'R':'N',
ha->binfo.upd_revision); ha->binfo.upd_revision);
else else
sprintf(hrec, "%d.%02d", (u8)(ha->cpar.version>>8), seq_printf(m, "%d.%02d\n", (u8)(ha->cpar.version>>8),
(u8)(ha->cpar.version)); (u8)(ha->cpar.version));
size = sprintf(buffer+len, if (ha->more_proc)
" Driver Ver.: \t%-10s\tFirmware Ver.: \t%s\n",
GDTH_VERSION_STR, hrec);
len += size; pos = begin + len;
if (ha->more_proc) {
/* more information: 1. about controller */ /* more information: 1. about controller */
size = sprintf(buffer+len, seq_printf(m,
" Serial No.: \t0x%8X\tCache RAM size:\t%d KB\n", " Serial No.: \t0x%8X\tCache RAM size:\t%d KB\n",
ha->binfo.ser_no, ha->binfo.memsize / 1024); ha->binfo.ser_no, ha->binfo.memsize / 1024);
len += size; pos = begin + len;
}
#ifdef GDTH_DMA_STATISTICS #ifdef GDTH_DMA_STATISTICS
/* controller statistics */ /* controller statistics */
size = sprintf(buffer+len,"\nController Statistics:\n"); seq_printf(m,"\nController Statistics:\n");
len += size; pos = begin + len; seq_printf(m,
size = sprintf(buffer+len,
" 32-bit DMA buffer:\t%lu\t64-bit DMA buffer:\t%lu\n", " 32-bit DMA buffer:\t%lu\t64-bit DMA buffer:\t%lu\n",
ha->dma32_cnt, ha->dma64_cnt); ha->dma32_cnt, ha->dma64_cnt);
len += size; pos = begin + len;
#endif #endif
if (pos < offset) {
len = 0;
begin = pos;
}
if (pos > offset + length)
goto stop_output;
if (ha->more_proc) { if (ha->more_proc) {
/* more information: 2. about physical devices */ /* more information: 2. about physical devices */
size = sprintf(buffer+len,"\nPhysical Devices:"); seq_printf(m, "\nPhysical Devices:");
len += size; pos = begin + len;
flag = FALSE; flag = FALSE;
buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr); buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr);
@ -309,21 +273,19 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
strncpy(hrec+8,pdi->product,16); strncpy(hrec+8,pdi->product,16);
strncpy(hrec+24,pdi->revision,4); strncpy(hrec+24,pdi->revision,4);
hrec[28] = 0; hrec[28] = 0;
size = sprintf(buffer+len, seq_printf(m,
"\n Chn/ID/LUN: \t%c/%02d/%d \tName: \t%s\n", "\n Chn/ID/LUN: \t%c/%02d/%d \tName: \t%s\n",
'A'+i,pdi->target_id,pdi->lun,hrec); 'A'+i,pdi->target_id,pdi->lun,hrec);
len += size; pos = begin + len;
flag = TRUE; flag = TRUE;
pdi->no_ldrive &= 0xffff; pdi->no_ldrive &= 0xffff;
if (pdi->no_ldrive == 0xffff) if (pdi->no_ldrive == 0xffff)
strcpy(hrec,"--"); strcpy(hrec,"--");
else else
sprintf(hrec,"%d",pdi->no_ldrive); sprintf(hrec,"%d",pdi->no_ldrive);
size = sprintf(buffer+len, seq_printf(m,
" Capacity [MB]:\t%-6d \tTo Log. Drive: \t%s\n", " Capacity [MB]:\t%-6d \tTo Log. Drive: \t%s\n",
pdi->blkcnt/(1024*1024/pdi->blksize), pdi->blkcnt/(1024*1024/pdi->blksize),
hrec); hrec);
len += size; pos = begin + len;
} else { } else {
pdi->devtype = 0xff; pdi->devtype = 0xff;
} }
@ -333,11 +295,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
for (k = 0; k < pds->count; ++k) { for (k = 0; k < pds->count; ++k) {
if (pds->list[k].tid == pdi->target_id && if (pds->list[k].tid == pdi->target_id &&
pds->list[k].lun == pdi->lun) { pds->list[k].lun == pdi->lun) {
size = sprintf(buffer+len, seq_printf(m,
" Retries: \t%-6d \tReassigns: \t%d\n", " Retries: \t%-6d \tReassigns: \t%d\n",
pds->list[k].retries, pds->list[k].retries,
pds->list[k].reassigns); pds->list[k].reassigns);
len += size; pos = begin + len;
break; break;
} }
} }
@ -355,32 +316,20 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
pdef->sddc_type = 0x08; pdef->sddc_type = 0x08;
if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) { if (gdth_execute(host, gdtcmd, cmnd, 30, NULL) == S_OK) {
size = sprintf(buffer+len, seq_printf(m,
" Grown Defects:\t%d\n", " Grown Defects:\t%d\n",
pdef->sddc_cnt); pdef->sddc_cnt);
len += size; pos = begin + len;
} }
} }
if (pos < offset) {
len = 0;
begin = pos;
}
if (pos > offset + length) {
gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
goto stop_output;
}
} }
} }
gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
if (!flag) { if (!flag)
size = sprintf(buffer+len, "\n --\n"); seq_printf(m, "\n --\n");
len += size; pos = begin + len;
}
/* 3. about logical drives */ /* 3. about logical drives */
size = sprintf(buffer+len,"\nLogical Drives:"); seq_printf(m,"\nLogical Drives:");
len += size; pos = begin + len;
flag = FALSE; flag = FALSE;
buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr); buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr);
@ -418,10 +367,9 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
} }
if (drv_no == i) { if (drv_no == i) {
size = sprintf(buffer+len, seq_printf(m,
"\n Number: \t%-2d \tStatus: \t%s\n", "\n Number: \t%-2d \tStatus: \t%s\n",
drv_no, hrec); drv_no, hrec);
len += size; pos = begin + len;
flag = TRUE; flag = TRUE;
no_mdrv = pcdi->cd_ldcnt; no_mdrv = pcdi->cd_ldcnt;
if (no_mdrv > 1 || pcdi->ld_slave != -1) { if (no_mdrv > 1 || pcdi->ld_slave != -1) {
@ -436,61 +384,37 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
} else { } else {
strcpy(hrec, "???"); strcpy(hrec, "???");
} }
size = sprintf(buffer+len, seq_printf(m,
" Capacity [MB]:\t%-6d \tType: \t%s\n", " Capacity [MB]:\t%-6d \tType: \t%s\n",
pcdi->ld_blkcnt/(1024*1024/pcdi->ld_blksize), pcdi->ld_blkcnt/(1024*1024/pcdi->ld_blksize),
hrec); hrec);
len += size; pos = begin + len;
} else { } else {
size = sprintf(buffer+len, seq_printf(m,
" Slave Number: \t%-2d \tStatus: \t%s\n", " Slave Number: \t%-2d \tStatus: \t%s\n",
drv_no & 0x7fff, hrec); drv_no & 0x7fff, hrec);
len += size; pos = begin + len;
} }
drv_no = pcdi->ld_slave; drv_no = pcdi->ld_slave;
if (pos < offset) {
len = 0;
begin = pos;
}
if (pos > offset + length) {
gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
goto stop_output;
}
} while (drv_no != -1); } while (drv_no != -1);
if (is_mirr) { if (is_mirr)
size = sprintf(buffer+len, seq_printf(m,
" Missing Drv.: \t%-2d \tInvalid Drv.: \t%d\n", " Missing Drv.: \t%-2d \tInvalid Drv.: \t%d\n",
no_mdrv - j - k, k); no_mdrv - j - k, k);
len += size; pos = begin + len;
}
if (!ha->hdr[i].is_arraydrv) if (!ha->hdr[i].is_arraydrv)
strcpy(hrec, "--"); strcpy(hrec, "--");
else else
sprintf(hrec, "%d", ha->hdr[i].master_no); sprintf(hrec, "%d", ha->hdr[i].master_no);
size = sprintf(buffer+len, seq_printf(m,
" To Array Drv.:\t%s\n", hrec); " To Array Drv.:\t%s\n", hrec);
len += size; pos = begin + len;
if (pos < offset) {
len = 0;
begin = pos;
}
if (pos > offset + length) {
gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
goto stop_output;
}
} }
gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
if (!flag) { if (!flag)
size = sprintf(buffer+len, "\n --\n"); seq_printf(m, "\n --\n");
len += size; pos = begin + len;
}
/* 4. about array drives */ /* 4. about array drives */
size = sprintf(buffer+len,"\nArray Drives:"); seq_printf(m,"\nArray Drives:");
len += size; pos = begin + len;
flag = FALSE; flag = FALSE;
buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr); buf = gdth_ioctl_alloc(ha, GDTH_SCRATCH, FALSE, &paddr);
@ -525,10 +449,9 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
strcat(hrec, "/expand"); strcat(hrec, "/expand");
else if (pai->ai_ext_state & 0x1) else if (pai->ai_ext_state & 0x1)
strcat(hrec, "/patch"); strcat(hrec, "/patch");
size = sprintf(buffer+len, seq_printf(m,
"\n Number: \t%-2d \tStatus: \t%s\n", "\n Number: \t%-2d \tStatus: \t%s\n",
i,hrec); i,hrec);
len += size; pos = begin + len;
flag = TRUE; flag = TRUE;
if (pai->ai_type == 0) if (pai->ai_type == 0)
@ -539,31 +462,19 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
strcpy(hrec, "RAID-5"); strcpy(hrec, "RAID-5");
else else
strcpy(hrec, "RAID-10"); strcpy(hrec, "RAID-10");
size = sprintf(buffer+len, seq_printf(m,
" Capacity [MB]:\t%-6d \tType: \t%s\n", " Capacity [MB]:\t%-6d \tType: \t%s\n",
pai->ai_size/(1024*1024/pai->ai_secsize), pai->ai_size/(1024*1024/pai->ai_secsize),
hrec); hrec);
len += size; pos = begin + len;
if (pos < offset) {
len = 0;
begin = pos;
}
if (pos > offset + length) {
gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
goto stop_output;
}
} }
} }
gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr); gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
if (!flag) { if (!flag)
size = sprintf(buffer+len, "\n --\n"); seq_printf(m, "\n --\n");
len += size; pos = begin + len;
}
/* 5. about host drives */ /* 5. about host drives */
size = sprintf(buffer+len,"\nHost Drives:"); seq_printf(m,"\nHost Drives:");
len += size; pos = begin + len;
flag = FALSE; flag = FALSE;
buf = gdth_ioctl_alloc(ha, sizeof(gdth_hget_str), FALSE, &paddr); buf = gdth_ioctl_alloc(ha, sizeof(gdth_hget_str), FALSE, &paddr);
@ -605,33 +516,22 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
if (!(ha->hdr[i].present)) if (!(ha->hdr[i].present))
continue; continue;
size = sprintf(buffer+len, seq_printf(m,
"\n Number: \t%-2d \tArr/Log. Drive:\t%d\n", "\n Number: \t%-2d \tArr/Log. Drive:\t%d\n",
i, ha->hdr[i].ldr_no); i, ha->hdr[i].ldr_no);
len += size; pos = begin + len;
flag = TRUE; flag = TRUE;
size = sprintf(buffer+len, seq_printf(m,
" Capacity [MB]:\t%-6d \tStart Sector: \t%d\n", " Capacity [MB]:\t%-6d \tStart Sector: \t%d\n",
(u32)(ha->hdr[i].size/2048), ha->hdr[i].start_sec); (u32)(ha->hdr[i].size/2048), ha->hdr[i].start_sec);
len += size; pos = begin + len;
if (pos < offset) {
len = 0;
begin = pos;
}
if (pos > offset + length)
goto stop_output;
} }
if (!flag) { if (!flag)
size = sprintf(buffer+len, "\n --\n"); seq_printf(m, "\n --\n");
len += size; pos = begin + len;
}
} }
/* controller events */ /* controller events */
size = sprintf(buffer+len,"\nController Events:\n"); seq_printf(m,"\nController Events:\n");
len += size; pos = begin + len;
for (id = -1;;) { for (id = -1;;) {
id = gdth_read_event(ha, id, estr); id = gdth_read_event(ha, id, estr);
@ -643,29 +543,14 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
do_gettimeofday(&tv); do_gettimeofday(&tv);
sec = (int)(tv.tv_sec - estr->first_stamp); sec = (int)(tv.tv_sec - estr->first_stamp);
if (sec < 0) sec = 0; if (sec < 0) sec = 0;
size = sprintf(buffer+len," date- %02d:%02d:%02d\t%s\n", seq_printf(m," date- %02d:%02d:%02d\t%s\n",
sec/3600, sec%3600/60, sec%60, hrec); sec/3600, sec%3600/60, sec%60, hrec);
len += size; pos = begin + len;
if (pos < offset) {
len = 0;
begin = pos;
}
if (pos > offset + length)
goto stop_output;
} }
if (id == -1) if (id == -1)
break; break;
} }
stop_output: stop_output:
*start = buffer +(offset-begin); rc = 0;
len -= (offset-begin);
if (len > length)
len = length;
TRACE2(("get_info() len %d pos %d begin %d offset %d length %d size %d\n",
len,(int)pos,(int)begin,(int)offset,length,size));
rc = len;
free_fail: free_fail:
kfree(gdtcmd); kfree(gdtcmd);
kfree(estr); kfree(estr);

View File

@ -8,11 +8,6 @@
int gdth_execute(struct Scsi_Host *shost, gdth_cmd_str *gdtcmd, char *cmnd, int gdth_execute(struct Scsi_Host *shost, gdth_cmd_str *gdtcmd, char *cmnd,
int timeout, u32 *info); int timeout, u32 *info);
static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host,
gdth_ha_str *ha);
static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
struct Scsi_Host *host, gdth_ha_str *ha);
static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer, static int gdth_set_asc_info(struct Scsi_Host *host, char *buffer,
int length, gdth_ha_str *ha); int length, gdth_ha_str *ha);