linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Fujita Tomonori
	<fujita.tomonori-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>,
	Brian King
	<brking-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>,
	David Dillow <dillowda-1Heg1YXhbW8@public.gmane.org>,
	Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
Cc: linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 10/14] srp_transport: Simplify attribute initialization code
Date: Thu, 1 Dec 2011 20:08:00 +0100	[thread overview]
Message-ID: <201112012008.00502.bvanassche@acm.org> (raw)
In-Reply-To: <201112011954.25811.bvanassche-HInyCGIudOg@public.gmane.org>

Eliminate the private_rport_attrs[] array and the SETUP_*() macros
used to set up that array since the information in that array
duplicates the information in the static device attributes. Also,
trigger a kernel warning if SRP_RPORT_ATTRS is not large enough
since it is easy to forget to update that macro when adding new
attributes.

Signed-off-by: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
Cc: FUJITA Tomonori <fujita.tomonori-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
Cc: Brian King <brking-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Cc: David Dillow <dillowda-1Heg1YXhbW8@public.gmane.org>
Cc: Roland Dreier <roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org>
---
 drivers/scsi/scsi_transport_srp.c |   26 ++++----------------------
 1 files changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
index 07c4394..1cbf097 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -47,7 +47,6 @@ struct srp_internal {
 	struct device_attribute *host_attrs[SRP_HOST_ATTRS + 1];
 
 	struct device_attribute *rport_attrs[SRP_RPORT_ATTRS + 1];
-	struct device_attribute private_rport_attrs[SRP_RPORT_ATTRS];
 	struct transport_container rport_attr_cont;
 };
 
