diff mbox series

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

Message ID 20210107160231.101243-3-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 | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index e3d57ba7ca19..d467ae3e46ee 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -286,12 +286,6 @@  static void iscsi_iface_release(struct device *dev)
 	put_device(parent);
 }
 
-
-static struct class iscsi_iface_class = {
-	.name = "iscsi_iface",
-	.dev_release = iscsi_iface_release,
-};
-
 #define ISCSI_IFACE_ATTR(_prefix, _name, _mode, _show, _store)	\
 struct device_attribute dev_attr_##_prefix##_##_name =		\
 	__ATTR(_name, _mode, _show, _store)
@@ -689,6 +683,14 @@  static struct attribute_group iscsi_iface_group = {
 	.is_visible = iscsi_iface_attr_is_visible,
 };
 
+__ATTRIBUTE_GROUPS(iscsi_iface);
+
+static struct class iscsi_iface_class = {
+	.name = "iscsi_iface",
+	.dev_groups = iscsi_iface_groups,
+	.dev_release = iscsi_iface_release,
+};
+
 /* convert iscsi_ipaddress_state values to ascii string name */
 static const struct {
 	enum iscsi_ipaddress_state	value;
@@ -773,18 +775,10 @@  iscsi_create_iface(struct Scsi_Host *shost, struct iscsi_transport *transport,
 	if (err)
 		goto free_iface;
 
-	err = sysfs_create_group(&iface->dev.kobj, &iscsi_iface_group);
-	if (err)
-		goto unreg_iface;
-
 	if (dd_size)
 		iface->dd_data = &iface[1];
 	return iface;
 
-unreg_iface:
-	device_unregister(&iface->dev);
-	return NULL;
-
 free_iface:
 	put_device(iface->dev.parent);
 	kfree(iface);
@@ -794,7 +788,6 @@  EXPORT_SYMBOL_GPL(iscsi_create_iface);
 
 void iscsi_destroy_iface(struct iscsi_iface *iface)
 {
-	sysfs_remove_group(&iface->dev.kobj, &iscsi_iface_group);
 	device_unregister(&iface->dev);
 }
 EXPORT_SYMBOL_GPL(iscsi_destroy_iface);