1
0
Fork 0

staging/fwserial: don't use PREPARE_WORK

PREPARE_[DELAYED_]WORK() are being phased out.  They have few users
and a nasty surprise in terms of reentrancy guarantee as workqueue
considers work items to be different if they don't have the same work
function.

fwtty_peer->work is multiplexed with multiple work functions.
Introduce fwserial_peer_workfn() which invokes fwtty_peer->workfn and
always use it as the work function and update the users to set the
->workfn field instead of overriding the work function using
PREPARE_WORK().

It would probably be best to route this with other related updates
through the workqueue tree.

Compile tested.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Peter Hurley <peter@hurleysoftware.com>
wifi-calibration
Tejun Heo 2014-03-07 10:24:50 -05:00
parent 059499453a
commit 6c256cb646
2 changed files with 11 additions and 3 deletions

View File

@ -2036,6 +2036,13 @@ static void fwserial_auto_connect(struct work_struct *work)
schedule_delayed_work(&peer->connect, CONNECT_RETRY_DELAY); schedule_delayed_work(&peer->connect, CONNECT_RETRY_DELAY);
} }
static void fwserial_peer_workfn(struct work_struct *work)
{
struct fwtty_peer *peer = to_peer(work, work);
peer->workfn(work);
}
/** /**
* fwserial_add_peer - add a newly probed 'serial' unit device as a 'peer' * fwserial_add_peer - add a newly probed 'serial' unit device as a 'peer'
* @serial: aggregate representing the specific fw_card to add the peer to * @serial: aggregate representing the specific fw_card to add the peer to
@ -2100,7 +2107,7 @@ static int fwserial_add_peer(struct fw_serial *serial, struct fw_unit *unit)
peer->port = NULL; peer->port = NULL;
init_timer(&peer->timer); init_timer(&peer->timer);
INIT_WORK(&peer->work, NULL); INIT_WORK(&peer->work, fwserial_peer_workfn);
INIT_DELAYED_WORK(&peer->connect, fwserial_auto_connect); INIT_DELAYED_WORK(&peer->connect, fwserial_auto_connect);
/* associate peer with specific fw_card */ /* associate peer with specific fw_card */
@ -2702,7 +2709,7 @@ static int fwserial_parse_mgmt_write(struct fwtty_peer *peer,
} else { } else {
peer->work_params.plug_req = pkt->plug_req; peer->work_params.plug_req = pkt->plug_req;
PREPARE_WORK(&peer->work, fwserial_handle_plug_req); peer->workfn = fwserial_handle_plug_req;
queue_work(system_unbound_wq, &peer->work); queue_work(system_unbound_wq, &peer->work);
} }
break; break;
@ -2731,7 +2738,7 @@ static int fwserial_parse_mgmt_write(struct fwtty_peer *peer,
fwtty_err(&peer->unit, "unplug req: busy\n"); fwtty_err(&peer->unit, "unplug req: busy\n");
rcode = RCODE_CONFLICT_ERROR; rcode = RCODE_CONFLICT_ERROR;
} else { } else {
PREPARE_WORK(&peer->work, fwserial_handle_unplug_req); peer->workfn = fwserial_handle_unplug_req;
queue_work(system_unbound_wq, &peer->work); queue_work(system_unbound_wq, &peer->work);
} }
break; break;

View File

@ -91,6 +91,7 @@ struct fwtty_peer {
struct rcu_head rcu; struct rcu_head rcu;
spinlock_t lock; spinlock_t lock;
work_func_t workfn;
struct work_struct work; struct work_struct work;
struct peer_work_params work_params; struct peer_work_params work_params;
struct timer_list timer; struct timer_list timer;