Re: [PATCH] Export current_is_keventd() for libphy

Andrew Morton
2006-12-07T07:50:13Z

On Wed, 6 Dec 2006 22:42:07 -0800
Andrew Morton <akpm@osdl.org> wrote:

> But I wouldn't want to think about an implementation as long as we have
> that WORK_STRUCT_NOAUTOREL horror in there. Can we just nuke that? Only
> three drivers need it and I bet they can be modified to use the usual
> mechanisms.

I guess I don't understand exactly what problem the noautorel stuff is
trying to solve. It _seems_ to me that in all cases we can simply stuff
the old `data' field in alongside the controlling work_struct or
delayed_work which wants to operate on it.

Bridge is the simple case..

diff -puN net/bridge/br_private.h~bridge-avoid-using-noautorel-workqueues net/bridge/br_private.h
--- a/net/bridge/br_private.h~bridge-avoid-using-noautorel-workqueues
+++ a/net/bridge/br_private.h
@@ -83,6 +83,7 @@ struct net_bridge_port
struct timer_list message_age_timer;
struct kobject kobj;
struct delayed_work carrier_check;
+ struct net_device *carrier_check_dev;
struct rcu_head rcu;
};

diff -puN net/bridge/br_if.c~bridge-avoid-using-noautorel-workqueues net/bridge/br_if.c
--- a/net/bridge/br_if.c~bridge-avoid-using-noautorel-workqueues
+++ a/net/bridge/br_if.c
@@ -83,14 +83,11 @@ static void port_carrier_check(struct wo
struct net_device *dev;
struct net_bridge *br;

- dev = container_of(work, struct net_bridge_port,
- carrier_check.work)->dev;
- work_release(work);
-
+ p = container_of(work, struct net_bridge_port, carrier_check.work);
+ dev = p->carrier_check_dev;
rtnl_lock();
- p = dev->br_port;
- if (!p)
- goto done;
+ if (!dev->br_port)
+ goto done; /* Can this happen? */
br = p->br;

if (netif_carrier_ok(dev))
@@ -280,7 +277,8 @@ static struct net_bridge_port *new_nbp(s
p->port_no = index;
br_init_port(p);
p->state = BR_STATE_DISABLED;
- INIT_DELAYED_WORK_NAR(&p->carrier_check, port_carrier_check);
+ p->carrier_check_dev = dev;
+ INIT_DELAYED_WORK(&p->carrier_check, port_carrier_check);
br_stp_port_timer_init(p);

kobject_init(&p->kobj);
_

What am I missing?