Skip to content

Commit e7d27cf

Browse files
committed
2 parents 1367a59 + 3177779 commit e7d27cf

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

drivers/virt/coco/tsm-core.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
#include <linux/cleanup.h>
1010
#include <linux/pci-tsm.h>
1111

12-
static struct class *tsm_class;
12+
static void tsm_release(struct device *);
13+
static const struct class tsm_class = {
14+
.name = "tsm",
15+
.dev_release = tsm_release
16+
};
1317
static DEFINE_IDA(tsm_ida);
1418

1519
static int match_id(struct device *dev, const void *data)
@@ -22,7 +26,7 @@ static int match_id(struct device *dev, const void *data)
2226

2327
struct tsm_dev *find_tsm_dev(int id)
2428
{
25-
struct device *dev = class_find_device(tsm_class, NULL, &id, match_id);
29+
struct device *dev = class_find_device(&tsm_class, NULL, &id, match_id);
2630

2731
if (!dev)
2832
return NULL;
@@ -46,7 +50,7 @@ static struct tsm_dev *alloc_tsm_dev(struct device *parent)
4650
tsm_dev->id = id;
4751
dev = &tsm_dev->dev;
4852
dev->parent = parent;
49-
dev->class = tsm_class;
53+
dev->class = &tsm_class;
5054
device_initialize(dev);
5155

5256
return no_free_ptr(tsm_dev);
@@ -114,18 +118,13 @@ static void tsm_release(struct device *dev)
114118

115119
static int __init tsm_init(void)
116120
{
117-
tsm_class = class_create("tsm");
118-
if (IS_ERR(tsm_class))
119-
return PTR_ERR(tsm_class);
120-
121-
tsm_class->dev_release = tsm_release;
122-
return 0;
121+
return class_register(&tsm_class);
123122
}
124123
module_init(tsm_init)
125124

126125
static void __exit tsm_exit(void)
127126
{
128-
class_destroy(tsm_class);
127+
class_unregister(&tsm_class);
129128
}
130129
module_exit(tsm_exit)
131130

0 commit comments

Comments
 (0)