diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2009-10-07 18:41:10 -0400 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2009-10-14 17:10:48 -0400 |
commit | 9fb551bf72929b316abb6d96cfb2ec05e896042a (patch) | |
tree | 63c52c2b3c6ee05b11176ce16fa3eb9c7b69edad /drivers/firewire/core-cdev.c | |
parent | 7e44c0b56b07a5e34de9943cfb2fee72e71a9f0e (diff) |
firewire: normalize style of queue_work wrappers
A few stylistic changes to unify some code patterns in the subsystem:
- The similar queue_delayed_work helpers fw_schedule_bm_work,
schedule_iso_resource, and sbp2_queue_work now have the same call
convention.
- Two conditional calls of schedule_iso_resource are factored into
another small helper.
- An sbp2_target_get helper is added as counterpart to
sbp2_target_put.
Object size of firewire-core is decreased a little bit, object size of
firewire-sbp2 remains unchanged.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire/core-cdev.c')
-rw-r--r-- | drivers/firewire/core-cdev.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c index 0516acd55ab..c5f63a93965 100644 --- a/drivers/firewire/core-cdev.c +++ b/drivers/firewire/core-cdev.c | |||
@@ -129,9 +129,22 @@ struct iso_resource { | |||
129 | struct iso_resource_event *e_alloc, *e_dealloc; | 129 | struct iso_resource_event *e_alloc, *e_dealloc; |
130 | }; | 130 | }; |
131 | 131 | ||
132 | static void schedule_iso_resource(struct iso_resource *); | ||
133 | static void release_iso_resource(struct client *, struct client_resource *); | 132 | static void release_iso_resource(struct client *, struct client_resource *); |
134 | 133 | ||
134 | static void schedule_iso_resource(struct iso_resource *r, unsigned long delay) | ||
135 | { | ||
136 | client_get(r->client); | ||
137 | if (!schedule_delayed_work(&r->work, delay)) | ||
138 | client_put(r->client); | ||
139 | } | ||
140 | |||
141 | static void schedule_if_iso_resource(struct client_resource *resource) | ||
142 | { | ||
143 | if (resource->release == release_iso_resource) | ||
144 | schedule_iso_resource(container_of(resource, | ||
145 | struct iso_resource, resource), 0); | ||
146 | } | ||
147 | |||
135 | /* | 148 | /* |
136 | * dequeue_event() just kfree()'s the event, so the event has to be | 149 | * dequeue_event() just kfree()'s the event, so the event has to be |
137 | * the first field in a struct XYZ_event. | 150 | * the first field in a struct XYZ_event. |
@@ -313,11 +326,8 @@ static void for_each_client(struct fw_device *device, | |||
313 | 326 | ||
314 | static int schedule_reallocations(int id, void *p, void *data) | 327 | static int schedule_reallocations(int id, void *p, void *data) |
315 | { | 328 | { |
316 | struct client_resource *r = p; | 329 | schedule_if_iso_resource(p); |
317 | 330 | ||
318 | if (r->release == release_iso_resource) | ||
319 | schedule_iso_resource(container_of(r, | ||
320 | struct iso_resource, resource)); | ||
321 | return 0; | 331 | return 0; |
322 | } | 332 | } |
323 | 333 | ||
@@ -413,9 +423,7 @@ static int add_client_resource(struct client *client, | |||
413 | &resource->handle); | 423 | &resource->handle); |
414 | if (ret >= 0) { | 424 | if (ret >= 0) { |
415 | client_get(client); | 425 | client_get(client); |
416 | if (resource->release == release_iso_resource) | 426 | schedule_if_iso_resource(resource); |
417 | schedule_iso_resource(container_of(resource, | ||
418 | struct iso_resource, resource)); | ||
419 | } | 427 | } |
420 | spin_unlock_irqrestore(&client->lock, flags); | 428 | spin_unlock_irqrestore(&client->lock, flags); |
421 | 429 | ||
@@ -1032,8 +1040,7 @@ static void iso_resource_work(struct work_struct *work) | |||
1032 | /* Allow 1000ms grace period for other reallocations. */ | 1040 | /* Allow 1000ms grace period for other reallocations. */ |
1033 | if (todo == ISO_RES_ALLOC && | 1041 | if (todo == ISO_RES_ALLOC && |
1034 | time_is_after_jiffies(client->device->card->reset_jiffies + HZ)) { | 1042 | time_is_after_jiffies(client->device->card->reset_jiffies + HZ)) { |
1035 | if (schedule_delayed_work(&r->work, DIV_ROUND_UP(HZ, 3))) | 1043 | schedule_iso_resource(r, DIV_ROUND_UP(HZ, 3)); |
1036 | client_get(client); | ||
1037 | skip = true; | 1044 | skip = true; |
1038 | } else { | 1045 | } else { |
1039 | /* We could be called twice within the same generation. */ | 1046 | /* We could be called twice within the same generation. */ |
@@ -1118,13 +1125,6 @@ static void iso_resource_work(struct work_struct *work) | |||
1118 | client_put(client); | 1125 | client_put(client); |
1119 | } | 1126 | } |
1120 | 1127 | ||
1121 | static void schedule_iso_resource(struct iso_resource *r) | ||
1122 | { | ||
1123 | client_get(r->client); | ||
1124 | if (!schedule_delayed_work(&r->work, 0)) | ||
1125 | client_put(r->client); | ||
1126 | } | ||
1127 | |||
1128 | static void release_iso_resource(struct client *client, | 1128 | static void release_iso_resource(struct client *client, |
1129 | struct client_resource *resource) | 1129 | struct client_resource *resource) |
1130 | { | 1130 | { |
@@ -1133,7 +1133,7 @@ static void release_iso_resource(struct client *client, | |||
1133 | 1133 | ||
1134 | spin_lock_irq(&client->lock); | 1134 | spin_lock_irq(&client->lock); |
1135 | r->todo = ISO_RES_DEALLOC; | 1135 | r->todo = ISO_RES_DEALLOC; |
1136 | schedule_iso_resource(r); | 1136 | schedule_iso_resource(r, 0); |
1137 | spin_unlock_irq(&client->lock); | 1137 | spin_unlock_irq(&client->lock); |
1138 | } | 1138 | } |
1139 | 1139 | ||
@@ -1179,7 +1179,7 @@ static int init_iso_resource(struct client *client, | |||
1179 | } else { | 1179 | } else { |
1180 | r->resource.release = NULL; | 1180 | r->resource.release = NULL; |
1181 | r->resource.handle = -1; | 1181 | r->resource.handle = -1; |
1182 | schedule_iso_resource(r); | 1182 | schedule_iso_resource(r, 0); |
1183 | } | 1183 | } |
1184 | request->handle = r->resource.handle; | 1184 | request->handle = r->resource.handle; |
1185 | 1185 | ||