diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2009-06-06 12:35:27 -0400 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2009-06-06 15:45:50 -0400 |
commit | e5110d011e03030926872457f05e49e3d5031737 (patch) | |
tree | 09037ffddcea6f5b8b18ab20035904408d2869ea /drivers/firewire/sbp2.c | |
parent | e71d31da062095d8b0b02a26fb5e8879e8d3d0de (diff) |
firewire: add parent-of-unit accessor
Retrieval of an fw_unit's parent is a common pattern in high-level code.
Wrap it up as device = fw_parent_device(unit).
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire/sbp2.c')
-rw-r--r-- | drivers/firewire/sbp2.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c index d41cb6e455bc..2353643721c1 100644 --- a/drivers/firewire/sbp2.c +++ b/drivers/firewire/sbp2.c | |||
@@ -180,6 +180,11 @@ struct sbp2_target { | |||
180 | int blocked; /* ditto */ | 180 | int blocked; /* ditto */ |
181 | }; | 181 | }; |
182 | 182 | ||
183 | static struct fw_device *target_device(struct sbp2_target *tgt) | ||
184 | { | ||
185 | return fw_parent_device(tgt->unit); | ||
186 | } | ||
187 | |||
183 | /* Impossible login_id, to detect logout attempt before successful login */ | 188 | /* Impossible login_id, to detect logout attempt before successful login */ |
184 | #define INVALID_LOGIN_ID 0x10000 | 189 | #define INVALID_LOGIN_ID 0x10000 |
185 | 190 | ||
@@ -488,7 +493,7 @@ static void complete_transaction(struct fw_card *card, int rcode, | |||
488 | static void sbp2_send_orb(struct sbp2_orb *orb, struct sbp2_logical_unit *lu, | 493 | static void sbp2_send_orb(struct sbp2_orb *orb, struct sbp2_logical_unit *lu, |
489 | int node_id, int generation, u64 offset) | 494 | int node_id, int generation, u64 offset) |
490 | { | 495 | { |
491 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); | 496 | struct fw_device *device = target_device(lu->tgt); |
492 | unsigned long flags; | 497 | unsigned long flags; |
493 | 498 | ||
494 | orb->pointer.high = 0; | 499 | orb->pointer.high = 0; |
@@ -510,7 +515,7 @@ static void sbp2_send_orb(struct sbp2_orb *orb, struct sbp2_logical_unit *lu, | |||
510 | 515 | ||
511 | static int sbp2_cancel_orbs(struct sbp2_logical_unit *lu) | 516 | static int sbp2_cancel_orbs(struct sbp2_logical_unit *lu) |
512 | { | 517 | { |
513 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); | 518 | struct fw_device *device = target_device(lu->tgt); |
514 | struct sbp2_orb *orb, *next; | 519 | struct sbp2_orb *orb, *next; |
515 | struct list_head list; | 520 | struct list_head list; |
516 | unsigned long flags; | 521 | unsigned long flags; |
@@ -548,7 +553,7 @@ static int sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id, | |||
548 | int generation, int function, | 553 | int generation, int function, |
549 | int lun_or_login_id, void *response) | 554 | int lun_or_login_id, void *response) |
550 | { | 555 | { |
551 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); | 556 | struct fw_device *device = target_device(lu->tgt); |
552 | struct sbp2_management_orb *orb; | 557 | struct sbp2_management_orb *orb; |
553 | unsigned int timeout; | 558 | unsigned int timeout; |
554 | int retval = -ENOMEM; | 559 | int retval = -ENOMEM; |
@@ -644,7 +649,7 @@ static int sbp2_send_management_orb(struct sbp2_logical_unit *lu, int node_id, | |||
644 | 649 | ||
645 | static void sbp2_agent_reset(struct sbp2_logical_unit *lu) | 650 | static void sbp2_agent_reset(struct sbp2_logical_unit *lu) |
646 | { | 651 | { |
647 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); | 652 | struct fw_device *device = target_device(lu->tgt); |
648 | __be32 d = 0; | 653 | __be32 d = 0; |
649 | 654 | ||
650 | fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST, | 655 | fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST, |
@@ -661,7 +666,7 @@ static void complete_agent_reset_write_no_wait(struct fw_card *card, | |||
661 | 666 | ||
662 | static void sbp2_agent_reset_no_wait(struct sbp2_logical_unit *lu) | 667 | static void sbp2_agent_reset_no_wait(struct sbp2_logical_unit *lu) |
663 | { | 668 | { |
664 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); | 669 | struct fw_device *device = target_device(lu->tgt); |
665 | struct fw_transaction *t; | 670 | struct fw_transaction *t; |
666 | static __be32 d; | 671 | static __be32 d; |
667 | 672 | ||
@@ -700,7 +705,7 @@ static inline void sbp2_allow_block(struct sbp2_logical_unit *lu) | |||
700 | static void sbp2_conditionally_block(struct sbp2_logical_unit *lu) | 705 | static void sbp2_conditionally_block(struct sbp2_logical_unit *lu) |
701 | { | 706 | { |
702 | struct sbp2_target *tgt = lu->tgt; | 707 | struct sbp2_target *tgt = lu->tgt; |
703 | struct fw_card *card = fw_device(tgt->unit->device.parent)->card; | 708 | struct fw_card *card = target_device(tgt)->card; |
704 | struct Scsi_Host *shost = | 709 | struct Scsi_Host *shost = |
705 | container_of((void *)tgt, struct Scsi_Host, hostdata[0]); | 710 | container_of((void *)tgt, struct Scsi_Host, hostdata[0]); |
706 | unsigned long flags; | 711 | unsigned long flags; |
@@ -724,7 +729,7 @@ static void sbp2_conditionally_block(struct sbp2_logical_unit *lu) | |||
724 | static void sbp2_conditionally_unblock(struct sbp2_logical_unit *lu) | 729 | static void sbp2_conditionally_unblock(struct sbp2_logical_unit *lu) |
725 | { | 730 | { |
726 | struct sbp2_target *tgt = lu->tgt; | 731 | struct sbp2_target *tgt = lu->tgt; |
727 | struct fw_card *card = fw_device(tgt->unit->device.parent)->card; | 732 | struct fw_card *card = target_device(tgt)->card; |
728 | struct Scsi_Host *shost = | 733 | struct Scsi_Host *shost = |
729 | container_of((void *)tgt, struct Scsi_Host, hostdata[0]); | 734 | container_of((void *)tgt, struct Scsi_Host, hostdata[0]); |
730 | unsigned long flags; | 735 | unsigned long flags; |
@@ -749,7 +754,7 @@ static void sbp2_conditionally_unblock(struct sbp2_logical_unit *lu) | |||
749 | */ | 754 | */ |
750 | static void sbp2_unblock(struct sbp2_target *tgt) | 755 | static void sbp2_unblock(struct sbp2_target *tgt) |
751 | { | 756 | { |
752 | struct fw_card *card = fw_device(tgt->unit->device.parent)->card; | 757 | struct fw_card *card = target_device(tgt)->card; |
753 | struct Scsi_Host *shost = | 758 | struct Scsi_Host *shost = |
754 | container_of((void *)tgt, struct Scsi_Host, hostdata[0]); | 759 | container_of((void *)tgt, struct Scsi_Host, hostdata[0]); |
755 | unsigned long flags; | 760 | unsigned long flags; |
@@ -779,7 +784,7 @@ static void sbp2_release_target(struct kref *kref) | |||
779 | struct Scsi_Host *shost = | 784 | struct Scsi_Host *shost = |
780 | container_of((void *)tgt, struct Scsi_Host, hostdata[0]); | 785 | container_of((void *)tgt, struct Scsi_Host, hostdata[0]); |
781 | struct scsi_device *sdev; | 786 | struct scsi_device *sdev; |
782 | struct fw_device *device = fw_device(tgt->unit->device.parent); | 787 | struct fw_device *device = target_device(tgt); |
783 | 788 | ||
784 | /* prevent deadlocks */ | 789 | /* prevent deadlocks */ |
785 | sbp2_unblock(tgt); | 790 | sbp2_unblock(tgt); |
@@ -852,7 +857,7 @@ static void sbp2_queue_work(struct sbp2_logical_unit *lu, unsigned long delay) | |||
852 | */ | 857 | */ |
853 | static void sbp2_set_busy_timeout(struct sbp2_logical_unit *lu) | 858 | static void sbp2_set_busy_timeout(struct sbp2_logical_unit *lu) |
854 | { | 859 | { |
855 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); | 860 | struct fw_device *device = target_device(lu->tgt); |
856 | __be32 d = cpu_to_be32(SBP2_CYCLE_LIMIT | SBP2_RETRY_LIMIT); | 861 | __be32 d = cpu_to_be32(SBP2_CYCLE_LIMIT | SBP2_RETRY_LIMIT); |
857 | 862 | ||
858 | fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST, | 863 | fw_run_transaction(device->card, TCODE_WRITE_QUADLET_REQUEST, |
@@ -868,7 +873,7 @@ static void sbp2_login(struct work_struct *work) | |||
868 | struct sbp2_logical_unit *lu = | 873 | struct sbp2_logical_unit *lu = |
869 | container_of(work, struct sbp2_logical_unit, work.work); | 874 | container_of(work, struct sbp2_logical_unit, work.work); |
870 | struct sbp2_target *tgt = lu->tgt; | 875 | struct sbp2_target *tgt = lu->tgt; |
871 | struct fw_device *device = fw_device(tgt->unit->device.parent); | 876 | struct fw_device *device = target_device(tgt); |
872 | struct Scsi_Host *shost; | 877 | struct Scsi_Host *shost; |
873 | struct scsi_device *sdev; | 878 | struct scsi_device *sdev; |
874 | struct sbp2_login_response response; | 879 | struct sbp2_login_response response; |
@@ -1116,7 +1121,7 @@ static struct scsi_host_template scsi_driver_template; | |||
1116 | static int sbp2_probe(struct device *dev) | 1121 | static int sbp2_probe(struct device *dev) |
1117 | { | 1122 | { |
1118 | struct fw_unit *unit = fw_unit(dev); | 1123 | struct fw_unit *unit = fw_unit(dev); |
1119 | struct fw_device *device = fw_device(unit->device.parent); | 1124 | struct fw_device *device = fw_parent_device(unit); |
1120 | struct sbp2_target *tgt; | 1125 | struct sbp2_target *tgt; |
1121 | struct sbp2_logical_unit *lu; | 1126 | struct sbp2_logical_unit *lu; |
1122 | struct Scsi_Host *shost; | 1127 | struct Scsi_Host *shost; |
@@ -1197,7 +1202,7 @@ static void sbp2_reconnect(struct work_struct *work) | |||
1197 | struct sbp2_logical_unit *lu = | 1202 | struct sbp2_logical_unit *lu = |
1198 | container_of(work, struct sbp2_logical_unit, work.work); | 1203 | container_of(work, struct sbp2_logical_unit, work.work); |
1199 | struct sbp2_target *tgt = lu->tgt; | 1204 | struct sbp2_target *tgt = lu->tgt; |
1200 | struct fw_device *device = fw_device(tgt->unit->device.parent); | 1205 | struct fw_device *device = target_device(tgt); |
1201 | int generation, node_id, local_node_id; | 1206 | int generation, node_id, local_node_id; |
1202 | 1207 | ||
1203 | if (fw_device_is_shutdown(device)) | 1208 | if (fw_device_is_shutdown(device)) |
@@ -1249,7 +1254,7 @@ static void sbp2_update(struct fw_unit *unit) | |||
1249 | struct sbp2_target *tgt = unit->device.driver_data; | 1254 | struct sbp2_target *tgt = unit->device.driver_data; |
1250 | struct sbp2_logical_unit *lu; | 1255 | struct sbp2_logical_unit *lu; |
1251 | 1256 | ||
1252 | fw_device_enable_phys_dma(fw_device(unit->device.parent)); | 1257 | fw_device_enable_phys_dma(fw_parent_device(unit)); |
1253 | 1258 | ||
1254 | /* | 1259 | /* |
1255 | * Fw-core serializes sbp2_update() against sbp2_remove(). | 1260 | * Fw-core serializes sbp2_update() against sbp2_remove(). |
@@ -1342,7 +1347,7 @@ static void complete_command_orb(struct sbp2_orb *base_orb, | |||
1342 | { | 1347 | { |
1343 | struct sbp2_command_orb *orb = | 1348 | struct sbp2_command_orb *orb = |
1344 | container_of(base_orb, struct sbp2_command_orb, base); | 1349 | container_of(base_orb, struct sbp2_command_orb, base); |
1345 | struct fw_device *device = fw_device(orb->lu->tgt->unit->device.parent); | 1350 | struct fw_device *device = target_device(orb->lu->tgt); |
1346 | int result; | 1351 | int result; |
1347 | 1352 | ||
1348 | if (status != NULL) { | 1353 | if (status != NULL) { |
@@ -1449,7 +1454,7 @@ static int sbp2_map_scatterlist(struct sbp2_command_orb *orb, | |||
1449 | static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done) | 1454 | static int sbp2_scsi_queuecommand(struct scsi_cmnd *cmd, scsi_done_fn_t done) |
1450 | { | 1455 | { |
1451 | struct sbp2_logical_unit *lu = cmd->device->hostdata; | 1456 | struct sbp2_logical_unit *lu = cmd->device->hostdata; |
1452 | struct fw_device *device = fw_device(lu->tgt->unit->device.parent); | 1457 | struct fw_device *device = target_device(lu->tgt); |
1453 | struct sbp2_command_orb *orb; | 1458 | struct sbp2_command_orb *orb; |
1454 | int generation, retval = SCSI_MLQUEUE_HOST_BUSY; | 1459 | int generation, retval = SCSI_MLQUEUE_HOST_BUSY; |
1455 | 1460 | ||