aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2009-04-02 19:56:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-02 22:04:50 -0400
commitbf6aede712334d7338d5c47a5ee5ba3883c82a61 (patch)
tree153483c5ef1de41f8dd3d233ba46117d0676c303
parente4c2ff1cf2d7fc65d0fc6f88bc98338e0212ad52 (diff)
workqueue: add to_delayed_work() helper function
It is a fairly common operation to have a pointer to a work and to need a pointer to the delayed work it is contained in. In particular, all delayed works which want to rearm themselves will have to do that. So it would seem fair to offer a helper function for this operation. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Ingo Molnar <mingo@elte.hu> Cc: "David S. Miller" <davem@davemloft.net> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Greg KH <greg@kroah.com> Cc: Pekka Enberg <penberg@cs.helsinki.fi> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/powerpc/kernel/vio.c2
-rw-r--r--drivers/crypto/hifn_795x.c2
-rw-r--r--drivers/input/mouse/hgpk.c2
-rw-r--r--drivers/net/dm9000.c2
-rw-r--r--drivers/net/mlx4/en_netdev.c2
-rw-r--r--drivers/net/mlx4/en_rx.c2
-rw-r--r--drivers/net/mlx4/sense.c2
-rw-r--r--drivers/net/phy/phy.c3
-rw-r--r--drivers/s390/scsi/zfcp_fc.c2
-rw-r--r--drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c8
-rw-r--r--drivers/staging/rtl8187se/r8180_core.c8
-rw-r--r--drivers/usb/wusbcore/devconnect.c2
-rw-r--r--include/linux/workqueue.h5
-rw-r--r--mm/slab.c3
14 files changed, 24 insertions, 21 deletions
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index d3694498f3af..819e59f6f7c7 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -482,7 +482,7 @@ static void vio_cmo_balance(struct work_struct *work)
482 cmo->excess.size = cmo->entitled - cmo->reserve.size; 482 cmo->excess.size = cmo->entitled - cmo->reserve.size;
483 cmo->excess.free = cmo->excess.size - need; 483 cmo->excess.free = cmo->excess.size - need;
484 484
485 cancel_delayed_work(container_of(work, struct delayed_work, work)); 485 cancel_delayed_work(to_delayed_work(work));
486 spin_unlock_irqrestore(&vio_cmo.lock, flags); 486 spin_unlock_irqrestore(&vio_cmo.lock, flags);
487} 487}
488 488
diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
index 0c79fe7f1567..4d85402a9e4a 100644
--- a/drivers/crypto/hifn_795x.c
+++ b/drivers/crypto/hifn_795x.c
@@ -1882,7 +1882,7 @@ static void hifn_clear_rings(struct hifn_device *dev, int error)
1882 1882
1883static void hifn_work(struct work_struct *work) 1883static void hifn_work(struct work_struct *work)
1884{ 1884{
1885 struct delayed_work *dw = container_of(work, struct delayed_work, work); 1885 struct delayed_work *dw = to_delayed_work(work);
1886 struct hifn_device *dev = container_of(dw, struct hifn_device, work); 1886 struct hifn_device *dev = container_of(dw, struct hifn_device, work);
1887 unsigned long flags; 1887 unsigned long flags;
1888 int reset = 0; 1888 int reset = 0;
diff --git a/drivers/input/mouse/hgpk.c b/drivers/input/mouse/hgpk.c
index 81e6ebf323e9..55cd0fa68339 100644
--- a/drivers/input/mouse/hgpk.c
+++ b/drivers/input/mouse/hgpk.c
@@ -381,7 +381,7 @@ static void hgpk_disconnect(struct psmouse *psmouse)
381 381
382static void hgpk_recalib_work(struct work_struct *work) 382static void hgpk_recalib_work(struct work_struct *work)
383{ 383{
384 struct delayed_work *w = container_of(work, struct delayed_work, work); 384 struct delayed_work *w = to_delayed_work(work);
385 struct hgpk_data *priv = container_of(w, struct hgpk_data, recalib_wq); 385 struct hgpk_data *priv = container_of(w, struct hgpk_data, recalib_wq);
386 struct psmouse *psmouse = priv->psmouse; 386 struct psmouse *psmouse = priv->psmouse;
387 387
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 254ec62b5f58..d8350860c0f8 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -559,7 +559,7 @@ static void dm9000_show_carrier(board_info_t *db,
559static void 559static void
560dm9000_poll_work(struct work_struct *w) 560dm9000_poll_work(struct work_struct *w)
561{ 561{
562 struct delayed_work *dw = container_of(w, struct delayed_work, work); 562 struct delayed_work *dw = to_delayed_work(w);
563 board_info_t *db = container_of(dw, board_info_t, phy_poll); 563 board_info_t *db = container_of(dw, board_info_t, phy_poll);
564 struct net_device *ndev = db->ndev; 564 struct net_device *ndev = db->ndev;
565 565
diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c
index 9f6644a44030..303c23de6cac 100644
--- a/drivers/net/mlx4/en_netdev.c
+++ b/drivers/net/mlx4/en_netdev.c
@@ -505,7 +505,7 @@ out:
505 505
506static void mlx4_en_do_get_stats(struct work_struct *work) 506static void mlx4_en_do_get_stats(struct work_struct *work)
507{ 507{
508 struct delayed_work *delay = container_of(work, struct delayed_work, work); 508 struct delayed_work *delay = to_delayed_work(work);
509 struct mlx4_en_priv *priv = container_of(delay, struct mlx4_en_priv, 509 struct mlx4_en_priv *priv = container_of(delay, struct mlx4_en_priv,
510 stats_task); 510 stats_task);
511 struct mlx4_en_dev *mdev = priv->mdev; 511 struct mlx4_en_dev *mdev = priv->mdev;
diff --git a/drivers/net/mlx4/en_rx.c b/drivers/net/mlx4/en_rx.c
index a4130e764991..7e40741fb7d8 100644
--- a/drivers/net/mlx4/en_rx.c
+++ b/drivers/net/mlx4/en_rx.c
@@ -298,7 +298,7 @@ static void mlx4_en_free_rx_buf(struct mlx4_en_priv *priv,
298 298
299void mlx4_en_rx_refill(struct work_struct *work) 299void mlx4_en_rx_refill(struct work_struct *work)
300{ 300{
301 struct delayed_work *delay = container_of(work, struct delayed_work, work); 301 struct delayed_work *delay = to_delayed_work(work);
302 struct mlx4_en_priv *priv = container_of(delay, struct mlx4_en_priv, 302 struct mlx4_en_priv *priv = container_of(delay, struct mlx4_en_priv,
303 refill_task); 303 refill_task);
304 struct mlx4_en_dev *mdev = priv->mdev; 304 struct mlx4_en_dev *mdev = priv->mdev;
diff --git a/drivers/net/mlx4/sense.c b/drivers/net/mlx4/sense.c
index 6d5089ecb5af..f36ae691cab3 100644
--- a/drivers/net/mlx4/sense.c
+++ b/drivers/net/mlx4/sense.c
@@ -103,7 +103,7 @@ void mlx4_do_sense_ports(struct mlx4_dev *dev,
103 103
104static void mlx4_sense_port(struct work_struct *work) 104static void mlx4_sense_port(struct work_struct *work)
105{ 105{
106 struct delayed_work *delay = container_of(work, struct delayed_work, work); 106 struct delayed_work *delay = to_delayed_work(work);
107 struct mlx4_sense *sense = container_of(delay, struct mlx4_sense, 107 struct mlx4_sense *sense = container_of(delay, struct mlx4_sense,
108 sense_poll); 108 sense_poll);
109 struct mlx4_dev *dev = sense->dev; 109 struct mlx4_dev *dev = sense->dev;
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 58b73b08dde0..3ff1f425f1bb 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -757,8 +757,7 @@ EXPORT_SYMBOL(phy_start);
757 */ 757 */
758static void phy_state_machine(struct work_struct *work) 758static void phy_state_machine(struct work_struct *work)
759{ 759{
760 struct delayed_work *dwork = 760 struct delayed_work *dwork = to_delayed_work(work);
761 container_of(work, struct delayed_work, work);
762 struct phy_device *phydev = 761 struct phy_device *phydev =
763 container_of(dwork, struct phy_device, state_queue); 762 container_of(dwork, struct phy_device, state_queue);
764 int needs_aneg = 0; 763 int needs_aneg = 0;
diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c
index aab8123c5966..e8d032b9dfbd 100644
--- a/drivers/s390/scsi/zfcp_fc.c
+++ b/drivers/s390/scsi/zfcp_fc.c
@@ -94,7 +94,7 @@ static int zfcp_wka_port_get(struct zfcp_wka_port *wka_port)
94 94
95static void zfcp_wka_port_offline(struct work_struct *work) 95static void zfcp_wka_port_offline(struct work_struct *work)
96{ 96{
97 struct delayed_work *dw = container_of(work, struct delayed_work, work); 97 struct delayed_work *dw = to_delayed_work(work);
98 struct zfcp_wka_port *wka_port = 98 struct zfcp_wka_port *wka_port =
99 container_of(dw, struct zfcp_wka_port, work); 99 container_of(dw, struct zfcp_wka_port, work);
100 100
diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
index e5752f615e09..80f9cc7137c2 100644
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c
@@ -719,7 +719,7 @@ void ieee80211_softmac_scan(struct ieee80211_device *ieee)
719#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) 719#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
720void ieee80211_softmac_scan_wq(struct work_struct *work) 720void ieee80211_softmac_scan_wq(struct work_struct *work)
721{ 721{
722 struct delayed_work *dwork = container_of(work, struct delayed_work, work); 722 struct delayed_work *dwork = to_delayed_work(work);
723 struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq); 723 struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq);
724#else 724#else
725void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee) 725void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee)
@@ -777,7 +777,7 @@ out:
777#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) 777#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
778void ieee80211_softmac_scan_wq(struct work_struct *work) 778void ieee80211_softmac_scan_wq(struct work_struct *work)
779{ 779{
780 struct delayed_work *dwork = container_of(work, struct delayed_work, work); 780 struct delayed_work *dwork = to_delayed_work(work);
781 struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, softmac_scan_wq); 781 struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, softmac_scan_wq);
782#else 782#else
783void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee) 783void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee)
@@ -2980,7 +2980,7 @@ void ieee80211_start_monitor_mode(struct ieee80211_device *ieee)
2980#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) 2980#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
2981void ieee80211_start_ibss_wq(struct work_struct *work) 2981void ieee80211_start_ibss_wq(struct work_struct *work)
2982{ 2982{
2983 struct delayed_work *dwork = container_of(work, struct delayed_work, work); 2983 struct delayed_work *dwork = to_delayed_work(work);
2984 struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, start_ibss_wq); 2984 struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, start_ibss_wq);
2985#else 2985#else
2986void ieee80211_start_ibss_wq(struct ieee80211_device *ieee) 2986void ieee80211_start_ibss_wq(struct ieee80211_device *ieee)
@@ -3162,7 +3162,7 @@ void ieee80211_disassociate(struct ieee80211_device *ieee)
3162#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) 3162#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
3163void ieee80211_associate_retry_wq(struct work_struct *work) 3163void ieee80211_associate_retry_wq(struct work_struct *work)
3164{ 3164{
3165 struct delayed_work *dwork = container_of(work, struct delayed_work, work); 3165 struct delayed_work *dwork = to_delayed_work(work);
3166 struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); 3166 struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq);
3167#else 3167#else
3168void ieee80211_associate_retry_wq(struct ieee80211_device *ieee) 3168void ieee80211_associate_retry_wq(struct ieee80211_device *ieee)
diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c
index 66de5cc8ddf1..ff1f23f99f27 100644
--- a/drivers/staging/rtl8187se/r8180_core.c
+++ b/drivers/staging/rtl8187se/r8180_core.c
@@ -5438,7 +5438,7 @@ void rtl8180_hw_wakeup_wq (struct work_struct *work)
5438// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq); 5438// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq);
5439// struct ieee80211_device * ieee = (struct ieee80211_device*) 5439// struct ieee80211_device * ieee = (struct ieee80211_device*)
5440// container_of(work, struct ieee80211_device, watch_dog_wq); 5440// container_of(work, struct ieee80211_device, watch_dog_wq);
5441 struct delayed_work *dwork = container_of(work,struct delayed_work,work); 5441 struct delayed_work *dwork = to_delayed_work(work);
5442 struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_wakeup_wq); 5442 struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_wakeup_wq);
5443 struct net_device *dev = ieee->dev; 5443 struct net_device *dev = ieee->dev;
5444#else 5444#else
@@ -5459,7 +5459,7 @@ void rtl8180_hw_sleep_wq (struct work_struct *work)
5459// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq); 5459// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq);
5460// struct ieee80211_device * ieee = (struct ieee80211_device*) 5460// struct ieee80211_device * ieee = (struct ieee80211_device*)
5461// container_of(work, struct ieee80211_device, watch_dog_wq); 5461// container_of(work, struct ieee80211_device, watch_dog_wq);
5462 struct delayed_work *dwork = container_of(work,struct delayed_work,work); 5462 struct delayed_work *dwork = to_delayed_work(work);
5463 struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_sleep_wq); 5463 struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_sleep_wq);
5464 struct net_device *dev = ieee->dev; 5464 struct net_device *dev = ieee->dev;
5465#else 5465#else
@@ -6407,7 +6407,7 @@ priv->txnpring)/8);
6407void rtl8180_tx_irq_wq(struct work_struct *work) 6407void rtl8180_tx_irq_wq(struct work_struct *work)
6408{ 6408{
6409 //struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq); 6409 //struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq);
6410 struct delayed_work *dwork = container_of(work,struct delayed_work,work); 6410 struct delayed_work *dwork = to_delayed_work(work);
6411 struct ieee80211_device * ieee = (struct ieee80211_device*) 6411 struct ieee80211_device * ieee = (struct ieee80211_device*)
6412 container_of(dwork, struct ieee80211_device, watch_dog_wq); 6412 container_of(dwork, struct ieee80211_device, watch_dog_wq);
6413 struct net_device *dev = ieee->dev; 6413 struct net_device *dev = ieee->dev;
@@ -6691,7 +6691,7 @@ lizhaoming--------------------------- RF power on/power off -----------------
6691#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)) 6691#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
6692void GPIOChangeRFWorkItemCallBack(struct work_struct *work) 6692void GPIOChangeRFWorkItemCallBack(struct work_struct *work)
6693{ 6693{
6694 //struct delayed_work *dwork = container_of(work, struct delayed_work, work); 6694 //struct delayed_work *dwork = to_delayed_work(work);
6695 struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, GPIOChangeRFWorkItem.work); 6695 struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, GPIOChangeRFWorkItem.work);
6696 struct net_device *dev = ieee->dev; 6696 struct net_device *dev = ieee->dev;
6697 struct r8180_priv *priv = ieee80211_priv(dev); 6697 struct r8180_priv *priv = ieee80211_priv(dev);
diff --git a/drivers/usb/wusbcore/devconnect.c b/drivers/usb/wusbcore/devconnect.c
index f0aac0cf315a..386eaa22d215 100644
--- a/drivers/usb/wusbcore/devconnect.c
+++ b/drivers/usb/wusbcore/devconnect.c
@@ -471,7 +471,7 @@ static void __wusbhc_keep_alive(struct wusbhc *wusbhc)
471 */ 471 */
472static void wusbhc_keep_alive_run(struct work_struct *ws) 472static void wusbhc_keep_alive_run(struct work_struct *ws)
473{ 473{
474 struct delayed_work *dw = container_of(ws, struct delayed_work, work); 474 struct delayed_work *dw = to_delayed_work(ws);
475 struct wusbhc *wusbhc = container_of(dw, struct wusbhc, keep_alive_timer); 475 struct wusbhc *wusbhc = container_of(dw, struct wusbhc, keep_alive_timer);
476 476
477 mutex_lock(&wusbhc->mutex); 477 mutex_lock(&wusbhc->mutex);
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index 3cd51e579ab1..13e1adf55c4c 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -41,6 +41,11 @@ struct delayed_work {
41 struct timer_list timer; 41 struct timer_list timer;
42}; 42};
43 43
44static inline struct delayed_work *to_delayed_work(struct work_struct *work)
45{
46 return container_of(work, struct delayed_work, work);
47}
48
44struct execute_work { 49struct execute_work {
45 struct work_struct work; 50 struct work_struct work;
46}; 51};
diff --git a/mm/slab.c b/mm/slab.c
index 825c606f691d..208323fd37bc 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -3992,8 +3992,7 @@ static void cache_reap(struct work_struct *w)
3992 struct kmem_cache *searchp; 3992 struct kmem_cache *searchp;
3993 struct kmem_list3 *l3; 3993 struct kmem_list3 *l3;
3994 int node = numa_node_id(); 3994 int node = numa_node_id();
3995 struct delayed_work *work = 3995 struct delayed_work *work = to_delayed_work(w);
3996 container_of(w, struct delayed_work, work);
3997 3996
3998 if (!mutex_trylock(&cache_chain_mutex)) 3997 if (!mutex_trylock(&cache_chain_mutex))
3999 /* Give up. Setup the next iteration. */ 3998 /* Give up. Setup the next iteration. */