diff mbox

[2/4] IB/core: export ib_get_cached_port_state

Message ID b5fbdcba-dffe-241f-5c4f-184b93c1cd73@mellanox.com (mailing list archive)
State Superseded
Headers show

Commit Message

Mark Bloch Dec. 12, 2016, 12:19 p.m. UTC
Hi,

 #endif /* _IB_CACHE_H */
diff mbox

Patch

diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index 025db27..1b064cf 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -1025,6 +1025,24 @@  int ib_get_cached_lmc(struct ib_device *device,
 }
 EXPORT_SYMBOL(ib_get_cached_lmc);

+int ib_get_cached_port_state(struct ib_device   *device,
+                 u8                  port_num,
+                 enum ib_port_state *port_state)
Can you please fix the style (indentation)

+{
+    unsigned long flags;
+    int ret = 0;
+
+    if (port_num < rdma_start_port(device) || port_num > rdma_end_port(device))
+        return -EINVAL;
+
+    read_lock_irqsave(&device->cache.lock, flags);
+    *port_state = device->cache.port_state_cache[port_num -
rdma_start_port(device)];
+    read_unlock_irqrestore(&device->cache.lock, flags);
+
+    return ret;
Why do you need ret? just return 0.

+}
+EXPORT_SYMBOL(ib_get_cached_port_state);
+
 static void ib_cache_update(struct ib_device *device,
                 u8                port)
 {
diff --git a/include/rdma/ib_cache.h b/include/rdma/ib_cache.h
index e30f19b..385ec88 100644
--- a/include/rdma/ib_cache.h
+++ b/include/rdma/ib_cache.h
@@ -165,4 +165,17 @@  int ib_get_cached_lmc(struct ib_device *device,
               u8                port_num,
               u8                *lmc);

+/**
+ * ib_get_cached_port_state - Returns a cached port state table entry
+ * @device: The device to query.
+ * @port_num: The port number of the device to query.
+ * @port_state: port_state for the specified port for that device.
+ *
+ * ib_get_cached_port_state() fetches the specified port_state table
entry stored in
+ * the local software cache.
+ */
+int ib_get_cached_port_state(struct ib_device *device,
+                  u8                port_num,
+                  enum ib_port_state *port_active);
+