[PATCH] chardev: make kobj_type structures constant

From: Thomas Weißschuh
Date: Wed Feb 15 2023 - 20:14:14 EST


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 definitions to prevent
modification at runtime.

Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
---
fs/char_dev.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/char_dev.c b/fs/char_dev.c
index 13deb45f1ec6..b33331cb97cd 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -624,11 +624,11 @@ static void cdev_dynamic_release(struct kobject *kobj)
kobject_put(parent);
}

-static struct kobj_type ktype_cdev_default = {
+static const struct kobj_type ktype_cdev_default = {
.release = cdev_default_release,
};

-static struct kobj_type ktype_cdev_dynamic = {
+static const struct kobj_type ktype_cdev_dynamic = {
.release = cdev_dynamic_release,
};


---
base-commit: 033c40a89f55525139fd5b6342281b09b97d05bf
change-id: 20230216-kobj_type-chardev-f0d84e96be2e

Best regards,
--
Thomas Weißschuh <linux@xxxxxxxxxxxxxx>