Skip to content

Commit 58df195

Browse files
muvarovjenswi-linaro
authored andcommitted
optee: use uuid for sysfs driver entry
With the evolving use-cases for TEE bus, now it's required to support multi-stage enumeration process. But using a simple index doesn't suffice this requirement and instead leads to duplicate sysfs entries. So instead switch to use more informative device UUID for sysfs entry like: /sys/bus/tee/devices/optee-ta-<uuid> Signed-off-by: Maxim Uvarov <[email protected]> Reviewed-by: Sumit Garg <[email protected]> Reviewed-by: Jarkko Sakkinen <[email protected]> Tested-by: Sumit Garg <[email protected]> Signed-off-by: Jens Wiklander <[email protected]>
1 parent 3d77e6a commit 58df195

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
What: /sys/bus/tee/devices/optee-ta-<uuid>/
2+
Date: May 2020
3+
KernelVersion 5.8
4+
5+
Description:
6+
OP-TEE bus provides reference to registered drivers under this directory. The <uuid>
7+
matches Trusted Application (TA) driver and corresponding TA in secure OS. Drivers
8+
are free to create needed API under optee-ta-<uuid> directory.

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12528,6 +12528,7 @@ OP-TEE DRIVER
1252812528
M: Jens Wiklander <[email protected]>
1252912529
1253012530
S: Maintained
12531+
F: Documentation/ABI/testing/sysfs-bus-optee-devices
1253112532
F: drivers/tee/optee/
1253212533

1253312534
OP-TEE RANDOM NUMBER GENERATOR (RNG) DRIVER

drivers/tee/optee/device.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static int get_devices(struct tee_context *ctx, u32 session,
6565
return 0;
6666
}
6767

68-
static int optee_register_device(const uuid_t *device_uuid, u32 device_id)
68+
static int optee_register_device(const uuid_t *device_uuid)
6969
{
7070
struct tee_client_device *optee_device = NULL;
7171
int rc;
@@ -75,7 +75,10 @@ static int optee_register_device(const uuid_t *device_uuid, u32 device_id)
7575
return -ENOMEM;
7676

7777
optee_device->dev.bus = &tee_bus_type;
78-
dev_set_name(&optee_device->dev, "optee-clnt%u", device_id);
78+
if (dev_set_name(&optee_device->dev, "optee-ta-%pUb", device_uuid)) {
79+
kfree(optee_device);
80+
return -ENOMEM;
81+
}
7982
uuid_copy(&optee_device->id.uuid, device_uuid);
8083

8184
rc = device_register(&optee_device->dev);
@@ -144,7 +147,7 @@ int optee_enumerate_devices(void)
144147
num_devices = shm_size / sizeof(uuid_t);
145148

146149
for (idx = 0; idx < num_devices; idx++) {
147-
rc = optee_register_device(&device_uuid[idx], idx);
150+
rc = optee_register_device(&device_uuid[idx]);
148151
if (rc)
149152
goto out_shm;
150153
}

0 commit comments

Comments
 (0)