summaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi/zfcp_sysfs.c
diff options
context:
space:
mode:
authorSwen Schillig <swen@vnet.ibm.com>2009-11-24 16:53:59 +0100
committerJames Bottomley <James.Bottomley@suse.de>2009-12-04 12:02:02 -0600
commitf3450c7b917201bb49d67032e9f60d5125675d6a (patch)
tree404b1c23490b0a5ba3d6cbbb14e64381a12a108a /drivers/s390/scsi/zfcp_sysfs.c
parentecf0c7721b104c0ce9c8ca534c911f6310cf92a8 (diff)
downloadtalos-obmc-linux-f3450c7b917201bb49d67032e9f60d5125675d6a.tar.gz
talos-obmc-linux-f3450c7b917201bb49d67032e9f60d5125675d6a.zip
[SCSI] zfcp: Replace local reference counting with common kref
Replace the local reference counting by already available mechanisms offered by kref. Where possible existing device structures were used, including the same functionality. Signed-off-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.c44
1 files changed, 18 insertions, 26 deletions
diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
index 8430b518357e..b4a7e17932c5 100644
--- a/drivers/s390/scsi/zfcp_sysfs.c
+++ b/drivers/s390/scsi/zfcp_sysfs.c
@@ -3,7 +3,7 @@
*
* sysfs attributes.
*
- * Copyright IBM Corporation 2008
+ * Copyright IBM Corporation 2008, 2009
*/
#define KMSG_COMPONENT "zfcp"
@@ -140,7 +140,6 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
struct zfcp_port *port;
u64 wwpn;
int retval = 0;
- LIST_HEAD(port_remove_lh);
mutex_lock(&zfcp_data.config_mutex);
if (atomic_read(&adapter->status) & ZFCP_STATUS_COMMON_REMOVE) {
@@ -154,23 +153,21 @@ static ssize_t zfcp_sysfs_port_remove_store(struct device *dev,
}
port = zfcp_get_port_by_wwpn(adapter, wwpn);
- if (port && (atomic_read(&port->refcount) == 1)) {
- atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status);
- write_lock_irq(&adapter->port_list_lock);
- list_move(&port->list, &port_remove_lh);
- write_unlock_irq(&adapter->port_list_lock);
- } else
- port = NULL;
-
if (!port) {
retval = -ENXIO;
goto out;
}
+ atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &port->status);
+
+ write_lock_irq(&adapter->port_list_lock);
+ list_del(&port->list);
+ write_unlock_irq(&adapter->port_list_lock);
+
+ put_device(&port->sysfs_device);
+
zfcp_erp_port_shutdown(port, 0, "syprs_1", NULL);
- zfcp_erp_wait(adapter);
- zfcp_port_put(port);
- zfcp_port_dequeue(port);
+ zfcp_device_unregister(&port->sysfs_device, &zfcp_sysfs_port_attrs);
out:
mutex_unlock(&zfcp_data.config_mutex);
return retval ? retval : (ssize_t) count;
@@ -224,7 +221,6 @@ static ssize_t zfcp_sysfs_unit_add_store(struct device *dev,
zfcp_erp_unit_reopen(unit, 0, "syuas_1", NULL);
zfcp_erp_wait(unit->port->adapter);
flush_work(&unit->scsi_work);
- zfcp_unit_put(unit);
out:
mutex_unlock(&zfcp_data.config_mutex);
return retval ? retval : (ssize_t) count;
@@ -239,7 +235,6 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev,
struct zfcp_unit *unit;
u64 fcp_lun;
int retval = 0;
- LIST_HEAD(unit_remove_lh);
mutex_lock(&zfcp_data.config_mutex);
if (atomic_read(&port->status) & ZFCP_STATUS_COMMON_REMOVE) {
@@ -261,19 +256,16 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev,
/* wait for possible timeout during SCSI probe */
flush_work(&unit->scsi_work);
- if (atomic_read(&unit->refcount) == 1) {
- atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status);
+ atomic_set_mask(ZFCP_STATUS_COMMON_REMOVE, &unit->status);
+
+ write_lock_irq(&port->unit_list_lock);
+ list_del(&unit->list);
+ write_unlock_irq(&port->unit_list_lock);
- write_lock_irq(&port->unit_list_lock);
- list_move(&unit->list, &unit_remove_lh);
- write_unlock_irq(&port->unit_list_lock);
+ put_device(&unit->sysfs_device);
- zfcp_erp_unit_shutdown(unit, 0, "syurs_1", NULL);
- zfcp_erp_wait(unit->port->adapter);
- zfcp_unit_put(unit);
- zfcp_unit_dequeue(unit);
- } else
- zfcp_unit_put(unit);
+ zfcp_erp_unit_shutdown(unit, 0, "syurs_1", NULL);
+ zfcp_device_unregister(&unit->sysfs_device, &zfcp_sysfs_unit_attrs);
out:
mutex_unlock(&zfcp_data.config_mutex);
return retval ? retval : (ssize_t) count;
OpenPOWER on IntegriCloud