Skip to contentSkip to conversation

drivers/net: sis: Convert timers to use timer_setup()

PATCH Applied Kees Cook 3 participants 3 messages Oct 24, 2017 – Oct 25, 2017

Subsystems (4)
lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 drivers/net: sis: 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 Francois Romieu <[email protected]>
Cc Daniele Venzano <[email protected]>
---
 drivers/net/ethernet/sis/sis190.c | 10 ++++------
 drivers/net/ethernet/sis/sis900.c | 10 +++++-----
 2 files changed, 9 insertions(+), 11 deletions(-)
drivers/net/ethernet/sis/sis190.c +4 -6
index 445109bd6910..c2c50522b96d 100644
@@ -1018,10 +1018,10 @@ static void sis190_phy_task(struct work_struct *work)
 	rtnl_unlock();
 }
 
-static void sis190_phy_timer(unsigned long __opaque)
+static void sis190_phy_timer(struct timer_list *t)
 {
-	struct net_device *dev = (struct net_device *)__opaque;
-	struct sis190_private *tp = netdev_priv(dev);
+	struct sis190_private *tp = from_timer(tp, t, timer);
+	struct net_device *dev = tp->dev;
 
 	if (likely(netif_running(dev)))
 		schedule_work(&tp->phy_task);
@@ -1039,10 +1039,8 @@ static inline void sis190_request_timer(struct net_device *dev)
 	struct sis190_private *tp = netdev_priv(dev);
 	struct timer_list *timer = &tp->timer;
 
-	init_timer(timer);
+	timer_setup(timer, sis190_phy_timer, 0);
 	timer->expires = jiffies + SIS190_PHY_TIMEOUT;
-	timer->data = (unsigned long)dev;
-	timer->function = sis190_phy_timer;
 	add_timer(timer);
 }
 
drivers/net/ethernet/sis/sis900.c +5 -5
index cb61247b0526..4bb89f74742c 100644
@@ -218,7 +218,7 @@ static void sis900_init_rxfilter (struct net_device * net_dev);
 static u16 read_eeprom(void __iomem *ioaddr, int location);
 static int mdio_read(struct net_device *net_dev, int phy_id, int location);
 static void mdio_write(struct net_device *net_dev, int phy_id, int location, int val);
-static void sis900_timer(unsigned long data);
+static void sis900_timer(struct timer_list *t);
 static void sis900_check_mode (struct net_device *net_dev, struct mii_phy *mii_phy);
 static void sis900_tx_timeout(struct net_device *net_dev);
 static void sis900_init_tx_ring(struct net_device *net_dev);
@@ -1065,7 +1065,7 @@ sis900_open(struct net_device *net_dev)
 
 	/* Set the timer to switch to check for link beat and perhaps switch
 	   to an alternate media type. */
-	setup_timer(&sis_priv->timer, sis900_timer, (unsigned long)net_dev);
+	timer_setup(&sis_priv->timer, sis900_timer, 0);
 	sis_priv->timer.expires = jiffies + HZ;
 	add_timer(&sis_priv->timer);
 
@@ -1300,10 +1300,10 @@ static void sis630_set_eq(struct net_device *net_dev, u8 revision)
  *	link status (ON/OFF) and link mode (10/100/Full/Half)
  */
 
-static void sis900_timer(unsigned long data)
+static void sis900_timer(struct timer_list *t)
 {
-	struct net_device *net_dev = (struct net_device *)data;
-	struct sis900_private *sis_priv = netdev_priv(net_dev);
+	struct sis900_private *sis_priv = from_timer(sis_priv, t, timer);
+	struct net_device *net_dev = sis_priv->mii_info.dev;
 	struct mii_phy *mii_phy = sis_priv->mii;
 	static const int next_tick = 5*HZ;
 	int speed = 0, duplex = 0;
Signature · 6 lines
2.7.4


-- 
Kees Cook
Pixel Security
maintainer
#1 lore raw
Quoted 10 lines · Kees Cook

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 Francois Romieu <[email protected]>
Cc Daniele Venzano <[email protected]>
Quoted 80 lines

---
drivers/net/ethernet/sis/sis190.c | 10 ++++------ drivers/net/ethernet/sis/sis900.c | 10 +++++-----

2 files changed, 9 insertions(+), 11 deletions(-)
drivers/net/ethernet/sis/sis190.c +3 -3
index 445109bd6910..c2c50522b96d 100644
@@ -1018,10 +1018,10 @@ static void sis190_phy_task(struct work_struct
 *work)
 	rtnl_unlock();
 }
 
