Skip to content

Commit bf6aede

Browse files
Jean Delvaretorvalds
authored andcommitted
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>
1 parent e4c2ff1 commit bf6aede

14 files changed

Lines changed: 24 additions & 21 deletions

File tree

‎arch/powerpc/kernel/vio.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ static void vio_cmo_balance(struct work_struct *work)
482482
cmo->excess.size = cmo->entitled - cmo->reserve.size;
483483
cmo->excess.free = cmo->excess.size - need;
484484

485-
cancel_delayed_work(container_of(work, struct delayed_work, work));
485+
cancel_delayed_work(to_delayed_work(work));
486486
spin_unlock_irqrestore(&vio_cmo.lock, flags);
487487
}
488488

‎drivers/crypto/hifn_795x.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1882,7 +1882,7 @@ static void hifn_clear_rings(struct hifn_device *dev, int error)
18821882

18831883
static void hifn_work(struct work_struct *work)
18841884
{
1885-
struct delayed_work *dw = container_of(work, struct delayed_work, work);
1885+
struct delayed_work *dw = to_delayed_work(work);
18861886
struct hifn_device *dev = container_of(dw, struct hifn_device, work);
18871887
unsigned long flags;
18881888
int reset = 0;

‎drivers/input/mouse/hgpk.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ static void hgpk_disconnect(struct psmouse *psmouse)
381381

382382
static void hgpk_recalib_work(struct work_struct *work)
383383
{
384-
struct delayed_work *w = container_of(work, struct delayed_work, work);
384+
struct delayed_work *w = to_delayed_work(work);
385385
struct hgpk_data *priv = container_of(w, struct hgpk_data, recalib_wq);
386386
struct psmouse *psmouse = priv->psmouse;
387387

‎drivers/net/dm9000.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ static void dm9000_show_carrier(board_info_t *db,
559559
static void
560560
dm9000_poll_work(struct work_struct *w)
561561
{
562-
struct delayed_work *dw = container_of(w, struct delayed_work, work);
562+
struct delayed_work *dw = to_delayed_work(w);
563563
board_info_t *db = container_of(dw, board_info_t, phy_poll);
564564
struct net_device *ndev = db->ndev;
565565

‎drivers/net/mlx4/en_netdev.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ static void mlx4_en_auto_moderation(struct mlx4_en_priv *priv)
505505

506506
static void mlx4_en_do_get_stats(struct work_struct *work)
507507
{
508-
struct delayed_work *delay = container_of(work, struct delayed_work, work);
508+
struct delayed_work *delay = to_delayed_work(work);
509509
struct mlx4_en_priv *priv = container_of(delay, struct mlx4_en_priv,
510510
stats_task);
511511
struct mlx4_en_dev *mdev = priv->mdev;

‎drivers/net/mlx4/en_rx.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static void mlx4_en_free_rx_buf(struct mlx4_en_priv *priv,
298298

299299
void mlx4_en_rx_refill(struct work_struct *work)
300300
{
301-
struct delayed_work *delay = container_of(work, struct delayed_work, work);
301+
struct delayed_work *delay = to_delayed_work(work);
302302
struct mlx4_en_priv *priv = container_of(delay, struct mlx4_en_priv,
303303
refill_task);
304304
struct mlx4_en_dev *mdev = priv->mdev;

‎drivers/net/mlx4/sense.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void mlx4_do_sense_ports(struct mlx4_dev *dev,
103103

104104
static void mlx4_sense_port(struct work_struct *work)
105105
{
106-
struct delayed_work *delay = container_of(work, struct delayed_work, work);
106+
struct delayed_work *delay = to_delayed_work(work);
107107
struct mlx4_sense *sense = container_of(delay, struct mlx4_sense,
108108
sense_poll);
109109
struct mlx4_dev *dev = sense->dev;

‎drivers/net/phy/phy.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,8 +757,7 @@ EXPORT_SYMBOL(phy_start);
757757
*/
758758
static void phy_state_machine(struct work_struct *work)
759759
{
760-
struct delayed_work *dwork =
761-
container_of(work, struct delayed_work, work);
760+
struct delayed_work *dwork = to_delayed_work(work);
762761
struct phy_device *phydev =
763762
container_of(dwork, struct phy_device, state_queue);
764763
int needs_aneg = 0;

‎drivers/s390/scsi/zfcp_fc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static int zfcp_wka_port_get(struct zfcp_wka_port *wka_port)
9494

9595
static void zfcp_wka_port_offline(struct work_struct *work)
9696
{
97-
struct delayed_work *dw = container_of(work, struct delayed_work, work);
97+
struct delayed_work *dw = to_delayed_work(work);
9898
struct zfcp_wka_port *wka_port =
9999
container_of(dw, struct zfcp_wka_port, work);
100100

‎drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@ void ieee80211_softmac_scan(struct ieee80211_device *ieee)
719719
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
720720
void ieee80211_softmac_scan_wq(struct work_struct *work)
721721
{
722-
struct delayed_work *dwork = container_of(work, struct delayed_work, work);
722+
struct delayed_work *dwork = to_delayed_work(work);
723723
struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq);
724724
#else
725725
void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee)
@@ -777,7 +777,7 @@ void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee)
777777
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
778778
void ieee80211_softmac_scan_wq(struct work_struct *work)
779779
{
780-
struct delayed_work *dwork = container_of(work, struct delayed_work, work);
780+
struct delayed_work *dwork = to_delayed_work(work);
781781
struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, softmac_scan_wq);
782782
#else
783783
void ieee80211_softmac_scan_wq(struct ieee80211_device *ieee)
@@ -2980,7 +2980,7 @@ void ieee80211_start_monitor_mode(struct ieee80211_device *ieee)
29802980
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
29812981
void ieee80211_start_ibss_wq(struct work_struct *work)
29822982
{
2983-
struct delayed_work *dwork = container_of(work, struct delayed_work, work);
2983+
struct delayed_work *dwork = to_delayed_work(work);
29842984
struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, start_ibss_wq);
29852985
#else
29862986
void ieee80211_start_ibss_wq(struct ieee80211_device *ieee)
@@ -3162,7 +3162,7 @@ void ieee80211_disassociate(struct ieee80211_device *ieee)
31623162
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20))
31633163
void ieee80211_associate_retry_wq(struct work_struct *work)
31643164
{
3165-
struct delayed_work *dwork = container_of(work, struct delayed_work, work);
3165+
struct delayed_work *dwork = to_delayed_work(work);
31663166
struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq);
31673167
#else
31683168
void ieee80211_associate_retry_wq(struct ieee80211_device *ieee)

0 commit comments

Comments
 (0)