Commit 3b716933 authored by Kamenee Arumugam's avatar Kamenee Arumugam Committed by Doug Ledford

IB/qib: Remove unnecessary memory allocation for boardname

Remove all the memory allocation implemented for boardname and
directly assign the defined string literal.
Reviewed-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: default avatarKamenee Arumugam <kamenee.arumugam@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 5b0ef650
...@@ -1742,38 +1742,32 @@ static void qib_setup_6120_interrupt(struct qib_devdata *dd) ...@@ -1742,38 +1742,32 @@ static void qib_setup_6120_interrupt(struct qib_devdata *dd)
*/ */
static void pe_boardname(struct qib_devdata *dd) static void pe_boardname(struct qib_devdata *dd)
{ {
char *n; u32 boardid;
u32 boardid, namelen;
boardid = SYM_FIELD(dd->revision, Revision, boardid = SYM_FIELD(dd->revision, Revision,
BoardID); BoardID);
switch (boardid) { switch (boardid) {
case 2: case 2:
n = "InfiniPath_QLE7140"; dd->boardname = "InfiniPath_QLE7140";
break; break;
default: default:
qib_dev_err(dd, "Unknown 6120 board with ID %u\n", boardid); qib_dev_err(dd, "Unknown 6120 board with ID %u\n", boardid);
n = "Unknown_InfiniPath_6120"; dd->boardname = "Unknown_InfiniPath_6120";
break; break;
} }
namelen = strlen(n) + 1;
dd->boardname = kmalloc(namelen, GFP_KERNEL);
if (dd->boardname)
snprintf(dd->boardname, namelen, "%s", n);
if (dd->majrev != 4 || !dd->minrev || dd->minrev > 2) if (dd->majrev != 4 || !dd->minrev || dd->minrev > 2)
qib_dev_err(dd, qib_dev_err(dd,
"Unsupported InfiniPath hardware revision %u.%u!\n", "Unsupported InfiniPath hardware revision %u.%u!\n",
dd->majrev, dd->minrev); dd->majrev, dd->minrev);
snprintf(dd->boardversion, sizeof(dd->boardversion), snprintf(dd->boardversion, sizeof(dd->boardversion),
"ChipABI %u.%u, %s, InfiniPath%u %u.%u, SW Compat %u\n", "ChipABI %u.%u, %s, InfiniPath%u %u.%u, SW Compat %u\n",
QIB_CHIP_VERS_MAJ, QIB_CHIP_VERS_MIN, dd->boardname, QIB_CHIP_VERS_MAJ, QIB_CHIP_VERS_MIN, dd->boardname,
(unsigned)SYM_FIELD(dd->revision, Revision_R, Arch), (unsigned int)SYM_FIELD(dd->revision, Revision_R, Arch),
dd->majrev, dd->minrev, dd->majrev, dd->minrev,
(unsigned)SYM_FIELD(dd->revision, Revision_R, SW)); (unsigned int)SYM_FIELD(dd->revision, Revision_R, SW));
} }
/* /*
......
...@@ -2050,41 +2050,35 @@ static void qib_setup_7220_interrupt(struct qib_devdata *dd) ...@@ -2050,41 +2050,35 @@ static void qib_setup_7220_interrupt(struct qib_devdata *dd)
*/ */
static void qib_7220_boardname(struct qib_devdata *dd) static void qib_7220_boardname(struct qib_devdata *dd)
{ {
char *n; u32 boardid;
u32 boardid, namelen;
boardid = SYM_FIELD(dd->revision, Revision, boardid = SYM_FIELD(dd->revision, Revision,
BoardID); BoardID);
switch (boardid) { switch (boardid) {
case 1: case 1:
n = "InfiniPath_QLE7240"; dd->boardname = "InfiniPath_QLE7240";
break; break;
case 2: case 2:
n = "InfiniPath_QLE7280"; dd->boardname = "InfiniPath_QLE7280";
break; break;
default: default:
qib_dev_err(dd, "Unknown 7220 board with ID %u\n", boardid); qib_dev_err(dd, "Unknown 7220 board with ID %u\n", boardid);
n = "Unknown_InfiniPath_7220"; dd->boardname = "Unknown_InfiniPath_7220";
break; break;
} }
namelen = strlen(n) + 1;
dd->boardname = kmalloc(namelen, GFP_KERNEL);
if (dd->boardname)
snprintf(dd->boardname, namelen, "%s", n);
if (dd->majrev != 5 || !dd->minrev || dd->minrev > 2) if (dd->majrev != 5 || !dd->minrev || dd->minrev > 2)
qib_dev_err(dd, qib_dev_err(dd,
"Unsupported InfiniPath hardware revision %u.%u!\n", "Unsupported InfiniPath hardware revision %u.%u!\n",
dd->majrev, dd->minrev); dd->majrev, dd->minrev);
snprintf(dd->boardversion, sizeof(dd->boardversion), snprintf(dd->boardversion, sizeof(dd->boardversion),
"ChipABI %u.%u, %s, InfiniPath%u %u.%u, SW Compat %u\n", "ChipABI %u.%u, %s, InfiniPath%u %u.%u, SW Compat %u\n",
QIB_CHIP_VERS_MAJ, QIB_CHIP_VERS_MIN, dd->boardname, QIB_CHIP_VERS_MAJ, QIB_CHIP_VERS_MIN, dd->boardname,
(unsigned)SYM_FIELD(dd->revision, Revision_R, Arch), (unsigned int)SYM_FIELD(dd->revision, Revision_R, Arch),
dd->majrev, dd->minrev, dd->majrev, dd->minrev,
(unsigned)SYM_FIELD(dd->revision, Revision_R, SW)); (unsigned int)SYM_FIELD(dd->revision, Revision_R, SW));
} }
/* /*
......
...@@ -3582,75 +3582,69 @@ bail:; ...@@ -3582,75 +3582,69 @@ bail:;
static unsigned qib_7322_boardname(struct qib_devdata *dd) static unsigned qib_7322_boardname(struct qib_devdata *dd)
{ {
/* Will need enumeration of board-types here */ /* Will need enumeration of board-types here */
char *n; u32 boardid;
u32 boardid, namelen; unsigned int features = DUAL_PORT_CAP;
unsigned features = DUAL_PORT_CAP;
boardid = SYM_FIELD(dd->revision, Revision, BoardID); boardid = SYM_FIELD(dd->revision, Revision, BoardID);
switch (boardid) { switch (boardid) {
case 0: case 0:
n = "InfiniPath_QLE7342_Emulation"; dd->boardname = "InfiniPath_QLE7342_Emulation";
break; break;
case 1: case 1:
n = "InfiniPath_QLE7340"; dd->boardname = "InfiniPath_QLE7340";
dd->flags |= QIB_HAS_QSFP; dd->flags |= QIB_HAS_QSFP;
features = PORT_SPD_CAP; features = PORT_SPD_CAP;
break; break;
case 2: case 2:
n = "InfiniPath_QLE7342"; dd->boardname = "InfiniPath_QLE7342";
dd->flags |= QIB_HAS_QSFP; dd->flags |= QIB_HAS_QSFP;
break; break;
case 3: case 3:
n = "InfiniPath_QMI7342"; dd->boardname = "InfiniPath_QMI7342";
break; break;
case 4: case 4:
n = "InfiniPath_Unsupported7342"; dd->boardname = "InfiniPath_Unsupported7342";
qib_dev_err(dd, "Unsupported version of QMH7342\n"); qib_dev_err(dd, "Unsupported version of QMH7342\n");
features = 0; features = 0;
break; break;
case BOARD_QMH7342: case BOARD_QMH7342:
n = "InfiniPath_QMH7342"; dd->boardname = "InfiniPath_QMH7342";
features = 0x24; features = 0x24;
break; break;
case BOARD_QME7342: case BOARD_QME7342:
n = "InfiniPath_QME7342"; dd->boardname = "InfiniPath_QME7342";
break; break;
case 8: case 8:
n = "InfiniPath_QME7362"; dd->boardname = "InfiniPath_QME7362";
dd->flags |= QIB_HAS_QSFP; dd->flags |= QIB_HAS_QSFP;
break; break;
case BOARD_QMH7360: case BOARD_QMH7360:
n = "Intel IB QDR 1P FLR-QSFP Adptr"; dd->boardname = "Intel IB QDR 1P FLR-QSFP Adptr";
dd->flags |= QIB_HAS_QSFP; dd->flags |= QIB_HAS_QSFP;
break; break;
case 15: case 15:
n = "InfiniPath_QLE7342_TEST"; dd->boardname = "InfiniPath_QLE7342_TEST";
dd->flags |= QIB_HAS_QSFP; dd->flags |= QIB_HAS_QSFP;
break; break;
default: default:
n = "InfiniPath_QLE73xy_UNKNOWN"; dd->boardname = "InfiniPath_QLE73xy_UNKNOWN";
qib_dev_err(dd, "Unknown 7322 board type %u\n", boardid); qib_dev_err(dd, "Unknown 7322 board type %u\n", boardid);
break; break;
} }
dd->board_atten = 1; /* index into txdds_Xdr */ dd->board_atten = 1; /* index into txdds_Xdr */
namelen = strlen(n) + 1;
dd->boardname = kmalloc(namelen, GFP_KERNEL);
if (dd->boardname)
snprintf(dd->boardname, namelen, "%s", n);
snprintf(dd->boardversion, sizeof(dd->boardversion), snprintf(dd->boardversion, sizeof(dd->boardversion),
"ChipABI %u.%u, %s, InfiniPath%u %u.%u, SW Compat %u\n", "ChipABI %u.%u, %s, InfiniPath%u %u.%u, SW Compat %u\n",
QIB_CHIP_VERS_MAJ, QIB_CHIP_VERS_MIN, dd->boardname, QIB_CHIP_VERS_MAJ, QIB_CHIP_VERS_MIN, dd->boardname,
(unsigned)SYM_FIELD(dd->revision, Revision_R, Arch), (unsigned int)SYM_FIELD(dd->revision, Revision_R, Arch),
dd->majrev, dd->minrev, dd->majrev, dd->minrev,
(unsigned)SYM_FIELD(dd->revision, Revision_R, SW)); (unsigned int)SYM_FIELD(dd->revision, Revision_R, SW));
if (qib_singleport && (features >> PORT_SPD_CAP_SHIFT) & PORT_SPD_CAP) { if (qib_singleport && (features >> PORT_SPD_CAP_SHIFT) & PORT_SPD_CAP) {
qib_devinfo(dd->pcidev, qib_devinfo(dd->pcidev,
"IB%u: Forced to single port mode by module parameter\n", "IB%u: Forced to single port mode by module parameter\n",
dd->unit); dd->unit);
features &= PORT_SPD_CAP; features &= PORT_SPD_CAP;
} }
......
...@@ -1398,7 +1398,6 @@ static void cleanup_device_data(struct qib_devdata *dd) ...@@ -1398,7 +1398,6 @@ static void cleanup_device_data(struct qib_devdata *dd)
qib_free_ctxtdata(dd, rcd); qib_free_ctxtdata(dd, rcd);
} }
kfree(tmp); kfree(tmp);
kfree(dd->boardname);
} }
/* /*
......
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