Skip to content

Commit a8c22a2

Browse files
keesdavem330
authored andcommitted
net: tulip: Convert timers to use timer_setup()
In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() to pass the timer pointer explicitly. Cc: "David S. Miller" <[email protected]> Cc: David Howells <[email protected]> Cc: Jarod Wilson <[email protected]> Cc: Stephen Hemminger <[email protected]> Cc: Johannes Berg <[email protected]> Cc: Eric Dumazet <[email protected]> Cc: Philippe Reynes <[email protected]> Cc: "[email protected]" <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Kees Cook <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3d2ceaa commit a8c22a2

File tree

10 files changed

+48
-50
lines changed

10 files changed

+48
-50
lines changed

drivers/net/ethernet/dec/tulip/de4x5.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ static int de4x5_init(struct net_device *dev);
912912
static int de4x5_sw_reset(struct net_device *dev);
913913
static int de4x5_rx(struct net_device *dev);
914914
static int de4x5_tx(struct net_device *dev);
915-
static void de4x5_ast(struct net_device *dev);
915+
static void de4x5_ast(struct timer_list *t);
916916
static int de4x5_txur(struct net_device *dev);
917917
static int de4x5_rx_ovfc(struct net_device *dev);
918918

@@ -1147,8 +1147,7 @@ de4x5_hw_init(struct net_device *dev, u_long iobase, struct device *gendev)
11471147
lp->timeout = -1;
11481148
lp->gendev = gendev;
11491149
spin_lock_init(&lp->lock);
1150-
setup_timer(&lp->timer, (void (*)(unsigned long))de4x5_ast,
1151-
(unsigned long)dev);
1150+
timer_setup(&lp->timer, de4x5_ast, 0);
11521151
de4x5_parse_params(dev);
11531152

11541153
/*
@@ -1741,9 +1740,10 @@ de4x5_tx(struct net_device *dev)
17411740
}
17421741

17431742
static void
1744-
de4x5_ast(struct net_device *dev)
1743+
de4x5_ast(struct timer_list *t)
17451744
{
1746-
struct de4x5_private *lp = netdev_priv(dev);
1745+
struct de4x5_private *lp = from_timer(lp, t, timer);
1746+
struct net_device *dev = dev_get_drvdata(lp->gendev);
17471747
int next_tick = DE4X5_AUTOSENSE_MS;
17481748
int dt;
17491749

@@ -2369,7 +2369,7 @@ autoconf_media(struct net_device *dev)
23692369
lp->media = INIT;
23702370
lp->tcount = 0;
23712371

2372-
de4x5_ast(dev);
2372+
de4x5_ast(&lp->timer);
23732373

23742374
return lp->media;
23752375
}

drivers/net/ethernet/dec/tulip/dmfe.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ static void dmfe_phy_write_1bit(void __iomem *, u32);
331331
static u16 dmfe_phy_read_1bit(void __iomem *);
332332
static u8 dmfe_sense_speed(struct dmfe_board_info *);
333333
static void dmfe_process_mode(struct dmfe_board_info *);
334-
static void dmfe_timer(unsigned long);
334+
static void dmfe_timer(struct timer_list *);
335335
static inline u32 cal_CRC(unsigned char *, unsigned int, u8);
336336
static void dmfe_rx_packet(struct net_device *, struct dmfe_board_info *);
337337
static void dmfe_free_tx_pkt(struct net_device *, struct dmfe_board_info *);
@@ -596,7 +596,7 @@ static int dmfe_open(struct net_device *dev)
596596
netif_wake_queue(dev);
597597

598598
/* set and active a timer process */
599-
setup_timer(&db->timer, dmfe_timer, (unsigned long)dev);
599+
timer_setup(&db->timer, dmfe_timer, 0);
600600
db->timer.expires = DMFE_TIMER_WUT + HZ * 2;
601601
add_timer(&db->timer);
602602

@@ -1128,10 +1128,10 @@ static const struct ethtool_ops netdev_ethtool_ops = {
11281128
* Dynamic media sense, allocate Rx buffer...
11291129
*/
11301130

1131-
static void dmfe_timer(unsigned long data)
1131+
static void dmfe_timer(struct timer_list *t)
11321132
{
1133-
struct net_device *dev = (struct net_device *)data;
1134-
struct dmfe_board_info *db = netdev_priv(dev);
1133+
struct dmfe_board_info *db = from_timer(db, t, timer);
1134+
struct net_device *dev = pci_get_drvdata(db->pdev);
11351135
void __iomem *ioaddr = db->ioaddr;
11361136
u32 tmp_cr8;
11371137
unsigned char tmp_cr12;

drivers/net/ethernet/dec/tulip/interrupt.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ int tulip_refill_rx(struct net_device *dev)
102102

103103
#ifdef CONFIG_TULIP_NAPI
104104

105-
void oom_timer(unsigned long data)
105+
void oom_timer(struct timer_list *t)
106106
{
107-
struct net_device *dev = (struct net_device *)data;
108-
struct tulip_private *tp = netdev_priv(dev);
107+
struct tulip_private *tp = from_timer(tp, t, oom_timer);
108+
109109
napi_schedule(&tp->napi);
110110
}
111111

drivers/net/ethernet/dec/tulip/pnic.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ void pnic_lnk_change(struct net_device *dev, int csr5)
8484
}
8585
}
8686