-static void sis190_phy_timer(unsigned long __opaque)
+static void sis190_phy_timer(struct timer_list *t)
 {
-	struct net_device *dev = (struct net_device *)__opaque;
-	struct sis190_private *tp = netdev_priv(dev);
+	struct sis190_private *tp = from_timer(tp, t, timer);
+	struct net_device *dev = tp->dev;
 
 	if (likely(netif_running(dev)))
		schedule_work(&tp->phy_task);
drivers/net/ethernet/sis/sis190.c +1 -3
@@ -1039,10 +1039,8 @@ static inline void sis190_request_timer(struct
 net_device *dev)
 	struct sis190_private *tp = netdev_priv(dev);
 	struct timer_list *timer = &tp->timer;
 
-	init_timer(timer);
+	timer_setup(timer, sis190_phy_timer, 0);
 	timer->expires = jiffies + SIS190_PHY_TIMEOUT;
-	timer->data = (unsigned long)dev;
-	timer->function = sis190_phy_timer;
 	add_timer(timer);
 }
drivers/net/ethernet/sis/sis900.c +0 -0
index cb61247b0526..4bb89f74742c 100644
@@ -218,7 +218,7 @@ static void sis900_init_rxfilter (struct net_device
 * net_dev);
 static u16 read_eeprom(void __iomem *ioaddr, int location);

static int mdio_read(struct net_device *net_dev, int phy_id, int location);
static void mdio_write(struct net_device *net_dev, int phy_id, int location, int val);

drivers/net/ethernet/sis/sis900.c +1 -1
-static void sis900_timer(unsigned long data);
+static void sis900_timer(struct timer_list *t);

static void sis900_check_mode (struct net_device *net_dev, struct mii_phy *mii_phy);
static void sis900_tx_timeout(struct net_device *net_dev); static void sis900_init_tx_ring(struct net_device *net_dev);

drivers/net/ethernet/sis/sis900.c +4 -4
@@ -1065,7 +1065,7 @@ sis900_open(struct net_device *net_dev)
 
 	/* Set the timer to switch to check for link beat and perhaps switch
 	   to an alternate media type. */
-	setup_timer(&sis_priv->timer, sis900_timer, (unsigned long)net_dev);
+	timer_setup(&sis_priv->timer, sis900_timer, 0);
 	sis_priv->timer.expires = jiffies + HZ;
 	add_timer(&sis_priv->timer);
 
@@ -1300,10 +1300,10 @@ static void sis630_set_eq(struct net_device
 *net_dev, u8 revision)
 *	link status (ON/OFF) and link mode (10/100/Full/Half)
 */
 
-static void sis900_timer(unsigned long data)
+static void sis900_timer(struct timer_list *t)
 {
-	struct net_device *net_dev = (struct net_device *)data;
-	struct sis900_private *sis_priv = netdev_priv(net_dev);
+	struct sis900_private *sis_priv = from_timer(sis_priv, t, timer);
+	struct net_device *net_dev = sis_priv->mii_info.dev;
 	struct mii_phy *mii_phy = sis_priv->mii;
 	static const int next_tick = 5*HZ;
	int speed = 0, duplex = 0;
maintainer Applied
#2 lore raw
In reply to Kees Cook

From: Kees Cook <[email protected]>
Date: Tue, 24 Oct 2017 01:46:52 -0700

Quoted 8 lines

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 Francois Romieu <[email protected]>
Cc Daniele Venzano <[email protected]>

Applied.