|
23 | 23 |
|
24 | 24 | #include "nvrm/client.h" |
25 | 25 |
|
26 | | -static void |
27 | | -r535_gsp_client_dtor(struct nvkm_gsp_client *client) |
28 | | -{ |
29 | | - struct nvkm_gsp *gsp = client->gsp; |
30 | | - |
31 | | - nvkm_gsp_rm_free(&client->object); |
32 | | - |
33 | | - mutex_lock(&gsp->client_id.mutex); |
34 | | - idr_remove(&gsp->client_id.idr, client->object.handle & 0xffff); |
35 | | - mutex_unlock(&gsp->client_id.mutex); |
36 | | - |
37 | | - client->gsp = NULL; |
38 | | -} |
39 | | - |
40 | 26 | static int |
41 | | -r535_gsp_client_ctor(struct nvkm_gsp *gsp, struct nvkm_gsp_client *client) |
| 27 | +r535_gsp_client_ctor(struct nvkm_gsp_client *client, u32 handle) |
42 | 28 | { |
43 | 29 | NV0000_ALLOC_PARAMETERS *args; |
44 | | - int ret; |
45 | | - |
46 | | - mutex_lock(&gsp->client_id.mutex); |
47 | | - ret = idr_alloc(&gsp->client_id.idr, client, 0, 0xffff + 1, GFP_KERNEL); |
48 | | - mutex_unlock(&gsp->client_id.mutex); |
49 | | - if (ret < 0) |
50 | | - return ret; |
51 | 30 |
|
52 | | - client->gsp = gsp; |
53 | | - client->object.client = client; |
54 | | - INIT_LIST_HEAD(&client->events); |
55 | | - |
56 | | - args = nvkm_gsp_rm_alloc_get(&client->object, NVKM_RM_CLIENT(ret), NV01_ROOT, sizeof(*args), |
| 31 | + args = nvkm_gsp_rm_alloc_get(&client->object, handle, NV01_ROOT, sizeof(*args), |
57 | 32 | &client->object); |
58 | | - if (IS_ERR(args)) { |
59 | | - r535_gsp_client_dtor(client); |
60 | | - return ret; |
61 | | - } |
| 33 | + if (IS_ERR(args)) |
| 34 | + return PTR_ERR(args); |
62 | 35 |
|
63 | 36 | args->hClient = client->object.handle; |
64 | 37 | args->processID = ~0; |
65 | 38 |
|
66 | | - ret = nvkm_gsp_rm_alloc_wr(&client->object, args); |
67 | | - if (ret) { |
68 | | - r535_gsp_client_dtor(client); |
69 | | - return ret; |
70 | | - } |
71 | | - |
72 | | - return 0; |
| 39 | + return nvkm_gsp_rm_alloc_wr(&client->object, args); |
73 | 40 | } |
74 | 41 |
|
75 | 42 | const struct nvkm_rm_api_client |
76 | 43 | r535_client = { |
77 | 44 | .ctor = r535_gsp_client_ctor, |
78 | | - .dtor = r535_gsp_client_dtor, |
79 | 45 | }; |
0 commit comments