Skip to content

Commit

Permalink
[BNX2X]: Correct init_one()
Browse files Browse the repository at this point in the history
Correct PCI-E info printed by init_one()
In one case it failed to free the netdev. 

Signed-off-by: Eliezer Tamir <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Eliezer Tamir authored and davem330 committed Feb 28, 2008
1 parent c14423f commit 2504795
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
41 changes: 26 additions & 15 deletions drivers/net/bnx2x.c
Original file line number Diff line number Diff line change
Expand Up @@ -8873,14 +8873,32 @@ static int __devinit bnx2x_init_board(struct pci_dev *pdev,
return rc;
}

static int __devinit bnx2x_get_pcie_width(struct bnx2x *bp)
{
u32 val = REG_RD(bp, PCICFG_OFFSET + PCICFG_LINK_CONTROL);

val = (val & PCICFG_LINK_WIDTH) >> PCICFG_LINK_WIDTH_SHIFT;
return val;
}

/* return value of 1=2.5GHz 2=5GHz */
static int __devinit bnx2x_get_pcie_speed(struct bnx2x *bp)
{
u32 val = REG_RD(bp, PCICFG_OFFSET + PCICFG_LINK_CONTROL);

val = (val & PCICFG_LINK_SPEED) >> PCICFG_LINK_SPEED_SHIFT;
return val;
}

static int __devinit bnx2x_init_one(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
static int version_printed;
struct net_device *dev = NULL;
struct bnx2x *bp;
int rc, i;
int rc;
int port = PCI_FUNC(pdev->devfn);
DECLARE_MAC_BUF(mac);

if (version_printed++ == 0)
printk(KERN_INFO "%s", version);
Expand All @@ -8897,6 +8915,7 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,

if (port && onefunc) {
printk(KERN_ERR PFX "second function disabled. exiting\n");
free_netdev(dev);
return 0;
}

Expand Down Expand Up @@ -8950,22 +8969,14 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
pci_set_drvdata(pdev, dev);

bp->name = board_info[ent->driver_data].name;
printk(KERN_INFO "%s: %s (%c%d) PCI%s %s %dMHz "
"found at mem %lx, IRQ %d, ",
dev->name, bp->name,
printk(KERN_INFO "%s: %s (%c%d) PCI-E x%d %s found at mem %lx,"
" IRQ %d, ", dev->name, bp->name,
((CHIP_ID(bp) & 0xf000) >> 12) + 'A',
((CHIP_ID(bp) & 0x0ff0) >> 4),
((bp->flags & PCIX_FLAG) ? "-X" : ""),
((bp->flags & PCI_32BIT_FLAG) ? "32-bit" : "64-bit"),
bp->bus_speed_mhz,
dev->base_addr,
bp->pdev->irq);

printk("node addr ");
for (i = 0; i < 6; i++)
printk("%2.2x", dev->dev_addr[i]);
printk("\n");

bnx2x_get_pcie_width(bp),
(bnx2x_get_pcie_speed(bp) == 2) ? "5GHz (Gen2)" : "2.5GHz",
dev->base_addr, bp->pdev->irq);
printk(KERN_CONT "node addr %s\n", print_mac(mac, dev->dev_addr));
return 0;
}

Expand Down
5 changes: 5 additions & 0 deletions drivers/net/bnx2x.h
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,11 @@ struct bnx2x {
DPM_TRIGER_TYPE); \
} while (0)

/* PCIE link and speed */
#define PCICFG_LINK_WIDTH 0x1f00000
#define PCICFG_LINK_WIDTH_SHIFT 20
#define PCICFG_LINK_SPEED 0xf0000
#define PCICFG_LINK_SPEED_SHIFT 16

/* stuff added to make the code fit 80Col */

Expand Down

0 comments on commit 2504795

Please sign in to comment.