Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jens Wiklander and committed by
Ulf Hansson
c30b855e 7852028a

+25 -6
+13 -6
drivers/tee/tee_core.c
··· 40 40 static DECLARE_BITMAP(dev_mask, TEE_NUM_DEVICES); 41 41 static DEFINE_SPINLOCK(driver_lock); 42 42 43 - static const struct class tee_class = { 44 - .name = "tee", 45 - }; 46 - 43 + static const struct class tee_class; 47 44 static dev_t tee_devt; 48 45 49 46 struct tee_context *teedev_open(struct tee_device *teedev) ··· 962 965 } 963 966 EXPORT_SYMBOL_GPL(tee_device_alloc); 964 967 968 + void tee_device_set_dev_groups(struct tee_device *teedev, 969 + const struct attribute_group **dev_groups) 970 + { 971 + teedev->dev.groups = dev_groups; 972 + } 973 + EXPORT_SYMBOL_GPL(tee_device_set_dev_groups); 974 + 965 975 static ssize_t implementation_id_show(struct device *dev, 966 976 struct device_attribute *attr, char *buf) 967 977 { ··· 987 983 988 984 ATTRIBUTE_GROUPS(tee_dev); 989 985 986 + static const struct class tee_class = { 987 + .name = "tee", 988 + .dev_groups = tee_dev_groups, 989 + }; 990 + 990 991 /** 991 992 * tee_device_register() - Registers a TEE device 992 993 * @teedev: Device to register ··· 1009 1000 dev_err(&teedev->dev, "attempt to register twice\n"); 1010 1001 return -EINVAL; 1011 1002 } 1012 - 1013 - teedev->dev.groups = tee_dev_groups; 1014 1003 1015 1004 rc = cdev_device_add(&teedev->cdev, &teedev->dev); 1016 1005 if (rc) {
+12
include/linux/tee_core.h
··· 155 155 void tee_device_unregister(struct tee_device *teedev); 156 156 157 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 + 169 + /** 158 170 * tee_session_calc_client_uuid() - Calculates client UUID for session 159 171 * @uuid: Resulting UUID 160 172 * @connection_method: Connection method for session (TEE_IOCTL_LOGIN_*)