aboutsummaryrefslogtreecommitdiff
path: root/drivers/accel/drm_accel.c
diff options
context:
space:
mode:
authorGravatar Ivan Orlov <ivan.orlov0322@gmail.com> 2023-06-20 20:25:29 +0200
committerGravatar Oded Gabbay <ogabbay@kernel.org> 2023-10-09 12:37:19 +0300
commite11a7d2ca5cd36b3d1db4d0ccce30c54a29e1ed9 (patch)
tree14c676424b3d114e502db1087f6690be9d7a2cfd /drivers/accel/drm_accel.c
parentaccel/habanalabs: dump temperature threshold boot error (diff)
downloadlinux-e11a7d2ca5cd36b3d1db4d0ccce30c54a29e1ed9.tar.gz
linux-e11a7d2ca5cd36b3d1db4d0ccce30c54a29e1ed9.tar.bz2
linux-e11a7d2ca5cd36b3d1db4d0ccce30c54a29e1ed9.zip
accel: make accel_class a static const structure
Now that the driver core allows for struct class to be in read-only memory, move the accel_class structure to be declared at build time placing it into read-only memory, instead of having to be dynamically allocated at boot time. Cc: dri-devel@lists.freedesktop.org Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ivan Orlov <ivan.orlov0322@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Tomer Tayar <ttayar@habana.ai> Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Diffstat (limited to 'drivers/accel/drm_accel.c')
-rw-r--r--drivers/accel/drm_accel.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/drivers/accel/drm_accel.c b/drivers/accel/drm_accel.c
index 94b4ac12cf24..294b572a9c33 100644
--- a/drivers/accel/drm_accel.c
+++ b/drivers/accel/drm_accel.c
@@ -21,7 +21,6 @@ static DEFINE_SPINLOCK(accel_minor_lock);
static struct idr accel_minors_idr;
static struct dentry *accel_debugfs_root;
-static struct class *accel_class;
static struct device_type accel_sysfs_device_minor = {
.name = "accel_minor"
@@ -32,23 +31,19 @@ static char *accel_devnode(const struct device *dev, umode_t *mode)
return kasprintf(GFP_KERNEL, "accel/%s", dev_name(dev));
}
+static const struct class accel_class = {
+ .name = "accel",
+ .devnode = accel_devnode,
+};
+
static int accel_sysfs_init(void)
{
- accel_class = class_create("accel");
- if (IS_ERR(accel_class))
- return PTR_ERR(accel_class);
-
- accel_class->devnode = accel_devnode;
-
- return 0;
+ return class_register(&accel_class);
}
static void accel_sysfs_destroy(void)
{
- if (IS_ERR_OR_NULL(accel_class))
- return;
- class_destroy(accel_class);
- accel_class = NULL;
+ class_unregister(&accel_class);
}
static int accel_name_info(struct seq_file *m, void *data)
@@ -117,7 +112,7 @@ void accel_debugfs_register(struct drm_device *dev)
void accel_set_device_instance_params(struct device *kdev, int index)
{
kdev->devt = MKDEV(ACCEL_MAJOR, index);
- kdev->class = accel_class;
+ kdev->class = &accel_class;
kdev->type = &accel_sysfs_device_minor;
}