summaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi/zfcp_sysfs.c
diff options
context:
space:
mode:
authorChristof Schmitt <christof.schmitt@de.ibm.com>2010-09-08 14:39:52 +0200
committerJames Bottomley <James.Bottomley@suse.de>2010-09-16 22:54:15 -0400
commit1daa4eb50fa5cd4c8f9c55452606e786fd42053b (patch)
tree2c299aacb948264e716ca6651c2f4ef234fc310a /drivers/s390/scsi/zfcp_sysfs.c
parent57c237731b92fadc7d44824276313ec330b1989b (diff)
downloadlinux-1daa4eb50fa5cd4c8f9c55452606e786fd42053b.tar.gz
linux-1daa4eb50fa5cd4c8f9c55452606e786fd42053b.tar.bz2
linux-1daa4eb50fa5cd4c8f9c55452606e786fd42053b.zip
[SCSI] zfcp: Move code for managing zfcp_unit devices to new file
Move the code for managing zfcp_unit devices to the new file zfcp_unit.c. This is in preparation for the change that zfcp_unit will only track the LUNs configured via unit_add, other data will be moved from zfcp_unit to the new struct zfcp_scsi_dev. Reviewed-by: Swen Schillig <swen@vnet.ibm.com> Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Diffstat (limited to 'drivers/s390/scsi/zfcp_sysfs.c')
-rw-r--r--drivers/s390/scsi/zfcp_sysfs.c56
1 files changed, 8 insertions, 48 deletions
diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
index b4561c86e230..56c46e09d2d4 100644
--- a/drivers/s390/scsi/zfcp_sysfs.c
+++ b/drivers/s390/scsi/zfcp_sysfs.c
@@ -257,28 +257,15 @@ static ssize_t zfcp_sysfs_unit_add_store(struct device *dev,
const char *buf, size_t count)
{
struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
- struct zfcp_unit *unit;
u64 fcp_lun;
- int retval = -EINVAL;
-
- if (!(port && get_device(&port->dev)))
- return -EBUSY;
if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun))
- goto out;
+ return -EINVAL;
- unit = zfcp_unit_enqueue(port, fcp_lun);
- if (IS_ERR(unit))
- goto out;
- else
- retval = 0;
+ if (zfcp_unit_add(port, fcp_lun))
+ return -EINVAL;
- zfcp_erp_unit_reopen(unit, 0, "syuas_1", NULL);
- zfcp_erp_wait(unit->port->adapter);
- zfcp_scsi_scan(unit);
-out:
- put_device(&port->dev);
- return retval ? retval : (ssize_t) count;
+ return count;
}
static DEVICE_ATTR(unit_add, S_IWUSR, NULL, zfcp_sysfs_unit_add_store);
@@ -287,42 +274,15 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev,
const char *buf, size_t count)
{
struct zfcp_port *port = container_of(dev, struct zfcp_port, dev);
- struct zfcp_unit *unit;
u64 fcp_lun;
- int retval = -EINVAL;
- struct scsi_device *sdev;
-
- if (!(port && get_device(&port->dev)))
- return -EBUSY;
if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun))
- goto out;
-
- unit = zfcp_get_unit_by_lun(port, fcp_lun);
- if (!unit)
- goto out;
- else
- retval = 0;
+ return -EINVAL;
- sdev = scsi_device_lookup(port->adapter->scsi_host, 0,
- port->starget_id,
- scsilun_to_int((struct scsi_lun *)&fcp_lun));
- if (sdev) {
- scsi_remove_device(sdev);
- scsi_device_put(sdev);
- }
+ if (zfcp_unit_remove(port, fcp_lun))
+ return -EINVAL;
- write_lock_irq(&port->unit_list_lock);
- list_del(&unit->list);
- write_unlock_irq(&port->unit_list_lock);
-
- put_device(&unit->dev);
-
- zfcp_erp_unit_shutdown(unit, 0, "syurs_1", NULL);
- zfcp_device_unregister(&unit->dev, &zfcp_sysfs_unit_attrs);
-out:
- put_device(&port->dev);
- return retval ? retval : (ssize_t) count;
+ return count;
}
static DEVICE_ATTR(unit_remove, S_IWUSR, NULL, zfcp_sysfs_unit_remove_store);