aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/qib/qib_sysfs.c
diff options
context:
space:
mode:
authorMitko Haralanov <mitko.haralanov@intel.com>2012-05-07 14:03:02 -0400
committerRoland Dreier <roland@purestorage.com>2012-05-14 12:39:04 -0700
commit6ceaadee341da89af143c5cd56a3652b406e1ff5 (patch)
tree5aa84c28c79f936d59bdcfb4475983a04799764d /drivers/infiniband/hw/qib/qib_sysfs.c
parentIB/qib: Correct ordering of reregister vs. port active events (diff)
downloadlinux-dev-6ceaadee341da89af143c5cd56a3652b406e1ff5.tar.xz
linux-dev-6ceaadee341da89af143c5cd56a3652b406e1ff5.zip
IB/qib: Display correct value for number of contexts
A "fix" for a bug with the number of contexts on a single-port board caused the calculation to be off by one, which causes problems with the upper layers. The same problem exists for number of free contexts, which is also fixed here. Signed-off-by: Mitko Haralanov <mitko.haralanov@intel.com> Signed-off-by: Mike Marciniszyn <mike.marciniszyn@intel.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband/hw/qib/qib_sysfs.c')
-rw-r--r--drivers/infiniband/hw/qib/qib_sysfs.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/infiniband/hw/qib/qib_sysfs.c b/drivers/infiniband/hw/qib/qib_sysfs.c
index dae51604cfcd..dd9cd49d0979 100644
--- a/drivers/infiniband/hw/qib/qib_sysfs.c
+++ b/drivers/infiniband/hw/qib/qib_sysfs.c
@@ -503,8 +503,11 @@ static ssize_t show_nctxts(struct device *device,
struct qib_devdata *dd = dd_from_dev(dev);
/* Return the number of user ports (contexts) available. */
- return scnprintf(buf, PAGE_SIZE, "%u\n", dd->cfgctxts -
- dd->first_user_ctxt);
+ /* The calculation below deals with a special case where
+ * cfgctxts is set to 1 on a single-port board. */
+ return scnprintf(buf, PAGE_SIZE, "%u\n",
+ (dd->first_user_ctxt > dd->cfgctxts) ? 0 :
+ (dd->cfgctxts - dd->first_user_ctxt));
}
static ssize_t show_nfreectxts(struct device *device,