diff options
author | Tejun Heo <tj@kernel.org> | 2014-03-07 10:24:50 -0500 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-03-07 10:24:50 -0500 |
commit | 6c256cb6467e60b54f41170076c7f625e231c282 (patch) | |
tree | 8796d0ac5ae7774ba08a203e3647e7242a0e062e | |
parent | 059499453a9abd1857d442b44da8b4c126dc72a8 (diff) |
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>
-rw-r--r-- | drivers/staging/fwserial/fwserial.c | 13 | ||||
-rw-r--r-- | drivers/staging/fwserial/fwserial.h | 1 |
2 files changed, 11 insertions, 3 deletions
diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index 8af136e9c9dc..b22142ee5262 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c | |||
@@ -2036,6 +2036,13 @@ static void fwserial_auto_connect(struct work_struct *work) | |||
2036 | schedule_delayed_work(&peer->connect, CONNECT_RETRY_DELAY); | 2036 | schedule_delayed_work(&peer->connect, CONNECT_RETRY_DELAY); |
2037 | } | 2037 | } |
2038 | 2038 | ||
2039 | static void fwserial_peer_workfn(struct work_struct *work) | ||
2040 | { | ||
2041 | struct fwtty_peer *peer = to_peer(work, work); | ||
2042 | |||
2043 | peer->workfn(work); | ||
2044 | } | ||
2045 | |||
2039 | /** | 2046 | /** |
2040 | * fwserial_add_peer - add a newly probed 'serial' unit device as a 'peer' | 2047 | * fwserial_add_peer - add a newly probed 'serial' unit device as a 'peer' |
2041 | * @serial: aggregate representing the specific fw_card to add the peer to | 2048 | * @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) | |||
2100 | peer->port = NULL; | 2107 | peer->port = NULL; |
2101 | 2108 | ||
2102 | init_timer(&peer->timer); | 2109 | init_timer(&peer->timer); |
2103 | INIT_WORK(&peer->work, NULL); | 2110 | INIT_WORK(&peer->work, fwserial_peer_workfn); |
2104 | INIT_DELAYED_WORK(&peer->connect, fwserial_auto_connect); | 2111 | INIT_DELAYED_WORK(&peer->connect, fwserial_auto_connect); |
2105 | 2112 | ||
2106 | /* associate peer with specific fw_card */ | 2113 | /* associate peer with specific fw_card */ |
@@ -2702,7 +2709,7 @@ static int fwserial_parse_mgmt_write(struct fwtty_peer *peer, | |||
2702 | 2709 | ||
2703 | } else { | 2710 | } else { |
2704 | peer->work_params.plug_req = pkt->plug_req; | 2711 | peer->work_params.plug_req = pkt->plug_req; |
2705 | PREPARE_WORK(&peer->work, fwserial_handle_plug_req); | 2712 | peer->workfn = fwserial_handle_plug_req; |
2706 | queue_work(system_unbound_wq, &peer->work); | 2713 | queue_work(system_unbound_wq, &peer->work); |
2707 | } | 2714 | } |
2708 | break; | 2715 | break; |
@@ -2731,7 +2738,7 @@ static int fwserial_parse_mgmt_write(struct fwtty_peer *peer, | |||
2731 | fwtty_err(&peer->unit, "unplug req: busy\n"); | 2738 | fwtty_err(&peer->unit, "unplug req: busy\n"); |
2732 | rcode = RCODE_CONFLICT_ERROR; | 2739 | rcode = RCODE_CONFLICT_ERROR; |
2733 | } else { | 2740 | } else { |
2734 | PREPARE_WORK(&peer->work, fwserial_handle_unplug_req); | 2741 | peer->workfn = fwserial_handle_unplug_req; |
2735 | queue_work(system_unbound_wq, &peer->work); | 2742 | queue_work(system_unbound_wq, &peer->work); |
2736 | } | 2743 | } |
2737 | break; | 2744 | break; |
diff --git a/drivers/staging/fwserial/fwserial.h b/drivers/staging/fwserial/fwserial.h index 54f7f9b9b212..98b853d4acbc 100644 --- a/drivers/staging/fwserial/fwserial.h +++ b/drivers/staging/fwserial/fwserial.h | |||
@@ -91,6 +91,7 @@ struct fwtty_peer { | |||
91 | struct rcu_head rcu; | 91 | struct rcu_head rcu; |
92 | 92 | ||
93 | spinlock_t lock; | 93 | spinlock_t lock; |
94 | work_func_t workfn; | ||
94 | struct work_struct work; | 95 | struct work_struct work; |
95 | struct peer_work_params work_params; | 96 | struct peer_work_params work_params; |
96 | struct timer_list timer; | 97 | struct timer_list timer; |