Commit f87cf287 authored by Nirmoy Das's avatar Nirmoy Das Committed by Matthew Auld

drm/xe: Remove usage of unsafe strcpy

Remove usage of unsafe strcpy with a helper function
to convert engine class to string.

Cc: Matthew Auld <matthew.auld@intel.com>
Signed-off-by: default avatarNirmoy Das <nirmoy.das@intel.com>
Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
Signed-off-by: default avatarMatthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240318091055.638-1-nirmoy.das@intel.com
parent 6d74e387
...@@ -499,8 +499,8 @@ static void kobj_xe_hw_engine_class_fini(struct drm_device *drm, void *arg) ...@@ -499,8 +499,8 @@ static void kobj_xe_hw_engine_class_fini(struct drm_device *drm, void *arg)
kobject_put(kobj); kobject_put(kobj);
} }
static struct kobj_eclass * static struct kobj_eclass *
kobj_xe_hw_engine_class(struct xe_device *xe, struct kobject *parent, char *name) kobj_xe_hw_engine_class(struct xe_device *xe, struct kobject *parent, const char *name)
{ {
struct kobj_eclass *keclass; struct kobj_eclass *keclass;
int err = 0; int err = 0;
...@@ -635,6 +635,24 @@ static void hw_engine_class_sysfs_fini(struct drm_device *drm, void *arg) ...@@ -635,6 +635,24 @@ static void hw_engine_class_sysfs_fini(struct drm_device *drm, void *arg)
kobject_put(kobj); kobject_put(kobj);
} }
static const char *xe_hw_engine_class_to_str(enum xe_engine_class class)
{
switch (class) {
case XE_ENGINE_CLASS_RENDER:
return "rcs";
case XE_ENGINE_CLASS_VIDEO_DECODE:
return "vcs";
case XE_ENGINE_CLASS_VIDEO_ENHANCE:
return "vecs";
case XE_ENGINE_CLASS_COPY:
return "bcs";
case XE_ENGINE_CLASS_COMPUTE:
return "ccs";
default:
return NULL;
}
}
/** /**
* xe_hw_engine_class_sysfs_init - Init HW engine classes on GT. * xe_hw_engine_class_sysfs_init - Init HW engine classes on GT.
* @gt: Xe GT. * @gt: Xe GT.
...@@ -664,7 +682,7 @@ int xe_hw_engine_class_sysfs_init(struct xe_gt *gt) ...@@ -664,7 +682,7 @@ int xe_hw_engine_class_sysfs_init(struct xe_gt *gt)
goto err_object; goto err_object;
for_each_hw_engine(hwe, gt, id) { for_each_hw_engine(hwe, gt, id) {
char name[MAX_ENGINE_CLASS_NAME_LEN]; const char *name;
struct kobj_eclass *keclass; struct kobj_eclass *keclass;
if (hwe->class == XE_ENGINE_CLASS_OTHER || if (hwe->class == XE_ENGINE_CLASS_OTHER ||
...@@ -675,24 +693,8 @@ int xe_hw_engine_class_sysfs_init(struct xe_gt *gt) ...@@ -675,24 +693,8 @@ int xe_hw_engine_class_sysfs_init(struct xe_gt *gt)
continue; continue;
class_mask |= 1 << hwe->class; class_mask |= 1 << hwe->class;
name = xe_hw_engine_class_to_str(hwe->class);
switch (hwe->class) { if (!name) {
case XE_ENGINE_CLASS_RENDER:
strcpy(name, "rcs");
break;
case XE_ENGINE_CLASS_VIDEO_DECODE:
strcpy(name, "vcs");
break;
case XE_ENGINE_CLASS_VIDEO_ENHANCE:
strcpy(name, "vecs");
break;
case XE_ENGINE_CLASS_COPY:
strcpy(name, "bcs");
break;
case XE_ENGINE_CLASS_COMPUTE:
strcpy(name, "ccs");
break;
default:
err = -EINVAL; err = -EINVAL;
goto err_object; goto err_object;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment