Add to_delayed_work macro
Subsystems (10)
PATCH 1/1 Add to_delayed_work macro
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 macro for this operation.
--- arch/powerpc/kernel/vio.c | 2 +- drivers/crypto/hifn_795x.c | 2 +- drivers/input/mouse/hgpk.c | 2 +- drivers/net/dm9000.c | 2 +- drivers/net/mlx4/en_netdev.c | 2 +- drivers/net/mlx4/en_rx.c | 2 +- drivers/s390/scsi/zfcp_fc.c | 2 +- drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c | 8 ++++---- drivers/staging/rtl8187se/r8180_core.c | 8 ++++---- drivers/staging/rtl8187se/r8180_dm.c | 6 +++--- drivers/usb/wusbcore/devconnect.c | 2 +- include/linux/workqueue.h | 2 ++ mm/slab.c | 3 +-- 13 files changed, 22 insertions(+), 21 deletions(-)
arch/powerpc/kernel/vio.c +1 -1
@@ -482,7 +482,7 @@ static void vio_cmo_balance(struct work_ cmo->excess.size = cmo->entitled - cmo->reserve.size; cmo->excess.free = cmo->excess.size - need; -cancel_delayed_work (container_of(work ,struct delayed_work ,work )); +cancel_delayed_work (to_delayed_work (work));spin_unlock_irqrestore (&vio_cmo.lock, flags); }
drivers/crypto/hifn_795x.c +1 -1
@@ -1882,7 +1882,7 @@ static void hifn_clear_rings(struct hifnstatic void hifn_work (struct work_struct *work) { - struct delayed_work *dw = container_of(work, struct delayed_work, work); +struct delayed_work *dw =to_delayed_work (work); struct hifn_device *dev = container_of(dw, struct hifn_device, work);unsigned long flags;int reset =0 ;
drivers/input/mouse/hgpk.c +1 -1
@@ -381,7 +381,7 @@ static void hgpk_disconnect(struct psmoustatic void hgpk_recalib_work (struct work_struct *work) { - struct delayed_work *w = container_of(work, struct delayed_work, work); +struct delayed_work *w =to_delayed_work (work); struct hgpk_data *priv = container_of(w, struct hgpk_data, recalib_wq);struct psmouse *psmouse = priv->psmouse;
drivers/net/dm9000.c +1 -1
@@ -559,7 +559,7 @@ static void dm9000_show_carrier(board_instatic void dm9000_poll_work (struct work_struct *w) { - struct delayed_work *dw = container_of(w, struct delayed_work, work); +struct delayed_work *dw =to_delayed_work (w);board_info_t *db =container_of (dw, board_info_t, phy_poll);struct net_device *ndev = db->ndev;
drivers/net/mlx4/en_netdev.c +1 -1
@@ -505,7 +505,7 @@ out:static void mlx4_en_do_get_stats (struct work_struct *work) { - struct delayed_work *delay = container_of(work, struct delayed_work, work); +struct delayed_work *delay =to_delayed_work (work); struct mlx4_en_priv *priv = container_of(delay, struct mlx4_en_priv, stats_task);struct mlx4_en_dev *mdev = priv->mdev;
drivers/net/mlx4/en_rx.c +1 -1
@@ -298,7 +298,7 @@ static void mlx4_en_free_rx_buf(struct mvoid mlx4_en_rx_refill (struct work_struct *work) { - struct delayed_work *delay = container_of(work, struct delayed_work, work); +struct delayed_work *delay =to_delayed_work (work); struct mlx4_en_priv *priv = container_of(delay, struct mlx4_en_priv, refill_task);struct mlx4_en_dev *mdev = priv->mdev;
drivers/s390/scsi/zfcp_fc.c +1 -1
@@ -94,7 +94,7 @@ static int zfcp_wka_port_get(struct zfcpstatic void zfcp_wka_port_offline (struct work_struct *work) { - struct delayed_work *dw = container_of(work, struct delayed_work, work); +struct delayed_work *dw =to_delayed_work (work);struct zfcp_wka_port *wka_port = container_of(dw, struct zfcp_wka_port, work);
drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c +4 -4
@@ -719,7 +719,7 @@ void ieee80211_softmac_scan(struct ieee8#if (LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,20 ))void ieee80211_softmac_scan_wq (struct work_struct *work) { - struct delayed_work *dwork = container_of(work, struct delayed_work, work); +struct delayed_work *dwork =to_delayed_work (work); struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq);#else void ieee80211_softmac_scan_wq (struct ieee80211_device *ieee)
@@ -777,7 +777,7 @@ out:#if (LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,20 ))void ieee80211_softmac_scan_wq (struct work_struct *work) { - struct delayed_work *dwork = container_of(work, struct delayed_work, work); +struct delayed_work *dwork =to_delayed_work (work); struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, softmac_scan_wq);#else void ieee80211_softmac_scan_wq (struct ieee80211_device *ieee)
@@ -2980,7 +2980,7 @@ void ieee80211_start_monitor_mode(struct#if (LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,20 ))void ieee80211_start_ibss_wq (struct work_struct *work) { - struct delayed_work *dwork = container_of(work, struct delayed_work, work); +struct delayed_work *dwork =to_delayed_work (work); struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, start_ibss_wq);#else void ieee80211_start_ibss_wq (struct ieee80211_device *ieee)
@@ -3162,7 +3162,7 @@ void ieee80211_disassociate(struct ieee8#if (LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,20 ))void ieee80211_associate_retry_wq (struct work_struct *work) { - struct delayed_work *dwork = container_of(work, struct delayed_work, work); +struct delayed_work *dwork =to_delayed_work (work); struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq);#else void ieee80211_associate_retry_wq (struct ieee80211_device *ieee)
drivers/staging/rtl8187se/r8180_core.c +4 -4
@@ -5438,7 +5438,7 @@ void rtl8180_hw_wakeup_wq (struct work_s// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq); // struct ieee80211_device * ieee = (struct ieee80211_device*) // container_of(work, struct ieee80211_device, watch_dog_wq); - struct delayed_work *dwork = container_of(work,struct delayed_work,work); +struct delayed_work *dwork =to_delayed_work (work); struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_wakeup_wq);struct net_device *dev = ieee->dev;#else
@@ -5459,7 +5459,7 @@ void rtl8180_hw_sleep_wq (struct work_st// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq); // struct ieee80211_device * ieee = (struct ieee80211_device*) // container_of(work, struct ieee80211_device, watch_dog_wq); - struct delayed_work *dwork = container_of(work,struct delayed_work,work); +struct delayed_work *dwork =to_delayed_work (work); struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_sleep_wq);struct net_device *dev = ieee->dev;#else
@@ -6407,7 +6407,7 @@ priv->txnpring)/8);void rtl8180_tx_irq_wq (struct work_struct *work) {//struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq); - struct delayed_work *dwork = container_of(work,struct delayed_work,work); +struct delayed_work *dwork =to_delayed_work (work);struct ieee80211_device * ieee = (struct ieee80211_device *) container_of(dwork, struct ieee80211_device, watch_dog_wq);struct net_device *dev = ieee->dev;
@@ -6691,7 +6691,7 @@ lizhaoming--------------------------- RF#if (LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,20 ))void GPIOChangeRFWorkItemCallBack (struct work_struct *work) { -//struct delayed_work *dwork = container_of(work, struct delayed_work, work); +//struct delayed_work *dwork = to_delayed_work(work); struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, GPIOChangeRFWorkItem.work);struct net_device *dev = ieee->dev;struct r8180_priv *priv =ieee80211_priv (dev);
drivers/staging/rtl8187se/r8180_dm.c +3 -3
@@ -132,7 +132,7 @@ void rtl8180_tx_pw_wq (struct work_struc// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq); // struct ieee80211_device * ieee = (struct ieee80211_device*) // container_of(work, struct ieee80211_device, watch_dog_wq); - struct delayed_work *dwork = container_of(work,struct delayed_work,work); +struct delayed_work *dwork =to_delayed_work (work); struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,tx_pw_wq);struct net_device *dev = ieee->dev;#else
@@ -314,7 +314,7 @@ void rtl8180_hw_dig_wq (struct work_stru// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq); // struct ieee80211_device * ieee = (struct ieee80211_device*) // container_of(work, struct ieee80211_device, watch_dog_wq); - struct delayed_work *dwork = container_of(work,struct delayed_work,work); +struct delayed_work *dwork =to_delayed_work (work); struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_dig_wq);struct net_device *dev = ieee->dev;#else
@@ -1250,7 +1250,7 @@ SetInitialGain:#if LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,20 )void rtl8180_rate_adapter (struct work_struct * work) { - struct delayed_work *dwork = container_of(work,struct delayed_work,work); +struct delayed_work *dwork =to_delayed_work (work); struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,rate_adapter_wq);struct net_device *dev = ieee->dev;#else
drivers/usb/wusbcore/devconnect.c +1 -1
@@ -471,7 +471,7 @@ static void __wusbhc_keep_alive(struct w*/ static void wusbhc_keep_alive_run (struct work_struct *ws) { - struct delayed_work *dw = container_of(ws, struct delayed_work, work); +struct delayed_work *dw =to_delayed_work (ws); struct wusbhc *wusbhc = container_of(dw, struct wusbhc, keep_alive_timer);mutex_lock (&wusbhc->mutex);
include/linux/workqueue.h +2 -0
@@ -41,6 +41,8 @@ struct delayed_work {struct timer_list timer; }; +#define to_delayed_work (_work) container_of(_work, struct delayed_work, work) +struct execute_work {struct work_struct work; };
mm/slab.c +1 -2
@@ -3988,8 +3988,7 @@ static void cache_reap(struct work_strucstruct kmem_cache *searchp;struct kmem_list3 *l3;int node =numa_node_id (); -struct delayed_work *work = - container_of(w, struct delayed_work, work); +struct delayed_work *work =to_delayed_work (w);if (!mutex_trylock (&cache_chain_mutex))/* Give up. Setup the next iteration. */
Signature · 1 line
Jean Delvare
Andrew Morton
maintainerQuoted 1 line · On Tue, 3 Mar 2009 08:34:40 +0100 Jean Delvare <[email protected]> wrote:
+#define
to_delayed_work(_work)container_of(_work, struct delayed_work, work)
As this is specifically designed to operate on a struct work*', as opposed to "any struct which has a field called work'", we can get additional type-safety by putting a C interface around it.
Hi Andrew,
Quoted 7 lines · Andrew Morton
Quoted 1 line · On Tue, 3 Mar 2009 08:34:40 +0100 Jean Delvare <[email protected]> wrote:
+#define
to_delayed_work(_work)container_of(_work, struct delayed_work, work)As this is specifically designed to operate on a
struct work*', as opposed to "any struct which has a field calledwork'", we can get additional type-safety by putting a C interface around it.
This is what I wanted to do in the first place, but then I noticed that _all_ such wrappers around container_of are implemented as macros rather than inline functions. So I decided to follow the crowd. Any idea why it is so?
I will resend a new patch implementing to_delayed_work as an inline function.
Signature · 1 line
Jean Delvare
Quoted 5 lines · Jean Delvare
Quoted 4 lines · Andrew Morton
Quoted 1 line · On Tue, 3 Mar 2009 08:34:40 +0100 Jean Delvare <[email protected]> wrote:
+#define
to_delayed_work(_work)container_of(_work, struct delayed_work, work)
Quoted 7 lines
Quoted 3 lines
As this is specifically designed to operate on a
struct work*', as opposed to "any struct which has a field calledwork'", we can get additional type-safety by putting a C interface around it.This is what I wanted to do in the first place, but then I noticed that _all_ such wrappers around
container_ofare implemented as macros rather than inline functions.
/Almost/ all.
http://lxr.linux.no/linux+v2.6.28/drivers/firewire/fw-device.h#L73
Quoted 1 line
So I decided to follow the crowd. Any idea why it is so?
Merely old habits.
Signature · 3 lines
Stefan Richter -=====-==--= --== ---== http://arcgraph.de/sr/
Quoted 10 lines · Stefan Richter
Quoted 9 lines · Jean Delvare
Quoted 7 lines · Andrew Morton
Quoted 1 line · On Tue, 3 Mar 2009 08:34:40 +0100 Jean Delvare <[email protected]> wrote:
+#define
to_delayed_work(_work)container_of(_work, struct delayed_work, work)As this is specifically designed to operate on a
struct work*', as opposed to "any struct which has a field calledwork'", we can get additional type-safety by putting a C interface around it.
Quoted 7 lines
Quoted 3 lines
This is what I wanted to do in the first place, but then I noticed that _all_ such wrappers around
container_ofare implemented as macros rather than inline functions./Almost/ all.
http://lxr.linux.no/linux+v2.6.28/drivers/firewire/fw-device.h#L73
Ah, I missed that one because it's not named to_<something>, sorry.
Quoted 3 lines
Quoted 1 line
So I decided to follow the crowd. Any idea why it is so?
Merely old habits.
Signature · 1 line
Jean Delvare
PATCH 1/1 Add to_delayed_work helper function
In reply to Andrew MortonIt 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.
---
Andrew, does this variant please you better?
arch/powerpc/kernel/vio.c | 2 +- drivers/crypto/hifn_795x.c | 2 +- drivers/input/mouse/hgpk.c | 2 +- drivers/net/dm9000.c | 2 +- drivers/net/mlx4/en_netdev.c | 2 +- drivers/net/mlx4/en_rx.c | 2 +- drivers/s390/scsi/zfcp_fc.c | 2 +- drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c | 8 ++++---- drivers/staging/rtl8187se/r8180_core.c | 8 ++++---- drivers/staging/rtl8187se/r8180_dm.c | 6 +++--- drivers/usb/wusbcore/devconnect.c | 2 +- include/linux/workqueue.h | 5 +++++ mm/slab.c | 3 +-- 13 files changed, 25 insertions(+), 21 deletions(-)
arch/powerpc/kernel/vio.c +1 -1
@@ -482,7 +482,7 @@ static void vio_cmo_balance(struct work_ cmo->excess.size = cmo->entitled - cmo->reserve.size; cmo->excess.free = cmo->excess.size - need; -cancel_delayed_work (container_of(work ,struct delayed_work ,work )); +cancel_delayed_work (to_delayed_work (work));spin_unlock_irqrestore (&vio_cmo.lock, flags); }
drivers/crypto/hifn_795x.c +1 -1
@@ -1882,7 +1882,7 @@ static void hifn_clear_rings(struct hifnstatic void hifn_work (struct work_struct *work) { - struct delayed_work *dw = container_of(work, struct delayed_work, work); +struct delayed_work *dw =to_delayed_work (work); struct hifn_device *dev = container_of(dw, struct hifn_device, work);unsigned long flags;int reset =0 ;
drivers/input/mouse/hgpk.c +1 -1
@@ -381,7 +381,7 @@ static void hgpk_disconnect(struct psmoustatic void hgpk_recalib_work (struct work_struct *work) { - struct delayed_work *w = container_of(work, struct delayed_work, work); +struct delayed_work *w =to_delayed_work (work); struct hgpk_data *priv = container_of(w, struct hgpk_data, recalib_wq);struct psmouse *psmouse = priv->psmouse;
drivers/net/dm9000.c +1 -1
@@ -559,7 +559,7 @@ static void dm9000_show_carrier(board_instatic void dm9000_poll_work (struct work_struct *w) { - struct delayed_work *dw = container_of(w, struct delayed_work, work); +struct delayed_work *dw =to_delayed_work (w);board_info_t *db =container_of (dw, board_info_t, phy_poll);struct net_device *ndev = db->ndev;
drivers/net/mlx4/en_netdev.c +1 -1
@@ -505,7 +505,7 @@ out:static void mlx4_en_do_get_stats (struct work_struct *work) { - struct delayed_work *delay = container_of(work, struct delayed_work, work); +struct delayed_work *delay =to_delayed_work (work); struct mlx4_en_priv *priv = container_of(delay, struct mlx4_en_priv, stats_task);struct mlx4_en_dev *mdev = priv->mdev;
drivers/net/mlx4/en_rx.c +1 -1
@@ -298,7 +298,7 @@ static void mlx4_en_free_rx_buf(struct mvoid mlx4_en_rx_refill (struct work_struct *work) { - struct delayed_work *delay = container_of(work, struct delayed_work, work); +struct delayed_work *delay =to_delayed_work (work); struct mlx4_en_priv *priv = container_of(delay, struct mlx4_en_priv, refill_task);struct mlx4_en_dev *mdev = priv->mdev;
drivers/s390/scsi/zfcp_fc.c +1 -1
@@ -94,7 +94,7 @@ static int zfcp_wka_port_get(struct zfcpstatic void zfcp_wka_port_offline (struct work_struct *work) { - struct delayed_work *dw = container_of(work, struct delayed_work, work); +struct delayed_work *dw =to_delayed_work (work);struct zfcp_wka_port *wka_port = container_of(dw, struct zfcp_wka_port, work);
drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c +4 -4
@@ -719,7 +719,7 @@ void ieee80211_softmac_scan(struct ieee8#if (LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,20 ))void ieee80211_softmac_scan_wq (struct work_struct *work) { - struct delayed_work *dwork = container_of(work, struct delayed_work, work); +struct delayed_work *dwork =to_delayed_work (work); struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq);#else void ieee80211_softmac_scan_wq (struct ieee80211_device *ieee)
@@ -777,7 +777,7 @@ out:#if (LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,20 ))void ieee80211_softmac_scan_wq (struct work_struct *work) { - struct delayed_work *dwork = container_of(work, struct delayed_work, work); +struct delayed_work *dwork =to_delayed_work (work); struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, softmac_scan_wq);#else void ieee80211_softmac_scan_wq (struct ieee80211_device *ieee)
@@ -2980,7 +2980,7 @@ void ieee80211_start_monitor_mode(struct#if (LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,20 ))void ieee80211_start_ibss_wq (struct work_struct *work) { - struct delayed_work *dwork = container_of(work, struct delayed_work, work); +struct delayed_work *dwork =to_delayed_work (work); struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, start_ibss_wq);#else void ieee80211_start_ibss_wq (struct ieee80211_device *ieee)
@@ -3162,7 +3162,7 @@ void ieee80211_disassociate(struct ieee8#if (LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,20 ))void ieee80211_associate_retry_wq (struct work_struct *work) { - struct delayed_work *dwork = container_of(work, struct delayed_work, work); +struct delayed_work *dwork =to_delayed_work (work); struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq);#else void ieee80211_associate_retry_wq (struct ieee80211_device *ieee)
drivers/staging/rtl8187se/r8180_core.c +4 -4
@@ -5438,7 +5438,7 @@ void rtl8180_hw_wakeup_wq (struct work_s// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq); // struct ieee80211_device * ieee = (struct ieee80211_device*) // container_of(work, struct ieee80211_device, watch_dog_wq); - struct delayed_work *dwork = container_of(work,struct delayed_work,work); +struct delayed_work *dwork =to_delayed_work (work); struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_wakeup_wq);struct net_device *dev = ieee->dev;#else
@@ -5459,7 +5459,7 @@ void rtl8180_hw_sleep_wq (struct work_st// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq); // struct ieee80211_device * ieee = (struct ieee80211_device*) // container_of(work, struct ieee80211_device, watch_dog_wq); - struct delayed_work *dwork = container_of(work,struct delayed_work,work); +struct delayed_work *dwork =to_delayed_work (work); struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_sleep_wq);struct net_device *dev = ieee->dev;#else
@@ -6407,7 +6407,7 @@ priv->txnpring)/8);void rtl8180_tx_irq_wq (struct work_struct *work) {//struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq); - struct delayed_work *dwork = container_of(work,struct delayed_work,work); +struct delayed_work *dwork =to_delayed_work (work);struct ieee80211_device * ieee = (struct ieee80211_device *) container_of(dwork, struct ieee80211_device, watch_dog_wq);struct net_device *dev = ieee->dev;
@@ -6691,7 +6691,7 @@ lizhaoming--------------------------- RF#if (LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,20 ))void GPIOChangeRFWorkItemCallBack (struct work_struct *work) { -//struct delayed_work *dwork = container_of(work, struct delayed_work, work); +//struct delayed_work *dwork = to_delayed_work(work); struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, GPIOChangeRFWorkItem.work);struct net_device *dev = ieee->dev;struct r8180_priv *priv =ieee80211_priv (dev);
drivers/staging/rtl8187se/r8180_dm.c +3 -3
@@ -132,7 +132,7 @@ void rtl8180_tx_pw_wq (struct work_struc// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq); // struct ieee80211_device * ieee = (struct ieee80211_device*) // container_of(work, struct ieee80211_device, watch_dog_wq); - struct delayed_work *dwork = container_of(work,struct delayed_work,work); +struct delayed_work *dwork =to_delayed_work (work); struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,tx_pw_wq);struct net_device *dev = ieee->dev;#else
@@ -314,7 +314,7 @@ void rtl8180_hw_dig_wq (struct work_stru// struct r8180_priv *priv = container_of(work, struct r8180_priv, watch_dog_wq); // struct ieee80211_device * ieee = (struct ieee80211_device*) // container_of(work, struct ieee80211_device, watch_dog_wq); - struct delayed_work *dwork = container_of(work,struct delayed_work,work); +struct delayed_work *dwork =to_delayed_work (work); struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,hw_dig_wq);struct net_device *dev = ieee->dev;#else
@@ -1250,7 +1250,7 @@ SetInitialGain:#if LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,20 )void rtl8180_rate_adapter (struct work_struct * work) { - struct delayed_work *dwork = container_of(work,struct delayed_work,work); +struct delayed_work *dwork =to_delayed_work (work); struct ieee80211_device *ieee = container_of(dwork,struct ieee80211_device,rate_adapter_wq);struct net_device *dev = ieee->dev;#else
drivers/usb/wusbcore/devconnect.c +1 -1
@@ -471,7 +471,7 @@ static void __wusbhc_keep_alive(struct w*/ static void wusbhc_keep_alive_run (struct work_struct *ws) { - struct delayed_work *dw = container_of(ws, struct delayed_work, work); +struct delayed_work *dw =to_delayed_work (ws); struct wusbhc *wusbhc = container_of(dw, struct wusbhc, keep_alive_timer);mutex_lock (&wusbhc->mutex);
include/linux/workqueue.h +5 -0
@@ -41,6 +41,11 @@ struct delayed_work {struct timer_list timer; }; +static inline struct delayed_work *to_delayed_work (struct work_struct *_work) +{ + return container_of(_work, struct delayed_work, work); +} +struct execute_work {struct work_struct work; };
mm/slab.c +1 -2
@@ -3988,8 +3988,7 @@ static void cache_reap(struct work_strucstruct kmem_cache *searchp;struct kmem_list3 *l3;int node =numa_node_id (); -struct delayed_work *work = - container_of(w, struct delayed_work, work); +struct delayed_work *work =to_delayed_work (w);if (!mutex_trylock (&cache_chain_mutex))/* Give up. Setup the next iteration. */
Signature · 1 line
Jean Delvare
Re: [PATCH] Add to_delayed_work helper function
Quoted 9 lines · Jean Delvare
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.
Signed-off-by Jean Delvare <[email protected]>---
Andrew, does this variant please you better?
Quoted 14 lines
arch/powerpc/kernel/vio.c | 2 +- drivers/crypto/hifn_795x.c | 2 +- drivers/input/mouse/hgpk.c | 2 +- drivers/net/dm9000.c | 2 +- drivers/net/mlx4/en_netdev.c | 2 +- drivers/net/mlx4/en_rx.c | 2 +- drivers/s390/scsi/zfcp_fc.c | 2 +- drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c | 8 ++++---- drivers/staging/rtl8187se/r8180_core.c | 8 ++++---- drivers/staging/rtl8187se/r8180_dm.c | 6 +++--- drivers/usb/wusbcore/devconnect.c | 2 +- include/linux/workqueue.h | 5 +++++ mm/slab.c | 3 +-- 13 files changed, 25 insertions(+), 21 deletions(-)
looks good,
one small detail:
include/linux/workqueue.h struct delayed_work { · line 48
Quoted 11 lines
include/linux/workqueue.h +5
-0@@ -41,6 +41,11 @@ struct delayed_work {struct timer_list timer; }; +static inline struct delayed_work *to_delayed_work (struct work_struct *_work) +{ + return container_of(_work, struct delayed_work, work); +} +
there's no need to name it _work i think and '*work' should be just fine - this isnt a macro so there's no danger of namespace interactions.
Ingo
Re: [PATCH] Add to_delayed_work helper function
Quoted 27 lines · Ingo Molnar
Quoted 9 lines · Jean Delvare
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.
Signed-off-by Jean Delvare <[email protected]>---
Andrew, does this variant please you better?Quoted 14 lines
arch/powerpc/kernel/vio.c | 2 +- drivers/crypto/hifn_795x.c | 2 +- drivers/input/mouse/hgpk.c | 2 +- drivers/net/dm9000.c | 2 +- drivers/net/mlx4/en_netdev.c | 2 +- drivers/net/mlx4/en_rx.c | 2 +- drivers/s390/scsi/zfcp_fc.c | 2 +- drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c | 8 ++++---- drivers/staging/rtl8187se/r8180_core.c | 8 ++++---- drivers/staging/rtl8187se/r8180_dm.c | 6 +++--- drivers/usb/wusbcore/devconnect.c | 2 +- include/linux/workqueue.h | 5 +++++ mm/slab.c | 3 +-- 13 files changed, 25 insertions(+), 21 deletions(-)
Quoted 3 lines
looks good,
Acked-by Ingo Molnar <[email protected]>
Thanks for the review.
Quoted 8 lines
one small detail:
Quoted 6 lines
include/linux/workqueue.h +0
-0@@ -41,6 +41,11 @@ struct delayed_work {struct timer_list timer; };
Quoted 9 lines
include/linux/workqueue.h struct delayed_work { · line 48
Quoted 5 lines
include/linux/workqueue.h +5
-0+static inline struct delayed_work *to_delayed_work (struct work_struct *_work) +{ + return container_of(_work, struct delayed_work, work); +} +there's no need to name it
_worki think and '*work' should be just fine - this isnt a macro so there's no danger of namespace interactions.
I was too chicken to do it because container_of itself is a macro. But I tried it and you are correct. Updated patch follows.
Signature · 1 line
Jean Delvare