[BNX2]: Fix nvram sizing
authorMichael Chan <mchan@broadcom.com>
Tue, 24 Jan 2006 00:11:42 +0000 (16:11 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 24 Jan 2006 00:11:42 +0000 (16:11 -0800)
Add code to correctly determine nvram size.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bnx2.c
drivers/net/bnx2.h

index 7b99cf26a129e9494fe22cbd6a46e9e8864878db..4f613b0be1403cd32944ba0c4eacefc556c8cca8 100644 (file)
@@ -2724,9 +2724,16 @@ bnx2_init_nvram(struct bnx2 *bp)
        if (j == entry_count) {
                bp->flash_info = NULL;
                printk(KERN_ALERT PFX "Unknown flash/EEPROM type.\n");
-               rc = -ENODEV;
+               return -ENODEV;
        }
 
+       val = REG_RD_IND(bp, bp->shmem_base + BNX2_SHARED_HW_CFG_CONFIG2);
+       val &= BNX2_SHARED_HW_CFG2_NVM_SIZE_MASK;
+       if (val)
+               bp->flash_size = val;
+       else
+               bp->flash_size = bp->flash_info->total_size;
+
        return rc;
 }
 
@@ -4809,10 +4816,10 @@ bnx2_get_eeprom_len(struct net_device *dev)
 {
        struct bnx2 *bp = dev->priv;
 
-       if (bp->flash_info == 0)
+       if (bp->flash_info == NULL)
                return 0;
 
-       return (int) bp->flash_info->total_size;
+       return (int) bp->flash_size;
 }
 
 static int
index ea70bbcd2542a3c6dad33ca18318c8ef3dc5de75..ae17b63b98b4f571dbee210f96e50496b2f4f08a 100644 (file)
@@ -4072,6 +4072,7 @@ struct bnx2 {
        struct net_device_stats net_stats;
 
        struct flash_spec       *flash_info;
+       u32                     flash_size;
 };
 
 static u32 bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset);
@@ -4273,6 +4274,9 @@ struct fw_info {
 #define BNX2_SHARED_HW_CFG_LED_MODE_GPHY1       0x100
 #define BNX2_SHARED_HW_CFG_LED_MODE_GPHY2       0x200
 
+#define BNX2_SHARED_HW_CFG_CONFIG2             0x00000040
+#define BNX2_SHARED_HW_CFG2_NVM_SIZE_MASK       0x00fff000
+
 #define BNX2_DEV_INFO_BC_REV                   0x0000004c
 
 #define BNX2_PORT_HW_CFG_MAC_UPPER             0x00000050