Skip to contentSkip to conversation

dma-buf: make kobj_type structure constant

PATCH In review Thomas Weißschuh 2 participants 2 messages Feb 17, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma-buf: make kobj_type structure constant

Since commit ee6d3dd4ed48 ("driver core: make kobj_type constant.") the driver core allows the usage of const struct kobj_type.

Take advantage of this to constify the structure definition to prevent modification at runtime.

---
 drivers/dma-buf/dma-buf-sysfs-stats.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma-buf/dma-buf-sysfs-stats.c +1 -1
index fbf725fae7c1..6cfbbf0720bd 100644
@@ -112,7 +112,7 @@ static void dma_buf_sysfs_release(struct kobject *kobj)
 	kfree(sysfs_entry);
 }
 
-static struct kobj_type dma_buf_ktype = {
+static const struct kobj_type dma_buf_ktype = {
 	.sysfs_ops = &dma_buf_stats_sysfs_ops,
 	.release = dma_buf_sysfs_release,
 	.default_groups = dma_buf_stats_default_groups,

---
base-commit: 3ac88fa4605ec98e545fb3ad0154f575fda2de5f
change-id: 20230217-kobj_type-dma-buf-a2ea6a8a1de3

Best regards,

Signature · 1 line
Thomas Weißschuh <[email protected]>
maintainer Reviewed-by on v1 1/1
#1 lore raw

Am 17.02.23 um 04:13 schrieb Thomas Weißschuh:

Quoted 7 lines

Since commit ee6d3dd4ed48 ("driver core: make kobj_type constant.") the driver core allows the usage of const struct kobj_type.

Take advantage of this to constify the structure definition to prevent modification at runtime.

I will pick this up for upstreaming through drm-misc-next.

Thanks,
Christian.

Quoted 23 lines
---
  drivers/dma-buf/dma-buf-sysfs-stats.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma-buf/dma-buf-sysfs-stats.c +1 -2
index fbf725fae7c1..6cfbbf0720bd 100644
@@ -112,7 +112,7 @@ static void dma_buf_sysfs_release(struct kobject *kobj)
  	kfree(sysfs_entry);
  }
 
-static struct kobj_type dma_buf_ktype = {
+static const struct kobj_type dma_buf_ktype = {
  	.sysfs_ops = &dma_buf_stats_sysfs_ops,
  	.release = dma_buf_sysfs_release,
  	.default_groups = dma_buf_stats_default_groups,
 
---

base-commit: 3ac88fa4605ec98e545fb3ad0154f575fda2de5f
change-id: 20230217-kobj_type-dma-buf-a2ea6a8a1de3

Best regards,