]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/infiniband/core/device.c
Merge tag 'regmap/range' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie...
[karo-tx-linux.git] / drivers / infiniband / core / device.c
index e711de400a01aaa27216318b82770bdb3647161e..18c1ece765f2c55b8317fba4daa5716df0ab814f 100644 (file)
@@ -707,18 +707,28 @@ int ib_find_pkey(struct ib_device *device,
 {
        int ret, i;
        u16 tmp_pkey;
+       int partial_ix = -1;
 
        for (i = 0; i < device->pkey_tbl_len[port_num - start_port(device)]; ++i) {
                ret = ib_query_pkey(device, port_num, i, &tmp_pkey);
                if (ret)
                        return ret;
-
                if ((pkey & 0x7fff) == (tmp_pkey & 0x7fff)) {
-                       *index = i;
-                       return 0;
+                       /* if there is full-member pkey take it.*/
+                       if (tmp_pkey & 0x8000) {
+                               *index = i;
+                               return 0;
+                       }
+                       if (partial_ix < 0)
+                               partial_ix = i;
                }
        }
 
+       /*no full-member, if exists take the limited*/
+       if (partial_ix >= 0) {
+               *index = partial_ix;
+               return 0;
+       }
        return -ENOENT;
 }
 EXPORT_SYMBOL(ib_find_pkey);