aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/fw-transaction.c
diff options
context:
space:
mode:
authorJay Fenlason <fenlason@redhat.com>2008-07-20 08:20:53 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2008-10-15 16:21:09 -0400
commit1e119fa9950dfe0e6d97470098db776110ca47a9 (patch)
tree02ad70ddae6d5cf4869c628e44dae97686a03d97 /drivers/firewire/fw-transaction.c
parentfc392fe83176cefbab99f9d12e6e27395aa2b5d0 (diff)
firewire: fw_send_request_sync()
Share code between fw_send_request + wait_for_completion callers. Signed-off-by: Jay Fenlason <fenlason@redhat.com> Addendum: Removes an unnecessary struct and an ununsed retry loop. Calls it fw_run_transaction() instead of fw_send_request_sync(). Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> Acked-by: Kristian Høgsberg <krh@redhat.com>
Diffstat (limited to 'drivers/firewire/fw-transaction.c')
-rw-r--r--drivers/firewire/fw-transaction.c48
1 files changed, 44 insertions, 4 deletions
diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c
index e5d1a0b64fcf..022ac4fabb67 100644
--- a/drivers/firewire/fw-transaction.c
+++ b/drivers/firewire/fw-transaction.c
@@ -247,7 +247,7 @@ fw_fill_request(struct fw_packet *packet, int tcode, int tlabel,
247 */ 247 */
248void 248void
249fw_send_request(struct fw_card *card, struct fw_transaction *t, 249fw_send_request(struct fw_card *card, struct fw_transaction *t,
250 int tcode, int node_id, int generation, int speed, 250 int tcode, int destination_id, int generation, int speed,
251 unsigned long long offset, 251 unsigned long long offset,
252 void *payload, size_t length, 252 void *payload, size_t length,
253 fw_transaction_callback_t callback, void *callback_data) 253 fw_transaction_callback_t callback, void *callback_data)
@@ -279,13 +279,14 @@ fw_send_request(struct fw_card *card, struct fw_transaction *t,
279 card->current_tlabel = (card->current_tlabel + 1) & 0x1f; 279 card->current_tlabel = (card->current_tlabel + 1) & 0x1f;
280 card->tlabel_mask |= (1 << tlabel); 280 card->tlabel_mask |= (1 << tlabel);
281 281
282 t->node_id = node_id; 282 t->node_id = destination_id;
283 t->tlabel = tlabel; 283 t->tlabel = tlabel;
284 t->callback = callback; 284 t->callback = callback;
285 t->callback_data = callback_data; 285 t->callback_data = callback_data;
286 286
287 fw_fill_request(&t->packet, tcode, t->tlabel, node_id, card->node_id, 287 fw_fill_request(&t->packet, tcode, t->tlabel,
288 generation, speed, offset, payload, length); 288 destination_id, card->node_id, generation,
289 speed, offset, payload, length);
289 t->packet.callback = transmit_complete_callback; 290 t->packet.callback = transmit_complete_callback;
290 291
291 list_add_tail(&t->link, &card->transaction_list); 292 list_add_tail(&t->link, &card->transaction_list);
@@ -296,6 +297,45 @@ fw_send_request(struct fw_card *card, struct fw_transaction *t,
296} 297}
297EXPORT_SYMBOL(fw_send_request); 298EXPORT_SYMBOL(fw_send_request);
298 299
300struct transaction_callback_data {
301 struct completion done;
302 void *payload;
303 int rcode;
304};
305
306static void transaction_callback(struct fw_card *card, int rcode,
307 void *payload, size_t length, void *data)
308{
309 struct transaction_callback_data *d = data;
310
311 if (rcode == RCODE_COMPLETE)
312 memcpy(d->payload, payload, length);
313 d->rcode = rcode;
314 complete(&d->done);
315}
316
317/**
318 * fw_run_transaction - send request and sleep until transaction is completed
319 *
320 * Returns the RCODE.
321 */
322int fw_run_transaction(struct fw_card *card, int tcode, int destination_id,
323 int generation, int speed, unsigned long long offset,
324 void *data, size_t length)
325{
326 struct transaction_callback_data d;
327 struct fw_transaction t;
328
329 init_completion(&d.done);
330 d.payload = data;
331 fw_send_request(card, &t, tcode, destination_id, generation, speed,
332 offset, data, length, transaction_callback, &d);
333 wait_for_completion(&d.done);
334
335 return d.rcode;
336}
337EXPORT_SYMBOL(fw_run_transaction);
338
299static DEFINE_MUTEX(phy_config_mutex); 339static DEFINE_MUTEX(phy_config_mutex);
300static DECLARE_COMPLETION(phy_config_done); 340static DECLARE_COMPLETION(phy_config_done);
301 341