IB/qib: Remove unnecessary memory allocation for boardname
authorKamenee Arumugam <kamenee.arumugam@intel.com>
Tue, 22 Aug 2017 01:26:26 +0000 (18:26 -0700)
committerDoug Ledford <dledford@redhat.com>
Mon, 28 Aug 2017 23:12:17 +0000 (19:12 -0400)
Remove all the memory allocation implemented for boardname and
directly assign the defined string literal.

Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: Kamenee Arumugam <kamenee.arumugam@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/qib/qib_iba6120.c
drivers/infiniband/hw/qib/qib_iba7220.c
drivers/infiniband/hw/qib/qib_iba7322.c
drivers/infiniband/hw/qib/qib_init.c

index 46045fc28fa0188c2ff6b6762eca757d87f49091..3259a60e4f4f35ac1b89ad3437687964c606a6b9 100644 (file)
@@ -1742,38 +1742,32 @@ static void qib_setup_6120_interrupt(struct qib_devdata *dd)
  */
 static void pe_boardname(struct qib_devdata *dd)
 {
-       char *n;
-       u32 boardid, namelen;
+       u32 boardid;
 
        boardid = SYM_FIELD(dd->revision, Revision,
                            BoardID);
 
        switch (boardid) {
        case 2:
-               n = "InfiniPath_QLE7140";
+               dd->boardname = "InfiniPath_QLE7140";
                break;
        default:
                qib_dev_err(dd, "Unknown 6120 board with ID %u\n", boardid);
-               n = "Unknown_InfiniPath_6120";
+               dd->boardname = "Unknown_InfiniPath_6120";
                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)
                qib_dev_err(dd,
-                       "Unsupported InfiniPath hardware revision %u.%u!\n",
-                       dd->majrev, dd->minrev);
+                           "Unsupported InfiniPath hardware revision %u.%u!\n",
+                           dd->majrev, dd->minrev);
 
        snprintf(dd->boardversion, sizeof(dd->boardversion),
                 "ChipABI %u.%u, %s, InfiniPath%u %u.%u, SW Compat %u\n",
                 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,
-                (unsigned)SYM_FIELD(dd->revision, Revision_R, SW));
-
+                (unsigned int)SYM_FIELD(dd->revision, Revision_R, SW));
 }
 
 /*
index 49cd6e3beb7274db40e9342f9b6853f03de12a0c..04bdd3d487b13d59f3eabadb316926cc6a8ca3c3 100644 (file)
@@ -2050,41 +2050,35 @@ static void qib_setup_7220_interrupt(struct qib_devdata *dd)
  */
 static void qib_7220_boardname(struct qib_devdata *dd)
 {
-       char *n;
-       u32 boardid, namelen;
+       u32 boardid;
 
        boardid = SYM_FIELD(dd->revision, Revision,
                            BoardID);
 
        switch (boardid) {
        case 1:
-               n = "InfiniPath_QLE7240";
+               dd->boardname = "InfiniPath_QLE7240";
                break;
        case 2:
-               n = "InfiniPath_QLE7280";
+               dd->boardname = "InfiniPath_QLE7280";
                break;
        default:
                qib_dev_err(dd, "Unknown 7220 board with ID %u\n", boardid);
-               n = "Unknown_InfiniPath_7220";
+               dd->boardname = "Unknown_InfiniPath_7220";
                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)
                qib_dev_err(dd,
-                       "Unsupported InfiniPath hardware revision %u.%u!\n",
-                       dd->majrev, dd->minrev);
+                           "Unsupported InfiniPath hardware revision %u.%u!\n",
+                           dd->majrev, dd->minrev);
 
        snprintf(dd->boardversion, sizeof(dd->boardversion),
                 "ChipABI %u.%u, %s, InfiniPath%u %u.%u, SW Compat %u\n",
                 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,
-                (unsigned)SYM_FIELD(dd->revision, Revision_R, SW));
+                (unsigned int)SYM_FIELD(dd->revision, Revision_R, SW));
 }
 
 /*
index 2653064ce9e91a0dc094f14243a891bd80d58320..92ae68c8e76f8d4e2aba200c9ad0ea43b0c261a3 100644 (file)
@@ -3582,75 +3582,69 @@ bail:;
 static unsigned qib_7322_boardname(struct qib_devdata *dd)
 {
        /* Will need enumeration of board-types here */
-       char *n;
-       u32 boardid, namelen;
-       unsigned features = DUAL_PORT_CAP;
+       u32 boardid;
+       unsigned int features = DUAL_PORT_CAP;
 
        boardid = SYM_FIELD(dd->revision, Revision, BoardID);
 
        switch (boardid) {
        case 0:
-               n = "InfiniPath_QLE7342_Emulation";
+               dd->boardname = "InfiniPath_QLE7342_Emulation";
                break;
        case 1:
-               n = "InfiniPath_QLE7340";
+               dd->boardname = "InfiniPath_QLE7340";
                dd->flags |= QIB_HAS_QSFP;
                features = PORT_SPD_CAP;
                break;
        case 2:
-               n = "InfiniPath_QLE7342";
+               dd->boardname = "InfiniPath_QLE7342";
                dd->flags |= QIB_HAS_QSFP;
                break;
        case 3:
-               n = "InfiniPath_QMI7342";
+               dd->boardname = "InfiniPath_QMI7342";
                break;
        case 4:
-               n = "InfiniPath_Unsupported7342";
+               dd->boardname = "InfiniPath_Unsupported7342";
                qib_dev_err(dd, "Unsupported version of QMH7342\n");
                features = 0;
                break;
        case BOARD_QMH7342:
-               n = "InfiniPath_QMH7342";
+               dd->boardname = "InfiniPath_QMH7342";
                features = 0x24;
                break;
        case BOARD_QME7342:
-               n = "InfiniPath_QME7342";
+               dd->boardname = "InfiniPath_QME7342";
                break;
        case 8:
-               n = "InfiniPath_QME7362";
+               dd->boardname = "InfiniPath_QME7362";
                dd->flags |= QIB_HAS_QSFP;
                break;
        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;
                break;
        case 15:
-               n = "InfiniPath_QLE7342_TEST";
+               dd->boardname = "InfiniPath_QLE7342_TEST";
                dd->flags |= QIB_HAS_QSFP;
                break;
        default:
-               n = "InfiniPath_QLE73xy_UNKNOWN";
+               dd->boardname = "InfiniPath_QLE73xy_UNKNOWN";
                qib_dev_err(dd, "Unknown 7322 board type %u\n", boardid);
                break;
        }
        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),
                 "ChipABI %u.%u, %s, InfiniPath%u %u.%u, SW Compat %u\n",
                 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,
-                (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) {
                qib_devinfo(dd->pcidev,
-                       "IB%u: Forced to single port mode by module parameter\n",
-                       dd->unit);
+                           "IB%u: Forced to single port mode by module parameter\n",
+                           dd->unit);
                features &= PORT_SPD_CAP;
        }
 
index cce4ab468b29486641375d704de1fa062fc5a932..c5a4c65636d635701d7c3df99c70679eedb72796 100644 (file)
@@ -1398,7 +1398,6 @@ static void cleanup_device_data(struct qib_devdata *dd)
                qib_free_ctxtdata(dd, rcd);
        }
        kfree(tmp);
-       kfree(dd->boardname);
 }
 
 /*