All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julian Wiedmann <jwi@linux.ibm.com>
To: "Martin K. Petersen" <martin.petersen@oracle.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: linux-scsi <linux-scsi@vger.kernel.org>,
	Julian Wiedmann <jwi@linux.ibm.com>,
	Lee Duncan <lduncan@suse.com>, Chris Leech <cleech@redhat.com>
Subject: [PATCH 2/3] scsi: iscsi: let transport class declare its sysfs attributes
Date: Thu,  7 Jan 2021 17:02:30 +0100	[thread overview]
Message-ID: <20210107160231.101243-2-jwi@linux.ibm.com> (raw)
In-Reply-To: <20210107160231.101243-1-jwi@linux.ibm.com>

Have device_register() create the attributes for us automatically, before
the KOBJ_ADD uevent is raised.

Cc: Lee Duncan <lduncan@suse.com>
Cc: Chris Leech <cleech@redhat.com>
Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
---
 drivers/scsi/scsi_transport_iscsi.c | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index c18d01e178b2..e3d57ba7ca19 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -118,15 +118,6 @@ static void iscsi_transport_release(struct device *dev)
 	kfree(priv);
 }
 
-/*
- * iscsi_transport_class represents the iscsi_transports that are
- * registered.
- */
-static struct class iscsi_transport_class = {
-	.name = "iscsi_transport",
-	.dev_release = iscsi_transport_release,
-};
-
 static ssize_t
 show_transport_handle(struct device *dev, struct device_attribute *attr,
 		      char *buf)
@@ -154,8 +145,16 @@ static struct attribute *iscsi_transport_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group iscsi_transport_group = {
-	.attrs = iscsi_transport_attrs,
+ATTRIBUTE_GROUPS(iscsi_transport);
+
+/*
+ * iscsi_transport_class represents the iscsi_transports that are
+ * registered.
+ */
+static struct class iscsi_transport_class = {
+	.name = "iscsi_transport",
+	.dev_groups = iscsi_transport_groups,
+	.dev_release = iscsi_transport_release,
 };
 
 /*
@@ -4622,10 +4621,6 @@ iscsi_register_transport(struct iscsi_transport *tt)
 	if (err)
 		goto free_priv;
 
-	err = sysfs_create_group(&priv->dev.kobj, &iscsi_transport_group);
-	if (err)
-		goto unregister_dev;
-
 	/* host parameters */
 	priv->t.host_attrs.ac.class = &iscsi_host_class.class;
 	priv->t.host_attrs.ac.match = iscsi_host_match;
@@ -4652,9 +4647,6 @@ iscsi_register_transport(struct iscsi_transport *tt)
 	printk(KERN_NOTICE "iscsi: registered transport (%s)\n", tt->name);
 	return &priv->t;
 
-unregister_dev:
-	device_unregister(&priv->dev);
-	return NULL;
 free_priv:
 	kfree(priv);
 	return NULL;
@@ -4681,7 +4673,6 @@ int iscsi_unregister_transport(struct iscsi_transport *tt)
 	transport_container_unregister(&priv->session_cont);
 	transport_container_unregister(&priv->t.host_attrs);
 
-	sysfs_remove_group(&priv->dev.kobj, &iscsi_transport_group);
 	device_unregister(&priv->dev);
 	mutex_unlock(&rx_queue_mutex);
 
-- 
2.17.1


  reply	other threads:[~2021-01-07 16:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-07 16:02 [PATCH 1/3] scsi: iscsi: let endpoint class declare its sysfs attributes Julian Wiedmann
2021-01-07 16:02 ` Julian Wiedmann [this message]
2021-01-07 16:02 ` [PATCH 3/3] scsi: iscsi: let iface " Julian Wiedmann

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=20210107160231.101243-2-jwi@linux.ibm.com \
    --to=jwi@linux.ibm.com \
    --cc=cleech@redhat.com \
    --cc=jejb@linux.ibm.com \
    --cc=lduncan@suse.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.