nfc: core: make nfc_class constant
authorRicardo B. Marliere <ricardo@marliere.net>
Sat, 2 Mar 2024 17:06:02 +0000 (14:06 -0300)
committerJakub Kicinski <kuba@kernel.org>
Tue, 5 Mar 2024 19:21:18 +0000 (11:21 -0800)
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>
include/net/nfc/nfc.h
net/nfc/core.c

index 5dee575fbe86ae3613e2b1a80d8e1202a148e7d8..3d07abacf08bd6161f6049235b24ba6daa92e4a6 100644 (file)
@@ -196,7 +196,7 @@ struct nfc_dev {
 };
 #define to_nfc_dev(_dev) container_of(_dev, struct nfc_dev, dev)
 
-extern struct class nfc_class;
+extern const struct class nfc_class;
 
 struct nfc_dev *nfc_allocate_device(const struct nfc_ops *ops,
                                    u32 supported_protocols,
index eb2c0959e5b6a56a0702adc598136b2426a87fa3..e58dc640505459eb55bc4fa8c5643b5cd59bdcb6 100644 (file)
@@ -1015,7 +1015,7 @@ static void nfc_check_pres_timeout(struct timer_list *t)
        schedule_work(&dev->check_pres_work);
 }
 
-struct class nfc_class = {
+const struct class nfc_class = {
        .name = "nfc",
        .dev_release = nfc_release,
 };