Skip to content

Commit

Permalink
firewire: sbp2: fold two functions into one
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stefan Richter committed Sep 16, 2011
1 parent b2af07b commit 32ce38f
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions drivers/firewire/sbp2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ static void sbp2_init_workarounds(struct sbp2_target *tgt, u32 model,
}

static struct scsi_host_template scsi_driver_template;
static void sbp2_release_target(struct sbp2_target *tgt);
static int sbp2_remove(struct device *dev);

static int sbp2_probe(struct device *dev)
{
Expand Down Expand Up @@ -1153,7 +1153,7 @@ static int sbp2_probe(struct device *dev)

if (sbp2_scan_unit_dir(tgt, unit->directory, &model,
&firmware_revision) < 0)
goto fail_release_target;
goto fail_remove;

sbp2_clamp_management_orb_timeout(tgt);
sbp2_init_workarounds(tgt, model, firmware_revision);
Expand All @@ -1173,8 +1173,8 @@ static int sbp2_probe(struct device *dev)

return 0;

fail_release_target:
sbp2_release_target(tgt);
fail_remove:
sbp2_remove(dev);
return -ENOMEM;

fail_shost_put:
Expand All @@ -1200,18 +1200,21 @@ static void sbp2_update(struct fw_unit *unit)
}
}

static void sbp2_release_target(struct sbp2_target *tgt)
static int sbp2_remove(struct device *dev)
{
struct fw_unit *unit = fw_unit(dev);
struct fw_device *device = fw_parent_device(unit);
struct sbp2_target *tgt = dev_get_drvdata(&unit->device);
struct sbp2_logical_unit *lu, *next;
struct Scsi_Host *shost =
container_of((void *)tgt, struct Scsi_Host, hostdata[0]);
struct scsi_device *sdev;
struct fw_device *device = target_device(tgt);

/* prevent deadlocks */
sbp2_unblock(tgt);

list_for_each_entry_safe(lu, next, &tgt->lu_list, link) {
cancel_delayed_work_sync(&lu->work);
sdev = scsi_device_lookup(shost, 0, 0, sbp2_lun2int(lu->lun));
if (sdev) {
scsi_remove_device(sdev);
Expand Down Expand Up @@ -1239,19 +1242,6 @@ static void sbp2_release_target(struct sbp2_target *tgt)
fw_notify("released %s, target %d:0:0\n", tgt->bus_id, shost->host_no);

scsi_host_put(shost);
}

static int sbp2_remove(struct device *dev)
{
struct fw_unit *unit = fw_unit(dev);
struct sbp2_target *tgt = dev_get_drvdata(&unit->device);
struct sbp2_logical_unit *lu;

list_for_each_entry(lu, &tgt->lu_list, link)
cancel_delayed_work_sync(&lu->work);

sbp2_release_target(tgt);

return 0;
}

Expand Down

0 comments on commit 32ce38f

Please sign in to comment.