Clean up the ioctl to not process nonsense on SCSI isp cards.

MFC after:	1 month
This commit is contained in:
mjacob 2006-07-10 22:39:32 +00:00
parent cfc179a934
commit 34d639efec

View File

@ -290,37 +290,40 @@ ispioctl(_DEV dev, u_long c, caddr_t addr, int flags, _IOP *td)
switch (c) {
#ifdef ISP_FW_CRASH_DUMP
case ISP_GET_FW_CRASH_DUMP:
{
uint16_t *ptr = FCPARAM(isp)->isp_dump_data;
size_t sz;
if (IS_FC(isp)) {
uint16_t *ptr = FCPARAM(isp)->isp_dump_data;
size_t sz;
retval = 0;
if (IS_2200(isp))
sz = QLA2200_RISC_IMAGE_DUMP_SIZE;
else
sz = QLA2300_RISC_IMAGE_DUMP_SIZE;
ISP_LOCK(isp);
if (ptr && *ptr) {
void *uaddr = *((void **) addr);
if (copyout(ptr, uaddr, sz)) {
retval = EFAULT;
retval = 0;
if (IS_2200(isp)) {
sz = QLA2200_RISC_IMAGE_DUMP_SIZE;
} else {
*ptr = 0;
sz = QLA2300_RISC_IMAGE_DUMP_SIZE;
}
} else {
retval = ENXIO;
ISP_LOCK(isp);
if (ptr && *ptr) {
void *uaddr = *((void **) addr);
if (copyout(ptr, uaddr, sz)) {
retval = EFAULT;
} else {
*ptr = 0;
}
} else {
retval = ENXIO;
}
ISP_UNLOCK(isp);
}
ISP_UNLOCK(isp);
break;
}
case ISP_FORCE_CRASH_DUMP:
ISP_LOCK(isp);
isp_freeze_loopdown(isp, "ispioctl(ISP_FORCE_CRASH_DUMP)");
isp_fw_dump(isp);
isp_reinit(isp);
ISP_UNLOCK(isp);
retval = 0;
if (IS_FC(isp)) {
ISP_LOCK(isp);
isp_freeze_loopdown(isp,
"ispioctl(ISP_FORCE_CRASH_DUMP)");
isp_fw_dump(isp);
isp_reinit(isp);
ISP_UNLOCK(isp);
retval = 0;
}
break;
#endif
case ISP_SDBLEV:
@ -377,6 +380,9 @@ ispioctl(_DEV dev, u_long c, caddr_t addr, int flags, _IOP *td)
struct isp_fc_device *ifc = (struct isp_fc_device *) addr;
struct lportdb *lp;
if (IS_SCSI(isp)) {
break;
}
if (ifc->loopid < 0 || ifc->loopid >= MAX_FC_TARG) {
retval = EINVAL;
break;
@ -434,19 +440,20 @@ ispioctl(_DEV dev, u_long c, caddr_t addr, int flags, _IOP *td)
{
struct isp_hba_device *hba = (struct isp_hba_device *) addr;
MEMZERO(hba, sizeof (*hba));
ISP_LOCK(isp);
hba->fc_fw_major = ISP_FW_MAJORX(isp->isp_fwrev);
hba->fc_fw_minor = ISP_FW_MINORX(isp->isp_fwrev);
hba->fc_fw_micro = ISP_FW_MICROX(isp->isp_fwrev);
hba->fc_speed = FCPARAM(isp)->isp_gbspeed;
hba->fc_scsi_supported = 1;
hba->fc_topology = FCPARAM(isp)->isp_topo + 1;
hba->fc_loopid = FCPARAM(isp)->isp_loopid;
hba->nvram_node_wwn = FCPARAM(isp)->isp_nodewwn;
hba->nvram_port_wwn = FCPARAM(isp)->isp_portwwn;
hba->active_node_wwn = ISP_NODEWWN(isp);
hba->active_port_wwn = ISP_PORTWWN(isp);
ISP_UNLOCK(isp);
if (IS_FC(isp)) {
hba->fc_speed = FCPARAM(isp)->isp_gbspeed;
hba->fc_scsi_supported = 1;
hba->fc_topology = FCPARAM(isp)->isp_topo + 1;
hba->fc_loopid = FCPARAM(isp)->isp_loopid;
hba->nvram_node_wwn = FCPARAM(isp)->isp_nodewwn;
hba->nvram_port_wwn = FCPARAM(isp)->isp_portwwn;
hba->active_node_wwn = ISP_NODEWWN(isp);
hba->active_port_wwn = ISP_PORTWWN(isp);
}
retval = 0;
break;
}
@ -454,8 +461,7 @@ ispioctl(_DEV dev, u_long c, caddr_t addr, int flags, _IOP *td)
{
struct isp_fc_param *f = (struct isp_fc_param *) addr;
if (!IS_FC(isp)) {
retval = EINVAL;
if (IS_SCSI(isp)) {
break;
}
f->parameter = 0;
@ -488,8 +494,7 @@ ispioctl(_DEV dev, u_long c, caddr_t addr, int flags, _IOP *td)
struct isp_fc_param *f = (struct isp_fc_param *) addr;
uint32_t param = f->parameter;
if (!IS_FC(isp)) {
retval = EINVAL;
if (IS_SCSI(isp)) {
break;
}
f->parameter = 0;
@ -546,7 +551,6 @@ ispioctl(_DEV dev, u_long c, caddr_t addr, int flags, _IOP *td)
mbreg_t mbs;
if (IS_SCSI(isp)) {
retval = EINVAL;
break;
}