public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Steffen Maier <maier@linux.vnet.ibm.com>
To: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: linux-scsi@vger.kernel.org, linux-s390@vger.kernel.org,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	Steffen Maier <maier@linux.vnet.ibm.com>,
	Sebastian Ott <sebott@linux.vnet.ibm.com>
Subject: [PATCH RESEND 3/9] zfcp: cleanup unit sysfs attribute usage
Date: Fri, 26 Apr 2013 16:13:49 +0200	[thread overview]
Message-ID: <1366985635-38270-4-git-send-email-maier@linux.vnet.ibm.com> (raw)
In-Reply-To: <1366985635-38270-1-git-send-email-maier@linux.vnet.ibm.com>

From: Sebastian Ott <sebott@linux.vnet.ibm.com>

Let the driver core handle device attribute creation and removal. This
will simplify the code and eliminates races between attribute
availability and userspace notification via uevents.

Reviewed-by: Steffen Maier <maier@linux.vnet.ibm.com>
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Steffen Maier <maier@linux.vnet.ibm.com>
---
 drivers/s390/scsi/zfcp_ccw.c   |    2 +-
 drivers/s390/scsi/zfcp_ext.h   |    2 +-
 drivers/s390/scsi/zfcp_sysfs.c |    7 +++++--
 drivers/s390/scsi/zfcp_unit.c  |    9 ++-------
 4 files changed, 9 insertions(+), 11 deletions(-)

--- a/drivers/s390/scsi/zfcp_ccw.c
+++ b/drivers/s390/scsi/zfcp_ccw.c
@@ -129,7 +129,7 @@ static void zfcp_ccw_remove(struct ccw_d
 	zfcp_ccw_adapter_put(adapter); /* put from zfcp_ccw_adapter_by_cdev */
 
 	list_for_each_entry_safe(unit, u, &unit_remove_lh, list)
-		zfcp_device_unregister(&unit->dev, &zfcp_sysfs_unit_attrs);
+		device_unregister(&unit->dev);
 
 	list_for_each_entry_safe(port, p, &port_remove_lh, list)
 		device_unregister(&port->dev);
--- a/drivers/s390/scsi/zfcp_ext.h
+++ b/drivers/s390/scsi/zfcp_ext.h
@@ -158,7 +158,7 @@ extern void zfcp_scsi_set_prot(struct zf
 extern void zfcp_scsi_dif_sense_error(struct scsi_cmnd *, int);
 
 /* zfcp_sysfs.c */
-extern struct attribute_group zfcp_sysfs_unit_attrs;
+extern const struct attribute_group *zfcp_unit_attr_groups[];
 extern struct attribute_group zfcp_sysfs_adapter_attrs;
 extern const struct attribute_group *zfcp_port_attr_groups[];
 extern struct mutex zfcp_sysfs_port_units_mutex;
--- a/drivers/s390/scsi/zfcp_sysfs.c
+++ b/drivers/s390/scsi/zfcp_sysfs.c
@@ -357,10 +357,13 @@ static struct attribute *zfcp_unit_attrs
 	&dev_attr_unit_access_readonly.attr,
 	NULL
 };
-
-struct attribute_group zfcp_sysfs_unit_attrs = {
+static struct attribute_group zfcp_unit_attr_group = {
 	.attrs = zfcp_unit_attrs,
 };
+const struct attribute_group *zfcp_unit_attr_groups[] = {
+	&zfcp_unit_attr_group,
+	NULL,
+};
 
 #define ZFCP_DEFINE_LATENCY_ATTR(_name) 				\
 static ssize_t								\
--- a/drivers/s390/scsi/zfcp_unit.c
+++ b/drivers/s390/scsi/zfcp_unit.c
@@ -145,6 +145,7 @@ int zfcp_unit_add(struct zfcp_port *port
 	unit->fcp_lun = fcp_lun;
 	unit->dev.parent = &port->dev;
 	unit->dev.release = zfcp_unit_release;
+	unit->dev.groups = zfcp_unit_attr_groups;
 	INIT_WORK(&unit->scsi_work, zfcp_unit_scsi_scan_work);
 
 	if (dev_set_name(&unit->dev, "0x%016llx",
@@ -160,12 +161,6 @@ int zfcp_unit_add(struct zfcp_port *port
 		goto out;
 	}
 
-	if (sysfs_create_group(&unit->dev.kobj, &zfcp_sysfs_unit_attrs)) {
-		device_unregister(&unit->dev);
-		retval = -EINVAL;
-		goto out;
-	}
-
 	atomic_inc(&port->units); /* under zfcp_sysfs_port_units_mutex ! */
 
 	write_lock_irq(&port->unit_list_lock);
@@ -254,7 +249,7 @@ int zfcp_unit_remove(struct zfcp_port *p
 
 	put_device(&unit->dev);
 
-	zfcp_device_unregister(&unit->dev, &zfcp_sysfs_unit_attrs);
+	device_unregister(&unit->dev);
 
 	return 0;
 }


  parent reply	other threads:[~2013-04-26 14:17 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-26 14:13 [PATCH RESEND 0/9] zfcp features and bugfixes for 3.10 merge window Steffen Maier
2013-04-26 14:13 ` [PATCH RESEND 1/9] zfcp: cfdc fops add owner Steffen Maier
2013-04-26 14:13 ` [PATCH RESEND 2/9] zfcp: cleanup port sysfs attribute usage Steffen Maier
2013-04-26 14:13 ` Steffen Maier [this message]
2013-04-26 14:13 ` [PATCH RESEND 4/9] zfcp: remove unused device_unregister wrapper Steffen Maier
2013-04-26 14:13 ` [PATCH RESEND 7/9] zfcp: module parameter dbflevel for early debugging Steffen Maier
2013-04-26 14:13 ` [PATCH RESEND 8/9] zfcp: remove access control tables interface Steffen Maier
2013-04-26 15:10 ` [PATCH RESEND 0/9] zfcp features and bugfixes for 3.10 merge window James Bottomley
2013-04-26 15:44   ` Steffen Maier
2013-04-26 16:10     ` James Bottomley
2013-04-27  9:44       ` Heiko Carstens
     [not found] ` <1366985635-38270-6-git-send-email-maier@linux.vnet.ibm.com>
2013-04-26 15:32   ` [PATCH RESEND 5/9] zfcp: fix adapter (re)open recovery while link to SAN is down Steffen Maier
     [not found] ` <1366985635-38270-7-git-send-email-maier@linux.vnet.ibm.com>
2013-04-26 15:33   ` [PATCH RESEND 6/9] zfcp: block queue limits with data router Steffen Maier
     [not found] ` <1366985635-38270-10-git-send-email-maier@linux.vnet.ibm.com>
2013-04-26 15:34   ` [PATCH RESEND 9/9] zfcp: status read buffers on first adapter open with link down Steffen Maier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1366985635-38270-4-git-send-email-maier@linux.vnet.ibm.com \
    --to=maier@linux.vnet.ibm.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=sebott@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox