Skip to content

Commit 6469933

Browse files
JoePerchesdavem330
authored andcommitted
ethernet: Remove casts to same type
Adding casts of objects to the same type is unnecessary and confusing for a human reader. For example, this cast: int y; int *p = (int *)&y; I used the coccinelle script below to find and remove these unnecessary casts. I manually removed the conversions this script produces of casts with __force, __iomem and __user. @@ type T; T *p; @@ - (T *)p + p A function in atl1e_main.c was passed a const pointer when it actually modified elements of the structure. Change the argument to a non-const pointer. A function in stmmac needed a __force to avoid a sparse warning. Added it. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 20d5ec4 commit 6469933

34 files changed

Lines changed: 87 additions & 97 deletions

File tree

‎drivers/net/ethernet/8390/apne.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ apne_block_input(struct net_device *dev, int count, struct sk_buff *skb, int rin
454454
buf[count-1] = inb(NE_BASE + NE_DATAPORT);
455455
}
456456
} else {
457-
ptrc = (char*)buf;
457+
ptrc = buf;
458458
for (cnt = 0; cnt < count; cnt++)
459459
*ptrc++ = inb(NE_BASE + NE_DATAPORT);
460460
}

‎drivers/net/ethernet/aeroflex/greth.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ static int greth_set_mac_add(struct net_device *dev, void *p)
10141014
struct greth_regs *regs;
10151015

10161016
greth = netdev_priv(dev);
1017-
regs = (struct greth_regs *) greth->regs;
1017+
regs = greth->regs;
10181018

10191019
if (!is_valid_ether_addr(addr->sa_data))
10201020
return -EADDRNOTAVAIL;
@@ -1036,7 +1036,7 @@ static void greth_set_hash_filter(struct net_device *dev)
10361036
{
10371037
struct netdev_hw_addr *ha;
10381038
struct greth_private *greth = netdev_priv(dev);
1039-
struct greth_regs *regs = (struct greth_regs *) greth->regs;
1039+
struct greth_regs *regs = greth->regs;
10401040
u32 mc_filter[2];
10411041
unsigned int bitnr;
10421042

@@ -1055,7 +1055,7 @@ static void greth_set_multicast_list(struct net_device *dev)
10551055
{
10561056
int cfg;
10571057
struct greth_private *greth = netdev_priv(dev);
1058-
struct greth_regs *regs = (struct greth_regs *) greth->regs;
1058+
struct greth_regs *regs = greth->regs;
10591059

10601060
cfg = GRETH_REGLOAD(regs->control);
10611061
if (dev->flags & IFF_PROMISC)
@@ -1414,7 +1414,7 @@ static int __devinit greth_of_probe(struct platform_device *ofdev)
14141414
goto error1;
14151415
}
14161416

1417-
regs = (struct greth_regs *) greth->regs;
1417+
regs = greth->regs;
14181418
greth->irq = ofdev->archdata.irqs[0];
14191419

14201420
dev_set_drvdata(greth->dev, dev);

‎drivers/net/ethernet/amd/declance.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ static int lance_rx(struct net_device *dev)
623623
skb_put(skb, len); /* make room */
624624

625625
cp_from_buf(lp->type, skb->data,
626-
(char *)lp->rx_buf_ptr_cpu[entry], len);
626+
lp->rx_buf_ptr_cpu[entry], len);
627627

628628
skb->protocol = eth_type_trans(skb, dev);
629629
netif_rx(skb);
@@ -919,7 +919,7 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev)
919919
*lib_ptr(ib, btx_ring[entry].length, lp->type) = (-len);
920920
*lib_ptr(ib, btx_ring[entry].misc, lp->type) = 0;
921921

922-
cp_to_buf(lp->type, (char *)lp->tx_buf_ptr_cpu[entry], skb->data, len);
922+
cp_to_buf(lp->type, lp->tx_buf_ptr_cpu[entry], skb->data, len);
923923

924924
/* Now, give the packet to the lance */
925925
*lib_ptr(ib, btx_ring[entry].tmd1, lp->type) =

‎drivers/net/ethernet/apple/macmace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static int __devinit mace_probe(struct platform_device *pdev)
228228
* bits are reversed.
229229
*/
230230

