diff mbox series

[2/3] scsi: iscsi: let transport class declare its sysfs attributes

Message ID 20210107160231.101243-2-jwi@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series [1/3] scsi: iscsi: let endpoint class declare its sysfs attributes | expand

Commit Message

Julian Wiedmann Jan. 7, 2021, 4:02 p.m. UTC
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 mbox series

Patch

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);