aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/fw-device.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-device.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-device.c')
-rw-r--r--drivers/firewire/fw-device.c37
1 files changed, 6 insertions, 31 deletions
diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c
index 0855fb5568e8..3fccdd484100 100644
--- a/drivers/firewire/fw-device.c
+++ b/drivers/firewire/fw-device.c
@@ -381,46 +381,21 @@ static struct device_attribute fw_device_attributes[] = {
381 __ATTR_NULL, 381 __ATTR_NULL,
382}; 382};
383 383
384struct read_quadlet_callback_data {
385 struct completion done;
386 int rcode;
387 u32 data;
388};
389
390static void
391complete_transaction(struct fw_card *card, int rcode,
392 void *payload, size_t length, void *data)
393{
394 struct read_quadlet_callback_data *callback_data = data;
395
396 if (rcode == RCODE_COMPLETE)
397 callback_data->data = be32_to_cpu(*(__be32 *)payload);
398 callback_data->rcode = rcode;
399 complete(&callback_data->done);
400}
401
402static int 384static int
403read_rom(struct fw_device *device, int generation, int index, u32 *data) 385read_rom(struct fw_device *device, int generation, int index, u32 *data)
404{ 386{
405 struct read_quadlet_callback_data callback_data; 387 int rcode;
406 struct fw_transaction t;
407 u64 offset;
408 388
409 /* device->node_id, accessed below, must not be older than generation */ 389 /* device->node_id, accessed below, must not be older than generation */
410 smp_rmb(); 390 smp_rmb();
411 391
412 init_completion(&callback_data.done); 392 rcode = fw_run_transaction(device->card, TCODE_READ_QUADLET_REQUEST,
413
414 offset = (CSR_REGISTER_BASE | CSR_CONFIG_ROM) + index * 4;
415 fw_send_request(device->card, &t, TCODE_READ_QUADLET_REQUEST,
416 device->node_id, generation, device->max_speed, 393 device->node_id, generation, device->max_speed,
417 offset, NULL, 4, complete_transaction, &callback_data); 394 (CSR_REGISTER_BASE | CSR_CONFIG_ROM) + index * 4,
418 395 data, 4);
419 wait_for_completion(&callback_data.done); 396 be32_to_cpus(data);
420
421 *data = callback_data.data;
422 397
423 return callback_data.rcode; 398 return rcode;
424} 399}
425 400
426#define READ_BIB_ROM_SIZE 256 401#define READ_BIB_ROM_SIZE 256