Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: core: make regulator_class constant

Since commit 43a7206b0963 ("driver core: class: make class_register() take
a const *"), the driver core allows for struct class to be in read-only
memory, so move the regulator_class structure to be declared at build time
placing it into read-only memory, instead of having to be dynamically
allocated at boot time.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Link: https://msgid.link/r/20240305-class_cleanup-regulator-v1-1-4950345d6d8f@marliere.net
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Ricardo B. Marliere and committed by
Mark Brown
4fe62075 d7370964

+2 -2
+1 -1
drivers/regulator/core.c
··· 5890 5890 }; 5891 5891 #endif 5892 5892 5893 - struct class regulator_class = { 5893 + const struct class regulator_class = { 5894 5894 .name = "regulator", 5895 5895 .dev_release = regulator_dev_release, 5896 5896 .dev_groups = regulator_dev_groups,
+1 -1
drivers/regulator/internal.h
··· 58 58 struct dentry *debugfs; 59 59 }; 60 60 61 - extern struct class regulator_class; 61 + extern const struct class regulator_class; 62 62 63 63 static inline struct regulator_dev *dev_to_rdev(struct device *dev) 64 64 {