aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/sbp2.c
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2011-08-27 09:35:23 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2011-09-16 16:23:56 -0400
commit32ce38f40337cf4a805552e494354d961587c838 (patch)
tree57ed8273ecf184c6ebf1ef4b155a1b648d23b1f7 /drivers/firewire/sbp2.c
parentb2af07b6844aade3a6d69511625bef2b1cb609cc (diff)
firewire: sbp2: fold two functions into one
sbp2_release_target() is folded into its primary user, sbp2_remove(). The only other caller, a failure path in sbp2_probe(), now uses sbp2_remove(). This adds unnecessary cancel_delayed_work_sync() calls to that failure path but results in less code and text. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire/sbp2.c')
-rw-r--r--drivers/firewire/sbp2.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c
index 09b79e940a20..8a8047db6980 100644
--- a/drivers/firewire/sbp2.c
+++ b/drivers/firewire/sbp2.c
@@ -1110,7 +1110,7 @@ static void sbp2_init_workarounds(struct sbp2_target *tgt, u32 model,
1110} 1110}
1111 1111
1112static struct scsi_host_template scsi_driver_template; 1112static struct scsi_host_template scsi_driver_template;
1113static void sbp2_release_target(struct sbp2_target *tgt); 1113static int sbp2_remove(struct device *dev);
1114 1114
1115static int sbp2_probe(struct device *dev) 1115static int sbp2_probe(struct device *dev)
1116{ 1116{
@@ -1153,7 +1153,7 @@ static int sbp2_probe(struct device *dev)
1153 1153
1154 if (sbp2_scan_unit_dir(tgt, unit->directory, &model, 1154 if (sbp2_scan_unit_dir(tgt, unit->directory, &model,
1155 &firmware_revision) < 0) 1155 &firmware_revision) < 0)
1156 goto fail_release_target; 1156 goto fail_remove;
1157 1157
1158 sbp2_clamp_management_orb_timeout(tgt); 1158 sbp2_clamp_management_orb_timeout(tgt);
1159 sbp2_init_workarounds(tgt, model, firmware_revision); 1159 sbp2_init_workarounds(tgt, model, firmware_revision);
@@ -1173,8 +1173,8 @@ static int sbp2_probe(struct device *dev)
1173 1173
1174 return 0; 1174 return 0;
1175 1175
1176 fail_release_target: 1176 fail_remove:
1177 sbp2_release_target(tgt); 1177 sbp2_remove(dev);
1178 return -ENOMEM; 1178 return -ENOMEM;
1179 1179
1180 fail_shost_put: 1180 fail_shost_put:
@@ -1200,18 +1200,21 @@ static void sbp2_update(struct fw_unit *unit)
1200 } 1200 }
1201} 1201}
1202 1202
1203static void sbp2_release_target(struct sbp2_target *tgt) 1203static int sbp2_remove(struct device *dev)
1204{ 1204{
1205 struct fw_unit *unit = fw_unit(dev);
1206 struct fw_device *device = fw_parent_device(unit);
1207 struct sbp2_target *tgt = dev_get_drvdata(&unit->device);
1205 struct sbp2_logical_unit *lu, *next; 1208 struct sbp2_logical_unit *lu, *next;
1206 struct Scsi_Host *shost = 1209 struct Scsi_Host *shost =
1207 container_of((void *)tgt, struct Scsi_Host, hostdata[0]); 1210 container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
1208 struct scsi_device *sdev; 1211 struct scsi_device *sdev;
1209 struct fw_device *device = target_device(tgt);
1210 1212
1211 /* prevent deadlocks */ 1213 /* prevent deadlocks */
1212 sbp2_unblock(tgt); 1214 sbp2_unblock(tgt);
1213 1215
1214 list_for_each_entry_safe(lu, next, &tgt->lu_list, link) { 1216 list_for_each_entry_safe(lu, next, &tgt->lu_list, link) {
1217 cancel_delayed_work_sync(&lu->work);
1215 sdev = scsi_device_lookup(shost, 0, 0, sbp2_lun2int(lu->lun)); 1218 sdev = scsi_device_lookup(shost, 0, 0, sbp2_lun2int(lu->lun));
1216 if (sdev) { 1219 if (sdev) {
1217 scsi_remove_device(sdev); 1220 scsi_remove_device(sdev);
@@ -1239,19 +1242,6 @@ static void sbp2_release_target(struct sbp2_target *tgt)
1239 fw_notify("released %s, target %d:0:0\n", tgt->bus_id, shost->host_no); 1242 fw_notify("released %s, target %d:0:0\n", tgt->bus_id, shost->host_no);
1240 1243
1241 scsi_host_put(shost); 1244 scsi_host_put(shost);
1242}
1243
1244static int sbp2_remove(struct device *dev)
1245{
1246 struct fw_unit *unit = fw_unit(dev);
1247 struct sbp2_target *tgt = dev_get_drvdata(&unit->device);
1248 struct sbp2_logical_unit *lu;
1249
1250 list_for_each_entry(lu, &tgt->lu_list, link)
1251 cancel_delayed_work_sync(&lu->work);
1252
1253 sbp2_release_target(tgt);
1254
1255 return 0; 1245 return 0;
1256} 1246}
1257 1247