netxen_nic: Log proper error message in case of mismatched adapter type
authorManish Chopra <manish.chopra@qlogic.com>
Thu, 30 May 2013 09:51:35 +0000 (09:51 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 30 May 2013 23:52:37 +0000 (16:52 -0700)
o log "Unknown" board name and "Unknown" serial number in case
  of mismatched adapter type found. This will avoid weird characters
  logs when an adapter is in bad state or corrupted.

Signed-off-by: Manish Chopra <manish.chopra@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/qlogic/netxen/netxen_nic.h
drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c

index 322a36b76727d3522bb8bb1a35440d18ee21b696..e5ab1ecb4bb20f3ac8555fa5b257ac843c0d5b6b 100644 (file)
@@ -1855,7 +1855,7 @@ static const struct netxen_brdinfo netxen_boards[] = {
 
 #define NUM_SUPPORTED_BOARDS ARRAY_SIZE(netxen_boards)
 
-static inline void get_brd_name_by_type(u32 type, char *name)
+static inline int netxen_nic_get_brd_name_by_type(u32 type, char *name)
 {
        int i, found = 0;
        for (i = 0; i < NUM_SUPPORTED_BOARDS; ++i) {
@@ -1864,10 +1864,14 @@ static inline void get_brd_name_by_type(u32 type, char *name)
                        found = 1;
                        break;
                }
+       }
 
+       if (!found) {
+               strcpy(name, "Unknown");
+               return -EINVAL;
        }
-       if (!found)
-               name = "Unknown";
+
+       return 0;
 }
 
 static inline u32 netxen_tx_avail(struct nx_host_tx_ring *tx_ring)
index 2294cd2293b11f41595eaabab532e694800e05f0..558df468f2e45c23246db40244b2b410cb6a58f0 100644 (file)
@@ -841,7 +841,9 @@ netxen_check_options(struct netxen_adapter *adapter)
        }
 
        if (adapter->portnum == 0) {
-               get_brd_name_by_type(adapter->ahw.board_type, brd_name);
+               if (netxen_nic_get_brd_name_by_type(adapter->ahw.board_type,
+                                                   brd_name))
+                       strcpy(serial_num, "Unknown");
 
                pr_info("%s: %s Board S/N %s  Chip rev 0x%x\n",
                                module_name(THIS_MODULE),