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

nfc: core: make nfc_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 nfc_class structure to be declared at build time
placing it into read-only memory, instead of having to be dynamically
allocated at boot time.

Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20240302-class_cleanup-net-next-v1-6-8fa378595b93@marliere.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Ricardo B. Marliere and committed by
Jakub Kicinski
e5560011 070bef83

+2 -2
+1 -1
include/net/nfc/nfc.h
··· 196 196 }; 197 197 #define to_nfc_dev(_dev) container_of(_dev, struct nfc_dev, dev) 198 198 199 - extern struct class nfc_class; 199 + extern const struct class nfc_class; 200 200 201 201 struct nfc_dev *nfc_allocate_device(const struct nfc_ops *ops, 202 202 u32 supported_protocols,
+1 -1
net/nfc/core.c
··· 1015 1015 schedule_work(&dev->check_pres_work); 1016 1016 } 1017 1017 1018 - struct class nfc_class = { 1018 + const struct class nfc_class = { 1019 1019 .name = "nfc", 1020 1020 .dev_release = nfc_release, 1021 1021 };