Commit 12aad947 authored by Ching Huang's avatar Ching Huang Committed by Christoph Hellwig

arcmsr: revise message_isr_bh_fn to remove duplicate code

Revise message_isr_bh_fn to remove the duplicate code for each adapter type.
Signed-off-by: default avatarChing Huang <ching2048@areca.com.tw>
Reviewed-by: default avatarTomas Henzl <thenzl@redhat.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 8b7c9942
...@@ -493,106 +493,57 @@ static int arcmsr_alloc_ccb_pool(struct AdapterControlBlock *acb) ...@@ -493,106 +493,57 @@ static int arcmsr_alloc_ccb_pool(struct AdapterControlBlock *acb)
static void arcmsr_message_isr_bh_fn(struct work_struct *work) static void arcmsr_message_isr_bh_fn(struct work_struct *work)
{ {
struct AdapterControlBlock *acb = container_of(work,struct AdapterControlBlock, arcmsr_do_message_isr_bh); struct AdapterControlBlock *acb = container_of(work,
switch (acb->adapter_type) { struct AdapterControlBlock, arcmsr_do_message_isr_bh);
case ACB_ADAPTER_TYPE_A: {
struct MessageUnit_A __iomem *reg = acb->pmuA;
char *acb_dev_map = (char *)acb->device_map; char *acb_dev_map = (char *)acb->device_map;
uint32_t __iomem *signature = (uint32_t __iomem*) (&reg->message_rwbuffer[0]); uint32_t __iomem *signature = NULL;
char __iomem *devicemap = (char __iomem*) (&reg->message_rwbuffer[21]); char __iomem *devicemap = NULL;
int target, lun; int target, lun;
struct scsi_device *psdev; struct scsi_device *psdev;
char diff; char diff, temp;
atomic_inc(&acb->rq_map_token); switch (acb->adapter_type) {
if (readl(signature) == ARCMSR_SIGNATURE_GET_CONFIG) { case ACB_ADAPTER_TYPE_A: {
for(target = 0; target < ARCMSR_MAX_TARGETID -1; target++) { struct MessageUnit_A __iomem *reg = acb->pmuA;
diff = (*acb_dev_map)^readb(devicemap);
if (diff != 0) { signature = (uint32_t __iomem *)(&reg->message_rwbuffer[0]);
char temp; devicemap = (char __iomem *)(&reg->message_rwbuffer[21]);
*acb_dev_map = readb(devicemap);
temp =*acb_dev_map;
for(lun = 0; lun < ARCMSR_MAX_TARGETLUN; lun++) {
if((temp & 0x01)==1 && (diff & 0x01) == 1) {
scsi_add_device(acb->host, 0, target, lun);
}else if((temp & 0x01) == 0 && (diff & 0x01) == 1) {
psdev = scsi_device_lookup(acb->host, 0, target, lun);
if (psdev != NULL ) {
scsi_remove_device(psdev);
scsi_device_put(psdev);
}
}
temp >>= 1;
diff >>= 1;
}
}
devicemap++;
acb_dev_map++;
}
}
break; break;
} }
case ACB_ADAPTER_TYPE_B: { case ACB_ADAPTER_TYPE_B: {
struct MessageUnit_B *reg = acb->pmuB; struct MessageUnit_B *reg = acb->pmuB;
char *acb_dev_map = (char *)acb->device_map;
uint32_t __iomem *signature = (uint32_t __iomem*)(&reg->message_rwbuffer[0]);
char __iomem *devicemap = (char __iomem*)(&reg->message_rwbuffer[21]);
int target, lun;
struct scsi_device *psdev;
char diff;
atomic_inc(&acb->rq_map_token); signature = (uint32_t __iomem *)(&reg->message_rwbuffer[0]);
if (readl(signature) == ARCMSR_SIGNATURE_GET_CONFIG) { devicemap = (char __iomem *)(&reg->message_rwbuffer[21]);
for(target = 0; target < ARCMSR_MAX_TARGETID -1; target++) {
diff = (*acb_dev_map)^readb(devicemap);
if (diff != 0) {
char temp;
*acb_dev_map = readb(devicemap);
temp =*acb_dev_map;
for(lun = 0; lun < ARCMSR_MAX_TARGETLUN; lun++) {
if((temp & 0x01)==1 && (diff & 0x01) == 1) {
scsi_add_device(acb->host, 0, target, lun);
}else if((temp & 0x01) == 0 && (diff & 0x01) == 1) {
psdev = scsi_device_lookup(acb->host, 0, target, lun);
if (psdev != NULL ) {
scsi_remove_device(psdev);
scsi_device_put(psdev);
}
}
temp >>= 1;
diff >>= 1;
}
}
devicemap++;
acb_dev_map++;
}
}
}
break; break;
}
case ACB_ADAPTER_TYPE_C: { case ACB_ADAPTER_TYPE_C: {
struct MessageUnit_C *reg = acb->pmuC; struct MessageUnit_C __iomem *reg = acb->pmuC;
char *acb_dev_map = (char *)acb->device_map;
uint32_t __iomem *signature = (uint32_t __iomem *)(&reg->msgcode_rwbuffer[0]);
char __iomem *devicemap = (char __iomem *)(&reg->msgcode_rwbuffer[21]);
int target, lun;
struct scsi_device *psdev;
char diff;
signature = (uint32_t __iomem *)(&reg->msgcode_rwbuffer[0]);
devicemap = (char __iomem *)(&reg->msgcode_rwbuffer[21]);
break;
}
}
atomic_inc(&acb->rq_map_token); atomic_inc(&acb->rq_map_token);
if (readl(signature) == ARCMSR_SIGNATURE_GET_CONFIG) { if (readl(signature) != ARCMSR_SIGNATURE_GET_CONFIG)
for (target = 0; target < ARCMSR_MAX_TARGETID - 1; target++) { return;
diff = (*acb_dev_map)^readb(devicemap); for (target = 0; target < ARCMSR_MAX_TARGETID - 1;
target++) {
temp = readb(devicemap);
diff = (*acb_dev_map) ^ temp;
if (diff != 0) { if (diff != 0) {
char temp; *acb_dev_map = temp;
*acb_dev_map = readb(devicemap); for (lun = 0; lun < ARCMSR_MAX_TARGETLUN;
temp = *acb_dev_map; lun++) {
for (lun = 0; lun < ARCMSR_MAX_TARGETLUN; lun++) { if ((diff & 0x01) == 1 &&
if ((temp & 0x01) == 1 && (diff & 0x01) == 1) { (temp & 0x01) == 1) {
scsi_add_device(acb->host, 0, target, lun); scsi_add_device(acb->host,
} else if ((temp & 0x01) == 0 && (diff & 0x01) == 1) { 0, target, lun);
psdev = scsi_device_lookup(acb->host, 0, target, lun); } else if ((diff & 0x01) == 1
&& (temp & 0x01) == 0) {
psdev = scsi_device_lookup(acb->host,
0, target, lun);
if (psdev != NULL) { if (psdev != NULL) {
scsi_remove_device(psdev); scsi_remove_device(psdev);
scsi_device_put(psdev); scsi_device_put(psdev);
...@@ -605,9 +556,6 @@ static void arcmsr_message_isr_bh_fn(struct work_struct *work) ...@@ -605,9 +556,6 @@ static void arcmsr_message_isr_bh_fn(struct work_struct *work)
devicemap++; devicemap++;
acb_dev_map++; acb_dev_map++;
} }
}
}
}
} }
static int static int
......
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