All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] scsi: iscsi: let endpoint class declare its sysfs attributes
@ 2021-01-07 16:02 Julian Wiedmann
  2021-01-07 16:02 ` [PATCH 2/3] scsi: iscsi: let transport " Julian Wiedmann
  2021-01-07 16:02 ` [PATCH 3/3] scsi: iscsi: let iface " Julian Wiedmann
  0 siblings, 2 replies; 3+ messages in thread
From: Julian Wiedmann @ 2021-01-07 16:02 UTC (permalink / raw)
  To: Martin K. Petersen, James E.J. Bottomley
  Cc: linux-scsi, Julian Wiedmann, Lee Duncan, Chris Leech

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 | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 2e68c0a87698..c18d01e178b2 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -174,11 +174,6 @@ static void iscsi_endpoint_release(struct device *dev)
 	kfree(ep);
 }
 
-static struct class iscsi_endpoint_class = {
-	.name = "iscsi_endpoint",
-	.dev_release = iscsi_endpoint_release,
-};
-
 static ssize_t
 show_ep_handle(struct device *dev, struct device_attribute *attr, char *buf)
 {
@@ -192,8 +187,12 @@ static struct attribute *iscsi_endpoint_attrs[] = {
 	NULL,
 };
 
-static struct attribute_group iscsi_endpoint_group = {
-	.attrs = iscsi_endpoint_attrs,
+ATTRIBUTE_GROUPS(iscsi_endpoint);
+
+static struct class iscsi_endpoint_class = {
+	.name = "iscsi_endpoint",
+	.dev_groups = iscsi_endpoint_groups,
+	.dev_release = iscsi_endpoint_release,
 };
 
 #define ISCSI_MAX_EPID -1
@@ -239,18 +238,10 @@ iscsi_create_endpoint(int dd_size)
         if (err)
                 goto free_ep;
 
-	err = sysfs_create_group(&ep->dev.kobj, &iscsi_endpoint_group);
-	if (err)
-		goto unregister_dev;
-
 	if (dd_size)
 		ep->dd_data = &ep[1];
 	return ep;
 
-unregister_dev:
-	device_unregister(&ep->dev);
-	return NULL;
-
 free_ep:
 	kfree(ep);
 	return NULL;
@@ -259,7 +250,6 @@ EXPORT_SYMBOL_GPL(iscsi_create_endpoint);
 
 void iscsi_destroy_endpoint(struct iscsi_endpoint *ep)
 {
-	sysfs_remove_group(&ep->dev.kobj, &iscsi_endpoint_group);
 	device_unregister(&ep->dev);
 }
 EXPORT_SYMBOL_GPL(iscsi_destroy_endpoint);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/3] scsi: iscsi: let transport class declare its sysfs attributes
  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
  2021-01-07 16:02 ` [PATCH 3/3] scsi: iscsi: let iface " Julian Wiedmann
  1 sibling, 0 replies; 3+ messages in thread
From: Julian Wiedmann @ 2021-01-07 16:02 UTC (permalink / raw)
  To: Martin K. Petersen, James E.J. Bottomley
  Cc: linux-scsi, Julian Wiedmann, Lee Duncan, Chris Leech

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 3/3] scsi: iscsi: let iface class declare its sysfs attributes
  2021-01-07 16:02 [PATCH 1/3] scsi: iscsi: let endpoint class declare its sysfs attributes Julian Wiedmann
  2021-01-07 16:02 ` [PATCH 2/3] scsi: iscsi: let transport " Julian Wiedmann
@ 2021-01-07 16:02 ` Julian Wiedmann
  1 sibling, 0 replies; 3+ messages in thread
From: Julian Wiedmann @ 2021-01-07 16:02 UTC (permalink / raw)
  To: Martin K. Petersen, James E.J. Bottomley
  Cc: linux-scsi, Julian Wiedmann, Lee Duncan, Chris Leech

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-07 16:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-07 16:02 [PATCH 1/3] scsi: iscsi: let endpoint class declare its sysfs attributes Julian Wiedmann
2021-01-07 16:02 ` [PATCH 2/3] scsi: iscsi: let transport " Julian Wiedmann
2021-01-07 16:02 ` [PATCH 3/3] scsi: iscsi: let iface " Julian Wiedmann

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.