aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/scsi/zfcp_aux.c
diff options
context:
space:
mode:
authorSwen Schillig <swen@vnet.ibm.com>2008-07-02 04:56:38 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-07-12 09:22:35 -0400
commit60221920706a01bef89af2577f9a90a8eeb4e662 (patch)
treef8b38412351e8be78c6f24524d963a08032fb2a1 /drivers/s390/scsi/zfcp_aux.c
parent317e6b6519b5a34263a33f150ed57ad468b26a64 (diff)
[SCSI] zfcp: consolidate sysfs things into one file.
zfcp was using three files to deal with sysfs representation for adapters, ports and units. The consolidation into one file prevents code-duplication and eases maintainability. 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@HansenPartnership.com>
Diffstat (limited to 'drivers/s390/scsi/zfcp_aux.c')
-rw-r--r--drivers/s390/scsi/zfcp_aux.c42
1 files changed, 34 insertions, 8 deletions
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 7777729419eb..5b9ca3cde898 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -262,6 +262,11 @@ struct zfcp_port *zfcp_get_port_by_wwpn(struct zfcp_adapter *adapter,
262 return NULL; 262 return NULL;
263} 263}
264 264
265static void zfcp_sysfs_unit_release(struct device *dev)
266{
267 kfree(container_of(dev, struct zfcp_unit, sysfs_device));
268}
269
265/** 270/**
266 * zfcp_unit_enqueue - enqueue unit to unit list of a port. 271 * zfcp_unit_enqueue - enqueue unit to unit list of a port.
267 * @port: pointer to port where unit is added 272 * @port: pointer to port where unit is added
@@ -311,7 +316,8 @@ struct zfcp_unit *zfcp_unit_enqueue(struct zfcp_port *port, fcp_lun_t fcp_lun)
311 if (device_register(&unit->sysfs_device)) 316 if (device_register(&unit->sysfs_device))
312 goto err_out_free; 317 goto err_out_free;
313 318
314 if (zfcp_sysfs_unit_create_files(&unit->sysfs_device)) { 319 if (sysfs_create_group(&unit->sysfs_device.kobj,
320 &zfcp_sysfs_unit_attrs)) {
315 device_unregister(&unit->sysfs_device); 321 device_unregister(&unit->sysfs_device);
316 return ERR_PTR(-EIO); 322 return ERR_PTR(-EIO);
317 } 323 }
@@ -351,7 +357,7 @@ void zfcp_unit_dequeue(struct zfcp_unit *unit)
351 write_unlock_irq(&zfcp_data.config_lock); 357 write_unlock_irq(&zfcp_data.config_lock);
352 unit->port->units--; 358 unit->port->units--;
353 zfcp_port_put(unit->port); 359 zfcp_port_put(unit->port);
354 zfcp_sysfs_unit_remove_files(&unit->sysfs_device); 360 sysfs_remove_group(&unit->sysfs_device.kobj, &zfcp_sysfs_unit_attrs);
355 device_unregister(&unit->sysfs_device); 361 device_unregister(&unit->sysfs_device);
356} 362}
357 363
@@ -527,7 +533,8 @@ int zfcp_adapter_enqueue(struct ccw_device *ccw_device)
527 533
528 dev_set_drvdata(&ccw_device->dev, adapter); 534 dev_set_drvdata(&ccw_device->dev, adapter);
529 535
530 if (zfcp_sysfs_adapter_create_files(&ccw_device->dev)) 536 if (sysfs_create_group(&ccw_device->dev.kobj,
537 &zfcp_sysfs_adapter_attrs))
531 goto sysfs_failed; 538 goto sysfs_failed;
532 539
533 adapter->generic_services.parent = &adapter->ccw_device->dev; 540 adapter->generic_services.parent = &adapter->ccw_device->dev;
@@ -550,7 +557,8 @@ int zfcp_adapter_enqueue(struct ccw_device *ccw_device)
550 return 0; 557 return 0;
551 558
552generic_services_failed: 559generic_services_failed:
553 zfcp_sysfs_adapter_remove_files(&adapter->ccw_device->dev); 560 sysfs_remove_group(&ccw_device->dev.kobj,
561 &zfcp_sysfs_adapter_attrs);
554sysfs_failed: 562sysfs_failed:
555 zfcp_adapter_debug_unregister(adapter); 563 zfcp_adapter_debug_unregister(adapter);
556debug_register_failed: 564debug_register_failed:
@@ -578,7 +586,8 @@ void zfcp_adapter_dequeue(struct zfcp_adapter *adapter)
578 cancel_work_sync(&adapter->stat_work); 586 cancel_work_sync(&adapter->stat_work);
579 zfcp_adapter_scsi_unregister(adapter); 587 zfcp_adapter_scsi_unregister(adapter);
580 device_unregister(&adapter->generic_services); 588 device_unregister(&adapter->generic_services);
581 zfcp_sysfs_adapter_remove_files(&adapter->ccw_device->dev); 589 sysfs_remove_group(&adapter->ccw_device->dev.kobj,
590 &zfcp_sysfs_adapter_attrs);
582 dev_set_drvdata(&adapter->ccw_device->dev, NULL); 591 dev_set_drvdata(&adapter->ccw_device->dev, NULL);
583 /* sanity check: no pending FSF requests */ 592 /* sanity check: no pending FSF requests */
584 spin_lock_irqsave(&adapter->req_list_lock, flags); 593 spin_lock_irqsave(&adapter->req_list_lock, flags);
@@ -606,6 +615,11 @@ void zfcp_adapter_dequeue(struct zfcp_adapter *adapter)
606 kfree(adapter); 615 kfree(adapter);
607} 616}
608 617
618static void zfcp_sysfs_port_release(struct device *dev)
619{
620 kfree(container_of(dev, struct zfcp_port, sysfs_device));
621}
622
609/** 623/**
610 * zfcp_port_enqueue - enqueue port to port list of adapter 624 * zfcp_port_enqueue - enqueue port to port list of adapter
611 * @adapter: adapter where remote port is added 625 * @adapter: adapter where remote port is added
@@ -623,6 +637,7 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, wwn_t wwpn,
623 u32 status, u32 d_id) 637 u32 status, u32 d_id)
624{ 638{
625 struct zfcp_port *port; 639 struct zfcp_port *port;
640 int retval;
626 char *bus_id; 641 char *bus_id;
627 642
628 port = kzalloc(sizeof(struct zfcp_port), GFP_KERNEL); 643 port = kzalloc(sizeof(struct zfcp_port), GFP_KERNEL);
@@ -685,7 +700,14 @@ struct zfcp_port *zfcp_port_enqueue(struct zfcp_adapter *adapter, wwn_t wwpn,
685 if (device_register(&port->sysfs_device)) 700 if (device_register(&port->sysfs_device))
686 goto err_out_free; 701 goto err_out_free;
687 702
688 if (zfcp_sysfs_port_create_files(&port->sysfs_device, status)) { 703 if (status & ZFCP_STATUS_PORT_WKA)
704 retval = sysfs_create_group(&port->sysfs_device.kobj,
705 &zfcp_sysfs_ns_port_attrs);
706 else
707 retval = sysfs_create_group(&port->sysfs_device.kobj,
708 &zfcp_sysfs_port_attrs);
709
710 if (retval) {
689 device_unregister(&port->sysfs_device); 711 device_unregister(&port->sysfs_device);
690 goto err_out; 712 goto err_out;
691 } 713 }
@@ -727,8 +749,12 @@ void zfcp_port_dequeue(struct zfcp_port *port)
727 fc_remote_port_delete(port->rport); 749 fc_remote_port_delete(port->rport);
728 port->rport = NULL; 750 port->rport = NULL;
729 zfcp_adapter_put(port->adapter); 751 zfcp_adapter_put(port->adapter);
730 zfcp_sysfs_port_remove_files(&port->sysfs_device, 752 if (atomic_read(&port->status) & ZFCP_STATUS_PORT_WKA)
731 atomic_read(&port->status)); 753 sysfs_remove_group(&port->sysfs_device.kobj,
754 &zfcp_sysfs_ns_port_attrs);
755 else
756 sysfs_remove_group(&port->sysfs_device.kobj,
757 &zfcp_sysfs_port_attrs);
732 device_unregister(&port->sysfs_device); 758 device_unregister(&port->sysfs_device);
733} 759}
734 760