@@ -72,24 +71,6 @@ static DECLARE_TRANSPORT_CLASS(srp_host_class, "srp_host", srp_host_setup,
 static DECLARE_TRANSPORT_CLASS(srp_rport_class, "srp_remote_ports",
 			       NULL, NULL, NULL);
 
-#define SETUP_TEMPLATE(attrb, field, perm, test, ro_test, ro_perm)	\
-	i->private_##attrb[count] = dev_attr_##field;		\
-	i->private_##attrb[count].attr.mode = perm;			\
-	if (ro_test) {							\
-		i->private_##attrb[count].attr.mode = ro_perm;		\
-		i->private_##attrb[count].store = NULL;			\
-	}								\
-	i->attrb[count] = &i->private_##attrb[count];			\
-	if (test)							\
-		count++
-
-#define SETUP_RPORT_ATTRIBUTE_RD(field)					\
-	SETUP_TEMPLATE(rport_attrs, field, S_IRUGO, 1, 0, 0)
-
-#define SETUP_RPORT_ATTRIBUTE_RW(field)					\
-	SETUP_TEMPLATE(rport_attrs, field, S_IRUGO | S_IWUSR,		\
-		       1, 1, S_IRUGO)
-
 #define SRP_PID(p) \
 	(p)->port_id[0], (p)->port_id[1], (p)->port_id[2], (p)->port_id[3], \
 	(p)->port_id[4], (p)->port_id[5], (p)->port_id[6], (p)->port_id[7], \
@@ -326,9 +307,10 @@ srp_attach_transport(struct srp_function_template *ft)
 	i->rport_attr_cont.ac.match = srp_rport_match;
 
 	count = 0;
-	SETUP_RPORT_ATTRIBUTE_RD(port_id);
-	SETUP_RPORT_ATTRIBUTE_RD(roles);
-	i->rport_attrs[count] = NULL;
+	i->rport_attrs[count++] = &dev_attr_port_id;
+	i->rport_attrs[count++] = &dev_attr_roles;
+	i->rport_attrs[count++] = NULL;
+	WARN_ON(count > ARRAY_SIZE(i->rport_attrs));
 
 	transport_container_register(&i->rport_attr_cont);
 
-- 
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2011-12-01 19:08 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-01 18:54 [PATCH 00/14] Make ib_srp better suited for H.A. purposes Bart Van Assche
2011-12-01 19:05 ` [PATCH 08/14] srp_transport: Document sysfs attributes Bart Van Assche
2011-12-01 19:06 ` [PATCH 09/14] srp_transport: Fix attribute registration Bart Van Assche
     [not found]   ` <201112012006.50445.bvanassche-HInyCGIudOg@public.gmane.org>
2011-12-15 20:09     ` David Dillow
     [not found] ` <201112011954.25811.bvanassche-HInyCGIudOg@public.gmane.org>
2011-12-01 19:08   ` Bart Van Assche [this message]
     [not found]     ` <201112012008.00502.bvanassche-HInyCGIudOg@public.gmane.org>
2011-12-19  0:07       ` [PATCH 10/14] srp_transport: Simplify attribute initialization code David Dillow
     [not found]         ` <1324253243.17849.45.camel-1q1vX8mYZiGLUyTwlgNVppKKF0rrzTr+@public.gmane.org>
2011-12-20 10:21           ` Bart Van Assche
2011-12-21  3:23             ` David Dillow
2011-12-01 19:11   ` [PATCH 13/14] ib_srp: Implement transport layer ping Bart Van Assche
2011-12-19  0:50     ` David Dillow
2011-12-19 10:16       ` Bart Van Assche
2011-12-19 22:32         ` David Dillow
     [not found]           ` <1324333931.7043.52.camel-FqX9LgGZnHWDB2HL1qBt2PIbXMQ5te18@public.gmane.org>
2011-12-20 10:13             ` Bart Van Assche
     [not found]               ` <CAO+b5-qLxmcXCCxA8+bPYsinjr1eqCDO2JUJbjgVr59N55CU1Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-12-21  2:32                 ` David Dillow
2011-12-20 10:27             ` Bart Van Assche
2011-12-21  3:05               ` David Dillow
     [not found]                 ` <1324436736.7621.38.camel-1q1vX8mYZiGLUyTwlgNVppKKF0rrzTr+@public.gmane.org>
2011-12-21 14:07                   ` Bart Van Assche
2011-12-23 22:34                     ` David Dillow
     [not found]                       ` <1324679698.3004.12.camel-1q1vX8mYZiGLUyTwlgNVppKKF0rrzTr+@public.gmane.org>
2011-12-23 22:56                         ` Mike Christie
2011-12-24 20:07                           ` David Dillow
2011-12-26 19:39                             ` Bart Van Assche
2011-12-28 23:53                               ` David Dillow
2011-12-26 20:01                           ` Bart Van Assche
2011-12-01 19:10 ` [PATCH 12/14] ib_srp: Rework error handling Bart Van Assche
     [not found]   ` <201112012010.37276.bvanassche-HInyCGIudOg@public.gmane.org>
2011-12-15 20:20     ` David Dillow
2011-12-19  3:36     ` David Dillow
2011-12-19 10:38       ` Bart Van Assche
2011-12-19 22:51         ` David Dillow
     [not found]           ` <1324335083.7043.66.camel-FqX9LgGZnHWDB2HL1qBt2PIbXMQ5te18@public.gmane.org>
2011-12-20  9:01             ` Bart Van Assche
     [not found]               ` <CAO+b5-qF2taG0B4n9SBwqnuh0wajH5fXFLTb-VAaDrfT9TZ6aQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-12-21  3:33                 ` David Dillow
     [not found]                   ` <1324438387.7621.53.camel-1q1vX8mYZiGLUyTwlgNVppKKF0rrzTr+@public.gmane.org>
2011-12-21 13:26                     ` Bart Van Assche
     [not found]       ` <1324265791.17849.92.camel-1q1vX8mYZiGLUyTwlgNVppKKF0rrzTr+@public.gmane.org>
2011-12-26 19:13         ` Bart Van Assche
2011-12-01 19:13 ` [PATCH 14/14] ib_srp: Allow SRP disconnect through sysfs Bart Van Assche
2011-12-19  4:03   ` David Dillow
     [not found]     ` <1324267414.17849.98.camel-1q1vX8mYZiGLUyTwlgNVppKKF0rrzTr+@public.gmane.org>
2011-12-19  9:04       ` Bart Van Assche
2011-12-01 23:26 ` [PATCH 00/14] Make ib_srp better suited for H.A. purposes David Dillow

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=201112012008.00502.bvanassche@acm.org \
    --to=bvanassche-hinycgiudog@public.gmane.org \
    --cc=brking-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
    --cc=dillowda-1Heg1YXhbW8@public.gmane.org \
    --cc=fujita.tomonori-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=roland-BHEL68pLQRGGvPXPguhicg@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).