Skip to content

Commit c30b855

Browse files
jenswi-linarostorulf
authored andcommitted
tee: add tee_device_set_dev_groups()
Add tee_device_set_dev_groups() to TEE drivers to supply driver specific attribute groups. The class specific attributes are from now on added via the tee_class, which currently only consist of implementation_id. Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Sumit Garg <sumit.garg@linaro.org> Link: https://lore.kernel.org/r/20240814153558.708365-4-jens.wiklander@linaro.org Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 7852028 commit c30b855

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

drivers/tee/tee_core.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ static const uuid_t tee_client_uuid_ns = UUID_INIT(0x58ac9ca0, 0x2086, 0x4683,
4040
static DECLARE_BITMAP(dev_mask, TEE_NUM_DEVICES);
4141
static DEFINE_SPINLOCK(driver_lock);
4242

43-
static const struct class tee_class = {
44-
.name = "tee",
45-
};
46-
43+
static const struct class tee_class;
4744
static dev_t tee_devt;
4845

4946
struct tee_context *teedev_open(struct tee_device *teedev)
@@ -965,6 +962,13 @@ struct tee_device *tee_device_alloc(const struct tee_desc *teedesc,
965962
}
966963
EXPORT_SYMBOL_GPL(tee_device_alloc);
967964

965+
void tee_device_set_dev_groups(struct tee_device *teedev,
966+
const struct attribute_group **dev_groups)
967+
{
968+
teedev->dev.groups = dev_groups;
969+
}
970+
EXPORT_SYMBOL_GPL(tee_device_set_dev_groups);
971+
968972
static ssize_t implementation_id_show(struct device *dev,
969973
struct device_attribute *attr, char *buf)
970974
{
@@ -983,6 +987,11 @@ static struct attribute *tee_dev_attrs[] = {
983987

984988
ATTRIBUTE_GROUPS(tee_dev);
985989

990+
static const struct class tee_class = {
991+
.name = "tee",
992+
.dev_groups = tee_dev_groups,
993+
};
994+
986995
/**
987996
* tee_device_register() - Registers a TEE device
988997
* @teedev: Device to register
@@ -1001,8 +1010,6 @@ int tee_device_register(struct tee_device *teedev)
10011010
return -EINVAL;
10021011
}
10031012

1004-
teedev->dev.groups = tee_dev_groups;
1005-
10061013
rc = cdev_device_add(&teedev->cdev, &teedev->dev);
10071014
if (rc) {
10081015
dev_err(&teedev->dev,

include/linux/tee_core.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,18 @@ int tee_device_register(struct tee_device *teedev);
154154
*/
155155
void tee_device_unregister(struct tee_device *teedev);
156156

157+
/**
158+
* tee_device_set_dev_groups() - Set device attribute groups
159+
* @teedev: Device to register
160+
* @dev_groups: Attribute groups
161+
*
162+
* Assigns the provided @dev_groups to the @teedev to be registered later
163+
* with tee_device_register(). Calling this function is optional, but if
164+
* it's called it must be called before tee_device_register().
165+
*/
166+
void tee_device_set_dev_groups(struct tee_device *teedev,
167+
const struct attribute_group **dev_groups);
168+
157169
/**
158170
* tee_session_calc_client_uuid() - Calculates client UUID for session
159171
* @uuid: Resulting UUID

0 commit comments

Comments
 (0)