.. | .. |
---|
33 | 33 | #include <linux/module.h> |
---|
34 | 34 | #include <linux/configfs.h> |
---|
35 | 35 | #include <rdma/ib_verbs.h> |
---|
| 36 | +#include <rdma/rdma_cm.h> |
---|
| 37 | + |
---|
36 | 38 | #include "core_priv.h" |
---|
| 39 | +#include "cma_priv.h" |
---|
37 | 40 | |
---|
38 | 41 | struct cma_device; |
---|
39 | 42 | |
---|
.. | .. |
---|
65 | 68 | |
---|
66 | 69 | static bool filter_by_name(struct ib_device *ib_dev, void *cookie) |
---|
67 | 70 | { |
---|
68 | | - return !strcmp(ib_dev->name, cookie); |
---|
| 71 | + return !strcmp(dev_name(&ib_dev->dev), cookie); |
---|
69 | 72 | } |
---|
70 | 73 | |
---|
71 | 74 | static int cma_configfs_params_get(struct config_item *item, |
---|
.. | .. |
---|
91 | 94 | |
---|
92 | 95 | static void cma_configfs_params_put(struct cma_device *cma_dev) |
---|
93 | 96 | { |
---|
94 | | - cma_deref_dev(cma_dev); |
---|
| 97 | + cma_dev_put(cma_dev); |
---|
95 | 98 | } |
---|
96 | 99 | |
---|
97 | 100 | static ssize_t default_roce_mode_show(struct config_item *item, |
---|
.. | .. |
---|
120 | 123 | { |
---|
121 | 124 | struct cma_device *cma_dev; |
---|
122 | 125 | struct cma_dev_port_group *group; |
---|
123 | | - int gid_type = ib_cache_gid_parse_type_str(buf); |
---|
| 126 | + int gid_type; |
---|
124 | 127 | ssize_t ret; |
---|
125 | | - |
---|
126 | | - if (gid_type < 0) |
---|
127 | | - return -EINVAL; |
---|
128 | 128 | |
---|
129 | 129 | ret = cma_configfs_params_get(item, &cma_dev, &group); |
---|
130 | 130 | if (ret) |
---|
131 | 131 | return ret; |
---|
| 132 | + |
---|
| 133 | + gid_type = ib_cache_gid_parse_type_str(buf); |
---|
| 134 | + if (gid_type < 0) { |
---|
| 135 | + cma_configfs_params_put(cma_dev); |
---|
| 136 | + return -EINVAL; |
---|
| 137 | + } |
---|
132 | 138 | |
---|
133 | 139 | ret = cma_set_default_gid_type(cma_dev, group->port_num, gid_type); |
---|
134 | 140 | |
---|
.. | .. |
---|
215 | 221 | } |
---|
216 | 222 | |
---|
217 | 223 | for (i = 0; i < ports_num; i++) { |
---|
218 | | - char port_str[10]; |
---|
| 224 | + char port_str[11]; |
---|
219 | 225 | |
---|
220 | 226 | ports[i].port_num = i + 1; |
---|
221 | 227 | snprintf(port_str, sizeof(port_str), "%u", i + 1); |
---|
.. | .. |
---|
309 | 315 | configfs_add_default_group(&cma_dev_group->ports_group, |
---|
310 | 316 | &cma_dev_group->device_group); |
---|
311 | 317 | |
---|
312 | | - cma_deref_dev(cma_dev); |
---|
| 318 | + cma_dev_put(cma_dev); |
---|
313 | 319 | return &cma_dev_group->device_group; |
---|
314 | 320 | |
---|
315 | 321 | fail: |
---|
316 | 322 | if (cma_dev) |
---|
317 | | - cma_deref_dev(cma_dev); |
---|
| 323 | + cma_dev_put(cma_dev); |
---|
318 | 324 | kfree(cma_dev_group); |
---|
319 | 325 | return ERR_PTR(err); |
---|
320 | 326 | } |
---|
.. | .. |
---|
352 | 358 | |
---|
353 | 359 | int __init cma_configfs_init(void) |
---|
354 | 360 | { |
---|
| 361 | + int ret; |
---|
| 362 | + |
---|
355 | 363 | config_group_init(&cma_subsys.su_group); |
---|
356 | 364 | mutex_init(&cma_subsys.su_mutex); |
---|
357 | | - return configfs_register_subsystem(&cma_subsys); |
---|
| 365 | + ret = configfs_register_subsystem(&cma_subsys); |
---|
| 366 | + if (ret) |
---|
| 367 | + mutex_destroy(&cma_subsys.su_mutex); |
---|
| 368 | + return ret; |
---|
358 | 369 | } |
---|
359 | 370 | |
---|
360 | 371 | void __exit cma_configfs_exit(void) |
---|
361 | 372 | { |
---|
362 | 373 | configfs_unregister_subsystem(&cma_subsys); |
---|
| 374 | + mutex_destroy(&cma_subsys.su_mutex); |
---|
363 | 375 | } |
---|