treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / infiniband / core / cgroup.c
blob1f037fe01450efcd00447e55d22caa3443927a2e
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright (C) 2016 Parav Pandit <pandit.parav@gmail.com>
4 */
6 #include "core_priv.h"
8 /**
9 * ib_device_register_rdmacg - register with rdma cgroup.
10 * @device: device to register to participate in resource
11 * accounting by rdma cgroup.
13 * Register with the rdma cgroup. Should be called before
14 * exposing rdma device to user space applications to avoid
15 * resource accounting leak.
17 void ib_device_register_rdmacg(struct ib_device *device)
19 device->cg_device.name = device->name;
20 rdmacg_register_device(&device->cg_device);
23 /**
24 * ib_device_unregister_rdmacg - unregister with rdma cgroup.
25 * @device: device to unregister.
27 * Unregister with the rdma cgroup. Should be called after
28 * all the resources are deallocated, and after a stage when any
29 * other resource allocation by user application cannot be done
30 * for this device to avoid any leak in accounting.
32 void ib_device_unregister_rdmacg(struct ib_device *device)
34 rdmacg_unregister_device(&device->cg_device);
37 int ib_rdmacg_try_charge(struct ib_rdmacg_object *cg_obj,
38 struct ib_device *device,
39 enum rdmacg_resource_type resource_index)
41 return rdmacg_try_charge(&cg_obj->cg, &device->cg_device,
42 resource_index);
44 EXPORT_SYMBOL(ib_rdmacg_try_charge);
46 void ib_rdmacg_uncharge(struct ib_rdmacg_object *cg_obj,
47 struct ib_device *device,
48 enum rdmacg_resource_type resource_index)
50 rdmacg_uncharge(cg_obj->cg, &device->cg_device,
51 resource_index);
53 EXPORT_SYMBOL(ib_rdmacg_uncharge);