From: Andrew Vasquez <andrew.vasquez@qlogic.com>
To: Linux SCSI Mailing List <linux-scsi@vger.kernel.org>,
James Bottomley <james.bottomley@steeleye.com>
Cc: Andrew Vasquez <andrew.vasquez@qlogic.com>
Subject: [PATCH 7/14] qla2xxx: Refactor set-HBA-model/description code.
Date: Mon, 29 Jan 2007 10:22:24 -0800 [thread overview]
Message-ID: <11700949513962-git-send-email-andrew.vasquez@qlogic.com> (raw)
In-Reply-To: <20070129182124.GA26940@andrew-vasquezs-computer.local>
Limit assignments via qla2x00_model_name[] array to HBA
subsystem vendor IDs equal to QLogic.
Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
---
drivers/scsi/qla2xxx/qla_init.c | 83 +++++++++++++++++---------------------
1 files changed, 37 insertions(+), 46 deletions(-)
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 5c9ce61..f4c63ad 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1355,6 +1355,39 @@ qla2x00_configure_hba(scsi_qla_host_t *ha)
return(rval);
}
+static inline void
+qla2x00_set_model_info(scsi_qla_host_t *ha, uint8_t *model, size_t len, char *def)
+{
+ char *st, *en;
+ uint16_t index;
+
+ if (memcmp(model, BINZERO, len) != 0) {
+ strncpy(ha->model_number, model, len);
+ st = en = ha->model_number;
+ en += len - 1;
+ while (en > st) {
+ if (*en != 0x20 && *en != 0x00)
+ break;
+ *en-- = '\0';
+ }
+
+ index = (ha->pdev->subsystem_device & 0xff);
+ if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC &&
+ index < QLA_MODEL_NAMES)
+ ha->model_desc = qla2x00_model_name[index * 2 + 1];
+ } else {
+ index = (ha->pdev->subsystem_device & 0xff);
+ if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC &&
+ index < QLA_MODEL_NAMES) {
+ strcpy(ha->model_number,
+ qla2x00_model_name[index * 2]);
+ ha->model_desc = qla2x00_model_name[index * 2 + 1];
+ } else {
+ strcpy(ha->model_number, def);
+ }
+ }
+}
+
/*
* NVRAM configuration for ISP 2xxx
*
@@ -1493,33 +1526,8 @@ qla2x00_nvram_config(scsi_qla_host_t *ha)
strcpy(ha->model_number, "QLA2300");
}
} else {
- if (rval == 0 &&
- memcmp(nv->model_number, BINZERO,
- sizeof(nv->model_number)) != 0) {
- char *st, *en;
-
- strncpy(ha->model_number, nv->model_number,
- sizeof(nv->model_number));
- st = en = ha->model_number;
- en += sizeof(nv->model_number) - 1;
- while (en > st) {
- if (*en != 0x20 && *en != 0x00)
- break;
- *en-- = '\0';
- }
- } else {
- uint16_t index;
-
- index = (ha->pdev->subsystem_device & 0xff);
- if (index < QLA_MODEL_NAMES) {
- strcpy(ha->model_number,
- qla2x00_model_name[index * 2]);
- ha->model_desc =
- qla2x00_model_name[index * 2 + 1];
- } else {
- strcpy(ha->model_number, "QLA23xx");
- }
- }
+ qla2x00_set_model_info(ha, nv->model_number,
+ sizeof(nv->model_number), "QLA23xx");
}
} else if (IS_QLA2200(ha)) {
nv->firmware_options[0] |= BIT_2;
@@ -3444,25 +3452,8 @@ qla24xx_nvram_config(scsi_qla_host_t *ha)
/*
* Setup driver NVRAM options.
*/
- if (memcmp(nv->model_name, BINZERO, sizeof(nv->model_name)) != 0) {
- char *st, *en;
- uint16_t index;
-
- strncpy(ha->model_number, nv->model_name,
- sizeof(nv->model_name));
- st = en = ha->model_number;
- en += sizeof(nv->model_name) - 1;
- while (en > st) {
- if (*en != 0x20 && *en != 0x00)
- break;
- *en-- = '\0';
- }
-
- index = (ha->pdev->subsystem_device & 0xff);
- if (index < QLA_MODEL_NAMES)
- ha->model_desc = qla2x00_model_name[index * 2 + 1];
- } else
- strcpy(ha->model_number, "QLA2462");
+ qla2x00_set_model_info(ha, nv->model_name, sizeof(nv->model_name),
+ "QLA2462");
/* Use alternate WWN? */
if (nv->host_p & __constant_cpu_to_le32(BIT_15)) {
--
1.5.0.rc2.gdbaa0
next prev parent reply other threads:[~2007-01-29 18:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-29 18:21 [PATCH 0/14] qla2xxx: driver update Andrew Vasquez
2007-01-29 18:22 ` [PATCH 1/14] qla2xxx: Correct sector-erase issues while writing flash Andrew Vasquez
2007-01-29 18:22 ` [PATCH 2/14] qla2xxx: Add MSI-X support Andrew Vasquez
2007-01-29 18:22 ` [PATCH 3/14] qla2xxx: Handle IRQ-0 assignments by the system Andrew Vasquez
2007-01-29 18:22 ` [PATCH 4/14] qla2xxx: Export OptionROM boot-codes version information Andrew Vasquez
2007-01-29 18:22 ` [PATCH 5/14] qla2xxx: Perform implicit LOGO during fabric logout request Andrew Vasquez
2007-01-29 18:22 ` [PATCH 6/14] qla2xxx: Set correct cabling state during initialization Andrew Vasquez
2007-01-29 18:22 ` Andrew Vasquez [this message]
2007-01-29 18:22 ` [PATCH 8/14] qla2xxx: Check loop-state before reading host statistics Andrew Vasquez
2007-01-29 18:22 ` [PATCH 9/14] qla2xxx: Fail initialization when inconsistent NVRAM detected Andrew Vasquez
2007-01-29 18:22 ` [PATCH 10/14] qla2xxx: Enable queue-full throttling when UNDERRUN detected Andrew Vasquez
2007-01-29 18:22 ` [PATCH 11/14] qla2xxx: Allow NVRAM updates to immediately go into affect Andrew Vasquez
2007-01-29 18:22 ` [PATCH 12/14] qla2xxx: Fixup printk() with proper new-line character Andrew Vasquez
2007-01-29 18:22 ` [PATCH 13/14] qla2xxx: Remove unnecessary spinlock primitive - mbx_reg_lock Andrew Vasquez
2007-01-29 18:22 ` [PATCH 14/14] qla2xxx: Update version number to 8.01.07-k5 Andrew Vasquez
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=11700949513962-git-send-email-andrew.vasquez@qlogic.com \
--to=andrew.vasquez@qlogic.com \
--cc=james.bottomley@steeleye.com \
--cc=linux-scsi@vger.kernel.org \
/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