From: ching <ching2048@areca.com.tw>
To: jbottomley@parallels.com, dan.carpenter@oracle.com,
thenzl@redhat.com, agordeev@redhat.com,
linux-scsi@vger.kernel.org,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH v1.2 6/16] arcmsr: precise checking adapter ID
Date: Wed, 14 May 2014 19:20:43 +0800 [thread overview]
Message-ID: <1400066443.6957.33.camel@localhost> (raw)
From: Ching<ching2048@areca.com.tw>
Rewriteing the arcmsr_define_adapter_type function to precisely check adapter ID.
This can prevent an unknown adapter be used as a default adapter type by driver.
Signed-off-by: Ching<ching2048@areca.com.tw>
---
diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
--- a/drivers/scsi/arcmsr/arcmsr_hba.c 2014-05-07 18:44:40.000000000 +0800
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c 2014-05-07 18:45:20.000000000 +0800
@@ -295,24 +295,43 @@ static int arcmsr_bios_param(struct scsi
return 0;
}
-static void arcmsr_define_adapter_type(struct AdapterControlBlock *acb)
+static bool arcmsr_define_adapter_type(struct AdapterControlBlock *acb)
{
struct pci_dev *pdev = acb->pdev;
u16 dev_id;
+
pci_read_config_word(pdev, PCI_DEVICE_ID, &dev_id);
acb->dev_id = dev_id;
switch (dev_id) {
- case 0x1880: {
+ case 0x1880:
acb->adapter_type = ACB_ADAPTER_TYPE_C;
- }
break;
- case 0x1201: {
+ case 0x1200:
+ case 0x1201:
+ case 0x1202:
acb->adapter_type = ACB_ADAPTER_TYPE_B;
- }
break;
-
- default: acb->adapter_type = ACB_ADAPTER_TYPE_A;
+ case 0x1110:
+ case 0x1120:
+ case 0x1130:
+ case 0x1160:
+ case 0x1170:
+ case 0x1210:
+ case 0x1220:
+ case 0x1230:
+ case 0x1260:
+ case 0x1270:
+ case 0x1280:
+ case 0x1380:
+ case 0x1381:
+ case 0x1680:
+ acb->adapter_type = ACB_ADAPTER_TYPE_A;
+ break;
+ default:
+ pr_notice("Unknown device ID = 0x%x\n", dev_id);
+ return false;
}
+ return true;
}
static uint8_t arcmsr_hba_wait_msgint_ready(struct AdapterControlBlock *acb)
@@ -714,7 +733,9 @@ static int arcmsr_probe(struct pci_dev *
ACB_F_MESSAGE_WQBUFFER_READED);
acb->acb_flags &= ~ACB_F_SCSISTOPADAPTER;
INIT_LIST_HEAD(&acb->ccb_free_list);
- arcmsr_define_adapter_type(acb);
+ error = arcmsr_define_adapter_type(acb);
+ if (!error)
+ goto pci_release_regs;
error = arcmsr_remap_pciregion(acb);
if(!error){
goto pci_release_regs;
reply other threads:[~2014-05-14 11:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1400066443.6957.33.camel@localhost \
--to=ching2048@areca.com.tw \
--cc=agordeev@redhat.com \
--cc=dan.carpenter@oracle.com \
--cc=jbottomley@parallels.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=thenzl@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).