Skip to content

Commit 1e0a285

Browse files
rbmarlierevinodkoul
authored andcommitted
dmaengine: idxd: constify the struct device_type usage
Since commit aed65af ("drivers: make device_type const"), the driver core can properly handle constant struct device_type. Move the dsa_device_type, iax_device_type, idxd_wq_device_type, idxd_cdev_file_type, idxd_cdev_device_type and idxd_group_device_type variables to be constant structures as well, placing it into read-only memory which can not be modified at runtime. Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: "Ricardo B. Marliere" <ricardo@marliere.net> Reviewed-by: Fenghua Yu <fenghua.yu@intel.com> Link: https://lore.kernel.org/r/20240219-device_cleanup-dmaengine-v1-1-9f72f3cf3587@marliere.net Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 35b78e2 commit 1e0a285

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

drivers/dma/idxd/cdev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static void idxd_file_dev_release(struct device *dev)
152152
mutex_unlock(&wq->wq_lock);
153153
}
154154

155-
static struct device_type idxd_cdev_file_type = {
155+
static const struct device_type idxd_cdev_file_type = {
156156
.name = "idxd_file",
157157
.release = idxd_file_dev_release,
158158
.groups = cdev_file_attribute_groups,
@@ -169,7 +169,7 @@ static void idxd_cdev_dev_release(struct device *dev)
169169
kfree(idxd_cdev);
170170
}
171171

172-
static struct device_type idxd_cdev_device_type = {
172+
static const struct device_type idxd_cdev_device_type = {
173173
.name = "idxd_cdev",
174174
.release = idxd_cdev_dev_release,
175175
};

drivers/dma/idxd/idxd.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ typedef int (*load_device_defaults_fn_t) (struct idxd_device *idxd);
282282
struct idxd_driver_data {
283283
const char *name_prefix;
284284
enum idxd_type type;
285-
struct device_type *dev_type;
285+
const struct device_type *dev_type;
286286
int compl_size;
287287
int align;
288288
int evl_cr_off;
@@ -520,11 +520,11 @@ extern const struct bus_type dsa_bus_type;
520520

521521
extern bool support_enqcmd;
522522
extern struct ida idxd_ida;
523-
extern struct device_type dsa_device_type;
524-
extern struct device_type iax_device_type;
525-
extern struct device_type idxd_wq_device_type;
526-
extern struct device_type idxd_engine_device_type;
527-
extern struct device_type idxd_group_device_type;
523+
extern const struct device_type dsa_device_type;
524+
extern const struct device_type iax_device_type;
525+
extern const struct device_type idxd_wq_device_type;
526+
extern const struct device_type idxd_engine_device_type;
527+
extern const struct device_type idxd_group_device_type;
528528

529529
static inline bool is_dsa_dev(struct idxd_dev *idxd_dev)
530530
{

drivers/dma/idxd/sysfs.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static void idxd_conf_engine_release(struct device *dev)
9191
kfree(engine);
9292
}
9393

94-
struct device_type idxd_engine_device_type = {
94+
const struct device_type idxd_engine_device_type = {
9595
.name = "engine",
9696
.release = idxd_conf_engine_release,
9797
.groups = idxd_engine_attribute_groups,
@@ -577,7 +577,7 @@ static void idxd_conf_group_release(struct device *dev)
577577
kfree(group);
578578
}
579579

580-
struct device_type idxd_group_device_type = {
580+
const struct device_type idxd_group_device_type = {
581581
.name = "group",
582582
.release = idxd_conf_group_release,
583583
.groups = idxd_group_attribute_groups,
@@ -1369,7 +1369,7 @@ static void idxd_conf_wq_release(struct device *dev)
13691369
kfree(wq);
13701370
}
13711371

1372-
struct device_type idxd_wq_device_type = {
1372+
const struct device_type idxd_wq_device_type = {
13731373
.name = "wq",
13741374
.release = idxd_conf_wq_release,
13751375
.groups = idxd_wq_attribute_groups,
@@ -1798,13 +1798,13 @@ static void idxd_conf_device_release(struct device *dev)
17981798
kfree(idxd);
17991799
}
18001800

1801-
struct device_type dsa_device_type = {
1801+
const struct device_type dsa_device_type = {
18021802
.name = "dsa",
18031803
.release = idxd_conf_device_release,
18041804
.groups = idxd_attribute_groups,
18051805
};
18061806

1807-
struct device_type iax_device_type = {
1807+
const struct device_type iax_device_type = {
18081808
.name = "iax",
18091809
.release = idxd_conf_device_release,
18101810
.groups = idxd_attribute_groups,

0 commit comments

Comments
 (0)