Commit 1241f359 authored by Mark Haverkamp's avatar Mark Haverkamp Committed by James Bottomley

[SCSI] aacraid: General driver cleanup

Received from Mark Salyzyn

Remove superfluous code, optimize code, harden code, cast code, correct
some text, use msleep instead of schedule_timeout_interruptible. No
bugs.
Signed-off-by: default avatarMark Haverkamp <markh@osdl.org>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 53926274
...@@ -1607,13 +1607,14 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd) ...@@ -1607,13 +1607,14 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
cp[11] = 0; cp[11] = 0;
cp[12] = 0; cp[12] = 0;
aac_internal_transfer(scsicmd, cp, 0, aac_internal_transfer(scsicmd, cp, 0,
min((unsigned int)scsicmd->cmnd[13], sizeof(cp))); min_t(size_t, scsicmd->cmnd[13], sizeof(cp)));
if (sizeof(cp) < scsicmd->cmnd[13]) { if (sizeof(cp) < scsicmd->cmnd[13]) {
unsigned int len, offset = sizeof(cp); unsigned int len, offset = sizeof(cp);
memset(cp, 0, offset); memset(cp, 0, offset);
do { do {
len = min(scsicmd->cmnd[13]-offset, sizeof(cp)); len = min_t(size_t, scsicmd->cmnd[13] - offset,
sizeof(cp));
aac_internal_transfer(scsicmd, cp, offset, len); aac_internal_transfer(scsicmd, cp, offset, len);
} while ((offset += len) < scsicmd->cmnd[13]); } while ((offset += len) < scsicmd->cmnd[13]);
} }
...@@ -2080,7 +2081,6 @@ static int aac_send_srb_fib(struct scsi_cmnd* scsicmd) ...@@ -2080,7 +2081,6 @@ static int aac_send_srb_fib(struct scsi_cmnd* scsicmd)
return 0; return 0;
} }
dev = (struct aac_dev *)scsicmd->device->host->hostdata;
switch(scsicmd->sc_data_direction){ switch(scsicmd->sc_data_direction){
case DMA_TO_DEVICE: case DMA_TO_DEVICE:
flag = SRB_DataOut; flag = SRB_DataOut;
...@@ -2198,8 +2198,6 @@ static unsigned long aac_build_sg(struct scsi_cmnd* scsicmd, struct sgmap* psg) ...@@ -2198,8 +2198,6 @@ static unsigned long aac_build_sg(struct scsi_cmnd* scsicmd, struct sgmap* psg)
scsicmd->sc_data_direction); scsicmd->sc_data_direction);
psg->count = cpu_to_le32(sg_count); psg->count = cpu_to_le32(sg_count);
byte_count = 0;
for (i = 0; i < sg_count; i++) { for (i = 0; i < sg_count; i++) {
psg->sg[i].addr = cpu_to_le32(sg_dma_address(sg)); psg->sg[i].addr = cpu_to_le32(sg_dma_address(sg));
psg->sg[i].count = cpu_to_le32(sg_dma_len(sg)); psg->sg[i].count = cpu_to_le32(sg_dma_len(sg));
...@@ -2255,18 +2253,17 @@ static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* p ...@@ -2255,18 +2253,17 @@ static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* p
sg_count = pci_map_sg(dev->pdev, sg, scsicmd->use_sg, sg_count = pci_map_sg(dev->pdev, sg, scsicmd->use_sg,
scsicmd->sc_data_direction); scsicmd->sc_data_direction);
psg->count = cpu_to_le32(sg_count);
byte_count = 0;
for (i = 0; i < sg_count; i++) { for (i = 0; i < sg_count; i++) {
int count = sg_dma_len(sg);
addr = sg_dma_address(sg); addr = sg_dma_address(sg);
psg->sg[i].addr[0] = cpu_to_le32(addr & 0xffffffff); psg->sg[i].addr[0] = cpu_to_le32(addr & 0xffffffff);
psg->sg[i].addr[1] = cpu_to_le32(addr>>32); psg->sg[i].addr[1] = cpu_to_le32(addr>>32);
psg->sg[i].count = cpu_to_le32(sg_dma_len(sg)); psg->sg[i].count = cpu_to_le32(count);
byte_count += sg_dma_len(sg); byte_count += count;
sg++; sg++;
} }
psg->count = cpu_to_le32(sg_count);
/* hba wants the size to be exact */ /* hba wants the size to be exact */
if(byte_count > scsicmd->request_bufflen){ if(byte_count > scsicmd->request_bufflen){
u32 temp = le32_to_cpu(psg->sg[i-1].count) - u32 temp = le32_to_cpu(psg->sg[i-1].count) -
...@@ -2281,16 +2278,15 @@ static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* p ...@@ -2281,16 +2278,15 @@ static unsigned long aac_build_sg64(struct scsi_cmnd* scsicmd, struct sgmap64* p
} }
} }
else if(scsicmd->request_bufflen) { else if(scsicmd->request_bufflen) {
u64 addr; scsicmd->SCp.dma_handle = pci_map_single(dev->pdev,
addr = pci_map_single(dev->pdev,
scsicmd->request_buffer, scsicmd->request_buffer,
scsicmd->request_bufflen, scsicmd->request_bufflen,
scsicmd->sc_data_direction); scsicmd->sc_data_direction);
addr = scsicmd->SCp.dma_handle;
psg->count = cpu_to_le32(1); psg->count = cpu_to_le32(1);
psg->sg[0].addr[0] = cpu_to_le32(addr & 0xffffffff); psg->sg[0].addr[0] = cpu_to_le32(addr & 0xffffffff);
psg->sg[0].addr[1] = cpu_to_le32(addr >> 32); psg->sg[0].addr[1] = cpu_to_le32(addr >> 32);
psg->sg[0].count = cpu_to_le32(scsicmd->request_bufflen); psg->sg[0].count = cpu_to_le32(scsicmd->request_bufflen);
scsicmd->SCp.dma_handle = addr;
byte_count = scsicmd->request_bufflen; byte_count = scsicmd->request_bufflen;
} }
return byte_count; return byte_count;
......
...@@ -767,9 +767,9 @@ void aac_printf(struct aac_dev *dev, u32 val) ...@@ -767,9 +767,9 @@ void aac_printf(struct aac_dev *dev, u32 val)
if (cp[length] != 0) if (cp[length] != 0)
cp[length] = 0; cp[length] = 0;
if (level == LOG_AAC_HIGH_ERROR) if (level == LOG_AAC_HIGH_ERROR)
printk(KERN_WARNING "aacraid:%s", cp); printk(KERN_WARNING "%s:%s", dev->name, cp);
else else
printk(KERN_INFO "aacraid:%s", cp); printk(KERN_INFO "%s:%s", dev->name, cp);
} }
memset(cp, 0, 256); memset(cp, 0, 256);
} }
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
MODULE_AUTHOR("Red Hat Inc and Adaptec"); MODULE_AUTHOR("Red Hat Inc and Adaptec");
MODULE_DESCRIPTION("Dell PERC2, 2/Si, 3/Si, 3/Di, " MODULE_DESCRIPTION("Dell PERC2, 2/Si, 3/Si, 3/Di, "
"Adaptec Advanced Raid Products, " "Adaptec Advanced Raid Products, "
"and HP NetRAID-4M SCSI driver"); "HP NetRAID-4M, IBM ServeRAID & ICP SCSI driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_VERSION(AAC_DRIVER_FULL_VERSION); MODULE_VERSION(AAC_DRIVER_FULL_VERSION);
...@@ -777,6 +777,7 @@ static struct scsi_host_template aac_driver_template = { ...@@ -777,6 +777,7 @@ static struct scsi_host_template aac_driver_template = {
.cmd_per_lun = AAC_NUM_IO_FIB, .cmd_per_lun = AAC_NUM_IO_FIB,
#endif #endif
.use_clustering = ENABLE_CLUSTERING, .use_clustering = ENABLE_CLUSTERING,
.emulated = 1,
}; };
......
...@@ -183,7 +183,7 @@ static int rkt_sync_cmd(struct aac_dev *dev, u32 command, ...@@ -183,7 +183,7 @@ static int rkt_sync_cmd(struct aac_dev *dev, u32 command,
/* /*
* Yield the processor in case we are slow * Yield the processor in case we are slow
*/ */
schedule_timeout_uninterruptible(1); msleep(1);
} }
if (ok != 1) { if (ok != 1) {
/* /*
...@@ -343,7 +343,7 @@ static int aac_rkt_check_health(struct aac_dev *dev) ...@@ -343,7 +343,7 @@ static int aac_rkt_check_health(struct aac_dev *dev)
NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL);
pci_free_consistent(dev->pdev, sizeof(struct POSTSTATUS), pci_free_consistent(dev->pdev, sizeof(struct POSTSTATUS),
post, paddr); post, paddr);
if ((buffer[0] == '0') && (buffer[1] == 'x')) { if ((buffer[0] == '0') && ((buffer[1] == 'x') || (buffer[1] == 'X'))) {
ret = (buffer[2] <= '9') ? (buffer[2] - '0') : (buffer[2] - 'A' + 10); ret = (buffer[2] <= '9') ? (buffer[2] - '0') : (buffer[2] - 'A' + 10);
ret <<= 4; ret <<= 4;
ret += (buffer[3] <= '9') ? (buffer[3] - '0') : (buffer[3] - 'A' + 10); ret += (buffer[3] <= '9') ? (buffer[3] - '0') : (buffer[3] - 'A' + 10);
......
...@@ -183,7 +183,7 @@ static int rx_sync_cmd(struct aac_dev *dev, u32 command, ...@@ -183,7 +183,7 @@ static int rx_sync_cmd(struct aac_dev *dev, u32 command,
/* /*
* Yield the processor in case we are slow * Yield the processor in case we are slow
*/ */
schedule_timeout_uninterruptible(1); msleep(1);
} }
if (ok != 1) { if (ok != 1) {
/* /*
...@@ -342,7 +342,7 @@ static int aac_rx_check_health(struct aac_dev *dev) ...@@ -342,7 +342,7 @@ static int aac_rx_check_health(struct aac_dev *dev)
NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL);
pci_free_consistent(dev->pdev, sizeof(struct POSTSTATUS), pci_free_consistent(dev->pdev, sizeof(struct POSTSTATUS),
post, paddr); post, paddr);
if ((buffer[0] == '0') && (buffer[1] == 'x')) { if ((buffer[0] == '0') && ((buffer[1] == 'x') || (buffer[1] == 'X'))) {
ret = (buffer[2] <= '9') ? (buffer[2] - '0') : (buffer[2] - 'A' + 10); ret = (buffer[2] <= '9') ? (buffer[2] - '0') : (buffer[2] - 'A' + 10);
ret <<= 4; ret <<= 4;
ret += (buffer[3] <= '9') ? (buffer[3] - '0') : (buffer[3] - 'A' + 10); ret += (buffer[3] <= '9') ? (buffer[3] - '0') : (buffer[3] - 'A' + 10);
......
...@@ -189,7 +189,7 @@ static int sa_sync_cmd(struct aac_dev *dev, u32 command, ...@@ -189,7 +189,7 @@ static int sa_sync_cmd(struct aac_dev *dev, u32 command,
ok = 1; ok = 1;
break; break;
} }
schedule_timeout_uninterruptible(1); msleep(1);
} }
if (ok != 1) if (ok != 1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment