IB/core: Refactor GID cache's ib_dispatch_event
authorMatan Barak <matanb@mellanox.com>
Wed, 28 Oct 2015 14:52:39 +0000 (16:52 +0200)
committerDoug Ledford <dledford@redhat.com>
Wed, 23 Dec 2015 15:19:54 +0000 (10:19 -0500)
Refactor ib_dispatch_event into a new function in order to avoid
duplicating code in the next patch.

Signed-off-by: Matan Barak <matanb@mellanox.com>
Reviewed-by: Haggai Eran <haggaie@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/cache.c

index 89bebeada38b9b5f6a09d9dd896c8047fa57d7ad..f0703d22ff98b2e41ccc742f4e632447f2d85787 100644 (file)
@@ -112,6 +112,19 @@ struct ib_gid_table {
        struct ib_gid_table_entry *data_vec;
 };
 
+static void dispatch_gid_change_event(struct ib_device *ib_dev, u8 port)
+{
+       if (rdma_cap_roce_gid_table(ib_dev, port)) {
+               struct ib_event event;
+
+               event.device            = ib_dev;
+               event.element.port_num  = port;
+               event.event             = IB_EVENT_GID_CHANGE;
+
+               ib_dispatch_event(&event);
+       }
+}
+
 static int write_gid(struct ib_device *ib_dev, u8 port,
                     struct ib_gid_table *table, int ix,
                     const union ib_gid *gid,
@@ -164,15 +177,9 @@ static int write_gid(struct ib_device *ib_dev, u8 port,
 
        write_unlock_irqrestore(&table->data_vec[ix].lock, flags);
 
-       if (!ret && rdma_cap_roce_gid_table(ib_dev, port)) {
-               struct ib_event event;
+       if (!ret)
+               dispatch_gid_change_event(ib_dev, port);
 
-               event.device            = ib_dev;
-               event.element.port_num  = port;
-               event.event             = IB_EVENT_GID_CHANGE;
-
-               ib_dispatch_event(&event);
-       }
        return ret;
 }