diff options
author | Peter Hagervall <hager@cs.umu.se> | 2005-08-10 17:18:16 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2005-08-29 18:56:43 -0400 |
commit | 14ab9b867aa6c107b4886bdc5b23f277ab10792e (patch) | |
tree | dec16a22fe4e18c1de63256454f5a0810ce17379 | |
parent | 07dc3f0718d2c88c3094a0aadeeb4744effc5439 (diff) |
[BNX2]: Possible sparse fixes, take two
This patch contains the following possible cleanups/fixes:
- use C99 struct initializers
- make a few arrays and structs static
- remove a few uses of literal 0 as NULL pointer
- use convenience function instead of cast+dereference in bnx2_ioctl()
- remove superfluous casts to u8 * in calls to readl/writel
Signed-off-by: Peter Hagervall <hager@cs.umu.se>
Acked-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/bnx2.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index 8acc655ec1e8..3a9d6a8b90a2 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c | |||
@@ -52,7 +52,6 @@ static struct { | |||
52 | { "HP NC370i Multifunction Gigabit Server Adapter" }, | 52 | { "HP NC370i Multifunction Gigabit Server Adapter" }, |
53 | { "Broadcom NetXtreme II BCM5706 1000Base-SX" }, | 53 | { "Broadcom NetXtreme II BCM5706 1000Base-SX" }, |
54 | { "HP NC370F Multifunction Gigabit Server Adapter" }, | 54 | { "HP NC370F Multifunction Gigabit Server Adapter" }, |
55 | { 0 }, | ||
56 | }; | 55 | }; |
57 | 56 | ||
58 | static struct pci_device_id bnx2_pci_tbl[] = { | 57 | static struct pci_device_id bnx2_pci_tbl[] = { |
@@ -3507,11 +3506,11 @@ bnx2_test_registers(struct bnx2 *bp) | |||
3507 | rw_mask = reg_tbl[i].rw_mask; | 3506 | rw_mask = reg_tbl[i].rw_mask; |
3508 | ro_mask = reg_tbl[i].ro_mask; | 3507 | ro_mask = reg_tbl[i].ro_mask; |
3509 | 3508 | ||
3510 | save_val = readl((u8 *) bp->regview + offset); | 3509 | save_val = readl(bp->regview + offset); |
3511 | 3510 | ||
3512 | writel(0, (u8 *) bp->regview + offset); | 3511 | writel(0, bp->regview + offset); |
3513 | 3512 | ||
3514 | val = readl((u8 *) bp->regview + offset); | 3513 | val = readl(bp->regview + offset); |
3515 | if ((val & rw_mask) != 0) { | 3514 | if ((val & rw_mask) != 0) { |
3516 | goto reg_test_err; | 3515 | goto reg_test_err; |
3517 | } | 3516 | } |
@@ -3520,9 +3519,9 @@ bnx2_test_registers(struct bnx2 *bp) | |||
3520 | goto reg_test_err; | 3519 | goto reg_test_err; |
3521 | } | 3520 | } |
3522 | 3521 | ||
3523 | writel(0xffffffff, (u8 *) bp->regview + offset); | 3522 | writel(0xffffffff, bp->regview + offset); |
3524 | 3523 | ||
3525 | val = readl((u8 *) bp->regview + offset); | 3524 | val = readl(bp->regview + offset); |
3526 | if ((val & rw_mask) != rw_mask) { | 3525 | if ((val & rw_mask) != rw_mask) { |
3527 | goto reg_test_err; | 3526 | goto reg_test_err; |
3528 | } | 3527 | } |
@@ -3531,11 +3530,11 @@ bnx2_test_registers(struct bnx2 *bp) | |||
3531 | goto reg_test_err; | 3530 | goto reg_test_err; |
3532 | } | 3531 | } |
3533 | 3532 | ||
3534 | writel(save_val, (u8 *) bp->regview + offset); | 3533 | writel(save_val, bp->regview + offset); |
3535 | continue; | 3534 | continue; |
3536 | 3535 | ||
3537 | reg_test_err: | 3536 | reg_test_err: |
3538 | writel(save_val, (u8 *) bp->regview + offset); | 3537 | writel(save_val, bp->regview + offset); |
3539 | ret = -ENODEV; | 3538 | ret = -ENODEV; |
3540 | break; | 3539 | break; |
3541 | } | 3540 | } |
@@ -4698,7 +4697,7 @@ bnx2_set_rx_csum(struct net_device *dev, u32 data) | |||
4698 | 4697 | ||
4699 | #define BNX2_NUM_STATS 45 | 4698 | #define BNX2_NUM_STATS 45 |
4700 | 4699 | ||
4701 | struct { | 4700 | static struct { |
4702 | char string[ETH_GSTRING_LEN]; | 4701 | char string[ETH_GSTRING_LEN]; |
4703 | } bnx2_stats_str_arr[BNX2_NUM_STATS] = { | 4702 | } bnx2_stats_str_arr[BNX2_NUM_STATS] = { |
4704 | { "rx_bytes" }, | 4703 | { "rx_bytes" }, |
@@ -4750,7 +4749,7 @@ struct { | |||
4750 | 4749 | ||
4751 | #define STATS_OFFSET32(offset_name) (offsetof(struct statistics_block, offset_name) / 4) | 4750 | #define STATS_OFFSET32(offset_name) (offsetof(struct statistics_block, offset_name) / 4) |
4752 | 4751 | ||
4753 | unsigned long bnx2_stats_offset_arr[BNX2_NUM_STATS] = { | 4752 | static unsigned long bnx2_stats_offset_arr[BNX2_NUM_STATS] = { |
4754 | STATS_OFFSET32(stat_IfHCInOctets_hi), | 4753 | STATS_OFFSET32(stat_IfHCInOctets_hi), |
4755 | STATS_OFFSET32(stat_IfHCInBadOctets_hi), | 4754 | STATS_OFFSET32(stat_IfHCInBadOctets_hi), |
4756 | STATS_OFFSET32(stat_IfHCOutOctets_hi), | 4755 | STATS_OFFSET32(stat_IfHCOutOctets_hi), |
@@ -4801,7 +4800,7 @@ unsigned long bnx2_stats_offset_arr[BNX2_NUM_STATS] = { | |||
4801 | /* stat_IfHCInBadOctets and stat_Dot3StatsCarrierSenseErrors are | 4800 | /* stat_IfHCInBadOctets and stat_Dot3StatsCarrierSenseErrors are |
4802 | * skipped because of errata. | 4801 | * skipped because of errata. |
4803 | */ | 4802 | */ |
4804 | u8 bnx2_5706_stats_len_arr[BNX2_NUM_STATS] = { | 4803 | static u8 bnx2_5706_stats_len_arr[BNX2_NUM_STATS] = { |
4805 | 8,0,8,8,8,8,8,8,8,8, | 4804 | 8,0,8,8,8,8,8,8,8,8, |
4806 | 4,0,4,4,4,4,4,4,4,4, | 4805 | 4,0,4,4,4,4,4,4,4,4, |
4807 | 4,4,4,4,4,4,4,4,4,4, | 4806 | 4,4,4,4,4,4,4,4,4,4, |
@@ -4811,7 +4810,7 @@ u8 bnx2_5706_stats_len_arr[BNX2_NUM_STATS] = { | |||
4811 | 4810 | ||
4812 | #define BNX2_NUM_TESTS 6 | 4811 | #define BNX2_NUM_TESTS 6 |
4813 | 4812 | ||
4814 | struct { | 4813 | static struct { |
4815 | char string[ETH_GSTRING_LEN]; | 4814 | char string[ETH_GSTRING_LEN]; |
4816 | } bnx2_tests_str_arr[BNX2_NUM_TESTS] = { | 4815 | } bnx2_tests_str_arr[BNX2_NUM_TESTS] = { |
4817 | { "register_test (offline)" }, | 4816 | { "register_test (offline)" }, |
@@ -4910,7 +4909,7 @@ bnx2_get_ethtool_stats(struct net_device *dev, | |||
4910 | struct bnx2 *bp = dev->priv; | 4909 | struct bnx2 *bp = dev->priv; |
4911 | int i; | 4910 | int i; |
4912 | u32 *hw_stats = (u32 *) bp->stats_blk; | 4911 | u32 *hw_stats = (u32 *) bp->stats_blk; |
4913 | u8 *stats_len_arr = 0; | 4912 | u8 *stats_len_arr = NULL; |
4914 | 4913 | ||
4915 | if (hw_stats == NULL) { | 4914 | if (hw_stats == NULL) { |
4916 | memset(buf, 0, sizeof(u64) * BNX2_NUM_STATS); | 4915 | memset(buf, 0, sizeof(u64) * BNX2_NUM_STATS); |
@@ -5012,7 +5011,7 @@ static struct ethtool_ops bnx2_ethtool_ops = { | |||
5012 | static int | 5011 | static int |
5013 | bnx2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | 5012 | bnx2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
5014 | { | 5013 | { |
5015 | struct mii_ioctl_data *data = (struct mii_ioctl_data *)&ifr->ifr_data; | 5014 | struct mii_ioctl_data *data = if_mii(ifr); |
5016 | struct bnx2 *bp = dev->priv; | 5015 | struct bnx2 *bp = dev->priv; |
5017 | int err; | 5016 | int err; |
5018 | 5017 | ||
@@ -5505,12 +5504,12 @@ bnx2_resume(struct pci_dev *pdev) | |||
5505 | } | 5504 | } |
5506 | 5505 | ||
5507 | static struct pci_driver bnx2_pci_driver = { | 5506 | static struct pci_driver bnx2_pci_driver = { |
5508 | name: DRV_MODULE_NAME, | 5507 | .name = DRV_MODULE_NAME, |
5509 | id_table: bnx2_pci_tbl, | 5508 | .id_table = bnx2_pci_tbl, |
5510 | probe: bnx2_init_one, | 5509 | .probe = bnx2_init_one, |
5511 | remove: __devexit_p(bnx2_remove_one), | 5510 | .remove = __devexit_p(bnx2_remove_one), |
5512 | suspend: bnx2_suspend, | 5511 | .suspend = bnx2_suspend, |
5513 | resume: bnx2_resume, | 5512 | .resume = bnx2_resume, |
5514 | }; | 5513 | }; |
5515 | 5514 | ||
5516 | static int __init bnx2_init(void) | 5515 | static int __init bnx2_init(void) |