]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tee: add tee_device_set_dev_groups()
authorJens Wiklander <jens.wiklander@linaro.org>
Wed, 14 Aug 2024 15:35:57 +0000 (17:35 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 26 Aug 2024 11:16:20 +0000 (13:16 +0200)
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>
drivers/tee/tee_core.c
include/linux/tee_core.h

index d52e879b204e3ddbf88a6aac36e5ead30568d392..d113679b1e2d7a6159b18e3c2044346bd37e4566 100644 (file)
@@ -40,10 +40,7 @@ static const uuid_t tee_client_uuid_ns = UUID_INIT(0x58ac9ca0, 0x2086, 0x4683,
 static DECLARE_BITMAP(dev_mask, TEE_NUM_DEVICES);
 static DEFINE_SPINLOCK(driver_lock);
 
-static const struct class tee_class = {
-       .name = "tee",
-};
-
+static const struct class tee_class;
 static dev_t tee_devt;
 
 struct tee_context *teedev_open(struct tee_device *teedev)
@@ -965,6 +962,13 @@ err:
 }
 EXPORT_SYMBOL_GPL(tee_device_alloc);
 
+void tee_device_set_dev_groups(struct tee_device *teedev,
+                              const struct attribute_group **dev_groups)
+{
+       teedev->dev.groups = dev_groups;
+}
+EXPORT_SYMBOL_GPL(tee_device_set_dev_groups);
+
 static ssize_t implementation_id_show(struct device *dev,
                                      struct device_attribute *attr, char *buf)
 {
@@ -983,6 +987,11 @@ static struct attribute *tee_dev_attrs[] = {
 
 ATTRIBUTE_GROUPS(tee_dev);
 
+static const struct class tee_class = {
+       .name = "tee",
+       .dev_groups = tee_dev_groups,
+};
+
 /**
  * tee_device_register() - Registers a TEE device
  * @teedev:    Device to register
@@ -1001,8 +1010,6 @@ int tee_device_register(struct tee_device *teedev)
                return -EINVAL;
        }
 
-       teedev->dev.groups = tee_dev_groups;
-
        rc = cdev_device_add(&teedev->cdev, &teedev->dev);
        if (rc) {
                dev_err(&teedev->dev,
index efd16ed52315828edb7735978c0677d199485910..a38494d6b5f4f8202c536c832f2d0c989e4e8626 100644 (file)
@@ -154,6 +154,18 @@ int tee_device_register(struct tee_device *teedev);
  */
 void tee_device_unregister(struct tee_device *teedev);
 
+/**
+ * tee_device_set_dev_groups() - Set device attribute groups
+ * @teedev:    Device to register
+ * @dev_groups: Attribute groups
+ *
+ * Assigns the provided @dev_groups to the @teedev to be registered later
+ * with tee_device_register(). Calling this function is optional, but if
+ * it's called it must be called before tee_device_register().
+ */
+void tee_device_set_dev_groups(struct tee_device *teedev,
+                              const struct attribute_group **dev_groups);
+
 /**
  * tee_session_calc_client_uuid() - Calculates client UUID for session
  * @uuid:              Resulting UUID