/* gdth_proc.c
* $Id: gdth_proc.c,v 1.42 2004/03/05 15:50:20 achim Exp $
*/
#include <linux/completion.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
int gdth_proc_info(struct Scsi_Host *host, char *buffer,char **start,off_t offset,int length,
int inout)
{
int hanum,busnum;
TRACE2(("gdth_proc_info() length %d offs %d inout %d\n",
length,(int)offset,inout));
hanum = NUMDATA(host)->hanum;
busnum= NUMDATA(host)->busnum;
if (inout)
return(gdth_set_info(buffer,length,host,hanum,busnum));
else
return(gdth_get_info(buffer,start,offset,length,host,hanum,busnum));
}
#else
int gdth_proc_info(char *buffer,char **start,off_t offset,int length,int hostno,
int inout)
{
int hanum,busnum,i;
TRACE2(("gdth_proc_info() length %d offs %d inout %d\n",
length,(int)offset,inout));
for (i = 0; i < gdth_ctr_vcount; ++i) {
if (gdth_ctr_vtab[i]->host_no == hostno)
break;
}
if (i == gdth_ctr_vcount)
return(-EINVAL);
hanum = NUMDATA(gdth_ctr_vtab[i])->hanum;
busnum= NUMDATA(gdth_ctr_vtab[i])->busnum;
if (inout)
return(gdth_set_info(buffer,length,gdth_ctr_vtab[i],hanum,busnum));
else
return(gdth_get_info(buffer,start,offset,length,
gdth_ctr_vtab[i],hanum,busnum));
}
#endif
static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host,
int hanum,int busnum)
{
int ret_val = -EINVAL;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
Scsi_Request *scp;
struct scsi_device *sdev;
#else
Scsi_Cmnd *scp;
struct scsi_device *sdev;
#endif
TRACE2(("gdth_set_info() ha %d bus %d\n",hanum,busnum));
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
sdev = scsi_get_host_dev(host);
scp = scsi_allocate_request(sdev, GFP_KERNEL);
if (!scp)
return -ENOMEM;
scp->sr_cmd_len = 12;
scp->sr_use_sg = 0;
#else
sdev = scsi_get_host_dev(host);
scp = scsi_allocate_device(sdev, 1, FALSE);
if (!scp)
return -ENOMEM;
scp->cmd_len = 12;
scp->use_sg = 0;
#endif
if (length >= 4) {
if (strncmp(buffer,"gdth",4) == 0) {
buffer += 5;
length -= 5;
ret_val = gdth_set_asc_info( buffer, length, hanum, scp );
}
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
scsi_release_request(scp);
scsi_free_host_dev(sdev);
#else
scsi_release_command(scp);
scsi_free_host_dev(sdev);
#endif
return ret_val;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Request *scp)
#else
static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp)
#endif
{
int orig_length, drive, wb_mode;
int i, found;
gdth_ha_str *ha;
gdth_cmd_str gdtcmd;
gdth_cpar_str *pcpar;
ulong64 paddr;
char cmnd[MAX_COMMAND_SIZE];
memset(cmnd, 0xff, 12);
memset(&gdtcmd, 0, sizeof(gdth_cmd_str));
TRACE2(("gdth_set_asc_info() ha %d\n",hanum));
ha = HADATA(gdth_ctr_tab[hanum]);
orig_length = length + 5;
drive = -1;
wb_mode = 0;
found = FALSE;
if (length >= 5 &&