Patchwork ATM: Fix wrong usage of INIT_WORK

login
register
mail settings
Submitter stufever@gmail.com
Date July 7, 2011, 11:51 a.m.
Message ID <1310039512-17579-1-git-send-email-wangshaoyan.pt@taobao.com>
Download mbox | patch
Permalink /patch/103644/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

stufever@gmail.com - July 7, 2011, 11:51 a.m.
From: Wang Shaoyan <wangshaoyan.pt@taobao.com>

If we define FILL_RX_POOLS_IN_BH, the compiler will report error such as
  drivers/atm/ambassador.c:2159:64: error: macro "INIT_WORK" passed 3 arguments, but takes just 2
because the function INIT_WORK() don't accept "data" now, it only has
two arguments, so use the right way to initialise work queue.

Cc: Chas Williams <chas@cmf.nrl.navy.mil> (maintainer:ATM)
Cc: linux-atm-general@lists.sourceforge.net (open list:ATM)
Signed-off-by: Wang Shaoyan <wangshaoyan.pt@taobao.com>
---
 drivers/atm/ambassador.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
David Miller - July 7, 2011, 11:51 a.m.
From: stufever@gmail.com
Date: Thu,  7 Jul 2011 19:51:52 +0800

> From: Wang Shaoyan <wangshaoyan.pt@taobao.com>
> 
> If we define FILL_RX_POOLS_IN_BH, the compiler will report error such as
>   drivers/atm/ambassador.c:2159:64: error: macro "INIT_WORK" passed 3 arguments, but takes just 2
> because the function INIT_WORK() don't accept "data" now, it only has
> two arguments, so use the right way to initialise work queue.
> 
> Cc: Chas Williams <chas@cmf.nrl.navy.mil> (maintainer:ATM)
> Cc: linux-atm-general@lists.sourceforge.net (open list:ATM)
> Signed-off-by: Wang Shaoyan <wangshaoyan.pt@taobao.com>

This just makes the driver a bigger CPP mess.

Unconditionally provide the dev->bh member, and unconditionally pass
it into the worker function.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
stufever@gmail.com - July 7, 2011, 12:04 p.m.
I just don't know whether the marco FILL_RX_POOLS_IN_BH is useful?

2011/7/7 David Miller <davem@davemloft.net>:

>
> This just makes the driver a bigger CPP mess.
>
> Unconditionally provide the dev->bh member, and unconditionally pass
> it into the worker function.
>
>
David Miller - July 7, 2011, 12:10 p.m.
From: Wang Shaoyan <stufever@gmail.com>
Date: Thu, 7 Jul 2011 20:04:25 +0800

> I just don't know whether the marco FILL_RX_POOLS_IN_BH is useful?

Yes, another option is to delete all of the code protected by
that macro altogether.

It obviously hasn't been build tested in a long time, if at all.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
chas williams - CONTRACTOR - July 7, 2011, 12:29 p.m.
On Thu, 7 Jul 2011 20:04:25 +0800
Wang Shaoyan <stufever@gmail.com> wrote:

> I just don't know whether the marco FILL_RX_POOLS_IN_BH is useful?

the macro doesnt seem to be useful in anyway.  it can simply be
eliminated.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
index a5fcb1e..3618c5c 100644
--- a/drivers/atm/ambassador.c
+++ b/drivers/atm/ambassador.c
@@ -814,7 +814,12 @@  static void fill_rx_pool (amb_dev * dev, unsigned char pool,
 }
 
 // top up all RX pools (can also be called as a bottom half)
+#ifdef FILL_RX_POOLS_IN_BH
+static void fill_rx_pools (struct work_struct * work) {
+  amb_dev * dev = container_of(work, amb_dev, bh);
+#else
 static void fill_rx_pools (amb_dev * dev) {
+#endif
   unsigned char pool;
   
   PRINTD (DBG_FLOW|DBG_POOL, "fill_rx_pools %p", dev);
@@ -1503,7 +1508,11 @@  static void do_housekeeping (unsigned long arg) {
   // could collect device-specific (not driver/atm-linux) stats here
       
   // last resort refill once every ten seconds
+#ifdef FILL_RX_POOLS_IN_BH
+  fill_rx_pools (&dev->bh);
+#else
   fill_rx_pools (dev);
+#endif
   mod_timer(&dev->housekeeping, jiffies + 10*HZ);
   
   return;
@@ -2156,7 +2165,7 @@  static void setup_dev(amb_dev *dev, struct pci_dev *pci_dev)
       
 #ifdef FILL_RX_POOLS_IN_BH
       // initialise bottom half
-      INIT_WORK(&dev->bh, (void (*)(void *)) fill_rx_pools, dev);
+      INIT_WORK(&dev->bh, fill_rx_pools);
 #endif
       
       // semaphore for txer/rxer modifications - we cannot use a