231-
addr = (void *)MACE_PROM;
231+
addr = MACE_PROM;
232232

233233
for (j = 0; j < 6; ++j) {
234234
u8 v = bitrev8(addr[j<<4]);

‎drivers/net/ethernet/atheros/atl1c/atl1c_hw.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ int atl1c_phy_reset(struct atl1c_hw *hw)
602602

603603
int atl1c_phy_init(struct atl1c_hw *hw)
604604
{
605-
struct atl1c_adapter *adapter = (struct atl1c_adapter *)hw->adapter;
605+
struct atl1c_adapter *adapter = hw->adapter;
606606
struct pci_dev *pdev = adapter->pdev;
607607
int ret_val;
608608
u16 mii_bmcr_data = BMCR_RESET;
@@ -696,7 +696,7 @@ int atl1c_get_speed_and_duplex(struct atl1c_hw *hw, u16 *speed, u16 *duplex)
696696
/* select one link mode to get lower power consumption */
697697
int atl1c_phy_to_ps_link(struct atl1c_hw *hw)
698698
{
699-
struct atl1c_adapter *adapter = (struct atl1c_adapter *)hw->adapter;
699+
struct atl1c_adapter *adapter = hw->adapter;
700700
struct pci_dev *pdev = adapter->pdev;
701701
int ret = 0;
702702
u16 autoneg_advertised = ADVERTISED_10baseT_Half;
@@ -768,7 +768,7 @@ int atl1c_restart_autoneg(struct atl1c_hw *hw)
768768

769769
int atl1c_power_saving(struct atl1c_hw *hw, u32 wufc)
770770
{
771-
struct atl1c_adapter *adapter = (struct atl1c_adapter *)hw->adapter;
771+
struct atl1c_adapter *adapter = hw->adapter;
772772
struct pci_dev *pdev = adapter->pdev;
773773
u32 master_ctrl, mac_ctrl, phy_ctrl;
774774
u32 wol_ctrl, speed;

‎drivers/net/ethernet/atheros/atl1c/atl1c_main.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -989,12 +989,12 @@ static int atl1c_setup_ring_resources(struct atl1c_adapter *adapter)
989989
}
990990
for (i = 0; i < AT_MAX_TRANSMIT_QUEUE; i++) {
991991
tpd_ring[i].buffer_info =
992-
(struct atl1c_buffer *) (tpd_ring->buffer_info + count);
992+
(tpd_ring->buffer_info + count);
993993
count += tpd_ring[i].count;
994994
}
995995

996996
rfd_ring->buffer_info =
997-
(struct atl1c_buffer *) (tpd_ring->buffer_info + count);
997+
(tpd_ring->buffer_info + count);
998998
count += rfd_ring->count;
999999
rx_desc_count += rfd_ring->count;
10001000

@@ -1227,7 +1227,7 @@ static void atl1c_start_mac(struct atl1c_adapter *adapter)
12271227
*/
12281228
static int atl1c_reset_mac(struct atl1c_hw *hw)
12291229
{
1230-
struct atl1c_adapter *adapter = (struct atl1c_adapter *)hw->adapter;
1230+
struct atl1c_adapter *adapter = hw->adapter;
12311231
struct pci_dev *pdev = adapter->pdev;
12321232
u32 ctrl_data = 0;
12331233

@@ -1531,8 +1531,7 @@ static inline void atl1c_clear_phy_int(struct atl1c_adapter *adapter)
15311531
static bool atl1c_clean_tx_irq(struct atl1c_adapter *adapter,
15321532
enum atl1c_trans_queue type)
15331533
{
1534-
struct atl1c_tpd_ring *tpd_ring = (struct atl1c_tpd_ring *)
1535-
&adapter->tpd_ring[type];
1534+
struct atl1c_tpd_ring *tpd_ring = &adapter->tpd_ring[type];
15361535
struct atl1c_buffer *buffer_info;
15371536
struct pci_dev *pdev = adapter->pdev;
15381537
u16 next_to_clean = atomic_read(&tpd_ring->next_to_clean);

‎drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ static int atl1e_set_eeprom(struct net_device *netdev,
268268
if (eeprom_buff == NULL)
269269
return -ENOMEM;
270270

271-
ptr = (u32 *)eeprom_buff;
271+
ptr = eeprom_buff;
272272

273273
if (eeprom->offset & 3) {
274274
/* need read/modify/write of first changed EEPROM word */

‎drivers/net/ethernet/atheros/atl1e/atl1e_main.c‎

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,7 @@ static int __devinit atl1e_sw_init(struct atl1e_adapter *adapter)
641641
*/
642642
static void atl1e_clean_tx_ring(struct atl1e_adapter *adapter)
643643
{
644-
struct atl1e_tx_ring *tx_ring = (struct atl1e_tx_ring *)
645-
&adapter->tx_ring;
644+
struct atl1e_tx_ring *tx_ring = &adapter->tx_ring;
646645
struct atl1e_tx_buffer *tx_buffer = NULL;
647646
struct pci_dev *pdev = adapter->pdev;
648647
u16 index, ring_count;
@@ -686,7 +685,7 @@ static void atl1e_clean_tx_ring(struct atl1e_adapter *adapter)
686685
static void atl1e_clean_rx_ring(struct atl1e_adapter *adapter)
687686
{
688687
struct atl1e_rx_ring *rx_ring =
689-
(struct atl1e_rx_ring *)&adapter->rx_ring;
688+
&adapter->rx_ring;
690689
struct atl1e_rx_page_desc *rx_page_desc = rx_ring->rx_page_desc;
691690
u16 i, j;
692691

@@ -884,14 +883,12 @@ static int atl1e_setup_ring_resources(struct atl1e_adapter *adapter)
884883
return err;
885884
}
886885

887-
static inline void atl1e_configure_des_ring(const struct atl1e_adapter *adapter)
886+
static inline void atl1e_configure_des_ring(struct atl1e_adapter *adapter)
888887
{
889888

890-
struct atl1e_hw *hw = (struct atl1e_hw *)&adapter->hw;
891-
struct atl1e_rx_ring *rx_ring =
892-
(struct atl1e_rx_ring *)&adapter->rx_ring;
893-
struct atl1e_tx_ring *tx_ring =
894-
(struct atl1e_tx_ring *)&adapter->tx_ring;
889+
struct atl1e_hw *hw = &adapter->hw;
890+
struct atl1e_rx_ring *rx_ring = &adapter->rx_ring;
891+
struct atl1e_tx_ring *tx_ring = &adapter->tx_ring;
895892
struct atl1e_rx_page_desc *rx_page_desc = NULL;
896893
int i, j;
897894

@@ -932,7 +929,7 @@ static inline void atl1e_configure_des_ring(const struct atl1e_adapter *adapter)
932929

933930
static inline void atl1e_configure_tx(struct atl1e_adapter *adapter)
934931
{
935-
struct atl1e_hw *hw = (struct atl1e_hw *)&adapter->hw;
932+
struct atl1e_hw *hw = &adapter->hw;
936933
u32 dev_ctrl_data = 0;
937934
u32 max_pay_load = 0;
938935
u32 jumbo_thresh = 0;
@@ -975,7 +972,7 @@ static inline void atl1e_configure_tx(struct atl1e_adapter *adapter)
975972

976973
static inline void atl1e_configure_rx(struct atl1e_adapter *adapter)
977974
{
978-
struct atl1e_hw *hw = (struct atl1e_hw *)&adapter->hw;
975+
struct atl1e_hw *hw = &adapter->hw;
979976
u32 rxf_len = 0;
980977
u32 rxf_low = 0;
981978
u32 rxf_high = 0;
@@ -1224,8 +1221,7 @@ static inline void atl1e_clear_phy_int(struct atl1e_adapter *adapter)
12241221

12251222
static bool atl1e_clean_tx_irq(struct atl1e_adapter *adapter)
12261223
{
1227-
struct atl1e_tx_ring *tx_ring = (struct atl1e_tx_ring *)
1228-
&adapter->tx_ring;
1224+
struct atl1e_tx_ring *tx_ring = &adapter->tx_ring;
12291225
struct atl1e_tx_buffer *tx_buffer = NULL;
12301226
u16 hw_next_to_clean = AT_READ_REGW(&adapter->hw, REG_TPD_CONS_IDX);
12311227
u16 next_to_clean = atomic_read(&tx_ring->next_to_clean);
@@ -1384,15 +1380,14 @@ static struct atl1e_rx_page *atl1e_get_rx_page(struct atl1e_adapter *adapter,
13841380
(struct atl1e_rx_page_desc *) adapter->rx_ring.rx_page_desc;
13851381
u8 rx_using = rx_page_desc[que].rx_using;
13861382

1387-
return (struct atl1e_rx_page *)&(rx_page_desc[que].rx_page[rx_using]);
1383+
return &(rx_page_desc[que].rx_page[rx_using]);
13881384
}
13891385

13901386
static void atl1e_clean_rx_irq(struct atl1e_adapter *adapter, u8 que,
13911387
int *work_done, int work_to_do)
13921388
{
13931389
struct net_device *netdev = adapter->netdev;
1394-
struct atl1e_rx_ring *rx_ring = (struct atl1e_rx_ring *)
1395-
&adapter->rx_ring;
1390+
struct atl1e_rx_ring *rx_ring = &adapter->rx_ring;
13961391
struct atl1e_rx_page_desc *rx_page_desc =
13971392
(struct atl1e_rx_page_desc *) rx_ring->rx_page_desc;
13981393
struct sk_buff *skb = NULL;
@@ -1576,7 +1571,7 @@ static struct atl1e_tpd_desc *atl1e_get_tpd(struct atl1e_adapter *adapter)
15761571
tx_ring->next_to_use = 0;
15771572

15781573
memset(&tx_ring->desc[next_to_use], 0, sizeof(struct atl1e_tpd_desc));
1579-
return (struct atl1e_tpd_desc *)&tx_ring->desc[next_to_use];
1574+
return &tx_ring->desc[next_to_use];
15801575
}
15811576

15821577
static struct atl1e_tx_buffer *
@@ -2061,8 +2056,8 @@ static int atl1e_suspend(struct pci_dev *pdev, pm_message_t state)
20612056

20622057
if (wufc) {
20632058
/* get link status */
2064-
atl1e_read_phy_reg(hw, MII_BMSR, (u16 *)&mii_bmsr_data);
2065-
atl1e_read_phy_reg(hw, MII_BMSR, (u16 *)&mii_bmsr_data);
2059+
atl1e_read_phy_reg(hw, MII_BMSR, &mii_bmsr_data);
2060+
atl1e_read_phy_reg(hw, MII_BMSR, &mii_bmsr_data);
20662061

20672062
mii_advertise_data = ADVERTISE_10HALF;
20682063

@@ -2086,7 +2081,7 @@ static int atl1e_suspend(struct pci_dev *pdev, pm_message_t state)
20862081
for (i = 0; i < AT_SUSPEND_LINK_TIMEOUT; i++) {
20872082
msleep(100);
20882083
atl1e_read_phy_reg(hw, MII_BMSR,
2089-
(u16 *)&mii_bmsr_data);
2084+
&mii_bmsr_data);
20902085
if (mii_bmsr_data & BMSR_LSTATUS)
20912086
break;
20922087
}

‎drivers/net/ethernet/atheros/atlx/atl1.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ static s32 atl1_setup_ring_resources(struct atl1_adapter *adapter)
10611061
goto err_nomem;
10621062
}
10631063
rfd_ring->buffer_info =
1064-
(struct atl1_buffer *)(tpd_ring->buffer_info + tpd_ring->count);
1064+
(tpd_ring->buffer_info + tpd_ring->count);
10651065

10661066
/*
10671067
* real ring DMA buffer

‎drivers/net/ethernet/broadcom/bnx2.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,8 +872,7 @@ bnx2_alloc_mem(struct bnx2 *bp)
872872

873873
bnapi = &bp->bnx2_napi[i];
874874

875-
sblk = (void *) (status_blk +
876-
BNX2_SBLK_MSIX_ALIGN_SIZE * i);
875+
sblk = (status_blk + BNX2_SBLK_MSIX_ALIGN_SIZE * i);
877876
bnapi->status_blk.msix = sblk;
878877
bnapi->hw_tx_cons_ptr =
879878
&sblk->status_tx_quick_consumer_index;

0 commit comments

Comments
 (0)