Skip to content

Commit

Permalink
netxen_nic: Log proper error message in case of mismatched adapter type
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Manish Chopra authored and davem330 committed May 30, 2013
1 parent dc7551c commit b08a92b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 7 additions & 3 deletions drivers/net/ethernet/qlogic/netxen/netxen_nic.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit b08a92b

Please sign in to comment.