87-
void pnic_timer(unsigned long data)
87+
void pnic_timer(struct timer_list *t)
8888
{
89-
struct net_device *dev = (struct net_device *)data;
90-
struct tulip_private *tp = netdev_priv(dev);
89+
struct tulip_private *tp = from_timer(tp, t, timer);
90+
struct net_device *dev = tp->dev;
9191
void __iomem *ioaddr = tp->base_addr;
9292
int next_tick = 60*HZ;
9393

drivers/net/ethernet/dec/tulip/pnic2.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@
7676
#include <linux/delay.h>
7777

7878

79-
void pnic2_timer(unsigned long data)
79+
void pnic2_timer(struct timer_list *t)
8080
{
81-
struct net_device *dev = (struct net_device *)data;
82-
struct tulip_private *tp = netdev_priv(dev);
81+
struct tulip_private *tp = from_timer(tp, t, timer);
82+
struct net_device *dev = tp->dev;
8383
void __iomem *ioaddr = tp->base_addr;
8484
int next_tick = 60*HZ;
8585

drivers/net/ethernet/dec/tulip/timer.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ void tulip_media_task(struct work_struct *work)
137137
}
138138

139139

140-
void mxic_timer(unsigned long data)
140+
void mxic_timer(struct timer_list *t)
141141
{
142-
struct net_device *dev = (struct net_device *)data;
143-
struct tulip_private *tp = netdev_priv(dev);
142+
struct tulip_private *tp = from_timer(tp, t, timer);
143+
struct net_device *dev = tp->dev;
144144
void __iomem *ioaddr = tp->base_addr;
145145
int next_tick = 60*HZ;
146146

@@ -154,10 +154,10 @@ void mxic_timer(unsigned long data)
154154
}
155155

156156

157-
void comet_timer(unsigned long data)
157+
void comet_timer(struct timer_list *t)
158158
{
159-
struct net_device *dev = (struct net_device *)data;
160-
struct tulip_private *tp = netdev_priv(dev);
159+
struct tulip_private *tp = from_timer(tp, t, timer);
160+
struct net_device *dev = tp->dev;
161161
int next_tick = 2*HZ;
162162

163163
if (tulip_debug > 1)

drivers/net/ethernet/dec/tulip/tulip.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct tulip_chip_table {
4343
int io_size;
4444
int valid_intrs; /* CSR7 interrupt enable settings */
4545
int flags;
46-
void (*media_timer) (unsigned long);
46+
void (*media_timer) (struct timer_list *);
4747
work_func_t media_task;
4848
};
4949

@@ -476,7 +476,7 @@ void t21142_lnk_change(struct net_device *dev, int csr5);
476476

477477
/* PNIC2.c */
478478
void pnic2_lnk_change(struct net_device *dev, int csr5);
479-
void pnic2_timer(unsigned long data);
479+
void pnic2_timer(struct timer_list *t);
480480
void pnic2_start_nway(struct net_device *dev);
481481
void pnic2_lnk_change(struct net_device *dev, int csr5);
482482

@@ -504,19 +504,19 @@ void tulip_find_mii (struct net_device *dev, int board_idx);
504504
/* pnic.c */
505505
void pnic_do_nway(struct net_device *dev);
506506
void pnic_lnk_change(struct net_device *dev, int csr5);
507-
void pnic_timer(unsigned long data);
507+
void pnic_timer(struct timer_list *t);
508508

509509
/* timer.c */
510510
void tulip_media_task(struct work_struct *work);
511-
void mxic_timer(unsigned long data);
512-
void comet_timer(unsigned long data);
511+
void mxic_timer(struct timer_list *t);
512+
void comet_timer(struct timer_list *t);
513513

514514
/* tulip_core.c */
515515
extern int tulip_debug;
516516
extern const char * const medianame[];
517517
extern const char tulip_media_cap[];
518518
extern const struct tulip_chip_table tulip_tbl[];
519-
void oom_timer(unsigned long data);
519+
void oom_timer(struct timer_list *t);
520520
extern u8 t21040_csr13[];
521521

522522
static inline void tulip_start_rxtx(struct tulip_private *tp)

drivers/net/ethernet/dec/tulip/tulip_core.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ int tulip_debug = TULIP_DEBUG;
123123
int tulip_debug = 1;
124124
#endif
125125

126-
static void tulip_timer(unsigned long data)
126+
static void tulip_timer(struct timer_list *t)
127127
{
128-
struct net_device *dev = (struct net_device *)data;
129-
struct tulip_private *tp = netdev_priv(dev);
128+
struct tulip_private *tp = from_timer(tp, t, timer);
129+
struct net_device *dev = tp->dev;
130130

131131
if (netif_running(dev))
132132
schedule_work(&tp->media_work);
@@ -505,7 +505,7 @@ static void tulip_up(struct net_device *dev)
505505
tp->timer.expires = RUN_AT(next_tick);
506506
add_timer(&tp->timer);
507507
#ifdef CONFIG_TULIP_NAPI
508-
setup_timer(&tp->oom_timer, oom_timer, (unsigned long)dev);
508+
timer_setup(&tp->oom_timer, oom_timer, 0);
509509
#endif
510510
}
511511

@@ -780,8 +780,7 @@ static void tulip_down (struct net_device *dev)
780780

781781
spin_unlock_irqrestore (&tp->lock, flags);
782782

783-
setup_timer(&tp->timer, tulip_tbl[tp->chip_id].media_timer,
784-
(unsigned long)dev);
783+
timer_setup(&tp->timer, tulip_tbl[tp->chip_id].media_timer, 0);
785784

786785
dev->if_port = tp->saved_if_port;
787786

@@ -1470,8 +1469,7 @@ static int tulip_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
14701469
tp->csr0 = csr0;
14711470
spin_lock_init(&tp->lock);
14721471
spin_lock_init(&tp->mii_lock);
1473-
setup_timer(&tp->timer, tulip_tbl[tp->chip_id].media_timer,
1474-
(unsigned long)dev);
1472+
timer_setup(&tp->timer, tulip_tbl[tp->chip_id].media_timer, 0);
14751473

14761474
INIT_WORK(&tp->media_work, tulip_tbl[tp->chip_id].media_task);
14771475

drivers/net/ethernet/dec/tulip/uli526x.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ static void phy_write_1bit(struct uli526x_board_info *db, u32);
241241
static u16 phy_read_1bit(struct uli526x_board_info *db);
242242
static u8 uli526x_sense_speed(struct uli526x_board_info *);
243243
static void uli526x_process_mode(struct uli526x_board_info *);
244-
static void uli526x_timer(unsigned long);
244+
static void uli526x_timer(struct timer_list *t);
245245
static void uli526x_rx_packet(struct net_device *, struct uli526x_board_info *);
246246
static void uli526x_free_tx_pkt(struct net_device *, struct uli526x_board_info *);
247247
static void uli526x_reuse_skb(struct uli526x_board_info *, struct sk_buff *);
@@ -491,7 +491,7 @@ static int uli526x_open(struct net_device *dev)
491491
netif_wake_queue(dev);
492492

493493
/* set and active a timer process */
494-
setup_timer(&db->timer, uli526x_timer, (unsigned long)dev);
494+
timer_setup(&db->timer, uli526x_timer, 0);
495495
db->timer.expires = ULI526X_TIMER_WUT + HZ * 2;
496496
add_timer(&db->timer);
497497

@@ -1021,10 +1021,10 @@ static const struct ethtool_ops netdev_ethtool_ops = {
10211021
* Dynamic media sense, allocate Rx buffer...
10221022
*/
10231023

1024-
static void uli526x_timer(unsigned long data)
1024+
static void uli526x_timer(struct timer_list *t)
10251025
{
1026-
struct net_device *dev = (struct net_device *) data;
1027-
struct uli526x_board_info *db = netdev_priv(dev);
1026+
struct uli526x_board_info *db = from_timer(db, t, timer);
1027+
struct net_device *dev = pci_get_drvdata(db->pdev);
10281028
struct uli_phy_ops *phy = &db->phy;
10291029
void __iomem *ioaddr = db->ioaddr;
10301030
unsigned long flags;

drivers/net/ethernet/dec/tulip/winbond-840.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ static int mdio_read(struct net_device *dev, int phy_id, int location);
327327
static void mdio_write(struct net_device *dev, int phy_id, int location, int value);
328328
static int netdev_open(struct net_device *dev);
329329
static int update_link(struct net_device *dev);
330-
static void netdev_timer(unsigned long data);
330+
static void netdev_timer(struct timer_list *t);
331331
static void init_rxtx_rings(struct net_device *dev);
332332
static void free_rxtx_rings(struct netdev_private *np);
333333
static void init_registers(struct net_device *dev);
@@ -655,7 +655,7 @@ static int netdev_open(struct net_device *dev)
655655
netdev_dbg(dev, "Done netdev_open()\n");
656656

657657
/* Set the timer to check for link beat. */
658-
setup_timer(&np->timer, netdev_timer, (unsigned long)dev);
658+
timer_setup(&np->timer, netdev_timer, 0);
659659
np->timer.expires = jiffies + 1*HZ;
660660
add_timer(&np->timer);
661661
return 0;
@@ -772,10 +772,10 @@ static inline void update_csr6(struct net_device *dev, int new)
772772
np->mii_if.full_duplex = 1;
773773
}
774774

775-
static void netdev_timer(unsigned long data)
775+
static void netdev_timer(struct timer_list *t)
776776
{
777-
struct net_device *dev = (struct net_device *)data;
778-
struct netdev_private *np = netdev_priv(dev);
777+
struct netdev_private *np = from_timer(np, t, timer);
778+
struct net_device *dev = pci_get_drvdata(np->pci_dev);
779779
void __iomem *ioaddr = np->base_addr;
780780

781781
if (debug > 2)

0 commit comments

Comments
 (0)