Skip to content

Commit aa17611

Browse files
committed
crypto: qat - make adf_ctl_class constant
JIRA: https://issues.redhat.com/browse/RHEL-52749 Upstream Status: merged into the linux.git commit a654b35 Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Date: Mon Jun 10 10:18:51 2024 +0200 crypto: qat - make adf_ctl_class constant Now that the driver core allows for struct class to be in read-only memory, we should make all 'class' structures declared at build time placing them into read-only memory, instead of having to be dynamically allocated at runtime. Cc: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: "David S. Miller" <davem@davemloft.net> Cc: Adam Guerin <adam.guerin@intel.com> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com> Cc: Tom Zanussi <tom.zanussi@linux.intel.com> Cc: Shashank Gupta <shashank.gupta@intel.com> Cc: qat-linux@intel.com Cc: linux-crypto@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Vladis Dronov <vdronov@redhat.com>
1 parent d69b966 commit aa17611

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

drivers/crypto/intel/qat/qat_common/adf_ctl_drv.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,45 +31,48 @@ static const struct file_operations adf_ctl_ops = {
3131
.compat_ioctl = compat_ptr_ioctl,
3232
};
3333

34+
static const struct class adf_ctl_class = {
35+
.name = DEVICE_NAME,
36+
};
37+
3438
struct adf_ctl_drv_info {
3539
unsigned int major;
3640
struct cdev drv_cdev;
37-
struct class *drv_class;
3841
};
3942

4043
static struct adf_ctl_drv_info adf_ctl_drv;
4144

4245
static void adf_chr_drv_destroy(void)
4346
{
44-
device_destroy(adf_ctl_drv.drv_class, MKDEV(adf_ctl_drv.major, 0));
47+
device_destroy(&adf_ctl_class, MKDEV(adf_ctl_drv.major, 0));
4548
cdev_del(&adf_ctl_drv.drv_cdev);
46-
class_destroy(adf_ctl_drv.drv_class);
49+
class_unregister(&adf_ctl_class);
4750
unregister_chrdev_region(MKDEV(adf_ctl_drv.major, 0), 1);
4851
}
4952

5053
static int adf_chr_drv_create(void)
5154
{
5255
dev_t dev_id;
5356
struct device *drv_device;
57+
int ret;
5458

5559
if (alloc_chrdev_region(&dev_id, 0, 1, DEVICE_NAME)) {
5660
pr_err("QAT: unable to allocate chrdev region\n");
5761
return -EFAULT;
5862
}
5963

60-
adf_ctl_drv.drv_class = class_create(DEVICE_NAME);
61-
if (IS_ERR(adf_ctl_drv.drv_class)) {
62-
pr_err("QAT: class_create failed for adf_ctl\n");
64+
ret = class_register(&adf_ctl_class);
65+
if (ret)
6366
goto err_chrdev_unreg;
64-
}
67+
6568
adf_ctl_drv.major = MAJOR(dev_id);
6669
cdev_init(&adf_ctl_drv.drv_cdev, &adf_ctl_ops);
6770
if (cdev_add(&adf_ctl_drv.drv_cdev, dev_id, 1)) {
6871
pr_err("QAT: cdev add failed\n");
6972
goto err_class_destr;
7073
}
7174

72-
drv_device = device_create(adf_ctl_drv.drv_class, NULL,
75+
drv_device = device_create(&adf_ctl_class, NULL,
7376
MKDEV(adf_ctl_drv.major, 0),
7477
NULL, DEVICE_NAME);
7578
if (IS_ERR(drv_device)) {
@@ -80,7 +83,7 @@ static int adf_chr_drv_create(void)
8083
err_cdev_del:
8184
cdev_del(&adf_ctl_drv.drv_cdev);
8285
err_class_destr:
83-
class_destroy(adf_ctl_drv.drv_class);
86+
class_unregister(&adf_ctl_class);
8487
err_chrdev_unreg:
8588
unregister_chrdev_region(dev_id, 1);
8689
return -EFAULT;

0 commit comments

Comments
 (0)