From 486d8b9f88cd0871a716e2f16873e811ee6c1ece Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Thu, 2 Feb 2012 12:55:58 -0800 Subject: IB/srpt: Use DEFINE_SPINLOCK()/LIST_HEAD() Signed-off-by: Roland Dreier --- drivers/infiniband/ulp/srpt/ib_srpt.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index cd5d05e22a77..284cb5092ee4 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -69,8 +69,8 @@ MODULE_LICENSE("Dual BSD/GPL"); */ static u64 srpt_service_guid; -static spinlock_t srpt_dev_lock; /* Protects srpt_dev_list. */ -static struct list_head srpt_dev_list; /* List of srpt_device structures. */ +static DEFINE_SPINLOCK(srpt_dev_lock); /* Protects srpt_dev_list. */ +static LIST_HEAD(srpt_dev_list); /* List of srpt_device structures. */ static unsigned srp_max_req_size = DEFAULT_MAX_REQ_SIZE; module_param(srp_max_req_size, int, 0444); @@ -4010,9 +4010,6 @@ static int __init srpt_init_module(void) goto out; } - spin_lock_init(&srpt_dev_lock); - INIT_LIST_HEAD(&srpt_dev_list); - ret = -ENODEV; srpt_target = target_fabric_configfs_init(THIS_MODULE, "srpt"); if (!srpt_target) { -- cgit v1.2.3 From f225066b64eaffe3a51ee488fb750c82fbcd971c Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Thu, 2 Feb 2012 12:55:58 -0800 Subject: IB/srpt: Use ARRAY_SIZE() instead of open-coding Signed-off-by: Roland Dreier --- drivers/infiniband/ulp/srpt/ib_srpt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index 284cb5092ee4..38ef61dbee0a 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -3264,8 +3264,7 @@ static void srpt_add_one(struct ib_device *device) for (i = 0; i < sdev->srq_size; ++i) srpt_post_recv(sdev, sdev->ioctx_ring[i]); - WARN_ON(sdev->device->phys_port_cnt - > sizeof(sdev->port)/sizeof(sdev->port[0])); + WARN_ON(sdev->device->phys_port_cnt > ARRAY_SIZE(sdev->port)); for (i = 1; i <= sdev->device->phys_port_cnt; i++) { sport = &sdev->port[i - 1]; -- cgit v1.2.3 From ebfded8c4b34caea450709ce467e67483fa4d8df Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Thu, 2 Feb 2012 12:55:59 -0800 Subject: IB/srpt: Remove unneeded include Signed-off-by: Jesper Juhl Signed-off-by: Roland Dreier --- drivers/infiniband/ulp/srpt/ib_srpt.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.h b/drivers/infiniband/ulp/srpt/ib_srpt.h index b4b4bbcd7f16..61e52b830816 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.h +++ b/drivers/infiniband/ulp/srpt/ib_srpt.h @@ -35,7 +35,6 @@ #ifndef IB_SRPT_H #define IB_SRPT_H -#include #include #include #include -- cgit v1.2.3 From 3af336376f77859da84bb1156ef29d5337b316a9 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 4 Nov 2011 21:27:32 +0300 Subject: IB/srpt: Fix ERR_PTR() vs. NULL checking confusion transport_init_session() and target_fabric_configfs_init() don't return NULL pointers, they only return ERR_PTRs or valid pointers. Signed-off-by: Dan Carpenter Signed-off-by: Roland Dreier --- drivers/infiniband/ulp/srpt/ib_srpt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index 38ef61dbee0a..c125614ac256 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -2595,7 +2595,7 @@ static int srpt_cm_req_recv(struct ib_cm_id *cm_id, } ch->sess = transport_init_session(); - if (!ch->sess) { + if (IS_ERR(ch->sess)) { rej->reason = __constant_cpu_to_be32( SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES); pr_debug("Failed to create session\n"); @@ -4009,10 +4009,10 @@ static int __init srpt_init_module(void) goto out; } - ret = -ENODEV; srpt_target = target_fabric_configfs_init(THIS_MODULE, "srpt"); - if (!srpt_target) { + if (IS_ERR(srpt_target)) { printk(KERN_ERR "couldn't register\n"); + ret = PTR_ERR(srpt_target); goto out; } -- cgit v1.2.3 From 715252d41912941efb791a7b7bad94d2614dc5c3 Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Sat, 4 Feb 2012 23:49:40 +0100 Subject: IB/srpt: Don't return freed pointer from srpt_alloc_ioctx_ring() Signed-off-by: Jesper Juhl Signed-off-by: Roland Dreier --- drivers/infiniband/ulp/srpt/ib_srpt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index c125614ac256..2b73d43cd691 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -687,6 +687,7 @@ err: while (--i >= 0) srpt_free_ioctx(sdev, ring[i], dma_size, dir); kfree(ring); + ring = NULL; out: return ring; } -- cgit v1.2.3