[PATCH 01/13] RDMA/verbs: Convert struct ib_send_wr conversion functions into macros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since the C programming language does not allow to define a single
function of which the constness of the return type depends on the
constness of an argument type, convert the struct ib_send_wr
conversion functions into macros. That will allow these conversion
functions to be used both in a context where the send work request
is modified and where it is not modified. The iSER initiator driver
is the only driver that uses one of these functions to obtain a
modifiable pointer to a work request, namely as follows:

	wr = reg_wr(iser_tx_next_wr(tx_desc));

Signed-off-by: Bart Van Assche <bart.vanassche@xxxxxxx>
Cc: Leon Romanovsky <leonro@xxxxxxxxxxxx>
Cc: Parav Pandit <parav@xxxxxxxxxxxx>
---
 include/rdma/ib_verbs.h | 26 ++++++--------------------
 1 file changed, 6 insertions(+), 20 deletions(-)

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index e1130c6c1377..f0b70f3f2a65 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1373,10 +1373,7 @@ struct ib_rdma_wr {
 	u32			rkey;
 };
 
-static inline struct ib_rdma_wr *rdma_wr(struct ib_send_wr *wr)
-{
-	return container_of(wr, struct ib_rdma_wr, wr);
-}
+#define rdma_wr(send_wr) container_of(send_wr, struct ib_rdma_wr, wr)
 
 struct ib_atomic_wr {
 	struct ib_send_wr	wr;
@@ -1388,10 +1385,7 @@ struct ib_atomic_wr {
 	u32			rkey;
 };
 
-static inline struct ib_atomic_wr *atomic_wr(struct ib_send_wr *wr)
-{
-	return container_of(wr, struct ib_atomic_wr, wr);
-}
+#define atomic_wr(send_wr) container_of(send_wr, struct ib_atomic_wr, wr)
 
 struct ib_ud_wr {
 	struct ib_send_wr	wr;
@@ -1405,10 +1399,7 @@ struct ib_ud_wr {
 	u8			port_num;   /* valid for DR SMPs on switch only */
 };
 
-static inline struct ib_ud_wr *ud_wr(struct ib_send_wr *wr)
-{
-	return container_of(wr, struct ib_ud_wr, wr);
-}
+#define ud_wr(send_wr) container_of(send_wr, struct ib_ud_wr, wr)
 
 struct ib_reg_wr {
 	struct ib_send_wr	wr;
@@ -1417,10 +1408,7 @@ struct ib_reg_wr {
 	int			access;
 };
 
-static inline struct ib_reg_wr *reg_wr(struct ib_send_wr *wr)
-{
-	return container_of(wr, struct ib_reg_wr, wr);
-}
+#define reg_wr(send_wr) container_of(send_wr, struct ib_reg_wr, wr)
 
 struct ib_sig_handover_wr {
 	struct ib_send_wr	wr;
@@ -1430,10 +1418,8 @@ struct ib_sig_handover_wr {
 	struct ib_sge	       *prot;
 };
 
-static inline struct ib_sig_handover_wr *sig_handover_wr(struct ib_send_wr *wr)
-{
-	return container_of(wr, struct ib_sig_handover_wr, wr);
-}
+#define sig_handover_wr(send_wr)				\
+	container_of(send_wr, struct ib_sig_handover_wr, wr)
 
 struct ib_recv_wr {
 	struct ib_recv_wr      *next;
-- 
2.18.0

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



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux