diff options
author | Christof Schmitt <christof.schmitt@de.ibm.com> | 2010-09-08 08:39:52 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@suse.de> | 2010-09-16 22:54:15 -0400 |
commit | 1daa4eb50fa5cd4c8f9c55452606e786fd42053b (patch) | |
tree | 2c299aacb948264e716ca6651c2f4ef234fc310a /drivers/s390/scsi/zfcp_sysfs.c | |
parent | 57c237731b92fadc7d44824276313ec330b1989b (diff) |
[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.c | 56 |
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, | |||
257 | const char *buf, size_t count) | 257 | const char *buf, size_t count) |
258 | { | 258 | { |
259 | struct zfcp_port *port = container_of(dev, struct zfcp_port, dev); | 259 | struct zfcp_port *port = container_of(dev, struct zfcp_port, dev); |
260 | struct zfcp_unit *unit; | ||
261 | u64 fcp_lun; | 260 | u64 fcp_lun; |
262 | int retval = -EINVAL; | ||
263 | |||
264 | if (!(port && get_device(&port->dev))) | ||
265 | return -EBUSY; | ||
266 | 261 | ||
267 | if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun)) | 262 | if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun)) |
268 | goto out; | 263 | return -EINVAL; |
269 | 264 | ||
270 | unit = zfcp_unit_enqueue(port, fcp_lun); | 265 | if (zfcp_unit_add(port, fcp_lun)) |
271 | if (IS_ERR(unit)) | 266 | return -EINVAL; |
272 | goto out; | ||
273 | else | ||
274 | retval = 0; | ||
275 | 267 | ||
276 | zfcp_erp_unit_reopen(unit, 0, "syuas_1", NULL); | 268 | return count; |
277 | zfcp_erp_wait(unit->port->adapter); | ||
278 | zfcp_scsi_scan(unit); | ||
279 | out: | ||
280 | put_device(&port->dev); | ||
281 | return retval ? retval : (ssize_t) count; | ||
282 | } | 269 | } |
283 | static DEVICE_ATTR(unit_add, S_IWUSR, NULL, zfcp_sysfs_unit_add_store); | 270 | static DEVICE_ATTR(unit_add, S_IWUSR, NULL, zfcp_sysfs_unit_add_store); |
284 | 271 | ||
@@ -287,42 +274,15 @@ static ssize_t zfcp_sysfs_unit_remove_store(struct device *dev, | |||
287 | const char *buf, size_t count) | 274 | const char *buf, size_t count) |
288 | { | 275 | { |
289 | struct zfcp_port *port = container_of(dev, struct zfcp_port, dev); | 276 | struct zfcp_port *port = container_of(dev, struct zfcp_port, dev); |
290 | struct zfcp_unit *unit; | ||
291 | u64 fcp_lun; | 277 | u64 fcp_lun; |
292 | int retval = -EINVAL; | ||
293 | struct scsi_device *sdev; | ||
294 | |||
295 | if (!(port && get_device(&port->dev))) | ||
296 | return -EBUSY; | ||
297 | 278 | ||
298 | if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun)) | 279 | if (strict_strtoull(buf, 0, (unsigned long long *) &fcp_lun)) |
299 | goto out; | 280 | return -EINVAL; |
300 | |||
301 | unit = zfcp_get_unit_by_lun(port, fcp_lun); | ||
302 | if (!unit) | ||
303 | goto out; | ||
304 | else | ||
305 | retval = 0; | ||
306 | 281 | ||
307 | sdev = scsi_device_lookup(port->adapter->scsi_host, 0, | 282 | if (zfcp_unit_remove(port, fcp_lun)) |
308 | port->starget_id, | 283 | return -EINVAL; |
309 | scsilun_to_int((struct scsi_lun *)&fcp_lun)); | ||
310 | if (sdev) { | ||
311 | scsi_remove_device(sdev); | ||
312 | scsi_device_put(sdev); | ||
313 | } | ||
314 | 284 | ||
315 | write_lock_irq(&port->unit_list_lock); | 285 | return count; |
316 | list_del(&unit->list); | ||
317 | write_unlock_irq(&port->unit_list_lock); | ||
318 | |||
319 | put_device(&unit->dev); | ||
320 | |||
321 | zfcp_erp_unit_shutdown(unit, 0, "syurs_1", NULL); | ||
322 | zfcp_device_unregister(&unit->dev, &zfcp_sysfs_unit_attrs); | ||
323 | out: | ||
324 | put_device(&port->dev); | ||
325 | return retval ? retval : (ssize_t) count; | ||
326 | } | 286 | } |
327 | static DEVICE_ATTR(unit_remove, S_IWUSR, NULL, zfcp_sysfs_unit_remove_store); | 287 | static DEVICE_ATTR(unit_remove, S_IWUSR, NULL, zfcp_sysfs_unit_remove_store); |
328 | 288 | ||